aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormikhnenko <mikhnenko@yandex-team.com>2023-09-20 11:01:13 +0300
committermikhnenko <mikhnenko@yandex-team.com>2023-09-20 11:29:08 +0300
commitf5b051f5e09f00265229985ba5fd47aa5c8959ff (patch)
tree7e11605ad566f09451623a1ac34cc644bae804ab
parent8ed995cdfb22a3dfa790b0a6ae7750d9dc85db7b (diff)
downloadydb-f5b051f5e09f00265229985ba5fd47aa5c8959ff.tar.gz
Split libcxx on msvc/other
-rw-r--r--build/sysincl/stl-to-libcxxmsvc.yml434
-rw-r--r--build/ymake.core.conf3
-rw-r--r--contrib/libs/cxxsupp/CMakeLists.windows-x86_64.txt4
-rw-r--r--contrib/libs/cxxsupp/libcxx/CMakeLists.txt2
-rw-r--r--contrib/libs/cxxsupp/libcxx/CMakeLists.windows-x86_64.txt75
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/CMakeLists.txt11
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/CMakeLists.windows-x86_64.txt75
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/CREDITS.TXT186
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/LICENSE.TXT311
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/adjacent_find.h46
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/all_of.h32
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/any_of.h32
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/binary_search.h55
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/clamp.h46
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/comp.h92
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/comp_ref_type.h81
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/copy.h77
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/copy_backward.h79
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/copy_if.h39
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/copy_n.h66
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/count.h35
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/count_if.h35
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/equal.h85
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/equal_range.h82
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/fill.h50
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/fill_n.h42
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/find.h32
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/find_end.h150
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/find_first_of.h52
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/find_if.h32
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/find_if_not.h32
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/for_each.h32
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/for_each_n.h42
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/generate.h31
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/generate_n.h35
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/half_positive.h49
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/in_fun_result.h49
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/in_in_out_result.h54
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/in_in_result.h51
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/in_out_out_result.h52
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/in_out_result.h54
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/includes.h62
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/inplace_merge.h231
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/is_heap.h45
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/is_heap_until.h67
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/is_partitioned.h38
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/is_permutation.h162
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/is_sorted.h45
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/is_sorted_until.h57
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/iter_swap.h32
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/lexicographical_compare.h63
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/lower_bound.h66
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/make_heap.h59
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/max.h72
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/max_element.h58
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/merge.h71
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/min.h72
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/min_element.h57
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/minmax.h95
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/minmax_element.h85
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/mismatch.h67
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/move.h77
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/move_backward.h79
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/next_permutation.h72
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/none_of.h32
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/nth_element.h248
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/partial_sort.h74
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/partial_sort_copy.h71
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/partition.h81
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/partition_copy.h47
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/partition_point.h46
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/pop_heap.h57
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/prev_permutation.h72
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/push_heap.h70
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/ranges_min_element.h72
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/ranges_swap_ranges.h69
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/remove.h45
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/remove_copy.h38
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/remove_copy_if.h38
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/remove_if.h44
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/replace.h32
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/replace_copy.h36
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/replace_copy_if.h36
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/replace_if.h32
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/reverse.h56
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/reverse_copy.h32
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/rotate.h200
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/rotate_copy.h31
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/sample.h102
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/search.h125
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/search_n.h112
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/set_difference.h72
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/set_intersection.h69
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/set_symmetric_difference.h77
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/set_union.h72
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/shift_left.h56
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/shift_right.h102
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/shuffle.h160
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/sift_down.h78
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/sort.h556
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/sort_heap.h53
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/stable_partition.h295
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/stable_sort.h230
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/swap_ranges.h31
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/transform.h43
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/unique.h56
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/unique_copy.h106
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/unwrap_iter.h84
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/upper_bound.h66
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__assert69
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__availability273
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__bit/bit_cast.h52
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__bit/byteswap.h55
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__bit_reference1317
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__bits149
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__bsd_locale_defaults.h37
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__bsd_locale_fallbacks.h143
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__charconv/chars_format.h77
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__charconv/from_chars_result.h37
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__charconv/to_chars_result.h37
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/calendar.h1285
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/convert_to_timespec.h55
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/duration.h625
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/file_clock.h85
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/high_resolution_clock.h36
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/steady_clock.h44
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/system_clock.h54
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/time_point.h249
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__compare/common_comparison_category.h94
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__compare/compare_partial_order_fallback.h73
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__compare/compare_strong_order_fallback.h70
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__compare/compare_three_way.h41
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__compare/compare_three_way_result.h43
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__compare/compare_weak_order_fallback.h70
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__compare/is_eq.h34
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__compare/ordering.h330
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__compare/partial_order.h71
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__compare/strong_order.h136
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__compare/synth_three_way.h51
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__compare/three_way_comparable.h58
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__compare/weak_order.h100
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/arithmetic.h50
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/assignable.h40
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/boolean_testable.h38
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/class_or_enum.h37
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/common_reference_with.h37
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/common_with.h47
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/constructible.h56
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/convertible_to.h37
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/copyable.h39
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/derived_from.h34
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/destructible.h32
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/different_from.h31
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/equality_comparable.h53
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/invocable.h41
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/movable.h39
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/predicate.h35
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/regular.h33
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/relation.h44
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/same_as.h35
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/semiregular.h33
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/swappable.h116
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/totally_ordered.h57
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__config1551
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__coroutine/coroutine_handle.h202
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__coroutine/coroutine_traits.h53
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__coroutine/noop_coroutine_handle.h112
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__coroutine/trivial_awaitables.h46
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__debug232
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__errc217
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/copy_options.h84
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/directory_entry.h516
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/directory_iterator.h154
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/directory_options.h82
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/file_status.h72
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/file_time_type.h31
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/file_type.h43
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/filesystem_error.h103
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/operations.h201
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/path.h1024
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/path_iterator.h134
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/perm_options.h77
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/perms.h95
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/recursive_directory_iterator.h185
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/space_info.h39
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/u8path.h100
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_arg.h288
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_args.h66
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_context.h160
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_error.h51
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_fwd.h45
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_parse_context.h109
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_string.h169
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_to_n_result.h41
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter.h287
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter_bool.h143
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter_char.h104
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter_floating_point.h718
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter_integer.h170
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter_integral.h465
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter_pointer.h90
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter_string.h158
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__format/parser_std_format_spec.h1398
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__functional/binary_function.h31
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__functional/binary_negate.h50
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__functional/bind.h418
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__functional/bind_back.h65
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__functional/bind_front.h58
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__functional/binder1st.h54
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__functional/binder2nd.h54
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__functional/compose.h52
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__functional/default_searcher.h56
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__functional/function.h2818
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__functional/hash.h875
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__functional/identity.h37
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__functional/invoke.h100
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__functional/is_transparent.h36
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__functional/mem_fn.h162
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__functional/mem_fun_ref.h173
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__functional/not_fn.h54
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__functional/operations.h729
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__functional/perfect_forward.h94
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__functional/pointer_to_binary_function.h46
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__functional/pointer_to_unary_function.h46
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__functional/ranges_operations.h98
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__functional/reference_wrapper.h212
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__functional/unary_function.h29
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__functional/unary_negate.h47
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__functional/unwrap_ref.h57
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__functional/weak_result_type.h482
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__hash_table2809
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__ios/fpos.h79
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/access.h129
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/advance.h200
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/back_insert_iterator.h70
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/common_iterator.h283
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/concepts.h280
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/counted_iterator.h303
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/data.h51
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/default_sentinel.h30
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/distance.h107
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/empty.h44
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/erase_if_container.h40
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/front_insert_iterator.h70
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/incrementable_traits.h72
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/indirectly_comparable.h34
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/insert_iterator.h81
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/istream_iterator.h104
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/istreambuf_iterator.h118
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/iter_move.h93
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/iter_swap.h106
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/iterator.h35
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/iterator_traits.h495
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/mergeable.h41
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/move_iterator.h185
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/next.h86
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/ostream_iterator.h70
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/ostreambuf_iterator.h76
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/permutable.h35
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/prev.h78
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/projected.h40
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/readable_traits.h86
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/reverse_access.h100
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/reverse_iterator.h235
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/size.h53
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/sortable.h37
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/unreachable_sentinel.h38
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/wrap_iter.h285
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__locale1818
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__mbstate_t.h44
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__memory/addressof.h76
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__memory/allocation_guard.h83
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__memory/allocator.h249
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__memory/allocator_arg_t.h78
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__memory/allocator_traits.h405
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__memory/auto_ptr.h80
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__memory/compressed_pair.h166
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__memory/concepts.h68
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__memory/construct_at.h110
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__memory/pointer_traits.h220
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__memory/ranges_construct_at.h124
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__memory/ranges_uninitialized_algorithms.h318
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__memory/raw_storage_iterator.h68
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__memory/shared_ptr.h1746
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__memory/temporary_buffer.h84
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__memory/uninitialized_algorithms.h351
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__memory/unique_ptr.h766
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__memory/uses_allocator.h61
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__memory/voidify.h30
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__mutex_base526
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__node_handle253
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/accumulate.h52
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/adjacent_difference.h72
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/exclusive_scan.h53
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/gcd_lcm.h96
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/inclusive_scan.h60
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/inner_product.h53
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/iota.h32
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/midpoint.h85
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/partial_sum.h70
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/reduce.h47
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/transform_exclusive_scan.h49
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/transform_inclusive_scan.h58
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/transform_reduce.h54
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/bernoulli_distribution.h143
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/binomial_distribution.h225
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/cauchy_distribution.h162
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/chi_squared_distribution.h144
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/clamp_to_integral.h60
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/default_random_engine.h25
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/discard_block_engine.h203
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/discrete_distribution.h260
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/exponential_distribution.h155
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/extreme_value_distribution.h161
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/fisher_f_distribution.h160
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/gamma_distribution.h213
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/generate_canonical.h53
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/geometric_distribution.h141
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/independent_bits_engine.h271
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/is_seed_sequence.h31
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/knuth_b.h26
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/linear_congruential_engine.h398
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/log2.h75
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/lognormal_distribution.h299
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/mersenne_twister_engine.h534
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/negative_binomial_distribution.h176
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/normal_distribution.h208
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/piecewise_constant_distribution.h356
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/piecewise_linear_distribution.h372
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/poisson_distribution.h277
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/random_device.h84
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/ranlux.h31
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/seed_seq.h153
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/shuffle_order_engine.h283
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/student_t_distribution.h153
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/subtract_with_carry_engine.h352
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/uniform_int_distribution.h290
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/uniform_random_bit_generator.h45
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/uniform_real_distribution.h160
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__random/weibull_distribution.h155
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/access.h225
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/all.h82
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/common_view.h135
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/concepts.h146
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/copyable_box.h178
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/counted.h81
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/dangling.h42
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/data.h106
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/drop_view.h127
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/empty.h82
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/empty_view.h45
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/enable_borrowed_range.h40
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/enable_view.h47
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/iota_view.h408
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/join_view.h350
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/non_propagating_cache.h114
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/owning_view.h81
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/range_adaptor.h73
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/rbegin.h130
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/ref_view.h86
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/rend.h134
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/reverse_view.h190
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/single_view.h81
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/size.h135
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/subrange.h289
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/take_view.h185
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/transform_view.h440
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/view_interface.h174
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/views.h35
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__split_buffer636
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__std_stream361
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__string1189
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__support/android/locale_bionic.h71
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__support/fuchsia/xlocale.h22
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__support/ibm/gettod_zos.h53
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__support/ibm/limits.h98
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__support/ibm/locale_mgmt_zos.h53
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__support/ibm/nanosleep.h55
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__support/ibm/support.h53
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__support/ibm/xlocale.h133
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__support/musl/xlocale.h57
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__support/newlib/xlocale.h27
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__support/openbsd/xlocale.h19
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__support/solaris/xlocale.h76
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__support/win32/atomic_win32.h1164
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__support/win32/limits_msvc_win32.h70
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__support/win32/locale_win32.h259
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__support/xlocale/__nop_locale_mgmt.h51
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__support/xlocale/__posix_l_fallback.h164
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__support/xlocale/__strtonum_fallback.h66
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__thread/poll_with_backoff.h69
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__thread/timed_backoff_policy.h45
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__threading_support676
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__tree2748
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__tuple635
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__undef_macros33
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__utility/as_const.h33
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__utility/auto_cast.h22
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__utility/cmp.h110
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__utility/declval.h53
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__utility/exchange.h37
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__utility/forward.h37
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__utility/in_place.h58
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__utility/integer_sequence.h94
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__utility/move.h47
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__utility/pair.h635
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__utility/piecewise_construct.h29
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__utility/priority_tag.h26
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__utility/rel_ops.h62
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__utility/swap.h50
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__utility/to_underlying.h40
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__utility/transaction.h94
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__utility/unreachable.h38
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__variant/monostate.h60
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/__wrappers_config50
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/algorithm801
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/any686
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/array523
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/atomic2735
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/barrier330
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/bit350
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/bitset1109
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/cassert24
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/ccomplex28
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/cctype120
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/cerrno32
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/cfenv81
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/cfloat79
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/charconv640
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/chrono713
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/cinttypes257
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/ciso64624
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/climits47
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/clocale52
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/cmath662
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/codecvt580
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/compare162
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/complex1496
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/complex.h40
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/concepts161
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/condition_variable269
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/coroutine52
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/csignal57
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/cstdarg47
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/cstddef166
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/cstdint190
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/cstdio169
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/cstdlib145
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/cstring94
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/ctime93
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/ctype.h63
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/cwchar184
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/cwctype88
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/deque3040
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/errno.h410
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/exception308
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/experimental/__config66
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/fenv.h120
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/filesystem269
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/float.h97
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/format560
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/forward_list1791
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/fstream1730
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/functional535
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/future2435
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/initializer_list131
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/inttypes.h266
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/iomanip670
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/ios1028
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/iosfwd292
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/iostream89
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/istream1640
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/iterator677
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/latch113
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/limits818
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/limits.h68
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/list2422
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/locale4364
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/locale.h52
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/map2339
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/math.h1771
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/memory1110
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/mutex730
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/new364
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/numeric175
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/optional1566
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/ostream1104
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/queue955
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/random1734
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/ranges269
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/ratio527
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/regex6834
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/semaphore188
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/set1564
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/setjmp.h48
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/shared_mutex509
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/span658
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/sstream872
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/stack357
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/stdatomic.h235
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/stdbool.h42
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/stddef.h60
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/stdexcept309
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/stdint.h129
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/stdio.h127
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/stdlib.h190
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/stlfwd63
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/streambuf500
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/string4528
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/string.h113
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/string_view970
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/strstream408
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/system_error486
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/thread410
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/tuple1663
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/type_traits4187
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/typeindex115
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/typeinfo407
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/unordered_map2619
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/unordered_set1807
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/unwind.h7
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/utility251
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/valarray4943
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/variant1789
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/vector3391
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/version416
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/wchar.h194
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/include/wctype.h99
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/algorithm.cpp51
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/any.cpp34
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/assert.cpp38
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/atomic.cpp194
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/barrier.cpp97
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/bind.cpp29
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/charconv.cpp196
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/chrono.cpp309
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/chrono_system_time_init.h2
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/condition_variable.cpp97
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/condition_variable_destructor.cpp46
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/debug.cpp559
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/exception.cpp34
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/filesystem/directory_iterator.cpp332
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/filesystem/filesystem_common.h624
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/filesystem/operations.cpp2104
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/filesystem/posix_compat.h522
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/format.cpp15
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/functional.cpp27
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/future.cpp269
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/hash.cpp559
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/include/apple_availability.h51
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/include/atomic_support.h176
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/include/config_elast.h49
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/include/refstring.h167
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/common.h108
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/d2fixed.h60
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/d2fixed_full_table.h4451
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/d2s.h62
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/d2s_full_table.h368
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/d2s_intrinsics.h260
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/digit_table.h68
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/f2s.h55
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/ryu.h149
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/include/sso_allocator.h77
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/include/to_chars_floating_point.h1078
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/ios.cpp443
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/ios.instantiations.cpp45
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/iostream.cpp204
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/iostream_init.h2
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/legacy_pointer_safety.cpp23
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/locale.cpp6613
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/memory.cpp238
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/mutex.cpp286
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/mutex_destructor.cpp50
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/new.cpp300
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/optional.cpp42
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/random.cpp220
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/random_shuffle.cpp62
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/regex.cpp436
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/ryu/README.txt11
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/ryu/d2fixed.cpp670
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/ryu/d2s.cpp783
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/ryu/f2s.cpp716
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/shared_mutex.cpp119
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/stdexcept.cpp18
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/string.cpp514
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/strstream.cpp340
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_fallback.ipp163
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_glibcxx.ipp32
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_libcxxabi.ipp27
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_libcxxrt.ipp25
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_msvc.ipp173
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_pointer_cxxabi.ipp73
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_pointer_glibcxx.ipp77
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_pointer_msvc.ipp258
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_pointer_unimplemented.ipp79
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/new_handler_fallback.ipp28
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/stdexcept_default.ipp64
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/stdexcept_vcruntime.ipp16
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/support/solaris/README4
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/support/win32/atomic_win32.cpp31
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/support/win32/locale_win32.cpp141
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/support/win32/new_win32.cpp28
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/support/win32/support.cpp172
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/support/win32/thread_win32.cpp274
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/system_error.cpp294
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/thread.cpp212
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/typeinfo.cpp58
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/utility.cpp15
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/valarray.cpp57
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/variant.cpp17
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/src/vector.cpp34
-rw-r--r--contrib/libs/cxxsupp/libcxxmsvc/ya.make258
-rw-r--r--contrib/libs/cxxsupp/ya.make13
613 files changed, 188800 insertions, 83 deletions
diff --git a/build/sysincl/stl-to-libcxxmsvc.yml b/build/sysincl/stl-to-libcxxmsvc.yml
new file mode 100644
index 0000000000..e622eb6f44
--- /dev/null
+++ b/build/sysincl/stl-to-libcxxmsvc.yml
@@ -0,0 +1,434 @@
+# libc & stl common headers should be resolved to either
+# * system libc (e.g. nothing in our repo)
+# * system libc++ (e.g. nothing in our repo)
+# * libcxx
+# * musl
+# or some combination of them depending on the build flags.
+
+# We want musl to resolve itself without these sysincls, but its test must have them
+# When these resolved in pure C modules, their own includes should be also resolved via sysincl (the list at the bottom)
+# If you add something here, please also add include to it into build/sysincl/check/cxx.c for proper testing
+- source_filter: "^(?!(contrib/libs/musl|contrib/tools/yasm)).*|^contrib/libs/musl/tests"
+ includes:
+ - complex.h: contrib/libs/cxxsupp/libcxxmsvc/include/complex.h
+ - ctype.h: contrib/libs/cxxsupp/libcxxmsvc/include/ctype.h
+ - errno.h: contrib/libs/cxxsupp/libcxxmsvc/include/errno.h
+ - fenv.h: contrib/libs/cxxsupp/libcxxmsvc/include/fenv.h
+ - float.h: contrib/libs/cxxsupp/libcxxmsvc/include/float.h
+ - inttypes.h: contrib/libs/cxxsupp/libcxxmsvc/include/inttypes.h
+ - limits.h: contrib/libs/cxxsupp/libcxxmsvc/include/limits.h
+ - locale.h: contrib/libs/cxxsupp/libcxxmsvc/include/locale.h
+ - math.h: contrib/libs/cxxsupp/libcxxmsvc/include/math.h
+ - stdatomic.h: contrib/libs/cxxsupp/libcxxmsvc/include/stdatomic.h
+ - setjmp.h: contrib/libs/cxxsupp/libcxxmsvc/include/setjmp.h
+ - stdbool.h: contrib/libs/cxxsupp/libcxxmsvc/include/stdbool.h
+ - stddef.h: contrib/libs/cxxsupp/libcxxmsvc/include/stddef.h
+ - stdint.h: contrib/libs/cxxsupp/libcxxmsvc/include/stdint.h
+ - stdio.h: contrib/libs/cxxsupp/libcxxmsvc/include/stdio.h
+ - stdlib.h: contrib/libs/cxxsupp/libcxxmsvc/include/stdlib.h
+ - string.h: contrib/libs/cxxsupp/libcxxmsvc/include/string.h
+ - tgmath.h: contrib/libs/cxxsupp/libcxxmsvc/include/tgmath.h
+ - wchar.h: contrib/libs/cxxsupp/libcxxmsvc/include/wchar.h
+ - wctype.h: contrib/libs/cxxsupp/libcxxmsvc/include/wctype.h
+
+- includes:
+ - unwind.h: contrib/libs/cxxsupp/libcxxmsvc/include/unwind.h
+
+- includes:
+ - algorithm: contrib/libs/cxxsupp/libcxxmsvc/include/algorithm
+ - any: contrib/libs/cxxsupp/libcxxmsvc/include/any
+ - array: contrib/libs/cxxsupp/libcxxmsvc/include/array
+ - atomic: contrib/libs/cxxsupp/libcxxmsvc/include/atomic
+ - bit: contrib/libs/cxxsupp/libcxxmsvc/include/bit
+ - bitset: contrib/libs/cxxsupp/libcxxmsvc/include/bitset
+ - cassert: contrib/libs/cxxsupp/libcxxmsvc/include/cassert
+ - ccomplex: contrib/libs/cxxsupp/libcxxmsvc/include/ccomplex
+ - cctype: contrib/libs/cxxsupp/libcxxmsvc/include/cctype
+ - cerrno: contrib/libs/cxxsupp/libcxxmsvc/include/cerrno
+ - cfenv: contrib/libs/cxxsupp/libcxxmsvc/include/cfenv
+ - cfloat: contrib/libs/cxxsupp/libcxxmsvc/include/cfloat
+ - charconv: contrib/libs/cxxsupp/libcxxmsvc/include/charconv
+ - chrono: contrib/libs/cxxsupp/libcxxmsvc/include/chrono
+ - cinttypes: contrib/libs/cxxsupp/libcxxmsvc/include/cinttypes
+ - ciso646: contrib/libs/cxxsupp/libcxxmsvc/include/ciso646
+ - climits: contrib/libs/cxxsupp/libcxxmsvc/include/climits
+ - clocale: contrib/libs/cxxsupp/libcxxmsvc/include/clocale
+ - cmath: contrib/libs/cxxsupp/libcxxmsvc/include/cmath
+ - codecvt: contrib/libs/cxxsupp/libcxxmsvc/include/codecvt
+ - compare: contrib/libs/cxxsupp/libcxxmsvc/include/compare
+ - complex: contrib/libs/cxxsupp/libcxxmsvc/include/complex
+ - concepts: contrib/libs/cxxsupp/libcxxmsvc/include/concepts
+ - condition_variable: contrib/libs/cxxsupp/libcxxmsvc/include/condition_variable
+ - coroutine: contrib/libs/cxxsupp/libcxxmsvc/include/coroutine
+ - csetjmp: contrib/libs/cxxsupp/libcxxmsvc/include/csetjmp
+ - csignal: contrib/libs/cxxsupp/libcxxmsvc/include/csignal
+ - cstdarg: contrib/libs/cxxsupp/libcxxmsvc/include/cstdarg
+ - cstdbool: contrib/libs/cxxsupp/libcxxmsvc/include/cstdbool
+ - cstddef: contrib/libs/cxxsupp/libcxxmsvc/include/cstddef
+ - cstdint: contrib/libs/cxxsupp/libcxxmsvc/include/cstdint
+ - cstdio: contrib/libs/cxxsupp/libcxxmsvc/include/cstdio
+ - cstdlib: contrib/libs/cxxsupp/libcxxmsvc/include/cstdlib
+ - cstring: contrib/libs/cxxsupp/libcxxmsvc/include/cstring
+ - ctgmath: contrib/libs/cxxsupp/libcxxmsvc/include/ctgmath
+ - ctime: contrib/libs/cxxsupp/libcxxmsvc/include/ctime
+ - cwchar: contrib/libs/cxxsupp/libcxxmsvc/include/cwchar
+ - cwctype: contrib/libs/cxxsupp/libcxxmsvc/include/cwctype
+ - deque: contrib/libs/cxxsupp/libcxxmsvc/include/deque
+ - exception: contrib/libs/cxxsupp/libcxxmsvc/include/exception
+ - filesystem: contrib/libs/cxxsupp/libcxxmsvc/include/filesystem
+ - forward_list: contrib/libs/cxxsupp/libcxxmsvc/include/forward_list
+ - fstream: contrib/libs/cxxsupp/libcxxmsvc/include/fstream
+ - functional: contrib/libs/cxxsupp/libcxxmsvc/include/functional
+ - future: contrib/libs/cxxsupp/libcxxmsvc/include/future
+ - initializer_list: contrib/libs/cxxsupp/libcxxmsvc/include/initializer_list
+ - iomanip: contrib/libs/cxxsupp/libcxxmsvc/include/iomanip
+ - ios: contrib/libs/cxxsupp/libcxxmsvc/include/ios
+ - iosfwd: contrib/libs/cxxsupp/libcxxmsvc/include/iosfwd
+ - iostream: contrib/libs/cxxsupp/libcxxmsvc/include/iostream
+ - istream: contrib/libs/cxxsupp/libcxxmsvc/include/istream
+ - iterator: contrib/libs/cxxsupp/libcxxmsvc/include/iterator
+ - limits: contrib/libs/cxxsupp/libcxxmsvc/include/limits
+ - list: contrib/libs/cxxsupp/libcxxmsvc/include/list
+ - locale: contrib/libs/cxxsupp/libcxxmsvc/include/locale
+ - map: contrib/libs/cxxsupp/libcxxmsvc/include/map
+ - memory: contrib/libs/cxxsupp/libcxxmsvc/include/memory
+ - mutex: contrib/libs/cxxsupp/libcxxmsvc/include/mutex
+ - new: contrib/libs/cxxsupp/libcxxmsvc/include/new
+ - numbers: contrib/libs/cxxsupp/libcxxmsvc/include/numbers
+ - numeric: contrib/libs/cxxsupp/libcxxmsvc/include/numeric
+ - optional: contrib/libs/cxxsupp/libcxxmsvc/include/optional
+ - ostream: contrib/libs/cxxsupp/libcxxmsvc/include/ostream
+ - queue: contrib/libs/cxxsupp/libcxxmsvc/include/queue
+ - random: contrib/libs/cxxsupp/libcxxmsvc/include/random
+ - ranges: contrib/libs/cxxsupp/libcxxmsvc/include/ranges
+ - ratio: contrib/libs/cxxsupp/libcxxmsvc/include/ratio
+ - regex: contrib/libs/cxxsupp/libcxxmsvc/include/regex
+ - scoped_allocator: contrib/libs/cxxsupp/libcxxmsvc/include/scoped_allocator
+ - set: contrib/libs/cxxsupp/libcxxmsvc/include/set
+ - shared_mutex: contrib/libs/cxxsupp/libcxxmsvc/include/shared_mutex
+ - span: contrib/libs/cxxsupp/libcxxmsvc/include/span
+ - sstream: contrib/libs/cxxsupp/libcxxmsvc/include/sstream
+ - stack: contrib/libs/cxxsupp/libcxxmsvc/include/stack
+ - stdexcept: contrib/libs/cxxsupp/libcxxmsvc/include/stdexcept
+ - stlfwd: contrib/libs/cxxsupp/libcxxmsvc/include/stlfwd
+ - streambuf: contrib/libs/cxxsupp/libcxxmsvc/include/streambuf
+ - string: contrib/libs/cxxsupp/libcxxmsvc/include/string
+ - string_view: contrib/libs/cxxsupp/libcxxmsvc/include/string_view
+ - strstream: contrib/libs/cxxsupp/libcxxmsvc/include/strstream
+ - system_error: contrib/libs/cxxsupp/libcxxmsvc/include/system_error
+ - thread: contrib/libs/cxxsupp/libcxxmsvc/include/thread
+ - tuple: contrib/libs/cxxsupp/libcxxmsvc/include/tuple
+ - typeindex: contrib/libs/cxxsupp/libcxxmsvc/include/typeindex
+ - typeinfo: contrib/libs/cxxsupp/libcxxmsvc/include/typeinfo
+ - type_traits: contrib/libs/cxxsupp/libcxxmsvc/include/type_traits
+ - unordered_map: contrib/libs/cxxsupp/libcxxmsvc/include/unordered_map
+ - unordered_set: contrib/libs/cxxsupp/libcxxmsvc/include/unordered_set
+ - use_ansi.h: contrib/libs/cxxsupp/libcxxmsvc/include/use_ansi.h
+ - utility: contrib/libs/cxxsupp/libcxxmsvc/include/utility
+ - valarray: contrib/libs/cxxsupp/libcxxmsvc/include/valarray
+ - variant: contrib/libs/cxxsupp/libcxxmsvc/include/variant
+ - vector: contrib/libs/cxxsupp/libcxxmsvc/include/vector
+ - version: contrib/libs/cxxsupp/libcxxmsvc/include/version
+
+# Though these are headers provided by libcxx, we do not want to allow them to be included.
+# We are using non-existent filename to generate error instead, as there is no specific syntax for this case.
+- includes:
+ # TODO: Forbid including <experimental/coroutine> upon migration to clang14
+ - experimental/coroutine: contrib/libs/cxxsupp/libcxxmsvc/include/experimental/coroutine
+
+# This includes all headers needed to resolve includes in c-headers from libcxx listed above
+- includes:
+ - __assert: contrib/libs/cxxsupp/libcxxmsvc/include/__assert
+ - __availability: contrib/libs/cxxsupp/libcxxmsvc/include/__availability
+ - __bsd_locale_defaults.h: contrib/libs/cxxsupp/libcxxmsvc/include/__bsd_locale_defaults.h
+ - __bsd_locale_fallbacks.h: contrib/libs/cxxsupp/libcxxmsvc/include/__bsd_locale_fallbacks.h
+ - __locale: contrib/libs/cxxsupp/libcxxmsvc/include/__locale
+ - __bit_reference: contrib/libs/cxxsupp/libcxxmsvc/include/__bit_reference
+ - __bits: contrib/libs/cxxsupp/libcxxmsvc/include/__bits
+ - __config: contrib/libs/cxxsupp/libcxxmsvc/include/__config
+ - __debug: contrib/libs/cxxsupp/libcxxmsvc/include/__debug
+ - __errc: contrib/libs/cxxsupp/libcxxmsvc/include/__errc
+ - __locale: contrib/libs/cxxsupp/libcxxmsvc/include/__locale
+ - __mbstate_t.h: contrib/libs/cxxsupp/libcxxmsvc/include/__mbstate_t.h
+ - __mutex_base: contrib/libs/cxxsupp/libcxxmsvc/include/__mutex_base
+ - __string: contrib/libs/cxxsupp/libcxxmsvc/include/__string
+ - __threading_support: contrib/libs/cxxsupp/libcxxmsvc/include/__threading_support
+ - __tuple: contrib/libs/cxxsupp/libcxxmsvc/include/__tuple
+ - __undef_macros: contrib/libs/cxxsupp/libcxxmsvc/include/__undef_macros
+ - __wrappers_config: contrib/libs/cxxsupp/libcxxmsvc/include/__wrappers_config
+ - __algorithm/adjacent_find.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/adjacent_find.h
+ - __algorithm/all_of.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/all_of.h
+ - __algorithm/any_of.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/any_of.h
+ - __algorithm/binary_search.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/binary_search.h
+ - __algorithm/clamp.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/clamp.h
+ - __algorithm/comp.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/comp.h
+ - __algorithm/comp_ref_type.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/comp_ref_type.h
+ - __algorithm/copy.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/copy.h
+ - __algorithm/copy_backward.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/copy_backward.h
+ - __algorithm/copy_if.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/copy_if.h
+ - __algorithm/copy_n.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/copy_n.h
+ - __algorithm/count.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/count.h
+ - __algorithm/count_if.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/count_if.h
+ - __algorithm/equal.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/equal.h
+ - __algorithm/equal_range.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/equal_range.h
+ - __algorithm/fill.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/fill.h
+ - __algorithm/fill_n.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/fill_n.h
+ - __algorithm/find.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/find.h
+ - __algorithm/find_end.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/find_end.h
+ - __algorithm/find_first_of.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/find_first_of.h
+ - __algorithm/find_if.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/find_if.h
+ - __algorithm/find_if_not.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/find_if_not.h
+ - __algorithm/for_each.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/for_each.h
+ - __algorithm/for_each_n.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/for_each_n.h
+ - __algorithm/generate.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/generate.h
+ - __algorithm/generate_n.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/generate_n.h
+ - __algorithm/half_positive.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/half_positive.h
+ - __algorithm/in_fun_result.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/in_fun_result.h
+ - __algorithm/in_in_out_result.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/in_in_out_result.h
+ - __algorithm/in_in_result.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/in_in_result.h
+ - __algorithm/in_out_out_result.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/in_out_out_result.h
+ - __algorithm/in_out_result.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/in_out_result.h
+ - __algorithm/includes.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/includes.h
+ - __algorithm/inplace_merge.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/inplace_merge.h
+ - __algorithm/is_heap.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/is_heap.h
+ - __algorithm/is_heap_until.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/is_heap_until.h
+ - __algorithm/is_partitioned.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/is_partitioned.h
+ - __algorithm/is_permutation.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/is_permutation.h
+ - __algorithm/is_sorted.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/is_sorted.h
+ - __algorithm/is_sorted_until.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/is_sorted_until.h
+ - __algorithm/iter_swap.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/iter_swap.h
+ - __algorithm/lexicographical_compare.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/lexicographical_compare.h
+ - __algorithm/lower_bound.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/lower_bound.h
+ - __algorithm/make_heap.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/make_heap.h
+ - __algorithm/max.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/max.h
+ - __algorithm/max_element.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/max_element.h
+ - __algorithm/merge.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/merge.h
+ - __algorithm/min.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/min.h
+ - __algorithm/min_element.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/min_element.h
+ - __algorithm/minmax.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/minmax.h
+ - __algorithm/minmax_element.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/minmax_element.h
+ - __algorithm/mismatch.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/mismatch.h
+ - __algorithm/move.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/move.h
+ - __algorithm/move_backward.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/move_backward.h
+ - __algorithm/next_permutation.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/next_permutation.h
+ - __algorithm/none_of.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/none_of.h
+ - __algorithm/nth_element.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/nth_element.h
+ - __algorithm/partial_sort.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/partial_sort.h
+ - __algorithm/partial_sort_copy.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/partial_sort_copy.h
+ - __algorithm/partition.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/partition.h
+ - __algorithm/partition_copy.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/partition_copy.h
+ - __algorithm/partition_point.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/partition_point.h
+ - __algorithm/pop_heap.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/pop_heap.h
+ - __algorithm/prev_permutation.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/prev_permutation.h
+ - __algorithm/push_heap.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/push_heap.h
+ - __algorithm/ranges_min_element.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/ranges_min_element.h
+ - __algorithm/ranges_swap_ranges.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/ranges_swap_ranges.h
+ - __algorithm/remove.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/remove.h
+ - __algorithm/remove_copy.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/remove_copy.h
+ - __algorithm/remove_copy_if.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/remove_copy_if.h
+ - __algorithm/remove_if.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/remove_if.h
+ - __algorithm/replace.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/replace.h
+ - __algorithm/replace_copy.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/replace_copy.h
+ - __algorithm/replace_copy_if.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/replace_copy_if.h
+ - __algorithm/replace_if.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/replace_if.h
+ - __algorithm/reverse.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/reverse.h
+ - __algorithm/reverse_copy.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/reverse_copy.h
+ - __algorithm/rotate.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/rotate.h
+ - __algorithm/rotate_copy.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/rotate_copy.h
+ - __algorithm/sample.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/sample.h
+ - __algorithm/search.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/search.h
+ - __algorithm/search_n.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/search_n.h
+ - __algorithm/set_difference.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/set_difference.h
+ - __algorithm/set_intersection.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/set_intersection.h
+ - __algorithm/set_symmetric_difference.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/set_symmetric_difference.h
+ - __algorithm/set_union.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/set_union.h
+ - __algorithm/shift_left.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/shift_left.h
+ - __algorithm/shift_right.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/shift_right.h
+ - __algorithm/shuffle.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/shuffle.h
+ - __algorithm/sift_down.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/sift_down.h
+ - __algorithm/sort.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/sort.h
+ - __algorithm/sort_heap.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/sort_heap.h
+ - __algorithm/stable_partition.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/stable_partition.h
+ - __algorithm/stable_sort.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/stable_sort.h
+ - __algorithm/swap_ranges.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/swap_ranges.h
+ - __algorithm/transform.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/transform.h
+ - __algorithm/unique.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/unique.h
+ - __algorithm/unique_copy.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/unique_copy.h
+ - __algorithm/unwrap_iter.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/unwrap_iter.h
+ - __algorithm/upper_bound.h: contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/upper_bound.h
+ - __bit/bit_cast.h: contrib/libs/cxxsupp/libcxxmsvc/include/__bit/bit_cast.h
+ - __bit/byteswap.h: contrib/libs/cxxsupp/libcxxmsvc/include/__bit/byteswap.h
+ - __chrono/calendar.h: contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/calendar.h
+ - __chrono/convert_to_timespec.h: contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/convert_to_timespec.h
+ - __chrono/duration.h: contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/duration.h
+ - __chrono/file_clock.h: contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/file_clock.h
+ - __chrono/high_resolution_clock.h: contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/high_resolution_clock.h
+ - __chrono/steady_clock.h: contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/steady_clock.h
+ - __chrono/system_clock.h: contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/system_clock.h
+ - __chrono/time_point.h: contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/time_point.h
+ - __compare/common_comparison_category.h: contrib/libs/cxxsupp/libcxxmsvc/include/__compare/common_comparison_category.h
+ - __compare/compare_partial_order_fallback.h: contrib/libs/cxxsupp/libcxxmsvc/include/__compare/compare_partial_order_fallback.h
+ - __compare/compare_strong_order_fallback.h: contrib/libs/cxxsupp/libcxxmsvc/include/__compare/compare_strong_order_fallback.h
+ - __compare/compare_three_way.h: contrib/libs/cxxsupp/libcxxmsvc/include/__compare/compare_three_way.h
+ - __compare/compare_three_way_result.h: contrib/libs/cxxsupp/libcxxmsvc/include/__compare/compare_three_way_result.h
+ - __compare/compare_weak_order_fallback.h: contrib/libs/cxxsupp/libcxxmsvc/include/__compare/compare_weak_order_fallback.h
+ - __compare/is_eq.h: contrib/libs/cxxsupp/libcxxmsvc/include/__compare/is_eq.h
+ - __compare/ordering.h: contrib/libs/cxxsupp/libcxxmsvc/include/__compare/ordering.h
+ - __compare/partial_order.h: contrib/libs/cxxsupp/libcxxmsvc/include/__compare/partial_order.h
+ - __compare/strong_order.h: contrib/libs/cxxsupp/libcxxmsvc/include/__compare/strong_order.h
+ - __compare/synth_three_way.h: contrib/libs/cxxsupp/libcxxmsvc/include/__compare/synth_three_way.h
+ - __compare/three_way_comparable.h: contrib/libs/cxxsupp/libcxxmsvc/include/__compare/three_way_comparable.h
+ - __compare/weak_order.h: contrib/libs/cxxsupp/libcxxmsvc/include/__compare/weak_order.h
+ - __concepts/arithmetic.h: contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/arithmetic.h
+ - __concepts/assignable.h: contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/assignable.h
+ - __concepts/boolean_testable.h: contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/boolean_testable.h
+ - __concepts/class_or_enum.h: contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/class_or_enum.h
+ - __concepts/common_reference_with.h: contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/common_reference_with.h
+ - __concepts/common_with.h: contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/common_with.h
+ - __concepts/constructible.h: contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/constructible.h
+ - __concepts/convertible_to.h: contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/convertible_to.h
+ - __concepts/copyable.h: contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/copyable.h
+ - __concepts/derived_from.h: contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/derived_from.h
+ - __concepts/destructible.h: contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/destructible.h
+ - __concepts/different_from.h: contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/different_from.h
+ - __concepts/equality_comparable.h: contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/equality_comparable.h
+ - __concepts/invocable.h: contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/invocable.h
+ - __concepts/movable.h: contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/movable.h
+ - __concepts/predicate.h: contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/predicate.h
+ - __concepts/regular.h: contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/regular.h
+ - __concepts/relation.h: contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/relation.h
+ - __concepts/same_as.h: contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/same_as.h
+ - __concepts/semiregular.h: contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/semiregular.h
+ - __concepts/swappable.h: contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/swappable.h
+ - __concepts/totally_ordered.h: contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/totally_ordered.h
+ - __functional/binary_function.h: contrib/libs/cxxsupp/libcxxmsvc/include/__functional/binary_function.h
+ - __functional/binary_negate.h: contrib/libs/cxxsupp/libcxxmsvc/include/__functional/binary_negate.h
+ - __functional/bind.h: contrib/libs/cxxsupp/libcxxmsvc/include/__functional/bind.h
+ - __functional/bind_back.h: contrib/libs/cxxsupp/libcxxmsvc/include/__functional/bind_back.h
+ - __functional/bind_front.h: contrib/libs/cxxsupp/libcxxmsvc/include/__functional/bind_front.h
+ - __functional/binder1st.h: contrib/libs/cxxsupp/libcxxmsvc/include/__functional/binder1st.h
+ - __functional/binder2nd.h: contrib/libs/cxxsupp/libcxxmsvc/include/__functional/binder2nd.h
+ - __functional/compose.h: contrib/libs/cxxsupp/libcxxmsvc/include/__functional/compose.h
+ - __functional/default_searcher.h: contrib/libs/cxxsupp/libcxxmsvc/include/__functional/default_searcher.h
+ - __functional/function.h: contrib/libs/cxxsupp/libcxxmsvc/include/__functional/function.h
+ - __functional/hash.h: contrib/libs/cxxsupp/libcxxmsvc/include/__functional/hash.h
+ - __functional/identity.h: contrib/libs/cxxsupp/libcxxmsvc/include/__functional/identity.h
+ - __functional/invoke.h: contrib/libs/cxxsupp/libcxxmsvc/include/__functional/invoke.h
+ - __functional/mem_fn.h: contrib/libs/cxxsupp/libcxxmsvc/include/__functional/mem_fn.h
+ - __functional/mem_fun_ref.h: contrib/libs/cxxsupp/libcxxmsvc/include/__functional/mem_fun_ref.h
+ - __functional/not_fn.h: contrib/libs/cxxsupp/libcxxmsvc/include/__functional/not_fn.h
+ - __functional/operations.h: contrib/libs/cxxsupp/libcxxmsvc/include/__functional/operations.h
+ - __functional/perfect_forward.h: contrib/libs/cxxsupp/libcxxmsvc/include/__functional/perfect_forward.h
+ - __functional/pointer_to_binary_function.h: contrib/libs/cxxsupp/libcxxmsvc/include/__functional/pointer_to_binary_function.h
+ - __functional/pointer_to_unary_function.h: contrib/libs/cxxsupp/libcxxmsvc/include/__functional/pointer_to_unary_function.h
+ - __functional/ranges_operations.h: contrib/libs/cxxsupp/libcxxmsvc/include/__functional/ranges_operations.h
+ - __functional/reference_wrapper.h: contrib/libs/cxxsupp/libcxxmsvc/include/__functional/reference_wrapper.h
+ - __functional/unary_function.h: contrib/libs/cxxsupp/libcxxmsvc/include/__functional/unary_function.h
+ - __functional/unary_negate.h: contrib/libs/cxxsupp/libcxxmsvc/include/__functional/unary_negate.h
+ - __functional/unwrap_ref.h: contrib/libs/cxxsupp/libcxxmsvc/include/__functional/unwrap_ref.h
+ - __functional/weak_result_type.h: contrib/libs/cxxsupp/libcxxmsvc/include/__functional/weak_result_type.h
+ - __ios/fpos.h: contrib/libs/cxxsupp/libcxxmsvc/include/__ios/fpos.h
+ - __iterator/access.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/access.h
+ - __iterator/advance.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/advance.h
+ - __iterator/back_insert_iterator.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/back_insert_iterator.h
+ - __iterator/common_iterator.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/common_iterator.h
+ - __iterator/concepts.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/concepts.h
+ - __iterator/counted_iterator.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/counted_iterator.h
+ - __iterator/data.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/data.h
+ - __iterator/default_sentinel.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/default_sentinel.h
+ - __iterator/distance.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/distance.h
+ - __iterator/empty.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/empty.h
+ - __iterator/erase_if_container.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/erase_if_container.h
+ - __iterator/front_insert_iterator.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/front_insert_iterator.h
+ - __iterator/incrementable_traits.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/incrementable_traits.h
+ - __iterator/indirectly_comparable.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/indirectly_comparable.h
+ - __iterator/insert_iterator.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/insert_iterator.h
+ - __iterator/istream_iterator.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/istream_iterator.h
+ - __iterator/istreambuf_iterator.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/istreambuf_iterator.h
+ - __iterator/iter_move.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/iter_move.h
+ - __iterator/iter_swap.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/iter_swap.h
+ - __iterator/iterator.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/iterator.h
+ - __iterator/iterator_traits.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/iterator_traits.h
+ - __iterator/mergeable.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/mergeable.h
+ - __iterator/move_iterator.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/move_iterator.h
+ - __iterator/next.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/next.h
+ - __iterator/ostream_iterator.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/ostream_iterator.h
+ - __iterator/ostreambuf_iterator.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/ostreambuf_iterator.h
+ - __iterator/permutable.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/permutable.h
+ - __iterator/prev.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/prev.h
+ - __iterator/projected.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/projected.h
+ - __iterator/readable_traits.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/readable_traits.h
+ - __iterator/reverse_access.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/reverse_access.h
+ - __iterator/reverse_iterator.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/reverse_iterator.h
+ - __iterator/size.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/size.h
+ - __iterator/sortable.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/sortable.h
+ - __iterator/unreachable_sentinel.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/unreachable_sentinel.h
+ - __iterator/wrap_iter.h: contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/wrap_iter.h
+ - __memory/addressof.h: contrib/libs/cxxsupp/libcxxmsvc/include/__memory/addressof.h
+ - __memory/allocation_guard.h: contrib/libs/cxxsupp/libcxxmsvc/include/__memory/allocation_guard.h
+ - __memory/allocator.h: contrib/libs/cxxsupp/libcxxmsvc/include/__memory/allocator.h
+ - __memory/allocator_arg_t.h: contrib/libs/cxxsupp/libcxxmsvc/include/__memory/allocator_arg_t.h
+ - __memory/allocator_traits.h: contrib/libs/cxxsupp/libcxxmsvc/include/__memory/allocator_traits.h
+ - __memory/auto_ptr.h: contrib/libs/cxxsupp/libcxxmsvc/include/__memory/auto_ptr.h
+ - __memory/compressed_pair.h: contrib/libs/cxxsupp/libcxxmsvc/include/__memory/compressed_pair.h
+ - __memory/concepts.h: contrib/libs/cxxsupp/libcxxmsvc/include/__memory/concepts.h
+ - __memory/construct_at.h: contrib/libs/cxxsupp/libcxxmsvc/include/__memory/construct_at.h
+ - __memory/pointer_traits.h: contrib/libs/cxxsupp/libcxxmsvc/include/__memory/pointer_traits.h
+ - __memory/ranges_construct_at.h: contrib/libs/cxxsupp/libcxxmsvc/include/__memory/ranges_construct_at.h
+ - __memory/ranges_uninitialized_algorithms.h: contrib/libs/cxxsupp/libcxxmsvc/include/__memory/ranges_uninitialized_algorithms.h
+ - __memory/raw_storage_iterator.h: contrib/libs/cxxsupp/libcxxmsvc/include/__memory/raw_storage_iterator.h
+ - __memory/shared_ptr.h: contrib/libs/cxxsupp/libcxxmsvc/include/__memory/shared_ptr.h
+ - __memory/temporary_buffer.h: contrib/libs/cxxsupp/libcxxmsvc/include/__memory/temporary_buffer.h
+ - __memory/uninitialized_algorithms.h: contrib/libs/cxxsupp/libcxxmsvc/include/__memory/uninitialized_algorithms.h
+ - __memory/unique_ptr.h: contrib/libs/cxxsupp/libcxxmsvc/include/__memory/unique_ptr.h
+ - __memory/uses_allocator.h: contrib/libs/cxxsupp/libcxxmsvc/include/__memory/uses_allocator.h
+ - __memory/voidify.h: contrib/libs/cxxsupp/libcxxmsvc/include/__memory/voidify.h
+ - __random/log2.h: contrib/libs/cxxsupp/libcxxmsvc/include/__random/log2.h
+ - __random/uniform_int_distribution.h: contrib/libs/cxxsupp/libcxxmsvc/include/__random/uniform_int_distribution.h
+ - __ranges/access.h: contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/access.h
+ - __ranges/concepts.h: contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/concepts.h
+ - __ranges/dangling.h: contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/dangling.h
+ - __ranges/data.h: contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/data.h
+ - __ranges/enable_borrowed_range.h: contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/enable_borrowed_range.h
+ - __ranges/enable_view.h: contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/enable_view.h
+ - __ranges/size.h: contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/size.h
+ - __support/android/locale_bionic.h: contrib/libs/cxxsupp/libcxxmsvc/include/__support/android/locale_bionic.h
+ - __support/fuchsia/xlocale.h: contrib/libs/cxxsupp/libcxxmsvc/include/__support/fuchsia/xlocale.h
+ - __support/ibm/locale_mgmt_zos.h: contrib/libs/cxxsupp/libcxxmsvc/include/__support/ibm/locale_mgmt_zos.h
+ - __support/ibm/nanosleep.h: contrib/libs/cxxsupp/libcxxmsvc/include/__support/ibm/nanosleep.h
+ - __support/ibm/xlocale.h: contrib/libs/cxxsupp/libcxxmsvc/include/__support/ibm/xlocale.h
+ - __support/musl/xlocale.h: contrib/libs/cxxsupp/libcxxmsvc/include/__support/musl/xlocale.h
+ - __support/newlib/xlocale.h: contrib/libs/cxxsupp/libcxxmsvc/include/__support/newlib/xlocale.h
+ - __support/openbsd/xlocale.h: contrib/libs/cxxsupp/libcxxmsvc/include/__support/openbsd/xlocale.h
+ - __support/solaris/xlocale.h: contrib/libs/cxxsupp/libcxxmsvc/include/__support/solaris/xlocale.h
+ - __support/win32/atomic_win32.h: contrib/libs/cxxsupp/libcxxmsvc/include/__support/win32/atomic_win32.h
+ - __support/win32/locale_win32.h: contrib/libs/cxxsupp/libcxxmsvc/include/__support/win32/locale_win32.h
+ - __support/xlocale/__posix_l_fallback.h: contrib/libs/cxxsupp/libcxxmsvc/include/__support/xlocale/__posix_l_fallback.h
+ - __support/xlocale/__posix_l_fallback.h: contrib/libs/cxxsupp/libcxxmsvc/include/__support/xlocale/__posix_l_fallback.h
+ - __support/xlocale/__strtonum_fallback.h: contrib/libs/cxxsupp/libcxxmsvc/include/__support/xlocale/__strtonum_fallback.h
+ - __support/xlocale/__nop_locale_mgmt.h: contrib/libs/cxxsupp/libcxxmsvc/include/__support/xlocale/__nop_locale_mgmt.h
+ - __support/xlocale/__posix_l_fallback.h: contrib/libs/cxxsupp/libcxxmsvc/include/__support/xlocale/__posix_l_fallback.h
+ - __support/xlocale/__strtonum_fallback.h: contrib/libs/cxxsupp/libcxxmsvc/include/__support/xlocale/__strtonum_fallback.h
+ - __support/xlocale/__strtonum_fallback.h: contrib/libs/cxxsupp/libcxxmsvc/include/__support/xlocale/__strtonum_fallback.h
+ - __support/xlocale/__posix_l_fallback.h: contrib/libs/cxxsupp/libcxxmsvc/include/__support/xlocale/__posix_l_fallback.h
+ - __support/xlocale/__strtonum_fallback.h: contrib/libs/cxxsupp/libcxxmsvc/include/__support/xlocale/__strtonum_fallback.h
+ - __thread/poll_with_backoff.h: contrib/libs/cxxsupp/libcxxmsvc/include/__thread/poll_with_backoff.h
+ - __thread/timed_backoff_policy.h: contrib/libs/cxxsupp/libcxxmsvc/include/__thread/timed_backoff_policy.h
+ - __utility/as_const.h: contrib/libs/cxxsupp/libcxxmsvc/include/__utility/as_const.h
+ - __utility/auto_cast.h: contrib/libs/cxxsupp/libcxxmsvc/include/__utility/auto_cast.h
+ - __utility/cmp.h: contrib/libs/cxxsupp/libcxxmsvc/include/__utility/cmp.h
+ - __utility/declval.h: contrib/libs/cxxsupp/libcxxmsvc/include/__utility/declval.h
+ - __utility/exchange.h: contrib/libs/cxxsupp/libcxxmsvc/include/__utility/exchange.h
+ - __utility/forward.h: contrib/libs/cxxsupp/libcxxmsvc/include/__utility/forward.h
+ - __utility/in_place.h: contrib/libs/cxxsupp/libcxxmsvc/include/__utility/in_place.h
+ - __utility/integer_sequence.h: contrib/libs/cxxsupp/libcxxmsvc/include/__utility/integer_sequence.h
+ - __utility/move.h: contrib/libs/cxxsupp/libcxxmsvc/include/__utility/move.h
+ - __utility/pair.h: contrib/libs/cxxsupp/libcxxmsvc/include/__utility/pair.h
+ - __utility/piecewise_construct.h: contrib/libs/cxxsupp/libcxxmsvc/include/__utility/piecewise_construct.h
+ - __utility/priority_tag.h: contrib/libs/cxxsupp/libcxxmsvc/include/__utility/priority_tag.h
+ - __utility/rel_ops.h: contrib/libs/cxxsupp/libcxxmsvc/include/__utility/rel_ops.h
+ - __utility/swap.h: contrib/libs/cxxsupp/libcxxmsvc/include/__utility/swap.h
+ - __utility/to_underlying.h: contrib/libs/cxxsupp/libcxxmsvc/include/__utility/to_underlying.h
+ - __utility/transaction.h: contrib/libs/cxxsupp/libcxxmsvc/include/__utility/transaction.h
+ - __utility/unreachable.h: contrib/libs/cxxsupp/libcxxmsvc/include/__utility/unreachable.h
+ - __variant/monostate.h: contrib/libs/cxxsupp/libcxxmsvc/include/__variant/monostate.h
diff --git a/build/ymake.core.conf b/build/ymake.core.conf
index c20db4917d..e4bfa1ae21 100644
--- a/build/ymake.core.conf
+++ b/build/ymake.core.conf
@@ -9,7 +9,7 @@
FAKEID=628318530716
SANDBOX_FAKEID=${FAKEID}.7600000
-CPP_FAKEID=2023-06-06
+CPP_FAKEID=2023-09-19
GO_FAKEID=11100371
ANDROID_FAKEID=2023-05-17
CLANG_TIDY_FAKEID=2023-06-06
@@ -234,6 +234,7 @@ otherwise {
# line when `ya make ...` is invoked.
when ($NORUNTIME != "yes") {
SYSINCL+=build/sysincl/stl-to-libcxx.yml
+ SYSINCL+=build/sysincl/stl-to-libcxxmsvc.yml
when ($MUSL == "yes") {
SYSINCL+=build/sysincl/libc-musl-libcxx.yml
}
diff --git a/contrib/libs/cxxsupp/CMakeLists.windows-x86_64.txt b/contrib/libs/cxxsupp/CMakeLists.windows-x86_64.txt
index 64bc59c91d..f1baa27a2a 100644
--- a/contrib/libs/cxxsupp/CMakeLists.windows-x86_64.txt
+++ b/contrib/libs/cxxsupp/CMakeLists.windows-x86_64.txt
@@ -6,9 +6,9 @@
# original buildsystem will not be accepted.
-add_subdirectory(libcxx)
+add_subdirectory(libcxxmsvc)
add_library(contrib-libs-cxxsupp INTERFACE)
target_link_libraries(contrib-libs-cxxsupp INTERFACE
- libs-cxxsupp-libcxx
+ libs-cxxsupp-libcxxmsvc
)
diff --git a/contrib/libs/cxxsupp/libcxx/CMakeLists.txt b/contrib/libs/cxxsupp/libcxx/CMakeLists.txt
index f8b31df0c1..606ff46b4b 100644
--- a/contrib/libs/cxxsupp/libcxx/CMakeLists.txt
+++ b/contrib/libs/cxxsupp/libcxx/CMakeLists.txt
@@ -10,8 +10,6 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarc
include(CMakeLists.linux-aarch64.txt)
elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
include(CMakeLists.darwin-x86_64.txt)
-elseif (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" AND NOT HAVE_CUDA)
- include(CMakeLists.windows-x86_64.txt)
elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND NOT HAVE_CUDA)
include(CMakeLists.linux-x86_64.txt)
endif()
diff --git a/contrib/libs/cxxsupp/libcxx/CMakeLists.windows-x86_64.txt b/contrib/libs/cxxsupp/libcxx/CMakeLists.windows-x86_64.txt
deleted file mode 100644
index 9bcd505f90..0000000000
--- a/contrib/libs/cxxsupp/libcxx/CMakeLists.windows-x86_64.txt
+++ /dev/null
@@ -1,75 +0,0 @@
-
-# This file was generated by the build system used internally in the Yandex monorepo.
-# Only simple modifications are allowed (adding source-files to targets, adding simple properties
-# like target_include_directories). These modifications will be ported to original
-# ya.make files by maintainers. Any complex modifications which can't be ported back to the
-# original buildsystem will not be accepted.
-
-
-
-add_library(libs-cxxsupp-libcxx)
-target_compile_options(libs-cxxsupp-libcxx PUBLIC
- -D_LIBCPP_VASPRINTF_DEFINED
- -D_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_
-)
-target_compile_options(libs-cxxsupp-libcxx PRIVATE
- -D_LIBCPP_BUILDING_LIBRARY
- $<IF:$<CXX_COMPILER_ID:MSVC>,,-Wno-everything>
-)
-target_include_directories(libs-cxxsupp-libcxx PUBLIC
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/include
-)
-target_include_directories(libs-cxxsupp-libcxx PRIVATE
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src
-)
-target_sources(libs-cxxsupp-libcxx PRIVATE
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/support/win32/locale_win32.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/support/win32/support.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/support/win32/atomic_win32.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/support/win32/new_win32.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/support/win32/thread_win32.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/algorithm.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/any.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/assert.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/atomic.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/barrier.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/bind.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/charconv.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/chrono.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/condition_variable.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/condition_variable_destructor.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/debug.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/exception.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/filesystem/directory_iterator.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/filesystem/operations.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/functional.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/future.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/hash.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/ios.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/ios.instantiations.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/iostream.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/legacy_pointer_safety.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/locale.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/memory.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/mutex.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/mutex_destructor.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/optional.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/random.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/random_shuffle.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/regex.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/ryu/d2fixed.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/ryu/d2s.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/ryu/f2s.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/shared_mutex.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/stdexcept.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/string.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/strstream.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/system_error.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/thread.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/typeinfo.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/utility.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/valarray.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/variant.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/vector.cpp
- ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxx/src/format.cpp
-)
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/CMakeLists.txt b/contrib/libs/cxxsupp/libcxxmsvc/CMakeLists.txt
new file mode 100644
index 0000000000..03d4a7153c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/CMakeLists.txt
@@ -0,0 +1,11 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+if (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" AND NOT HAVE_CUDA)
+ include(CMakeLists.windows-x86_64.txt)
+endif()
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/CMakeLists.windows-x86_64.txt b/contrib/libs/cxxsupp/libcxxmsvc/CMakeLists.windows-x86_64.txt
new file mode 100644
index 0000000000..33422e3d6e
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/CMakeLists.windows-x86_64.txt
@@ -0,0 +1,75 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_library(libs-cxxsupp-libcxxmsvc)
+target_compile_options(libs-cxxsupp-libcxxmsvc PUBLIC
+ -D_LIBCPP_VASPRINTF_DEFINED
+ -D_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_
+)
+target_compile_options(libs-cxxsupp-libcxxmsvc PRIVATE
+ -D_LIBCPP_BUILDING_LIBRARY
+ $<IF:$<CXX_COMPILER_ID:MSVC>,,-Wno-everything>
+)
+target_include_directories(libs-cxxsupp-libcxxmsvc PUBLIC
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/include
+)
+target_include_directories(libs-cxxsupp-libcxxmsvc PRIVATE
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src
+)
+target_sources(libs-cxxsupp-libcxxmsvc PRIVATE
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/support/win32/locale_win32.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/support/win32/support.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/support/win32/atomic_win32.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/support/win32/new_win32.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/support/win32/thread_win32.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/algorithm.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/any.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/assert.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/atomic.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/barrier.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/bind.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/charconv.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/chrono.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/condition_variable.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/condition_variable_destructor.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/debug.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/exception.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/filesystem/directory_iterator.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/filesystem/operations.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/functional.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/future.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/hash.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/ios.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/ios.instantiations.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/iostream.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/legacy_pointer_safety.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/locale.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/memory.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/mutex.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/mutex_destructor.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/optional.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/random.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/random_shuffle.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/regex.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/ryu/d2fixed.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/ryu/d2s.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/ryu/f2s.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/shared_mutex.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/stdexcept.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/string.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/strstream.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/system_error.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/thread.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/typeinfo.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/utility.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/valarray.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/variant.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/vector.cpp
+ ${CMAKE_SOURCE_DIR}/contrib/libs/cxxsupp/libcxxmsvc/src/format.cpp
+)
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/CREDITS.TXT b/contrib/libs/cxxsupp/libcxxmsvc/CREDITS.TXT
new file mode 100644
index 0000000000..cd5bc08a60
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/CREDITS.TXT
@@ -0,0 +1,186 @@
+This file is a partial list of people who have contributed to the LLVM/libc++
+project. If you have contributed a patch or made some other contribution to
+LLVM/libc++, please submit a patch to this file to add yourself, and it will be
+done!
+
+The list is sorted by surname and formatted to allow easy grepping and
+beautification by scripts. The fields are: name (N), email (E), web-address
+(W), PGP key ID and fingerprint (P), description (D), and snail-mail address
+(S).
+
+N: Saleem Abdulrasool
+E: compnerd@compnerd.org
+D: Minor patches and Linux fixes.
+
+N: Ulf Adams
+D: Invented the Ryu and Ryu Printf algorithms used in floating-point to_chars, and wrote the initial code.
+
+N: Muiez Ahmed
+E: muiez@ibm.com
+D: z/OS port.
+
+N: Dan Albert
+E: danalbert@google.com
+D: Android support and test runner improvements.
+
+N: Dimitry Andric
+E: dimitry@andric.com
+D: Visibility fixes, minor FreeBSD portability patches.
+
+N: Holger Arnold
+E: holgerar@gmail.com
+D: Minor fix.
+
+N: Jorg Brown
+D: Ported floating-point to_chars from MSVC to libc++.
+
+N: David Chisnall
+E: theraven at theravensnest dot org
+D: FreeBSD and Solaris ports, libcxxrt support, some atomics work.
+
+N: Marshall Clow
+E: mclow.lists@gmail.com
+E: marshall@idio.com
+D: C++14 support, patches and bug fixes.
+
+N: Jonathan B Coe
+E: jbcoe@me.com
+D: Implementation of propagate_const.
+
+N: Matthew Dempsky
+E: matthew@dempsky.org
+D: Minor patches and bug fixes.
+
+N: Christopher Di Bella
+E: cjdb@google.com
+E: cjdb.ns@gmail.com
+D: Library concepts.
+
+N: Glen Joseph Fernandes
+E: glenjofe@gmail.com
+D: Implementation of to_address.
+
+N: Eric Fiselier
+E: eric@efcs.ca
+D: LFTS support, patches and bug fixes.
+
+N: Bill Fisher
+E: william.w.fisher@gmail.com
+D: Regex bug fixes.
+
+N: Google Inc.
+D: Copyright owner and contributor of the CityHash algorithm
+
+N: Howard Hinnant
+E: hhinnant@apple.com
+D: Architect and primary author of libc++
+
+N: Sergej Jaskiewicz
+E: jaskiewiczs@icloud.com
+D: Minor improvements in the testing infrastructure
+
+N: Hyeon-bin Jeong
+E: tuhertz@gmail.com
+D: Minor patches and bug fixes.
+
+N: Argyrios Kyrtzidis
+E: kyrtzidis@apple.com
+D: Bug fixes.
+
+N: Stephan T. Lavavej
+E: stl@microsoft.com
+E: stl@nuwen.net
+D: Implemented floating-point to_chars.
+
+N: Microsoft Corporation
+D: Contributed floating-point to_chars.
+
+N: Bruce Mitchener, Jr.
+E: bruce.mitchener@gmail.com
+D: Emscripten-related changes.
+
+N: Michel Morin
+E: mimomorin@gmail.com
+D: Minor patches to is_convertible.
+
+N: Andrew Morrow
+E: andrew.c.morrow@gmail.com
+D: Minor patches and Linux fixes.
+
+N: Michael Park
+E: mcypark@gmail.com
+D: Implementation of <variant>.
+
+N: Arvid Picciani
+E: aep at exys dot org
+D: Minor patches and musl port.
+
+N: Bjorn Reese
+E: breese@users.sourceforge.net
+D: Initial regex prototype
+
+N: Nico Rieck
+E: nico.rieck@gmail.com
+D: Windows fixes
+
+N: Jon Roelofs
+E: jroelofS@jroelofs.com
+D: Remote testing, Newlib port, baremetal/single-threaded support.
+
+N: Kent Ross
+E: k@mad.cash
+D: Patches for operator<=> support
+
+N: Jonathan Sauer
+D: Minor patches, mostly related to constexpr
+
+N: Craig Silverstein
+E: csilvers@google.com
+D: Implemented Cityhash as the string hash function on 64-bit machines
+
+N: Richard Smith
+D: Minor patches.
+
+N: Joerg Sonnenberger
+E: joerg@NetBSD.org
+D: NetBSD port.
+
+N: Stephan Tolksdorf
+E: st@quanttec.com
+D: Minor <atomic> fix
+
+N: Ruben Van Boxem
+E: vanboxem dot ruben at gmail dot com
+D: Initial Windows patches.
+
+N: Michael van der Westhuizen
+E: r1mikey at gmail dot com
+
+N: Larisse Voufo
+D: Minor patches.
+
+N: Klaas de Vries
+E: klaas at klaasgaaf dot nl
+D: Minor bug fix.
+
+N: Mark de Wever
+E: koraq at xs4all dot nl
+D: Format library support.
+D: Finalized the porting of MSVC's to_chars to libc++.
+
+N: Zhang Xiongpang
+E: zhangxiongpang@gmail.com
+D: Minor patches and bug fixes.
+
+N: Xing Xue
+E: xingxue@ca.ibm.com
+D: AIX port
+
+N: Jeffrey Yasskin
+E: jyasskin@gmail.com
+E: jyasskin@google.com
+D: Linux fixes.
+
+N: Zhihao Yuan
+E: lichray@gmail.com
+D: Standard compatibility fixes.
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/LICENSE.TXT b/contrib/libs/cxxsupp/libcxxmsvc/LICENSE.TXT
new file mode 100644
index 0000000000..e159d28344
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/LICENSE.TXT
@@ -0,0 +1,311 @@
+==============================================================================
+The LLVM Project is under the Apache License v2.0 with LLVM Exceptions:
+==============================================================================
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+---- LLVM Exceptions to the Apache 2.0 License ----
+
+As an exception, if, as a result of your compiling your source code, portions
+of this Software are embedded into an Object form of such source code, you
+may redistribute such embedded portions in such Object form without complying
+with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
+
+In addition, if you combine or link compiled forms of this Software with
+software that is licensed under the GPLv2 ("Combined Software") and if a
+court of competent jurisdiction determines that the patent provision (Section
+3), the indemnity provision (Section 9) or other Section of the License
+conflicts with the conditions of the GPLv2, you may retroactively and
+prospectively choose to deem waived or otherwise exclude such Section(s) of
+the License, but only in their entirety and only with respect to the Combined
+Software.
+
+==============================================================================
+Software from third parties included in the LLVM Project:
+==============================================================================
+The LLVM Project contains third party software which is under different license
+terms. All such code will be identified clearly using at least one of two
+mechanisms:
+1) It will be in a separate directory tree with its own `LICENSE.txt` or
+ `LICENSE` file at the top containing the specific license and restrictions
+ which apply to that software, or
+2) It will contain specific license and restriction terms at the top of every
+ file.
+
+==============================================================================
+Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy):
+==============================================================================
+
+The libc++ library is dual licensed under both the University of Illinois
+"BSD-Like" license and the MIT license. As a user of this code you may choose
+to use it under either license. As a contributor, you agree to allow your code
+to be used under both.
+
+Full text of the relevant licenses is included below.
+
+==============================================================================
+
+University of Illinois/NCSA
+Open Source License
+
+Copyright (c) 2009-2019 by the contributors listed in CREDITS.TXT
+
+All rights reserved.
+
+Developed by:
+
+ LLVM Team
+
+ University of Illinois at Urbana-Champaign
+
+ http://llvm.org
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal with
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimers.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimers in the
+ documentation and/or other materials provided with the distribution.
+
+ * Neither the names of the LLVM Team, University of Illinois at
+ Urbana-Champaign, nor the names of its contributors may be used to
+ endorse or promote products derived from this Software without specific
+ prior written permission.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
+SOFTWARE.
+
+==============================================================================
+
+Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/adjacent_find.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/adjacent_find.h
new file mode 100644
index 0000000000..83d8c260f2
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/adjacent_find.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___ALGORITHM_ADJACENT_FIND_H
+#define _LIBCPP___ALGORITHM_ADJACENT_FIND_H
+
+#include <__algorithm/comp.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___ALGORITHM_ADJACENT_FIND_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/all_of.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/all_of.h
new file mode 100644
index 0000000000..3af32a5775
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/all_of.h
@@ -0,0 +1,32 @@
+// -*- 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_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
+
+#endif // _LIBCPP___ALGORITHM_ALL_OF_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/any_of.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/any_of.h
new file mode 100644
index 0000000000..6fe6a0b6b3
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/any_of.h
@@ -0,0 +1,32 @@
+// -*- 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_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
+
+#endif // _LIBCPP___ALGORITHM_ANY_OF_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/binary_search.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/binary_search.h
new file mode 100644
index 0000000000..15a17e1cde
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/binary_search.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_BINARY_SEARCH_H
+#define _LIBCPP___ALGORITHM_BINARY_SEARCH_H
+
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/lower_bound.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___ALGORITHM_BINARY_SEARCH_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/clamp.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/clamp.h
new file mode 100644
index 0000000000..b3762b85a0
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/clamp.h
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <__algorithm/comp.h>
+#include <__assert>
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 14
+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
+
+#endif // _LIBCPP___ALGORITHM_CLAMP_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/comp.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/comp.h
new file mode 100644
index 0000000000..62c06ae57f
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/comp.h
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_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
+
+#endif // _LIBCPP___ALGORITHM_COMP_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/comp_ref_type.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/comp_ref_type.h
new file mode 100644
index 0000000000..3e90e9adae
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/comp_ref_type.h
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <__assert>
+#include <__config>
+#include <__debug>
+#include <__utility/declval.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Compare>
+struct __debug_less
+{
+ _Compare &__comp_;
+ _LIBCPP_CONSTEXPR_AFTER_CXX11
+ __debug_less(_Compare& __c) : __comp_(__c) {}
+
+ template <class _Tp, class _Up>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11
+ 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_CXX11
+ 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_CXX11
+ inline _LIBCPP_INLINE_VISIBILITY
+ decltype((void)declval<_Compare&>()(
+ declval<_LHS const&>(), declval<_RHS const&>()))
+ __do_compare_assert(int, _LHS & __l, _RHS & __r) {
+ _LIBCPP_ASSERT(!__comp_(__l, __r),
+ "Comparator does not induce a strict weak ordering");
+ (void)__l;
+ (void)__r;
+ }
+
+ template <class _LHS, class _RHS>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11
+ inline _LIBCPP_INLINE_VISIBILITY
+ void __do_compare_assert(long, _LHS &, _RHS &) {}
+};
+
+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.
+#if _LIBCPP_DEBUG_LEVEL == 0
+ typedef _Comp& type;
+#else
+ typedef __debug_less<_Comp> type;
+#endif
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ALGORITHM_COMP_REF_TYPE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/copy.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/copy.h
new file mode 100644
index 0000000000..b4045cd06a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/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_COPY_H
+#define _LIBCPP___ALGORITHM_COPY_H
+
+#include <__algorithm/unwrap_iter.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <cstring>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___ALGORITHM_COPY_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/copy_backward.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/copy_backward.h
new file mode 100644
index 0000000000..9754f0c95b
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/copy_backward.h
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <__algorithm/unwrap_iter.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <cstring>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___ALGORITHM_COPY_BACKWARD_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/copy_if.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/copy_if.h
new file mode 100644
index 0000000000..9c3cd29e24
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/copy_if.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___ALGORITHM_COPY_IF_H
+#define _LIBCPP___ALGORITHM_COPY_IF_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___ALGORITHM_COPY_IF_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/copy_n.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/copy_n.h
new file mode 100644
index 0000000000..8b915af63c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/copy_n.h
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <__algorithm/copy.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_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 typename iterator_traits<_InputIterator>::difference_type difference_type;
+ typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
+ _IntegralSize __n = __orig_n;
+ return _VSTD::copy(__first, __first + difference_type(__n), __result);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ALGORITHM_COPY_N_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/count.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/count.h
new file mode 100644
index 0000000000..e18128cae8
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/count.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___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_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
+
+#endif // _LIBCPP___ALGORITHM_COUNT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/count_if.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/count_if.h
new file mode 100644
index 0000000000..1ec2d83394
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/count_if.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___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_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
+
+#endif // _LIBCPP___ALGORITHM_COUNT_IF_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/equal.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/equal.h
new file mode 100644
index 0000000000..ca1bc6bc56
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/equal.h
@@ -0,0 +1,85 @@
+// -*- 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 <__algorithm/comp.h>
+#include <__config>
+#include <__iterator/distance.h>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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,
+ _BinaryPredicate&>(__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<_BinaryPredicate&>(
+ __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
+
+#endif // _LIBCPP___ALGORITHM_EQUAL_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/equal_range.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/equal_range.h
new file mode 100644
index 0000000000..37a2c299f0
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/equal_range.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_EQUAL_RANGE_H
+#define _LIBCPP___ALGORITHM_EQUAL_RANGE_H
+
+#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 <__config>
+#include <iterator>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___ALGORITHM_EQUAL_RANGE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/fill.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/fill.h
new file mode 100644
index 0000000000..be5b4740a5
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/fill.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_FILL_H
+#define _LIBCPP___ALGORITHM_FILL_H
+
+#include <__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_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
+
+#endif // _LIBCPP___ALGORITHM_FILL_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/fill_n.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/fill_n.h
new file mode 100644
index 0000000000..590c8f38f3
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/fill_n.h
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_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
+
+#endif // _LIBCPP___ALGORITHM_FILL_N_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/find.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/find.h
new file mode 100644
index 0000000000..641b85e2f6
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/find.h
@@ -0,0 +1,32 @@
+// -*- 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_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
+
+#endif // _LIBCPP___ALGORITHM_FIND_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/find_end.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/find_end.h
new file mode 100644
index 0000000000..0220c09397
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/find_end.h
@@ -0,0 +1,150 @@
+// -*- 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 <__algorithm/comp.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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) {
+ 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
+ _D2 __len2 = __last2 - __first2;
+ if (__len2 == 0)
+ return __last1;
+ _D1 __len1 = __last1 - __first1;
+ if (__len1 < __len2)
+ return __last1;
+ const _RandomAccessIterator1 __s = __first1 + _D1(__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<_BinaryPredicate&>(
+ __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
+
+#endif // _LIBCPP___ALGORITHM_FIND_END_OF_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/find_first_of.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/find_first_of.h
new file mode 100644
index 0000000000..b968329fc3
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/find_first_of.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___ALGORITHM_FIND_FIRST_OF_H
+#define _LIBCPP___ALGORITHM_FIND_FIRST_OF_H
+
+#include <__algorithm/comp.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___ALGORITHM_FIND_FIRST_OF_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/find_if.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/find_if.h
new file mode 100644
index 0000000000..aa98171a1f
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/find_if.h
@@ -0,0 +1,32 @@
+// -*- 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_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
+
+#endif // _LIBCPP___ALGORITHM_FIND_IF_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/find_if_not.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/find_if_not.h
new file mode 100644
index 0000000000..61ddab0b98
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/find_if_not.h
@@ -0,0 +1,32 @@
+// -*- 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_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
+
+#endif // _LIBCPP___ALGORITHM_FIND_IF_NOT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/for_each.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/for_each.h
new file mode 100644
index 0000000000..bfbd37c3a3
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/for_each.h
@@ -0,0 +1,32 @@
+// -*- 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_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
+
+#endif // _LIBCPP___ALGORITHM_FOR_EACH_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/for_each_n.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/for_each_n.h
new file mode 100644
index 0000000000..2552b40c27
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/for_each_n.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___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_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
+
+#endif // _LIBCPP___ALGORITHM_FOR_EACH_N_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/generate.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/generate.h
new file mode 100644
index 0000000000..dacbd8c681
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/generate.h
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_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
+
+#endif // _LIBCPP___ALGORITHM_GENERATE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/generate_n.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/generate_n.h
new file mode 100644
index 0000000000..2650e9e5d8
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/generate_n.h
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_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
+
+#endif // _LIBCPP___ALGORITHM_GENERATE_N_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/half_positive.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/half_positive.h
new file mode 100644
index 0000000000..7666ef1449
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/half_positive.h
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_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
+
+#endif // _LIBCPP___ALGORITHM_HALF_POSITIVE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/in_fun_result.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/in_fun_result.h
new file mode 100644
index 0000000000..d5186e11b7
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/in_fun_result.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___ALGORITHM_IN_FUN_RESULT_H
+#define _LIBCPP___ALGORITHM_IN_FUN_RESULT_H
+
+#include <__concepts/convertible_to.h>
+#include <__config>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifndef _LIBCPP_HAS_NO_CONCEPTS
+
+namespace ranges {
+template <class _Ip, class _Fp>
+struct in_fun_result {
+ _LIBCPP_NO_UNIQUE_ADDRESS _Ip in;
+ _LIBCPP_NO_UNIQUE_ADDRESS _Fp fun;
+
+ template <class _I2, class _F2>
+ requires convertible_to<const _Ip&, _I2> && convertible_to<const _Fp&, _F2>
+ _LIBCPP_HIDE_FROM_ABI constexpr operator in_fun_result<_I2, _F2>() const & {
+ return {in, fun};
+ }
+
+ template <class _I2, class _F2>
+ requires convertible_to<_Ip, _I2> && convertible_to<_Fp, _F2>
+ _LIBCPP_HIDE_FROM_ABI constexpr operator in_fun_result<_I2, _F2>() && {
+ return {std::move(in), std::move(fun)};
+ }
+};
+} // namespace ranges
+
+#endif // _LIBCPP_HAS_NO_RANGES
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ALGORITHM_IN_FUN_RESULT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/in_in_out_result.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/in_in_out_result.h
new file mode 100644
index 0000000000..f7cb698472
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/in_in_out_result.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___ALGORITHM_IN_IN_OUT_RESULT_H
+#define _LIBCPP___ALGORITHM_IN_IN_OUT_RESULT_H
+
+#include <__concepts/convertible_to.h>
+#include <__config>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+namespace ranges {
+
+template <class _I1, class _I2, class _O1>
+struct in_in_out_result {
+ _LIBCPP_NO_UNIQUE_ADDRESS _I1 in1;
+ _LIBCPP_NO_UNIQUE_ADDRESS _I2 in2;
+ _LIBCPP_NO_UNIQUE_ADDRESS _O1 out;
+
+ template <class _II1, class _II2, class _OO1>
+ requires convertible_to<const _I1&, _II1> && convertible_to<const _I2&, _II2> && convertible_to<const _O1&, _OO1>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ operator in_in_out_result<_II1, _II2, _OO1>() const& {
+ return {in1, in2, out};
+ }
+
+ template <class _II1, class _II2, class _OO1>
+ requires convertible_to<_I1, _II1> && convertible_to<_I2, _II2> && convertible_to<_O1, _OO1>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ operator in_in_out_result<_II1, _II2, _OO1>() && {
+ return {_VSTD::move(in1), _VSTD::move(in2), _VSTD::move(out)};
+ }
+};
+
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ALGORITHM_IN_IN_OUT_RESULT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/in_in_result.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/in_in_result.h
new file mode 100644
index 0000000000..159092189a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/in_in_result.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_IN_IN_RESULT_H
+#define _LIBCPP___ALGORITHM_IN_IN_RESULT_H
+
+#include <__concepts/convertible_to.h>
+#include <__config>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+namespace ranges {
+
+template <class _I1, class _I2>
+struct in_in_result {
+ _LIBCPP_NO_UNIQUE_ADDRESS _I1 in1;
+ _LIBCPP_NO_UNIQUE_ADDRESS _I2 in2;
+
+ template <class _II1, class _II2>
+ requires convertible_to<const _I1&, _II1> && convertible_to<const _I2&, _II2>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ operator in_in_result<_II1, _II2>() const & {
+ return {in1, in2};
+ }
+
+ template <class _II1, class _II2>
+ requires convertible_to<_I1, _II1> && convertible_to<_I2, _II2>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ operator in_in_result<_II1, _II2>() && { return {_VSTD::move(in1), _VSTD::move(in2)}; }
+};
+
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ALGORITHM_IN_IN_RESULT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/in_out_out_result.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/in_out_out_result.h
new file mode 100644
index 0000000000..9788fbfa2e
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/in_out_out_result.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___ALGORITHM_IN_OUT_OUT_RESULT_H
+#define _LIBCPP___ALGORITHM_IN_OUT_OUT_RESULT_H
+
+#include <__concepts/convertible_to.h>
+#include <__config>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifndef _LIBCPP_HAS_NO_CONCEPTS
+
+namespace ranges {
+template <class _I1, class _O1, class _O2>
+struct in_out_out_result {
+ _LIBCPP_NO_UNIQUE_ADDRESS _I1 in;
+ _LIBCPP_NO_UNIQUE_ADDRESS _O1 out1;
+ _LIBCPP_NO_UNIQUE_ADDRESS _O2 out2;
+
+ template <class _II1, class _OO1, class _OO2>
+ requires convertible_to<const _I1&, _II1> && convertible_to<const _O1&, _OO1> && convertible_to<const _O2&, _OO2>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ operator in_out_out_result<_II1, _OO1, _OO2>() const& {
+ return {in, out1, out2};
+ }
+
+ template <class _II1, class _OO1, class _OO2>
+ requires convertible_to<_I1, _II1> && convertible_to<_O1, _OO1> && convertible_to<_O2, _OO2>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ operator in_out_out_result<_II1, _OO1, _OO2>() && {
+ return {_VSTD::move(in), _VSTD::move(out1), _VSTD::move(out2)};
+ }
+};
+} // namespace ranges
+
+#endif // _LIBCPP_HAS_NO_CONCEPTS
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ALGORITHM_IN_OUT_OUT_RESULT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/in_out_result.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/in_out_result.h
new file mode 100644
index 0000000000..fd394a3621
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/in_out_result.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___ALGORITHM_IN_OUT_RESULT_H
+#define _LIBCPP___ALGORITHM_IN_OUT_RESULT_H
+
+#include <__concepts/convertible_to.h>
+#include <__config>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+namespace ranges {
+
+template<class _InputIterator, class _OutputIterator>
+struct in_out_result {
+ _LIBCPP_NO_UNIQUE_ADDRESS _InputIterator in;
+ _LIBCPP_NO_UNIQUE_ADDRESS _OutputIterator out;
+
+ template <class _InputIterator2, class _OutputIterator2>
+ requires convertible_to<const _InputIterator&, _InputIterator2> && convertible_to<const _OutputIterator&,
+ _OutputIterator2>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr operator in_out_result<_InputIterator2, _OutputIterator2>() const & {
+ return {in, out};
+ }
+
+ template <class _InputIterator2, class _OutputIterator2>
+ requires convertible_to<_InputIterator, _InputIterator2> && convertible_to<_OutputIterator, _OutputIterator2>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr operator in_out_result<_InputIterator2, _OutputIterator2>() && {
+ return {_VSTD::move(in), _VSTD::move(out)};
+ }
+};
+
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ALGORITHM_IN_OUT_RESULT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/includes.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/includes.h
new file mode 100644
index 0000000000..4c87e8d221
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/includes.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_INCLUDES_H
+#define _LIBCPP___ALGORITHM_INCLUDES_H
+
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___ALGORITHM_INCLUDES_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/inplace_merge.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/inplace_merge.h
new file mode 100644
index 0000000000..90ca152c5b
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/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 <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/lower_bound.h>
+#include <__algorithm/min.h>
+#include <__algorithm/move.h>
+#include <__algorithm/rotate.h>
+#include <__algorithm/upper_bound.h>
+#include <__config>
+#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/libs/cxxsupp/libcxxmsvc/include/__algorithm/is_heap.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/is_heap.h
new file mode 100644
index 0000000000..fe44e634f6
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/is_heap.h
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/is_heap_until.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__is_heap_until<_Comp_ref>(__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
+
+#endif // _LIBCPP___ALGORITHM_IS_HEAP_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/is_heap_until.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/is_heap_until.h
new file mode 100644
index 0000000000..39f313eb0d
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/is_heap_until.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_IS_HEAP_UNTIL_H
+#define _LIBCPP___ALGORITHM_IS_HEAP_UNTIL_H
+
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Compare, class _RandomAccessIterator>
+_LIBCPP_HIDE_FROM_ABI _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, class _Compare>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator
+is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__is_heap_until<_Comp_ref>(__first, __last, __comp);
+}
+
+template<class _RandomAccessIterator>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _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
+
+#endif // _LIBCPP___ALGORITHM_IS_HEAP_UNTIL_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/is_partitioned.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/is_partitioned.h
new file mode 100644
index 0000000000..b4f421cfc0
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/is_partitioned.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_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_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
+
+#endif // _LIBCPP___ALGORITHM_IS_PARTITIONED_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/is_permutation.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/is_permutation.h
new file mode 100644
index 0000000000..cdd7420484
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/is_permutation.h
@@ -0,0 +1,162 @@
+// -*- 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/distance.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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,
+ _BinaryPredicate&>(__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<_BinaryPredicate&>(
+ __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
+
+#endif // _LIBCPP___ALGORITHM_IS_PERMUTATION_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/is_sorted.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/is_sorted.h
new file mode 100644
index 0000000000..56de95bb31
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/is_sorted.h
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// 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/comp_ref_type.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_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)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__is_sorted_until<_Comp_ref>(__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
+
+#endif // _LIBCPP___ALGORITHM_IS_SORTED_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/is_sorted_until.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/is_sorted_until.h
new file mode 100644
index 0000000000..338d28508c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/is_sorted_until.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_IS_SORTED_UNTIL_H
+#define _LIBCPP___ALGORITHM_IS_SORTED_UNTIL_H
+
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Compare, class _ForwardIterator>
+_LIBCPP_HIDE_FROM_ABI _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, class _Compare>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__is_sorted_until<_Comp_ref>(__first, __last, __comp);
+}
+
+template<class _ForwardIterator>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _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
+
+#endif // _LIBCPP___ALGORITHM_IS_SORTED_UNTIL_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/iter_swap.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/iter_swap.h
new file mode 100644
index 0000000000..038859e136
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/iter_swap.h
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_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
+
+#endif // _LIBCPP___ALGORITHM_ITER_SWAP_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/lexicographical_compare.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/lexicographical_compare.h
new file mode 100644
index 0000000000..30ddf24081
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/lexicographical_compare.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_LEXICOGRAPHICAL_COMPARE_H
+#define _LIBCPP___ALGORITHM_LEXICOGRAPHICAL_COMPARE_H
+
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___ALGORITHM_LEXICOGRAPHICAL_COMPARE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/lower_bound.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/lower_bound.h
new file mode 100644
index 0000000000..26b64ec12d
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/lower_bound.h
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <__algorithm/comp.h>
+#include <__algorithm/half_positive.h>
+#include <__config>
+#include <iterator>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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)
+{
+ return _VSTD::__lower_bound<_Compare&>(__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
+
+#endif // _LIBCPP___ALGORITHM_LOWER_BOUND_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/make_heap.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/make_heap.h
new file mode 100644
index 0000000000..acac0aabf1
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/make_heap.h
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/sift_down.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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, __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
+
+#endif // _LIBCPP___ALGORITHM_MAKE_HEAP_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/max.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/max.h
new file mode 100644
index 0000000000..345b235a21
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/max.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_MAX_H
+#define _LIBCPP___ALGORITHM_MAX_H
+
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/max_element.h>
+#include <__config>
+#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)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return *_VSTD::__max_element<_Comp_ref>(__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/libs/cxxsupp/libcxxmsvc/include/__algorithm/max_element.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/max_element.h
new file mode 100644
index 0000000000..795ec8e1dd
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/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 <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Compare, class _ForwardIterator>
+inline _LIBCPP_HIDE_FROM_ABI _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, class _Compare>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
+max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__max_element<_Comp_ref>(__first, __last, __comp);
+}
+
+
+template <class _ForwardIterator>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _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
+
+#endif // _LIBCPP___ALGORITHM_MAX_ELEMENT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/merge.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/merge.h
new file mode 100644
index 0000000000..48360ed5b4
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/merge.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_MERGE_H
+#define _LIBCPP___ALGORITHM_MERGE_H
+
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/copy.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___ALGORITHM_MERGE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/min.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/min.h
new file mode 100644
index 0000000000..3d8c73d78f
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/min.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_MIN_H
+#define _LIBCPP___ALGORITHM_MIN_H
+
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/min_element.h>
+#include <__config>
+#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)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return *_VSTD::__min_element<_Comp_ref>(__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/libs/cxxsupp/libcxxmsvc/include/__algorithm/min_element.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/min_element.h
new file mode 100644
index 0000000000..129833d42b
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/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 <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Compare, class _ForwardIterator>
+inline _LIBCPP_HIDE_FROM_ABI _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, class _Compare>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
+min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__min_element<_Comp_ref>(__first, __last, __comp);
+}
+
+template <class _ForwardIterator>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _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
+
+#endif // _LIBCPP___ALGORITHM_MIN_ELEMENT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/minmax.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/minmax.h
new file mode 100644
index 0000000000..30a119491a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/minmax.h
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <__algorithm/comp.h>
+#include <__config>
+#include <__utility/pair.h>
+#include <initializer_list>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___ALGORITHM_MINMAX_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/minmax_element.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/minmax_element.h
new file mode 100644
index 0000000000..80afbdf87a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/minmax_element.h
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <__algorithm/comp.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <__utility/pair.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___ALGORITHM_MINMAX_ELEMENT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/mismatch.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/mismatch.h
new file mode 100644
index 0000000000..f2011faf2f
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/mismatch.h
@@ -0,0 +1,67 @@
+// -*- 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 <__algorithm/comp.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <__utility/pair.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___ALGORITHM_MISMATCH_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/move.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/move.h
new file mode 100644
index 0000000000..72bf3d76ea
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/move.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_MOVE_H
+#define _LIBCPP___ALGORITHM_MOVE_H
+
+#include <__algorithm/unwrap_iter.h>
+#include <__config>
+#include <__utility/move.h>
+#include <cstring>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___ALGORITHM_MOVE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/move_backward.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/move_backward.h
new file mode 100644
index 0000000000..a56f6b826c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/move_backward.h
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <__algorithm/unwrap_iter.h>
+#include <__config>
+#include <__utility/move.h>
+#include <cstring>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___ALGORITHM_MOVE_BACKWARD_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/next_permutation.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/next_permutation.h
new file mode 100644
index 0000000000..05e56f4a17
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/next_permutation.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_NEXT_PERMUTATION_H
+#define _LIBCPP___ALGORITHM_NEXT_PERMUTATION_H
+
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/reverse.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <__utility/swap.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___ALGORITHM_NEXT_PERMUTATION_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/none_of.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/none_of.h
new file mode 100644
index 0000000000..b34b1e00dd
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/none_of.h
@@ -0,0 +1,32 @@
+// -*- 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_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
+
+#endif // _LIBCPP___ALGORITHM_NONE_OF_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/nth_element.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/nth_element.h
new file mode 100644
index 0000000000..0f9f66d3ca
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/nth_element.h
@@ -0,0 +1,248 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/sort.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <__utility/swap.h>
+
+#if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY)
+# include <__algorithm/shuffle.h>
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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)
+{
+ _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last);
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ _VSTD::__nth_element<_Comp_ref>(__first, __nth, __last, __comp);
+ _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __nth);
+ if (__nth != __last) {
+ _LIBCPP_DEBUG_RANDOMIZE_RANGE(++__nth, __last);
+ }
+}
+
+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
+
+#endif // _LIBCPP___ALGORITHM_NTH_ELEMENT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/partial_sort.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/partial_sort.h
new file mode 100644
index 0000000000..8adf5b2f4f
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/partial_sort.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_PARTIAL_SORT_H
+#define _LIBCPP___ALGORITHM_PARTIAL_SORT_H
+
+#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 <__config>
+#include <__iterator/iterator_traits.h>
+#include <__utility/swap.h>
+
+#if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY)
+# include <__algorithm/shuffle.h>
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Compare, class _RandomAccessIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
+__partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
+ _Compare __comp)
+{
+ if (__first == __middle)
+ return;
+ _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, __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)
+{
+ _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last);
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ _VSTD::__partial_sort<_Comp_ref>(__first, __middle, __last, __comp);
+ _LIBCPP_DEBUG_RANDOMIZE_RANGE(__middle, __last);
+}
+
+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
+
+#endif // _LIBCPP___ALGORITHM_PARTIAL_SORT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/partial_sort_copy.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/partial_sort_copy.h
new file mode 100644
index 0000000000..7ed1e538e9
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/partial_sort_copy.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_COPY_H
+#define _LIBCPP___ALGORITHM_PARTIAL_SORT_COPY_H
+
+#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 <__config>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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, __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
+
+#endif // _LIBCPP___ALGORITHM_PARTIAL_SORT_COPY_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/partition.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/partition.h
new file mode 100644
index 0000000000..73d94831ed
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/partition.h
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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<_Predicate&>(
+ __first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ALGORITHM_PARTITION_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/partition_copy.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/partition_copy.h
new file mode 100644
index 0000000000..cacde0bfd4
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/partition_copy.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_PARTITION_COPY_H
+#define _LIBCPP___ALGORITHM_PARTITION_COPY_H
+
+#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <__utility/pair.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___ALGORITHM_PARTITION_COPY_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/partition_point.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/partition_point.h
new file mode 100644
index 0000000000..c2fa841edc
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/partition_point.h
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <__algorithm/half_positive.h>
+#include <__config>
+#include <iterator>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___ALGORITHM_PARTITION_POINT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/pop_heap.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/pop_heap.h
new file mode 100644
index 0000000000..2a69f6ee47
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/pop_heap.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_POP_HEAP_H
+#define _LIBCPP___ALGORITHM_POP_HEAP_H
+
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/sift_down.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <__utility/swap.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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, __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
+
+#endif // _LIBCPP___ALGORITHM_POP_HEAP_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/prev_permutation.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/prev_permutation.h
new file mode 100644
index 0000000000..9dbc1dad01
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/prev_permutation.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_PREV_PERMUTATION_H
+#define _LIBCPP___ALGORITHM_PREV_PERMUTATION_H
+
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/reverse.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <__utility/swap.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___ALGORITHM_PREV_PERMUTATION_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/push_heap.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/push_heap.h
new file mode 100644
index 0000000000..66973e082f
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/push_heap.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_PUSH_HEAP_H
+#define _LIBCPP___ALGORITHM_PUSH_HEAP_H
+
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.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_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
+
+#endif // _LIBCPP___ALGORITHM_PUSH_HEAP_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/ranges_min_element.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/ranges_min_element.h
new file mode 100644
index 0000000000..82aaeea1c8
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/ranges_min_element.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_RANGES_MIN_ELEMENT_H
+#define _LIBCPP___ALGORITHM_RANGES_MIN_ELEMENT_H
+
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/forward.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __min_element {
+struct __fn {
+ template <class _Ip, class _Sp, class _Proj, class _Comp>
+ _LIBCPP_HIDE_FROM_ABI static constexpr
+ _Ip __go(_Ip __first, _Sp __last, _Comp& __comp, _Proj& __proj) {
+ if (__first == __last)
+ return __first;
+
+ _Ip __i = __first;
+ while (++__i != __last)
+ if (std::invoke(__comp, std::invoke(__proj, *__i), std::invoke(__proj, *__first)))
+ __first = __i;
+ return __first;
+ }
+
+ template <forward_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity,
+ indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ _Ip operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const {
+ return __go(__first, __last, __comp, __proj);
+ }
+
+ template <forward_range _Rp, class _Proj = identity,
+ indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
+ return __go(ranges::begin(__r), ranges::end(__r), __comp, __proj);
+ }
+};
+} // namespace __min_element
+
+inline namespace __cpo {
+ inline constexpr auto min_element = __min_element::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_MIN_ELEMENT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/ranges_swap_ranges.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/ranges_swap_ranges.h
new file mode 100644
index 0000000000..59a875ae3b
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/ranges_swap_ranges.h
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_RANGES_SWAP_RANGES_H
+#define _LIBCPP___ALGORITHM_RANGES_SWAP_RANGES_H
+
+#include <__algorithm/in_in_result.h>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/iter_swap.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifndef _LIBCPP_HAS_NO_CONCEPTS
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _I1, class _I2>
+using swap_ranges_result = in_in_result<_I1, _I2>;
+
+namespace __swap_ranges {
+struct __fn {
+ template <input_iterator _I1, sentinel_for<_I1> _S1,
+ input_iterator _I2, sentinel_for<_I2> _S2>
+ requires indirectly_swappable<_I1, _I2>
+ _LIBCPP_HIDE_FROM_ABI constexpr swap_ranges_result<_I1, _I2>
+ operator()(_I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2) const {
+ while (__first1 != __last1 && __first2 != __last2) {
+ ranges::iter_swap(__first1, __first2);
+ ++__first1;
+ ++__first2;
+ }
+ return {_VSTD::move(__first1), _VSTD::move(__first2)};
+ }
+
+ template <input_range _R1, input_range _R2>
+ requires indirectly_swappable<iterator_t<_R1>, iterator_t<_R2>>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ swap_ranges_result<borrowed_iterator_t<_R1>, borrowed_iterator_t<_R2>>
+ operator()(_R1&& __r1, _R2&& __r2) const {
+ return operator()(ranges::begin(__r1), ranges::end(__r1),
+ ranges::begin(__r2), ranges::end(__r2));
+ }
+};
+} // namespace __swap_ranges
+
+inline namespace __cpo {
+ inline constexpr auto swap_ranges = __swap_ranges::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_HAS_NO_RANGES
+
+#endif // _LIBCPP___ALGORITHM_RANGES_SWAP_RANGES_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/remove.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/remove.h
new file mode 100644
index 0000000000..c00f96f78a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/remove.h
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <__algorithm/find.h>
+#include <__algorithm/find_if.h>
+#include <__config>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___ALGORITHM_REMOVE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/remove_copy.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/remove_copy.h
new file mode 100644
index 0000000000..a29a385af9
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/remove_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_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_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
+
+#endif // _LIBCPP___ALGORITHM_REMOVE_COPY_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/remove_copy_if.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/remove_copy_if.h
new file mode 100644
index 0000000000..36ddba4883
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/remove_copy_if.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_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_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
+
+#endif // _LIBCPP___ALGORITHM_REMOVE_COPY_IF_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/remove_if.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/remove_if.h
new file mode 100644
index 0000000000..0ae131498d
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/remove_if.h
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <__algorithm/find_if.h>
+#include <__config>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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, _Predicate&>(__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
+
+#endif // _LIBCPP___ALGORITHM_REMOVE_IF_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/replace.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/replace.h
new file mode 100644
index 0000000000..d0ae8f65d4
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/replace.h
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_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
+
+#endif // _LIBCPP___ALGORITHM_REPLACE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/replace_copy.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/replace_copy.h
new file mode 100644
index 0000000000..7c8a5a0b93
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/replace_copy.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_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_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
+
+#endif // _LIBCPP___ALGORITHM_REPLACE_COPY_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/replace_copy_if.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/replace_copy_if.h
new file mode 100644
index 0000000000..9d8a68fdc0
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/replace_copy_if.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_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_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
+
+#endif // _LIBCPP___ALGORITHM_REPLACE_COPY_IF_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/replace_if.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/replace_if.h
new file mode 100644
index 0000000000..37c719a34c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/replace_if.h
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_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
+
+#endif // _LIBCPP___ALGORITHM_REPLACE_IF_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/reverse.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/reverse.h
new file mode 100644
index 0000000000..0202cd7408
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/reverse.h
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <__algorithm/iter_swap.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___ALGORITHM_REVERSE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/reverse_copy.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/reverse_copy.h
new file mode 100644
index 0000000000..1583907078
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/reverse_copy.h
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_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
+
+#endif // _LIBCPP___ALGORITHM_REVERSE_COPY_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/rotate.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/rotate.h
new file mode 100644
index 0000000000..344c2f8cc9
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/rotate.h
@@ -0,0 +1,200 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_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
+
+#endif // _LIBCPP___ALGORITHM_ROTATE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/rotate_copy.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/rotate_copy.h
new file mode 100644
index 0000000000..ab569ef7c6
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/rotate_copy.h
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <__algorithm/copy.h>
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___ALGORITHM_ROTATE_COPY_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/sample.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/sample.h
new file mode 100644
index 0000000000..5234961082
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/sample.h
@@ -0,0 +1,102 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <__algorithm/min.h>
+#include <__assert>
+#include <__config>
+#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/libs/cxxsupp/libcxxmsvc/include/__algorithm/search.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/search.h
new file mode 100644
index 0000000000..d89ec2b1c5
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/search.h
@@ -0,0 +1,125 @@
+// -*- 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 <__utility/pair.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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 - _D1(__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 + _D1(__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<_BinaryPredicate&>(
+ __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
+
+#endif // _LIBCPP___ALGORITHM_SEARCH_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/search_n.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/search_n.h
new file mode 100644
index 0000000000..4c083de65e
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/search_n.h
@@ -0,0 +1,112 @@
+// -*- 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 <__algorithm/comp.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <type_traits> // __convert_to_integral
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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) {
+ typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+ if (__count <= 0)
+ return __first;
+ _Size __len = static_cast<_Size>(__last - __first);
+ if (__len < __count)
+ return __last;
+ const _RandomAccessIterator __s = __last - difference_type(__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<_BinaryPredicate&>(
+ __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
+
+#endif // _LIBCPP___ALGORITHM_SEARCH_N_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/set_difference.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/set_difference.h
new file mode 100644
index 0000000000..5e2dca24e4
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/set_difference.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_SET_DIFFERENCE_H
+#define _LIBCPP___ALGORITHM_SET_DIFFERENCE_H
+
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/copy.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___ALGORITHM_SET_DIFFERENCE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/set_intersection.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/set_intersection.h
new file mode 100644
index 0000000000..c4163fcd4c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/set_intersection.h
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___ALGORITHM_SET_INTERSECTION_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/set_symmetric_difference.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/set_symmetric_difference.h
new file mode 100644
index 0000000000..2dbfb35d7b
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/set_symmetric_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_SYMMETRIC_DIFFERENCE_H
+#define _LIBCPP___ALGORITHM_SET_SYMMETRIC_DIFFERENCE_H
+
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/copy.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___ALGORITHM_SET_SYMMETRIC_DIFFERENCE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/set_union.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/set_union.h
new file mode 100644
index 0000000000..0ec6b09380
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/set_union.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_SET_UNION_H
+#define _LIBCPP___ALGORITHM_SET_UNION_H
+
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/copy.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___ALGORITHM_SET_UNION_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/shift_left.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/shift_left.h
new file mode 100644
index 0000000000..33f06d57e2
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/shift_left.h
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <__algorithm/move.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_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
+
+#endif // _LIBCPP___ALGORITHM_SHIFT_LEFT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/shift_right.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/shift_right.h
new file mode 100644
index 0000000000..14bc761598
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/shift_right.h
@@ -0,0 +1,102 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <__algorithm/move.h>
+#include <__algorithm/move_backward.h>
+#include <__algorithm/swap_ranges.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <__utility/swap.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___ALGORITHM_SHIFT_RIGHT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/shuffle.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/shuffle.h
new file mode 100644
index 0000000000..647aa3f067
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/shuffle.h
@@ -0,0 +1,160 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+class _LIBCPP_TYPE_VIS __libcpp_debug_randomizer {
+public:
+ __libcpp_debug_randomizer() {
+ __state = __seed();
+ __inc = __state + 0xda3e39cb94b95bdbULL;
+ __inc = (__inc << 1) | 1;
+ }
+ typedef uint_fast32_t result_type;
+
+ static const result_type _Min = 0;
+ static const result_type _Max = 0xFFFFFFFF;
+
+ _LIBCPP_HIDE_FROM_ABI result_type operator()() {
+ uint_fast64_t __oldstate = __state;
+ __state = __oldstate * 6364136223846793005ULL + __inc;
+ return __oldstate >> 32;
+ }
+
+ static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR result_type min() { return _Min; }
+ static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR result_type max() { return _Max; }
+
+private:
+ uint_fast64_t __state;
+ uint_fast64_t __inc;
+ _LIBCPP_HIDE_FROM_ABI static uint_fast64_t __seed() {
+#ifdef _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY_SEED
+ return _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY_SEED;
+#else
+ static char __x;
+ return reinterpret_cast<uintptr_t>(&__x);
+#endif
+ }
+};
+
+#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/libs/cxxsupp/libcxxmsvc/include/__algorithm/sift_down.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/sift_down.h
new file mode 100644
index 0000000000..b636da78b0
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/sift_down.h
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_BEGIN_NAMESPACE_STD
+
+template <class _Compare, class _RandomAccessIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 void
+__sift_down(_RandomAccessIterator __first, _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 + difference_type(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 its 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 + difference_type(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
+
+#endif // _LIBCPP___ALGORITHM_SIFT_DOWN_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/sort.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/sort.h
new file mode 100644
index 0000000000..27ce647c81
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/sort.h
@@ -0,0 +1,556 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <__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 <__config>
+#include <__utility/swap.h>
+#include <memory>
+
+#if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY)
+# include <__algorithm/shuffle.h>
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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(__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>::difference_type difference_type;
+ typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
+ _RandomAccessIterator __j = __first+difference_type(2);
+ _VSTD::__sort3<_Compare>(__first, __first+difference_type(1), __j, __comp);
+ for (_RandomAccessIterator __i = __j+difference_type(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)
+{
+ typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+ 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+difference_type(1), --__last, __comp);
+ return true;
+ case 4:
+ _VSTD::__sort4<_Compare>(__first, __first+difference_type(1), __first+difference_type(2), --__last, __comp);
+ return true;
+ case 5:
+ _VSTD::__sort5<_Compare>(__first, __first+difference_type(1), __first+difference_type(2), __first+difference_type(3), --__last, __comp);
+ return true;
+ }
+ typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
+ _RandomAccessIterator __j = __first+difference_type(2);
+ _VSTD::__sort3<_Compare>(__first, __first+difference_type(1), __j, __comp);
+ const unsigned __limit = 8;
+ unsigned __count = 0;
+ for (_RandomAccessIterator __i = __j+difference_type(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
+__introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
+ typename iterator_traits<_RandomAccessIterator>::difference_type __depth)
+{
+ 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+difference_type(1), --__last, __comp);
+ return;
+ case 4:
+ _VSTD::__sort4<_Compare>(__first, __first+difference_type(1), __first+difference_type(2), --__last, __comp);
+ return;
+ case 5:
+ _VSTD::__sort5<_Compare>(__first, __first+difference_type(1), __first+difference_type(2), __first+difference_type(3), --__last, __comp);
+ return;
+ }
+ if (__len <= __limit)
+ {
+ _VSTD::__insertion_sort_3<_Compare>(__first, __last, __comp);
+ return;
+ }
+ // __len > 5
+ if (__depth == 0)
+ {
+ // Fallback to heap sort as Introsort suggests.
+ _VSTD::__partial_sort<_Compare>(__first, __last, __last, __comp);
+ return;
+ }
+ --__depth;
+ _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+difference_type(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::__introsort<_Compare>(__first, __i, __comp, __depth);
+ __first = ++__i;
+ }
+ else
+ {
+ _VSTD::__introsort<_Compare>(__i + difference_type(1), __last, __comp, __depth);
+ __last = __i;
+ }
+ }
+}
+
+template <typename _Number>
+inline _LIBCPP_HIDE_FROM_ABI _Number __log2i(_Number __n) {
+ _Number __log2 = 0;
+ while (__n > 1) {
+ __log2++;
+ __n >>= 1;
+ }
+ return __log2;
+}
+
+template <class _Compare, class _RandomAccessIterator>
+void __sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
+ typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+ difference_type __depth_limit = 2 * __log2i(__last - __first);
+ _VSTD::__introsort<_Compare>(__first, __last, __comp, __depth_limit);
+}
+
+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>&))
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&))
+#endif
+_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>&))
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&))
+#endif
+_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)
+{
+ _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last);
+ 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
+
+#endif // _LIBCPP___ALGORITHM_SORT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/sort_heap.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/sort_heap.h
new file mode 100644
index 0000000000..3a63d744fc
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/sort_heap.h
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/pop_heap.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <type_traits> // swap
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___ALGORITHM_SORT_HEAP_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/stable_partition.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/stable_partition.h
new file mode 100644
index 0000000000..1233cc157f
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/stable_partition.h
@@ -0,0 +1,295 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <__algorithm/rotate.h>
+#include <__config>
+#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_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
+ _ForwardIterator __first_false = _VSTD::__stable_partition<_Predicate&>(__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<_Predicate&>(__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<_Predicate&>(__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
+ __first_false = _VSTD::__stable_partition<_Predicate&>(__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<_Predicate&>(__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<_Predicate&>(__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<_Predicate&>(__first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ALGORITHM_STABLE_PARTITION_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/stable_sort.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/stable_sort.h
new file mode 100644
index 0000000000..33df6e8ba7
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/stable_sort.h
@@ -0,0 +1,230 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/inplace_merge.h>
+#include <__algorithm/sort.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <__utility/swap.h>
+#include <memory>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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, (void) ++__result, __d.template __incr<value_type>())
+ ::new ((void*)__result) value_type(_VSTD::move(*__first2));
+ __h.release();
+ return;
+ }
+ if (__first2 == __last2)
+ {
+ for (; __first1 != __last1; ++__first1, (void) ++__result, __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
+
+#endif // _LIBCPP___ALGORITHM_STABLE_SORT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/swap_ranges.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/swap_ranges.h
new file mode 100644
index 0000000000..0422265bb4
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/swap_ranges.h
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___ALGORITHM_SWAP_RANGES_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/transform.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/transform.h
new file mode 100644
index 0000000000..f9db806f5b
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/transform.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_TRANSFORM_H
+#define _LIBCPP___ALGORITHM_TRANSFORM_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___ALGORITHM_TRANSFORM_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/unique.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/unique.h
new file mode 100644
index 0000000000..264d727d93
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/unique.h
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <__algorithm/adjacent_find.h>
+#include <__algorithm/comp.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_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, _BinaryPredicate&>(__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
+
+#endif // _LIBCPP___ALGORITHM_UNIQUE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/unique_copy.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/unique_copy.h
new file mode 100644
index 0000000000..f58517749f
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/unique_copy.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_UNIQUE_COPY_H
+#define _LIBCPP___ALGORITHM_UNIQUE_COPY_H
+
+#include <__algorithm/comp.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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<_BinaryPredicate&>(__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
+
+#endif // _LIBCPP___ALGORITHM_UNIQUE_COPY_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/unwrap_iter.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/unwrap_iter.h
new file mode 100644
index 0000000000..e738cb26fc
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/unwrap_iter.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_UNWRAP_ITER_H
+#define _LIBCPP___ALGORITHM_UNWRAP_ITER_H
+
+#include <__config>
+#include <__memory/pointer_traits.h>
+#include <iterator>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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>
+_LIBCPP_HIDE_FROM_ABI
+_OrigIter __rewrap_iter(_OrigIter, _OrigIter __result)
+{
+ return __result;
+}
+
+template<class _OrigIter, class _UnwrappedIter>
+_LIBCPP_HIDE_FROM_ABI
+_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
+
+#endif // _LIBCPP___ALGORITHM_UNWRAP_ITER_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/upper_bound.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/upper_bound.h
new file mode 100644
index 0000000000..cfa021e142
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__algorithm/upper_bound.h
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <__algorithm/comp.h>
+#include <__algorithm/half_positive.h>
+#include <__config>
+#include <iterator>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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)
+{
+ return _VSTD::__upper_bound<_Compare&>(__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
+
+#endif // _LIBCPP___ALGORITHM_UPPER_BOUND_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__assert b/contrib/libs/cxxsupp/libcxxmsvc/include/__assert
new file mode 100644
index 0000000000..d51512dcf3
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__assert
@@ -0,0 +1,69 @@
+// -*- 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___ASSERT
+#define _LIBCPP___ASSERT
+
+#include <__config>
+#include <iosfwd> // for std::string
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_DEBUG_LEVEL >= 1
+# define _LIBCPP_ASSERT_IMPL(x, m) ((x) ? (void)0 : ::std::__libcpp_debug_function(::std::__libcpp_debug_info(__FILE__, __LINE__, #x, m)))
+#else
+# define _LIBCPP_ASSERT_IMPL(x, m) ((void)0)
+#endif
+
+// We do this dance because some of our tests re-define _LIBCPP_ASSERT to something else.
+// In the future, we should find other ways to test our assertions and disallow re-defining
+// _LIBCPP_ASSERT.
+#if !defined(_LIBCPP_ASSERT)
+# define _LIBCPP_ASSERT(x, m) _LIBCPP_ASSERT_IMPL(x, m)
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+struct _LIBCPP_TEMPLATE_VIS __libcpp_debug_info {
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ __libcpp_debug_info()
+ : __file_(nullptr), __line_(-1), __pred_(nullptr), __msg_(nullptr) {}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ __libcpp_debug_info(const char* __f, int __l, const char* __p, const char* __m)
+ : __file_(__f), __line_(__l), __pred_(__p), __msg_(__m) {}
+
+ _LIBCPP_FUNC_VIS string what() const;
+
+ const char* __file_;
+ int __line_;
+ const char* __pred_;
+ const char* __msg_;
+};
+
+/// __libcpp_debug_function_type - The type of the assertion failure handler.
+typedef void(*__libcpp_debug_function_type)(__libcpp_debug_info const&);
+
+/// __libcpp_debug_function - The handler function called when a _LIBCPP_ASSERT
+/// fails.
+extern _LIBCPP_EXPORTED_FROM_ABI __libcpp_debug_function_type __libcpp_debug_function;
+
+/// __libcpp_abort_debug_function - A debug handler that aborts when called.
+_LIBCPP_NORETURN _LIBCPP_FUNC_VIS
+void __libcpp_abort_debug_function(__libcpp_debug_info const&);
+
+/// __libcpp_set_debug_function - Set the debug handler to the specified
+/// function.
+_LIBCPP_FUNC_VIS
+bool __libcpp_set_debug_function(__libcpp_debug_function_type __func);
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ASSERT
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__availability b/contrib/libs/cxxsupp/libcxxmsvc/include/__availability
new file mode 100644
index 0000000000..12eafee99b
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__availability
@@ -0,0 +1,273 @@
+// -*- 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___AVAILABILITY
+#define _LIBCPP___AVAILABILITY
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+// Libc++ is shipped by various vendors. In particular, it is used as a system
+// library on macOS, iOS and other Apple platforms. In order for users to be
+// able to compile a binary that is intended to be deployed to an older version
+// of a platform, Clang provides availability attributes [1]. These attributes
+// can be placed on declarations and are used to describe the life cycle of a
+// symbol in the library.
+//
+// The main goal is to ensure a compile-time error if a symbol that hasn't been
+// introduced in a previously released library is used in a program that targets
+// that previously released library. Normally, this would be a load-time error
+// when one tries to launch the program against the older library.
+//
+// For example, the filesystem library was introduced in the dylib in macOS 10.15.
+// If a user compiles on a macOS 10.15 host but targets macOS 10.13 with their
+// program, the compiler would normally not complain (because the required
+// declarations are in the headers), but the dynamic loader would fail to find
+// the symbols when actually trying to launch the program on macOS 10.13. To
+// turn this into a compile-time issue instead, declarations are annotated with
+// when they were introduced, and the compiler can produce a diagnostic if the
+// program references something that isn't available on the deployment target.
+//
+// This mechanism is general in nature, and any vendor can add their markup to
+// the library (see below). Whenever a new feature is added that requires support
+// in the shared library, a macro should be added below to mark this feature
+// as unavailable. When vendors decide to ship the feature as part of their
+// shared library, they can update the markup appropriately.
+//
+// Furthermore, many features in the standard library have corresponding
+// feature-test macros. When a feature is made unavailable on some deployment
+// target, a macro should be defined to signal that it is unavailable. That
+// macro can then be picked up when feature-test macros are generated (see
+// generate_feature_test_macro_components.py) to make sure that feature-test
+// macros don't announce a feature as being implemented if it has been marked
+// as unavailable.
+//
+// Note that this mechanism is disabled by default in the "upstream" libc++.
+// Availability annotations are only meaningful when shipping libc++ inside
+// a platform (i.e. as a system library), and so vendors that want them should
+// turn those annotations on at CMake configuration time.
+//
+// [1]: https://clang.llvm.org/docs/AttributeReference.html#availability
+
+
+// For backwards compatibility, allow users to define _LIBCPP_DISABLE_AVAILABILITY
+// for a while.
+#if defined(_LIBCPP_DISABLE_AVAILABILITY)
+# if !defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
+# define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS
+# endif
+#endif
+
+// Availability markup is disabled when building the library, or when the compiler
+// doesn't support the proper attributes.
+#if defined(_LIBCPP_BUILDING_LIBRARY) || \
+ defined(_LIBCXXABI_BUILDING_LIBRARY) || \
+ !__has_feature(attribute_availability_with_strict) || \
+ !__has_feature(attribute_availability_in_templates) || \
+ !__has_extension(pragma_clang_attribute_external_declaration)
+# if !defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
+# define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS
+# endif
+#endif
+
+#if defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
+
+ // This controls the availability of std::shared_mutex and std::shared_timed_mutex,
+ // which were added to the dylib later.
+# define _LIBCPP_AVAILABILITY_SHARED_MUTEX
+// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_shared_mutex
+// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_shared_timed_mutex
+
+ // These macros control the availability of std::bad_optional_access and
+ // other exception types. These were put in the shared library to prevent
+ // code bloat from every user program defining the vtable for these exception
+ // types.
+# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
+# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
+# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST
+
+ // This controls the availability of std::uncaught_exceptions().
+# define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS
+
+ // This controls the availability of the sized version of ::operator delete,
+ // which was added to the dylib later.
+# define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE
+
+ // This controls the availability of the std::future_error exception.
+# define _LIBCPP_AVAILABILITY_FUTURE_ERROR
+
+ // This controls the availability of std::type_info's vtable.
+ // I can't imagine how using std::type_info can work at all if
+ // this isn't supported.
+# define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE
+
+ // This controls the availability of std::locale::category members
+ // (e.g. std::locale::collate), which are defined in the dylib.
+# define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY
+
+ // This controls the availability of atomic operations on std::shared_ptr
+ // (e.g. `std::atomic_store(std::shared_ptr)`), which require a shared
+ // lock table located in the dylib.
+# define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
+
+ // These macros control the availability of all parts of <filesystem> that
+ // depend on something in the dylib.
+# define _LIBCPP_AVAILABILITY_FILESYSTEM
+# define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH
+# define _LIBCPP_AVAILABILITY_FILESYSTEM_POP
+// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_filesystem
+
+ // This controls the availability of std::to_chars.
+# define _LIBCPP_AVAILABILITY_TO_CHARS
+
+ // This controls the availability of floating-point std::to_chars functions.
+ // These overloads were added later than the integer overloads.
+# define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT
+
+ // This controls the availability of the C++20 synchronization library,
+ // which requires shared library support for various operations
+ // (see libcxx/src/atomic.cpp).
+# define _LIBCPP_AVAILABILITY_SYNC
+// # 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
+
+ // This controls the availability of the C++20 format library.
+ // The library is in development and not ABI stable yet. P2216 is
+ // 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 \
+ __attribute__((availability(macosx,strict,introduced=10.12))) \
+ __attribute__((availability(ios,strict,introduced=10.0))) \
+ __attribute__((availability(tvos,strict,introduced=10.0))) \
+ __attribute__((availability(watchos,strict,introduced=3.0)))
+# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101200) || \
+ (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 100000) || \
+ (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 100000) || \
+ (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 30000)
+# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_shared_mutex
+# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_shared_timed_mutex
+# endif
+
+# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS \
+ __attribute__((availability(macosx,strict,introduced=10.13))) \
+ __attribute__((availability(ios,strict,introduced=11.0))) \
+ __attribute__((availability(tvos,strict,introduced=11.0))) \
+ __attribute__((availability(watchos,strict,introduced=4.0)))
+# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS \
+ _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
+# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST \
+ _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
+
+# define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS \
+ __attribute__((availability(macosx,strict,introduced=10.12))) \
+ __attribute__((availability(ios,strict,introduced=10.0))) \
+ __attribute__((availability(tvos,strict,introduced=10.0))) \
+ __attribute__((availability(watchos,strict,introduced=3.0)))
+
+# define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE \
+ __attribute__((availability(macosx,strict,introduced=10.12))) \
+ __attribute__((availability(ios,strict,introduced=10.0))) \
+ __attribute__((availability(tvos,strict,introduced=10.0))) \
+ __attribute__((availability(watchos,strict,introduced=3.0)))
+
+# define _LIBCPP_AVAILABILITY_FUTURE_ERROR \
+ __attribute__((availability(ios,strict,introduced=6.0)))
+
+# define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE \
+ __attribute__((availability(macosx,strict,introduced=10.9))) \
+ __attribute__((availability(ios,strict,introduced=7.0)))
+
+# define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY \
+ __attribute__((availability(macosx,strict,introduced=10.9))) \
+ __attribute__((availability(ios,strict,introduced=7.0)))
+
+# define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR \
+ __attribute__((availability(macosx,strict,introduced=10.9))) \
+ __attribute__((availability(ios,strict,introduced=7.0)))
+
+# define _LIBCPP_AVAILABILITY_FILESYSTEM \
+ __attribute__((availability(macosx,strict,introduced=10.15))) \
+ __attribute__((availability(ios,strict,introduced=13.0))) \
+ __attribute__((availability(tvos,strict,introduced=13.0))) \
+ __attribute__((availability(watchos,strict,introduced=6.0)))
+# define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH \
+ _Pragma("clang attribute push(__attribute__((availability(macosx,strict,introduced=10.15))), apply_to=any(function,record))") \
+ _Pragma("clang attribute push(__attribute__((availability(ios,strict,introduced=13.0))), apply_to=any(function,record))") \
+ _Pragma("clang attribute push(__attribute__((availability(tvos,strict,introduced=13.0))), apply_to=any(function,record))") \
+ _Pragma("clang attribute push(__attribute__((availability(watchos,strict,introduced=6.0))), apply_to=any(function,record))")
+# define _LIBCPP_AVAILABILITY_FILESYSTEM_POP \
+ _Pragma("clang attribute pop") \
+ _Pragma("clang attribute pop") \
+ _Pragma("clang attribute pop") \
+ _Pragma("clang attribute pop")
+# 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_AVAILABILITY_DISABLE_FTM___cpp_lib_filesystem
+# endif
+
+# define _LIBCPP_AVAILABILITY_TO_CHARS \
+ _LIBCPP_AVAILABILITY_FILESYSTEM
+
+# define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT \
+ __attribute__((unavailable))
+
+# define _LIBCPP_AVAILABILITY_SYNC \
+ __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
+
+# define _LIBCPP_AVAILABILITY_FORMAT \
+ __attribute__((unavailable))
+# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format
+#else
+
+// ...New vendors can add availability markup here...
+
+# error "It looks like you're trying to enable vendor availability markup, but you haven't defined the corresponding macros yet!"
+
+#endif
+
+// Define availability attributes that depend on _LIBCPP_NO_EXCEPTIONS.
+// Those are defined in terms of the availability attributes above, and
+// should not be vendor-specific.
+#if defined(_LIBCPP_NO_EXCEPTIONS)
+# define _LIBCPP_AVAILABILITY_FUTURE
+# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
+# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
+# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
+#else
+# define _LIBCPP_AVAILABILITY_FUTURE _LIBCPP_AVAILABILITY_FUTURE_ERROR
+# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _LIBCPP_AVAILABILITY_BAD_ANY_CAST
+# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
+# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
+#endif
+
+#endif // _LIBCPP___AVAILABILITY
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__bit/bit_cast.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__bit/bit_cast.h
new file mode 100644
index 0000000000..10c2c94281
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__bit/bit_cast.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___BIT_BIT_CAST_H
+#define _LIBCPP___BIT_BIT_CAST_H
+
+#include <__config>
+#include <cstring>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+template<class _ToType, class _FromType, class = enable_if_t<
+ sizeof(_ToType) == sizeof(_FromType) &&
+ is_trivially_copyable_v<_ToType> &&
+ is_trivially_copyable_v<_FromType>
+>>
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI
+constexpr _ToType bit_cast(_FromType const& __from) noexcept {
+ return __builtin_bit_cast(_ToType, __from);
+}
+#else _LIBCPP_STD_VER > 14
+
+template<class _ToType, class _FromType, class = enable_if_t<
+ sizeof(_ToType) == sizeof(_FromType) &&
+ is_trivially_copyable<_ToType>::value &&
+ is_trivially_copyable<_FromType>::value
+>>
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI
+constexpr _ToType bit_cast(_FromType const& __from) noexcept {
+ _ToType __to;
+ ::memcpy(&__to, &__from, sizeof(__from));
+ return __to;
+}
+
+#endif // _LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___BIT_BIT_CAST_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__bit/byteswap.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__bit/byteswap.h
new file mode 100644
index 0000000000..970074ed98
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__bit/byteswap.h
@@ -0,0 +1,55 @@
+// -*- 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___BIT_BYTESWAP_H
+#define _LIBCPP___BIT_BYTESWAP_H
+
+#include <__concepts/arithmetic.h>
+#include <__config>
+#include <cstdint>
+#include <cstdlib>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+template <integral _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp byteswap(_Tp __val) noexcept {
+
+ if constexpr (sizeof(_Tp) == 1) {
+ return __val;
+ } else if constexpr (sizeof(_Tp) == 2) {
+ return __builtin_bswap16(__val);
+ } else if constexpr (sizeof(_Tp) == 4) {
+ return __builtin_bswap32(__val);
+ } else if constexpr (sizeof(_Tp) == 8) {
+ return __builtin_bswap64(__val);
+#ifndef _LIBCPP_HAS_NO_INT128
+ } else if constexpr (sizeof(_Tp) == 16) {
+#if __has_builtin(__builtin_bswap128)
+ return __builtin_bswap128(__val);
+#else
+ return static_cast<_Tp>(byteswap(static_cast<uint64_t>(__val))) << 64 |
+ static_cast<_Tp>(byteswap(static_cast<uint64_t>(__val >> 64)));
+#endif // __has_builtin(__builtin_bswap128)
+#endif // _LIBCPP_HAS_NO_INT128
+ } else {
+ static_assert(sizeof(_Tp) == 0, "byteswap is unimplemented for integral types of this size");
+ }
+}
+
+#endif // _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___BIT_BYTESWAP_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__bit_reference b/contrib/libs/cxxsupp/libcxxmsvc/include/__bit_reference
new file mode 100644
index 0000000000..60e77868c2
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__bit_reference
@@ -0,0 +1,1317 @@
+// -*- 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___BIT_REFERENCE
+#define _LIBCPP___BIT_REFERENCE
+
+#include <__algorithm/min.h>
+#include <__bits>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <__memory/pointer_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 _Cp, bool _IsConst, class = typename _Cp::__storage_type> class __bit_iterator;
+template <class _Cp> class __bit_const_reference;
+
+template <class _Tp>
+struct __has_storage_type
+{
+ static const bool value = false;
+};
+
+template <class _Cp, bool = __has_storage_type<_Cp>::value>
+class __bit_reference
+{
+ typedef typename _Cp::__storage_type __storage_type;
+ typedef typename _Cp::__storage_pointer __storage_pointer;
+
+ __storage_pointer __seg_;
+ __storage_type __mask_;
+
+ friend typename _Cp::__self;
+
+ friend class __bit_const_reference<_Cp>;
+ friend class __bit_iterator<_Cp, false>;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ __bit_reference(const __bit_reference&) = default;
+
+ _LIBCPP_INLINE_VISIBILITY operator bool() const _NOEXCEPT
+ {return static_cast<bool>(*__seg_ & __mask_);}
+ _LIBCPP_INLINE_VISIBILITY bool operator ~() const _NOEXCEPT
+ {return !static_cast<bool>(*this);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __bit_reference& operator=(bool __x) _NOEXCEPT
+ {
+ if (__x)
+ *__seg_ |= __mask_;
+ else
+ *__seg_ &= ~__mask_;
+ return *this;
+ }
+
+#if _LIBCPP_STD_VER > 20
+ _LIBCPP_HIDE_FROM_ABI const __bit_reference& operator=(bool __x) const noexcept {
+ if (__x)
+ *__seg_ |= __mask_;
+ else
+ *__seg_ &= ~__mask_;
+ return *this;
+ }
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ __bit_reference& operator=(const __bit_reference& __x) _NOEXCEPT
+ {return operator=(static_cast<bool>(__x));}
+
+ _LIBCPP_INLINE_VISIBILITY void flip() _NOEXCEPT {*__seg_ ^= __mask_;}
+ _LIBCPP_INLINE_VISIBILITY __bit_iterator<_Cp, false> operator&() const _NOEXCEPT
+ {return __bit_iterator<_Cp, false>(__seg_, static_cast<unsigned>(__libcpp_ctz(__mask_)));}
+private:
+ _LIBCPP_INLINE_VISIBILITY
+ __bit_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT
+ : __seg_(__s), __mask_(__m) {}
+};
+
+template <class _Cp>
+class __bit_reference<_Cp, false>
+{
+};
+
+template <class _Cp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT
+{
+ bool __t = __x;
+ __x = __y;
+ __y = __t;
+}
+
+template <class _Cp, class _Dp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT
+{
+ bool __t = __x;
+ __x = __y;
+ __y = __t;
+}
+
+template <class _Cp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT
+{
+ bool __t = __x;
+ __x = __y;
+ __y = __t;
+}
+
+template <class _Cp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(bool& __x, __bit_reference<_Cp> __y) _NOEXCEPT
+{
+ bool __t = __x;
+ __x = __y;
+ __y = __t;
+}
+
+template <class _Cp>
+class __bit_const_reference
+{
+ typedef typename _Cp::__storage_type __storage_type;
+ typedef typename _Cp::__const_storage_pointer __storage_pointer;
+
+ __storage_pointer __seg_;
+ __storage_type __mask_;
+
+ friend typename _Cp::__self;
+ friend class __bit_iterator<_Cp, true>;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ __bit_const_reference(const __bit_const_reference&) = default;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __bit_const_reference(const __bit_reference<_Cp>& __x) _NOEXCEPT
+ : __seg_(__x.__seg_), __mask_(__x.__mask_) {}
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator bool() const _NOEXCEPT
+ {return static_cast<bool>(*__seg_ & __mask_);}
+
+ _LIBCPP_INLINE_VISIBILITY __bit_iterator<_Cp, true> operator&() const _NOEXCEPT
+ {return __bit_iterator<_Cp, true>(__seg_, static_cast<unsigned>(__libcpp_ctz(__mask_)));}
+private:
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR
+ __bit_const_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT
+ : __seg_(__s), __mask_(__m) {}
+
+ __bit_const_reference& operator=(const __bit_const_reference&) = delete;
+};
+
+// find
+
+template <class _Cp, bool _IsConst>
+__bit_iterator<_Cp, _IsConst>
+__find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)
+{
+ typedef __bit_iterator<_Cp, _IsConst> _It;
+ typedef typename _It::__storage_type __storage_type;
+ static const int __bits_per_word = _It::__bits_per_word;
+ // do first partial word
+ if (__first.__ctz_ != 0)
+ {
+ __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_);
+ __storage_type __dn = _VSTD::min(__clz_f, __n);
+ __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
+ __storage_type __b = *__first.__seg_ & __m;
+ if (__b)
+ return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__libcpp_ctz(__b)));
+ if (__n == __dn)
+ return __first + __n;
+ __n -= __dn;
+ ++__first.__seg_;
+ }
+ // do middle whole words
+ for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word)
+ if (*__first.__seg_)
+ return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__libcpp_ctz(*__first.__seg_)));
+ // do last partial word
+ if (__n > 0)
+ {
+ __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
+ __storage_type __b = *__first.__seg_ & __m;
+ if (__b)
+ return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__libcpp_ctz(__b)));
+ }
+ return _It(__first.__seg_, static_cast<unsigned>(__n));
+}
+
+template <class _Cp, bool _IsConst>
+__bit_iterator<_Cp, _IsConst>
+__find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)
+{
+ typedef __bit_iterator<_Cp, _IsConst> _It;
+ typedef typename _It::__storage_type __storage_type;
+ const int __bits_per_word = _It::__bits_per_word;
+ // do first partial word
+ if (__first.__ctz_ != 0)
+ {
+ __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_);
+ __storage_type __dn = _VSTD::min(__clz_f, __n);
+ __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
+ __storage_type __b = ~*__first.__seg_ & __m;
+ if (__b)
+ return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__libcpp_ctz(__b)));
+ if (__n == __dn)
+ return __first + __n;
+ __n -= __dn;
+ ++__first.__seg_;
+ }
+ // do middle whole words
+ for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word)
+ {
+ __storage_type __b = ~*__first.__seg_;
+ if (__b)
+ return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__libcpp_ctz(__b)));
+ }
+ // do last partial word
+ if (__n > 0)
+ {
+ __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
+ __storage_type __b = ~*__first.__seg_ & __m;
+ if (__b)
+ return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__libcpp_ctz(__b)));
+ }
+ return _It(__first.__seg_, static_cast<unsigned>(__n));
+}
+
+template <class _Cp, bool _IsConst, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+__bit_iterator<_Cp, _IsConst>
+find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value_)
+{
+ if (static_cast<bool>(__value_))
+ return _VSTD::__find_bool_true(__first, static_cast<typename _Cp::size_type>(__last - __first));
+ return _VSTD::__find_bool_false(__first, static_cast<typename _Cp::size_type>(__last - __first));
+}
+
+// count
+
+template <class _Cp, bool _IsConst>
+typename __bit_iterator<_Cp, _IsConst>::difference_type
+__count_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)
+{
+ typedef __bit_iterator<_Cp, _IsConst> _It;
+ typedef typename _It::__storage_type __storage_type;
+ typedef typename _It::difference_type difference_type;
+ const int __bits_per_word = _It::__bits_per_word;
+ difference_type __r = 0;
+ // do first partial word
+ if (__first.__ctz_ != 0)
+ {
+ __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_);
+ __storage_type __dn = _VSTD::min(__clz_f, __n);
+ __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
+ __r = _VSTD::__libcpp_popcount(*__first.__seg_ & __m);
+ __n -= __dn;
+ ++__first.__seg_;
+ }
+ // do middle whole words
+ for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word)
+ __r += _VSTD::__libcpp_popcount(*__first.__seg_);
+ // do last partial word
+ if (__n > 0)
+ {
+ __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
+ __r += _VSTD::__libcpp_popcount(*__first.__seg_ & __m);
+ }
+ return __r;
+}
+
+template <class _Cp, bool _IsConst>
+typename __bit_iterator<_Cp, _IsConst>::difference_type
+__count_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)
+{
+ typedef __bit_iterator<_Cp, _IsConst> _It;
+ typedef typename _It::__storage_type __storage_type;
+ typedef typename _It::difference_type difference_type;
+ const int __bits_per_word = _It::__bits_per_word;
+ difference_type __r = 0;
+ // do first partial word
+ if (__first.__ctz_ != 0)
+ {
+ __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_);
+ __storage_type __dn = _VSTD::min(__clz_f, __n);
+ __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
+ __r = _VSTD::__libcpp_popcount(~*__first.__seg_ & __m);
+ __n -= __dn;
+ ++__first.__seg_;
+ }
+ // do middle whole words
+ for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word)
+ __r += _VSTD::__libcpp_popcount(~*__first.__seg_);
+ // do last partial word
+ if (__n > 0)
+ {
+ __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
+ __r += _VSTD::__libcpp_popcount(~*__first.__seg_ & __m);
+ }
+ return __r;
+}
+
+template <class _Cp, bool _IsConst, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename __bit_iterator<_Cp, _IsConst>::difference_type
+count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value_)
+{
+ if (static_cast<bool>(__value_))
+ return _VSTD::__count_bool_true(__first, static_cast<typename _Cp::size_type>(__last - __first));
+ return _VSTD::__count_bool_false(__first, static_cast<typename _Cp::size_type>(__last - __first));
+}
+
+// fill_n
+
+template <class _Cp>
+void
+__fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
+{
+ typedef __bit_iterator<_Cp, false> _It;
+ typedef typename _It::__storage_type __storage_type;
+ const int __bits_per_word = _It::__bits_per_word;
+ // do first partial word
+ if (__first.__ctz_ != 0)
+ {
+ __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_);
+ __storage_type __dn = _VSTD::min(__clz_f, __n);
+ __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
+ *__first.__seg_ &= ~__m;
+ __n -= __dn;
+ ++__first.__seg_;
+ }
+ // do middle whole words
+ __storage_type __nw = __n / __bits_per_word;
+ _VSTD::memset(_VSTD::__to_address(__first.__seg_), 0, __nw * sizeof(__storage_type));
+ __n -= __nw * __bits_per_word;
+ // do last partial word
+ if (__n > 0)
+ {
+ __first.__seg_ += __nw;
+ __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
+ *__first.__seg_ &= ~__m;
+ }
+}
+
+template <class _Cp>
+void
+__fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
+{
+ typedef __bit_iterator<_Cp, false> _It;
+ typedef typename _It::__storage_type __storage_type;
+ const int __bits_per_word = _It::__bits_per_word;
+ // do first partial word
+ if (__first.__ctz_ != 0)
+ {
+ __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_);
+ __storage_type __dn = _VSTD::min(__clz_f, __n);
+ __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
+ *__first.__seg_ |= __m;
+ __n -= __dn;
+ ++__first.__seg_;
+ }
+ // do middle whole words
+ __storage_type __nw = __n / __bits_per_word;
+ _VSTD::memset(_VSTD::__to_address(__first.__seg_), -1, __nw * sizeof(__storage_type));
+ __n -= __nw * __bits_per_word;
+ // do last partial word
+ if (__n > 0)
+ {
+ __first.__seg_ += __nw;
+ __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
+ *__first.__seg_ |= __m;
+ }
+}
+
+template <class _Cp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __value_)
+{
+ if (__n > 0)
+ {
+ if (__value_)
+ _VSTD::__fill_n_true(__first, __n);
+ else
+ _VSTD::__fill_n_false(__first, __n);
+ }
+}
+
+// fill
+
+template <class _Cp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+fill(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, bool __value_)
+{
+ _VSTD::fill_n(__first, static_cast<typename _Cp::size_type>(__last - __first), __value_);
+}
+
+// copy
+
+template <class _Cp, bool _IsConst>
+__bit_iterator<_Cp, false>
+__copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
+ __bit_iterator<_Cp, false> __result)
+{
+ typedef __bit_iterator<_Cp, _IsConst> _In;
+ typedef typename _In::difference_type difference_type;
+ typedef typename _In::__storage_type __storage_type;
+ const int __bits_per_word = _In::__bits_per_word;
+ difference_type __n = __last - __first;
+ if (__n > 0)
+ {
+ // do first word
+ if (__first.__ctz_ != 0)
+ {
+ unsigned __clz = __bits_per_word - __first.__ctz_;
+ difference_type __dn = _VSTD::min(static_cast<difference_type>(__clz), __n);
+ __n -= __dn;
+ __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz - __dn));
+ __storage_type __b = *__first.__seg_ & __m;
+ *__result.__seg_ &= ~__m;
+ *__result.__seg_ |= __b;
+ __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word;
+ __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word);
+ ++__first.__seg_;
+ // __first.__ctz_ = 0;
+ }
+ // __first.__ctz_ == 0;
+ // do middle words
+ __storage_type __nw = __n / __bits_per_word;
+ _VSTD::memmove(_VSTD::__to_address(__result.__seg_),
+ _VSTD::__to_address(__first.__seg_),
+ __nw * sizeof(__storage_type));
+ __n -= __nw * __bits_per_word;
+ __result.__seg_ += __nw;
+ // do last word
+ if (__n > 0)
+ {
+ __first.__seg_ += __nw;
+ __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
+ __storage_type __b = *__first.__seg_ & __m;
+ *__result.__seg_ &= ~__m;
+ *__result.__seg_ |= __b;
+ __result.__ctz_ = static_cast<unsigned>(__n);
+ }
+ }
+ return __result;
+}
+
+template <class _Cp, bool _IsConst>
+__bit_iterator<_Cp, false>
+__copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
+ __bit_iterator<_Cp, false> __result)
+{
+ typedef __bit_iterator<_Cp, _IsConst> _In;
+ typedef typename _In::difference_type difference_type;
+ typedef typename _In::__storage_type __storage_type;
+ static const int __bits_per_word = _In::__bits_per_word;
+ difference_type __n = __last - __first;
+ if (__n > 0)
+ {
+ // do first word
+ if (__first.__ctz_ != 0)
+ {
+ unsigned __clz_f = __bits_per_word - __first.__ctz_;
+ difference_type __dn = _VSTD::min(static_cast<difference_type>(__clz_f), __n);
+ __n -= __dn;
+ __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
+ __storage_type __b = *__first.__seg_ & __m;
+ unsigned __clz_r = __bits_per_word - __result.__ctz_;
+ __storage_type __ddn = _VSTD::min<__storage_type>(__dn, __clz_r);
+ __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __ddn));
+ *__result.__seg_ &= ~__m;
+ if (__result.__ctz_ > __first.__ctz_)
+ *__result.__seg_ |= __b << (__result.__ctz_ - __first.__ctz_);
+ else
+ *__result.__seg_ |= __b >> (__first.__ctz_ - __result.__ctz_);
+ __result.__seg_ += (__ddn + __result.__ctz_) / __bits_per_word;
+ __result.__ctz_ = static_cast<unsigned>((__ddn + __result.__ctz_) % __bits_per_word);
+ __dn -= __ddn;
+ if (__dn > 0)
+ {
+ __m = ~__storage_type(0) >> (__bits_per_word - __dn);
+ *__result.__seg_ &= ~__m;
+ *__result.__seg_ |= __b >> (__first.__ctz_ + __ddn);
+ __result.__ctz_ = static_cast<unsigned>(__dn);
+ }
+ ++__first.__seg_;
+ // __first.__ctz_ = 0;
+ }
+ // __first.__ctz_ == 0;
+ // do middle words
+ unsigned __clz_r = __bits_per_word - __result.__ctz_;
+ __storage_type __m = ~__storage_type(0) << __result.__ctz_;
+ for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_)
+ {
+ __storage_type __b = *__first.__seg_;
+ *__result.__seg_ &= ~__m;
+ *__result.__seg_ |= __b << __result.__ctz_;
+ ++__result.__seg_;
+ *__result.__seg_ &= __m;
+ *__result.__seg_ |= __b >> __clz_r;
+ }
+ // do last word
+ if (__n > 0)
+ {
+ __m = ~__storage_type(0) >> (__bits_per_word - __n);
+ __storage_type __b = *__first.__seg_ & __m;
+ __storage_type __dn = _VSTD::min(__n, static_cast<difference_type>(__clz_r));
+ __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __dn));
+ *__result.__seg_ &= ~__m;
+ *__result.__seg_ |= __b << __result.__ctz_;
+ __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word;
+ __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word);
+ __n -= __dn;
+ if (__n > 0)
+ {
+ __m = ~__storage_type(0) >> (__bits_per_word - __n);
+ *__result.__seg_ &= ~__m;
+ *__result.__seg_ |= __b >> __dn;
+ __result.__ctz_ = static_cast<unsigned>(__n);
+ }
+ }
+ }
+ return __result;
+}
+
+template <class _Cp, bool _IsConst>
+inline _LIBCPP_INLINE_VISIBILITY
+__bit_iterator<_Cp, false>
+copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result)
+{
+ if (__first.__ctz_ == __result.__ctz_)
+ return _VSTD::__copy_aligned(__first, __last, __result);
+ return _VSTD::__copy_unaligned(__first, __last, __result);
+}
+
+// copy_backward
+
+template <class _Cp, bool _IsConst>
+__bit_iterator<_Cp, false>
+__copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
+ __bit_iterator<_Cp, false> __result)
+{
+ typedef __bit_iterator<_Cp, _IsConst> _In;
+ typedef typename _In::difference_type difference_type;
+ typedef typename _In::__storage_type __storage_type;
+ const int __bits_per_word = _In::__bits_per_word;
+ difference_type __n = __last - __first;
+ if (__n > 0)
+ {
+ // do first word
+ if (__last.__ctz_ != 0)
+ {
+ difference_type __dn = _VSTD::min(static_cast<difference_type>(__last.__ctz_), __n);
+ __n -= __dn;
+ unsigned __clz = __bits_per_word - __last.__ctz_;
+ __storage_type __m = (~__storage_type(0) << (__last.__ctz_ - __dn)) & (~__storage_type(0) >> __clz);
+ __storage_type __b = *__last.__seg_ & __m;
+ *__result.__seg_ &= ~__m;
+ *__result.__seg_ |= __b;
+ __result.__ctz_ = static_cast<unsigned>(((-__dn & (__bits_per_word - 1)) +
+ __result.__ctz_) % __bits_per_word);
+ // __last.__ctz_ = 0
+ }
+ // __last.__ctz_ == 0 || __n == 0
+ // __result.__ctz_ == 0 || __n == 0
+ // do middle words
+ __storage_type __nw = __n / __bits_per_word;
+ __result.__seg_ -= __nw;
+ __last.__seg_ -= __nw;
+ _VSTD::memmove(_VSTD::__to_address(__result.__seg_),
+ _VSTD::__to_address(__last.__seg_),
+ __nw * sizeof(__storage_type));
+ __n -= __nw * __bits_per_word;
+ // do last word
+ if (__n > 0)
+ {
+ __storage_type __m = ~__storage_type(0) << (__bits_per_word - __n);
+ __storage_type __b = *--__last.__seg_ & __m;
+ *--__result.__seg_ &= ~__m;
+ *__result.__seg_ |= __b;
+ __result.__ctz_ = static_cast<unsigned>(-__n & (__bits_per_word - 1));
+ }
+ }
+ return __result;
+}
+
+template <class _Cp, bool _IsConst>
+__bit_iterator<_Cp, false>
+__copy_backward_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
+ __bit_iterator<_Cp, false> __result)
+{
+ typedef __bit_iterator<_Cp, _IsConst> _In;
+ typedef typename _In::difference_type difference_type;
+ typedef typename _In::__storage_type __storage_type;
+ const int __bits_per_word = _In::__bits_per_word;
+ difference_type __n = __last - __first;
+ if (__n > 0)
+ {
+ // do first word
+ if (__last.__ctz_ != 0)
+ {
+ difference_type __dn = _VSTD::min(static_cast<difference_type>(__last.__ctz_), __n);
+ __n -= __dn;
+ unsigned __clz_l = __bits_per_word - __last.__ctz_;
+ __storage_type __m = (~__storage_type(0) << (__last.__ctz_ - __dn)) & (~__storage_type(0) >> __clz_l);
+ __storage_type __b = *__last.__seg_ & __m;
+ unsigned __clz_r = __bits_per_word - __result.__ctz_;
+ __storage_type __ddn = _VSTD::min(__dn, static_cast<difference_type>(__result.__ctz_));
+ if (__ddn > 0)
+ {
+ __m = (~__storage_type(0) << (__result.__ctz_ - __ddn)) & (~__storage_type(0) >> __clz_r);
+ *__result.__seg_ &= ~__m;
+ if (__result.__ctz_ > __last.__ctz_)
+ *__result.__seg_ |= __b << (__result.__ctz_ - __last.__ctz_);
+ else
+ *__result.__seg_ |= __b >> (__last.__ctz_ - __result.__ctz_);
+ __result.__ctz_ = static_cast<unsigned>(((-__ddn & (__bits_per_word - 1)) +
+ __result.__ctz_) % __bits_per_word);
+ __dn -= __ddn;
+ }
+ if (__dn > 0)
+ {
+ // __result.__ctz_ == 0
+ --__result.__seg_;
+ __result.__ctz_ = static_cast<unsigned>(-__dn & (__bits_per_word - 1));
+ __m = ~__storage_type(0) << __result.__ctz_;
+ *__result.__seg_ &= ~__m;
+ __last.__ctz_ -= __dn + __ddn;
+ *__result.__seg_ |= __b << (__result.__ctz_ - __last.__ctz_);
+ }
+ // __last.__ctz_ = 0
+ }
+ // __last.__ctz_ == 0 || __n == 0
+ // __result.__ctz_ != 0 || __n == 0
+ // do middle words
+ unsigned __clz_r = __bits_per_word - __result.__ctz_;
+ __storage_type __m = ~__storage_type(0) >> __clz_r;
+ for (; __n >= __bits_per_word; __n -= __bits_per_word)
+ {
+ __storage_type __b = *--__last.__seg_;
+ *__result.__seg_ &= ~__m;
+ *__result.__seg_ |= __b >> __clz_r;
+ *--__result.__seg_ &= __m;
+ *__result.__seg_ |= __b << __result.__ctz_;
+ }
+ // do last word
+ if (__n > 0)
+ {
+ __m = ~__storage_type(0) << (__bits_per_word - __n);
+ __storage_type __b = *--__last.__seg_ & __m;
+ __clz_r = __bits_per_word - __result.__ctz_;
+ __storage_type __dn = _VSTD::min(__n, static_cast<difference_type>(__result.__ctz_));
+ __m = (~__storage_type(0) << (__result.__ctz_ - __dn)) & (~__storage_type(0) >> __clz_r);
+ *__result.__seg_ &= ~__m;
+ *__result.__seg_ |= __b >> (__bits_per_word - __result.__ctz_);
+ __result.__ctz_ = static_cast<unsigned>(((-__dn & (__bits_per_word - 1)) +
+ __result.__ctz_) % __bits_per_word);
+ __n -= __dn;
+ if (__n > 0)
+ {
+ // __result.__ctz_ == 0
+ --__result.__seg_;
+ __result.__ctz_ = static_cast<unsigned>(-__n & (__bits_per_word - 1));
+ __m = ~__storage_type(0) << __result.__ctz_;
+ *__result.__seg_ &= ~__m;
+ *__result.__seg_ |= __b << (__result.__ctz_ - (__bits_per_word - __n - __dn));
+ }
+ }
+ }
+ return __result;
+}
+
+template <class _Cp, bool _IsConst>
+inline _LIBCPP_INLINE_VISIBILITY
+__bit_iterator<_Cp, false>
+copy_backward(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result)
+{
+ if (__last.__ctz_ == __result.__ctz_)
+ return _VSTD::__copy_backward_aligned(__first, __last, __result);
+ return _VSTD::__copy_backward_unaligned(__first, __last, __result);
+}
+
+// move
+
+template <class _Cp, bool _IsConst>
+inline _LIBCPP_INLINE_VISIBILITY
+__bit_iterator<_Cp, false>
+move(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result)
+{
+ return _VSTD::copy(__first, __last, __result);
+}
+
+// move_backward
+
+template <class _Cp, bool _IsConst>
+inline _LIBCPP_INLINE_VISIBILITY
+__bit_iterator<_Cp, false>
+move_backward(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result)
+{
+ return _VSTD::copy_backward(__first, __last, __result);
+}
+
+// swap_ranges
+
+template <class __C1, class __C2>
+__bit_iterator<__C2, false>
+__swap_ranges_aligned(__bit_iterator<__C1, false> __first, __bit_iterator<__C1, false> __last,
+ __bit_iterator<__C2, false> __result)
+{
+ typedef __bit_iterator<__C1, false> _I1;
+ typedef typename _I1::difference_type difference_type;
+ typedef typename _I1::__storage_type __storage_type;
+ const int __bits_per_word = _I1::__bits_per_word;
+ difference_type __n = __last - __first;
+ if (__n > 0)
+ {
+ // do first word
+ if (__first.__ctz_ != 0)
+ {
+ unsigned __clz = __bits_per_word - __first.__ctz_;
+ difference_type __dn = _VSTD::min(static_cast<difference_type>(__clz), __n);
+ __n -= __dn;
+ __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz - __dn));
+ __storage_type __b1 = *__first.__seg_ & __m;
+ *__first.__seg_ &= ~__m;
+ __storage_type __b2 = *__result.__seg_ & __m;
+ *__result.__seg_ &= ~__m;
+ *__result.__seg_ |= __b1;
+ *__first.__seg_ |= __b2;
+ __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word;
+ __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word);
+ ++__first.__seg_;
+ // __first.__ctz_ = 0;
+ }
+ // __first.__ctz_ == 0;
+ // do middle words
+ for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_, ++__result.__seg_)
+ swap(*__first.__seg_, *__result.__seg_);
+ // do last word
+ if (__n > 0)
+ {
+ __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
+ __storage_type __b1 = *__first.__seg_ & __m;
+ *__first.__seg_ &= ~__m;
+ __storage_type __b2 = *__result.__seg_ & __m;
+ *__result.__seg_ &= ~__m;
+ *__result.__seg_ |= __b1;
+ *__first.__seg_ |= __b2;
+ __result.__ctz_ = static_cast<unsigned>(__n);
+ }
+ }
+ return __result;
+}
+
+template <class __C1, class __C2>
+__bit_iterator<__C2, false>
+__swap_ranges_unaligned(__bit_iterator<__C1, false> __first, __bit_iterator<__C1, false> __last,
+ __bit_iterator<__C2, false> __result)
+{
+ typedef __bit_iterator<__C1, false> _I1;
+ typedef typename _I1::difference_type difference_type;
+ typedef typename _I1::__storage_type __storage_type;
+ const int __bits_per_word = _I1::__bits_per_word;
+ difference_type __n = __last - __first;
+ if (__n > 0)
+ {
+ // do first word
+ if (__first.__ctz_ != 0)
+ {
+ unsigned __clz_f = __bits_per_word - __first.__ctz_;
+ difference_type __dn = _VSTD::min(static_cast<difference_type>(__clz_f), __n);
+ __n -= __dn;
+ __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
+ __storage_type __b1 = *__first.__seg_ & __m;
+ *__first.__seg_ &= ~__m;
+ unsigned __clz_r = __bits_per_word - __result.__ctz_;
+ __storage_type __ddn = _VSTD::min<__storage_type>(__dn, __clz_r);
+ __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __ddn));
+ __storage_type __b2 = *__result.__seg_ & __m;
+ *__result.__seg_ &= ~__m;
+ if (__result.__ctz_ > __first.__ctz_)
+ {
+ unsigned __s = __result.__ctz_ - __first.__ctz_;
+ *__result.__seg_ |= __b1 << __s;
+ *__first.__seg_ |= __b2 >> __s;
+ }
+ else
+ {
+ unsigned __s = __first.__ctz_ - __result.__ctz_;
+ *__result.__seg_ |= __b1 >> __s;
+ *__first.__seg_ |= __b2 << __s;
+ }
+ __result.__seg_ += (__ddn + __result.__ctz_) / __bits_per_word;
+ __result.__ctz_ = static_cast<unsigned>((__ddn + __result.__ctz_) % __bits_per_word);
+ __dn -= __ddn;
+ if (__dn > 0)
+ {
+ __m = ~__storage_type(0) >> (__bits_per_word - __dn);
+ __b2 = *__result.__seg_ & __m;
+ *__result.__seg_ &= ~__m;
+ unsigned __s = __first.__ctz_ + __ddn;
+ *__result.__seg_ |= __b1 >> __s;
+ *__first.__seg_ |= __b2 << __s;
+ __result.__ctz_ = static_cast<unsigned>(__dn);
+ }
+ ++__first.__seg_;
+ // __first.__ctz_ = 0;
+ }
+ // __first.__ctz_ == 0;
+ // do middle words
+ __storage_type __m = ~__storage_type(0) << __result.__ctz_;
+ unsigned __clz_r = __bits_per_word - __result.__ctz_;
+ for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_)
+ {
+ __storage_type __b1 = *__first.__seg_;
+ __storage_type __b2 = *__result.__seg_ & __m;
+ *__result.__seg_ &= ~__m;
+ *__result.__seg_ |= __b1 << __result.__ctz_;
+ *__first.__seg_ = __b2 >> __result.__ctz_;
+ ++__result.__seg_;
+ __b2 = *__result.__seg_ & ~__m;
+ *__result.__seg_ &= __m;
+ *__result.__seg_ |= __b1 >> __clz_r;
+ *__first.__seg_ |= __b2 << __clz_r;
+ }
+ // do last word
+ if (__n > 0)
+ {
+ __m = ~__storage_type(0) >> (__bits_per_word - __n);
+ __storage_type __b1 = *__first.__seg_ & __m;
+ *__first.__seg_ &= ~__m;
+ __storage_type __dn = _VSTD::min<__storage_type>(__n, __clz_r);
+ __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __dn));
+ __storage_type __b2 = *__result.__seg_ & __m;
+ *__result.__seg_ &= ~__m;
+ *__result.__seg_ |= __b1 << __result.__ctz_;
+ *__first.__seg_ |= __b2 >> __result.__ctz_;
+ __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word;
+ __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word);
+ __n -= __dn;
+ if (__n > 0)
+ {
+ __m = ~__storage_type(0) >> (__bits_per_word - __n);
+ __b2 = *__result.__seg_ & __m;
+ *__result.__seg_ &= ~__m;
+ *__result.__seg_ |= __b1 >> __dn;
+ *__first.__seg_ |= __b2 << __dn;
+ __result.__ctz_ = static_cast<unsigned>(__n);
+ }
+ }
+ }
+ return __result;
+}
+
+template <class __C1, class __C2>
+inline _LIBCPP_INLINE_VISIBILITY
+__bit_iterator<__C2, false>
+swap_ranges(__bit_iterator<__C1, false> __first1, __bit_iterator<__C1, false> __last1,
+ __bit_iterator<__C2, false> __first2)
+{
+ if (__first1.__ctz_ == __first2.__ctz_)
+ return _VSTD::__swap_ranges_aligned(__first1, __last1, __first2);
+ return _VSTD::__swap_ranges_unaligned(__first1, __last1, __first2);
+}
+
+// rotate
+
+template <class _Cp>
+struct __bit_array
+{
+ typedef typename _Cp::difference_type difference_type;
+ typedef typename _Cp::__storage_type __storage_type;
+ typedef typename _Cp::__storage_pointer __storage_pointer;
+ typedef typename _Cp::iterator iterator;
+ static const unsigned __bits_per_word = _Cp::__bits_per_word;
+ static const unsigned _Np = 4;
+
+ difference_type __size_;
+ __storage_type __word_[_Np];
+
+ _LIBCPP_INLINE_VISIBILITY static difference_type capacity()
+ {return static_cast<difference_type>(_Np * __bits_per_word);}
+ _LIBCPP_INLINE_VISIBILITY explicit __bit_array(difference_type __s) : __size_(__s) {}
+ _LIBCPP_INLINE_VISIBILITY iterator begin()
+ {
+ return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]), 0);
+ }
+ _LIBCPP_INLINE_VISIBILITY iterator end()
+ {
+ return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]) + __size_ / __bits_per_word,
+ static_cast<unsigned>(__size_ % __bits_per_word));
+ }
+};
+
+template <class _Cp>
+__bit_iterator<_Cp, false>
+rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle, __bit_iterator<_Cp, false> __last)
+{
+ typedef __bit_iterator<_Cp, false> _I1;
+ typedef typename _I1::difference_type difference_type;
+ difference_type __d1 = __middle - __first;
+ difference_type __d2 = __last - __middle;
+ _I1 __r = __first + __d2;
+ while (__d1 != 0 && __d2 != 0)
+ {
+ if (__d1 <= __d2)
+ {
+ if (__d1 <= __bit_array<_Cp>::capacity())
+ {
+ __bit_array<_Cp> __b(__d1);
+ _VSTD::copy(__first, __middle, __b.begin());
+ _VSTD::copy(__b.begin(), __b.end(), _VSTD::copy(__middle, __last, __first));
+ break;
+ }
+ else
+ {
+ __bit_iterator<_Cp, false> __mp = _VSTD::swap_ranges(__first, __middle, __middle);
+ __first = __middle;
+ __middle = __mp;
+ __d2 -= __d1;
+ }
+ }
+ else
+ {
+ if (__d2 <= __bit_array<_Cp>::capacity())
+ {
+ __bit_array<_Cp> __b(__d2);
+ _VSTD::copy(__middle, __last, __b.begin());
+ _VSTD::copy_backward(__b.begin(), __b.end(), _VSTD::copy_backward(__first, __middle, __last));
+ break;
+ }
+ else
+ {
+ __bit_iterator<_Cp, false> __mp = __first + __d2;
+ _VSTD::swap_ranges(__first, __mp, __middle);
+ __first = __mp;
+ __d1 -= __d2;
+ }
+ }
+ }
+ return __r;
+}
+
+// equal
+
+template <class _Cp, bool _IC1, bool _IC2>
+bool
+__equal_unaligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1,
+ __bit_iterator<_Cp, _IC2> __first2)
+{
+ typedef __bit_iterator<_Cp, _IC1> _It;
+ typedef typename _It::difference_type difference_type;
+ typedef typename _It::__storage_type __storage_type;
+ static const int __bits_per_word = _It::__bits_per_word;
+ difference_type __n = __last1 - __first1;
+ if (__n > 0)
+ {
+ // do first word
+ if (__first1.__ctz_ != 0)
+ {
+ unsigned __clz_f = __bits_per_word - __first1.__ctz_;
+ difference_type __dn = _VSTD::min(static_cast<difference_type>(__clz_f), __n);
+ __n -= __dn;
+ __storage_type __m = (~__storage_type(0) << __first1.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
+ __storage_type __b = *__first1.__seg_ & __m;
+ unsigned __clz_r = __bits_per_word - __first2.__ctz_;
+ __storage_type __ddn = _VSTD::min<__storage_type>(__dn, __clz_r);
+ __m = (~__storage_type(0) << __first2.__ctz_) & (~__storage_type(0) >> (__clz_r - __ddn));
+ if (__first2.__ctz_ > __first1.__ctz_)
+ {
+ if ((*__first2.__seg_ & __m) != (__b << (__first2.__ctz_ - __first1.__ctz_)))
+ return false;
+ }
+ else
+ {
+ if ((*__first2.__seg_ & __m) != (__b >> (__first1.__ctz_ - __first2.__ctz_)))
+ return false;
+ }
+ __first2.__seg_ += (__ddn + __first2.__ctz_) / __bits_per_word;
+ __first2.__ctz_ = static_cast<unsigned>((__ddn + __first2.__ctz_) % __bits_per_word);
+ __dn -= __ddn;
+ if (__dn > 0)
+ {
+ __m = ~__storage_type(0) >> (__bits_per_word - __dn);
+ if ((*__first2.__seg_ & __m) != (__b >> (__first1.__ctz_ + __ddn)))
+ return false;
+ __first2.__ctz_ = static_cast<unsigned>(__dn);
+ }
+ ++__first1.__seg_;
+ // __first1.__ctz_ = 0;
+ }
+ // __first1.__ctz_ == 0;
+ // do middle words
+ unsigned __clz_r = __bits_per_word - __first2.__ctz_;
+ __storage_type __m = ~__storage_type(0) << __first2.__ctz_;
+ for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first1.__seg_)
+ {
+ __storage_type __b = *__first1.__seg_;
+ if ((*__first2.__seg_ & __m) != (__b << __first2.__ctz_))
+ return false;
+ ++__first2.__seg_;
+ if ((*__first2.__seg_ & ~__m) != (__b >> __clz_r))
+ return false;
+ }
+ // do last word
+ if (__n > 0)
+ {
+ __m = ~__storage_type(0) >> (__bits_per_word - __n);
+ __storage_type __b = *__first1.__seg_ & __m;
+ __storage_type __dn = _VSTD::min(__n, static_cast<difference_type>(__clz_r));
+ __m = (~__storage_type(0) << __first2.__ctz_) & (~__storage_type(0) >> (__clz_r - __dn));
+ if ((*__first2.__seg_ & __m) != (__b << __first2.__ctz_))
+ return false;
+ __first2.__seg_ += (__dn + __first2.__ctz_) / __bits_per_word;
+ __first2.__ctz_ = static_cast<unsigned>((__dn + __first2.__ctz_) % __bits_per_word);
+ __n -= __dn;
+ if (__n > 0)
+ {
+ __m = ~__storage_type(0) >> (__bits_per_word - __n);
+ if ((*__first2.__seg_ & __m) != (__b >> __dn))
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
+template <class _Cp, bool _IC1, bool _IC2>
+bool
+__equal_aligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1,
+ __bit_iterator<_Cp, _IC2> __first2)
+{
+ typedef __bit_iterator<_Cp, _IC1> _It;
+ typedef typename _It::difference_type difference_type;
+ typedef typename _It::__storage_type __storage_type;
+ static const int __bits_per_word = _It::__bits_per_word;
+ difference_type __n = __last1 - __first1;
+ if (__n > 0)
+ {
+ // do first word
+ if (__first1.__ctz_ != 0)
+ {
+ unsigned __clz = __bits_per_word - __first1.__ctz_;
+ difference_type __dn = _VSTD::min(static_cast<difference_type>(__clz), __n);
+ __n -= __dn;
+ __storage_type __m = (~__storage_type(0) << __first1.__ctz_) & (~__storage_type(0) >> (__clz - __dn));
+ if ((*__first2.__seg_ & __m) != (*__first1.__seg_ & __m))
+ return false;
+ ++__first2.__seg_;
+ ++__first1.__seg_;
+ // __first1.__ctz_ = 0;
+ // __first2.__ctz_ = 0;
+ }
+ // __first1.__ctz_ == 0;
+ // __first2.__ctz_ == 0;
+ // do middle words
+ for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first1.__seg_, ++__first2.__seg_)
+ if (*__first2.__seg_ != *__first1.__seg_)
+ return false;
+ // do last word
+ if (__n > 0)
+ {
+ __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
+ if ((*__first2.__seg_ & __m) != (*__first1.__seg_ & __m))
+ return false;
+ }
+ }
+ return true;
+}
+
+template <class _Cp, bool _IC1, bool _IC2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+equal(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __bit_iterator<_Cp, _IC2> __first2)
+{
+ if (__first1.__ctz_ == __first2.__ctz_)
+ return _VSTD::__equal_aligned(__first1, __last1, __first2);
+ return _VSTD::__equal_unaligned(__first1, __last1, __first2);
+}
+
+template <class _Cp, bool _IsConst,
+ class>
+class __bit_iterator
+{
+public:
+ typedef typename _Cp::difference_type difference_type;
+ typedef bool value_type;
+ typedef __bit_iterator pointer;
+ typedef typename conditional<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> >::type reference;
+ typedef random_access_iterator_tag iterator_category;
+
+private:
+ typedef typename _Cp::__storage_type __storage_type;
+ typedef typename conditional<_IsConst, typename _Cp::__const_storage_pointer,
+ typename _Cp::__storage_pointer>::type __storage_pointer;
+ static const unsigned __bits_per_word = _Cp::__bits_per_word;
+
+ __storage_pointer __seg_;
+ unsigned __ctz_;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY __bit_iterator() _NOEXCEPT
+#if _LIBCPP_STD_VER > 11
+ : __seg_(nullptr), __ctz_(0)
+#endif
+ {}
+
+ // When _IsConst=false, this is the copy constructor.
+ // It is non-trivial. Making it trivial would break ABI.
+ // When _IsConst=true, this is a converting constructor;
+ // the copy and move constructors are implicitly generated
+ // and trivial.
+ _LIBCPP_INLINE_VISIBILITY
+ __bit_iterator(const __bit_iterator<_Cp, false>& __it) _NOEXCEPT
+ : __seg_(__it.__seg_), __ctz_(__it.__ctz_) {}
+
+ // When _IsConst=false, we have a user-provided copy constructor,
+ // so we must also provide a copy assignment operator because
+ // the implicit generation of a defaulted one is deprecated.
+ // When _IsConst=true, the assignment operators are
+ // implicitly generated and trivial.
+ _LIBCPP_INLINE_VISIBILITY
+ __bit_iterator& operator=(const _If<_IsConst, struct __private_nat, __bit_iterator>& __it) {
+ __seg_ = __it.__seg_;
+ __ctz_ = __it.__ctz_;
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY reference operator*() const _NOEXCEPT
+ {return reference(__seg_, __storage_type(1) << __ctz_);}
+
+ _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator++()
+ {
+ if (__ctz_ != __bits_per_word-1)
+ ++__ctz_;
+ else
+ {
+ __ctz_ = 0;
+ ++__seg_;
+ }
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY __bit_iterator operator++(int)
+ {
+ __bit_iterator __tmp = *this;
+ ++(*this);
+ return __tmp;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator--()
+ {
+ if (__ctz_ != 0)
+ --__ctz_;
+ else
+ {
+ __ctz_ = __bits_per_word - 1;
+ --__seg_;
+ }
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY __bit_iterator operator--(int)
+ {
+ __bit_iterator __tmp = *this;
+ --(*this);
+ return __tmp;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator+=(difference_type __n)
+ {
+ if (__n >= 0)
+ __seg_ += (__n + __ctz_) / __bits_per_word;
+ else
+ __seg_ += static_cast<difference_type>(__n - __bits_per_word + __ctz_ + 1)
+ / static_cast<difference_type>(__bits_per_word);
+ __n &= (__bits_per_word - 1);
+ __ctz_ = static_cast<unsigned>((__n + __ctz_) % __bits_per_word);
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator-=(difference_type __n)
+ {
+ return *this += -__n;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY __bit_iterator operator+(difference_type __n) const
+ {
+ __bit_iterator __t(*this);
+ __t += __n;
+ return __t;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY __bit_iterator operator-(difference_type __n) const
+ {
+ __bit_iterator __t(*this);
+ __t -= __n;
+ return __t;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ friend __bit_iterator operator+(difference_type __n, const __bit_iterator& __it) {return __it + __n;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ friend difference_type operator-(const __bit_iterator& __x, const __bit_iterator& __y)
+ {return (__x.__seg_ - __y.__seg_) * __bits_per_word + __x.__ctz_ - __y.__ctz_;}
+
+ _LIBCPP_INLINE_VISIBILITY reference operator[](difference_type __n) const {return *(*this + __n);}
+
+ _LIBCPP_INLINE_VISIBILITY friend bool operator==(const __bit_iterator& __x, const __bit_iterator& __y)
+ {return __x.__seg_ == __y.__seg_ && __x.__ctz_ == __y.__ctz_;}
+
+ _LIBCPP_INLINE_VISIBILITY friend bool operator!=(const __bit_iterator& __x, const __bit_iterator& __y)
+ {return !(__x == __y);}
+
+ _LIBCPP_INLINE_VISIBILITY friend bool operator<(const __bit_iterator& __x, const __bit_iterator& __y)
+ {return __x.__seg_ < __y.__seg_ || (__x.__seg_ == __y.__seg_ && __x.__ctz_ < __y.__ctz_);}
+
+ _LIBCPP_INLINE_VISIBILITY friend bool operator>(const __bit_iterator& __x, const __bit_iterator& __y)
+ {return __y < __x;}
+
+ _LIBCPP_INLINE_VISIBILITY friend bool operator<=(const __bit_iterator& __x, const __bit_iterator& __y)
+ {return !(__y < __x);}
+
+ _LIBCPP_INLINE_VISIBILITY friend bool operator>=(const __bit_iterator& __x, const __bit_iterator& __y)
+ {return !(__x < __y);}
+
+private:
+ _LIBCPP_INLINE_VISIBILITY
+ __bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT
+ : __seg_(__s), __ctz_(__ctz) {}
+
+ friend typename _Cp::__self;
+
+ friend class __bit_reference<_Cp>;
+ friend class __bit_const_reference<_Cp>;
+ friend class __bit_iterator<_Cp, true>;
+ template <class _Dp> friend struct __bit_array;
+ template <class _Dp> friend void __fill_n_false(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);
+ template <class _Dp> friend void __fill_n_true(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);
+ template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_aligned(__bit_iterator<_Dp, _IC> __first,
+ __bit_iterator<_Dp, _IC> __last,
+ __bit_iterator<_Dp, false> __result);
+ template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_unaligned(__bit_iterator<_Dp, _IC> __first,
+ __bit_iterator<_Dp, _IC> __last,
+ __bit_iterator<_Dp, false> __result);
+ template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> copy(__bit_iterator<_Dp, _IC> __first,
+ __bit_iterator<_Dp, _IC> __last,
+ __bit_iterator<_Dp, false> __result);
+ template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_backward_aligned(__bit_iterator<_Dp, _IC> __first,
+ __bit_iterator<_Dp, _IC> __last,
+ __bit_iterator<_Dp, false> __result);
+ template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_backward_unaligned(__bit_iterator<_Dp, _IC> __first,
+ __bit_iterator<_Dp, _IC> __last,
+ __bit_iterator<_Dp, false> __result);
+ template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> copy_backward(__bit_iterator<_Dp, _IC> __first,
+ __bit_iterator<_Dp, _IC> __last,
+ __bit_iterator<_Dp, false> __result);
+ template <class __C1, class __C2>friend __bit_iterator<__C2, false> __swap_ranges_aligned(__bit_iterator<__C1, false>,
+ __bit_iterator<__C1, false>,
+ __bit_iterator<__C2, false>);
+ template <class __C1, class __C2>friend __bit_iterator<__C2, false> __swap_ranges_unaligned(__bit_iterator<__C1, false>,
+ __bit_iterator<__C1, false>,
+ __bit_iterator<__C2, false>);
+ template <class __C1, class __C2>friend __bit_iterator<__C2, false> swap_ranges(__bit_iterator<__C1, false>,
+ __bit_iterator<__C1, false>,
+ __bit_iterator<__C2, false>);
+ template <class _Dp> friend __bit_iterator<_Dp, false> rotate(__bit_iterator<_Dp, false>,
+ __bit_iterator<_Dp, false>,
+ __bit_iterator<_Dp, false>);
+ template <class _Dp, bool _IC1, bool _IC2> friend bool __equal_aligned(__bit_iterator<_Dp, _IC1>,
+ __bit_iterator<_Dp, _IC1>,
+ __bit_iterator<_Dp, _IC2>);
+ template <class _Dp, bool _IC1, bool _IC2> friend bool __equal_unaligned(__bit_iterator<_Dp, _IC1>,
+ __bit_iterator<_Dp, _IC1>,
+ __bit_iterator<_Dp, _IC2>);
+ template <class _Dp, bool _IC1, bool _IC2> friend bool equal(__bit_iterator<_Dp, _IC1>,
+ __bit_iterator<_Dp, _IC1>,
+ __bit_iterator<_Dp, _IC2>);
+ template <class _Dp, bool _IC> friend __bit_iterator<_Dp, _IC> __find_bool_true(__bit_iterator<_Dp, _IC>,
+ typename _Dp::size_type);
+ template <class _Dp, bool _IC> friend __bit_iterator<_Dp, _IC> __find_bool_false(__bit_iterator<_Dp, _IC>,
+ typename _Dp::size_type);
+ template <class _Dp, bool _IC> friend typename __bit_iterator<_Dp, _IC>::difference_type
+ __count_bool_true(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
+ template <class _Dp, bool _IC> friend typename __bit_iterator<_Dp, _IC>::difference_type
+ __count_bool_false(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___BIT_REFERENCE
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__bits b/contrib/libs/cxxsupp/libcxxmsvc/include/__bits
new file mode 100644
index 0000000000..f6835aa078
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__bits
@@ -0,0 +1,149 @@
+// -*- 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___BITS
+#define _LIBCPP___BITS
+
+#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
+
+#ifndef _LIBCPP_COMPILER_MSVC
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+int __libcpp_ctz(unsigned __x) _NOEXCEPT { return __builtin_ctz(__x); }
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+int __libcpp_ctz(unsigned long __x) _NOEXCEPT { return __builtin_ctzl(__x); }
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+int __libcpp_ctz(unsigned long long __x) _NOEXCEPT { return __builtin_ctzll(__x); }
+
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+int __libcpp_clz(unsigned __x) _NOEXCEPT { return __builtin_clz(__x); }
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+int __libcpp_clz(unsigned long __x) _NOEXCEPT { return __builtin_clzl(__x); }
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+int __libcpp_clz(unsigned long long __x) _NOEXCEPT { return __builtin_clzll(__x); }
+
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+int __libcpp_popcount(unsigned __x) _NOEXCEPT { return __builtin_popcount(__x); }
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+int __libcpp_popcount(unsigned long __x) _NOEXCEPT { return __builtin_popcountl(__x); }
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+int __libcpp_popcount(unsigned long long __x) _NOEXCEPT { return __builtin_popcountll(__x); }
+
+#else // _LIBCPP_COMPILER_MSVC
+
+// Precondition: __x != 0
+inline _LIBCPP_INLINE_VISIBILITY
+int __libcpp_ctz(unsigned __x) {
+ static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
+ static_assert(sizeof(unsigned long) == 4, "");
+ unsigned long __where;
+ if (_BitScanForward(&__where, __x))
+ return static_cast<int>(__where);
+ return 32;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+int __libcpp_ctz(unsigned long __x) {
+ static_assert(sizeof(unsigned long) == sizeof(unsigned), "");
+ return __libcpp_ctz(static_cast<unsigned>(__x));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+int __libcpp_ctz(unsigned long long __x) {
+ unsigned long __where;
+#if defined(_LIBCPP_HAS_BITSCAN64)
+ if (_BitScanForward64(&__where, __x))
+ return static_cast<int>(__where);
+#else
+ // Win32 doesn't have _BitScanForward64 so emulate it with two 32 bit calls.
+ if (_BitScanForward(&__where, static_cast<unsigned long>(__x)))
+ return static_cast<int>(__where);
+ if (_BitScanForward(&__where, static_cast<unsigned long>(__x >> 32)))
+ return static_cast<int>(__where + 32);
+#endif
+ return 64;
+}
+
+// Precondition: __x != 0
+inline _LIBCPP_INLINE_VISIBILITY
+int __libcpp_clz(unsigned __x) {
+ static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
+ static_assert(sizeof(unsigned long) == 4, "");
+ unsigned long __where;
+ if (_BitScanReverse(&__where, __x))
+ return static_cast<int>(31 - __where);
+ return 32; // Undefined Behavior.
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+int __libcpp_clz(unsigned long __x) {
+ static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
+ return __libcpp_clz(static_cast<unsigned>(__x));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+int __libcpp_clz(unsigned long long __x) {
+ unsigned long __where;
+#if defined(_LIBCPP_HAS_BITSCAN64)
+ if (_BitScanReverse64(&__where, __x))
+ return static_cast<int>(63 - __where);
+#else
+ // Win32 doesn't have _BitScanReverse64 so emulate it with two 32 bit calls.
+ if (_BitScanReverse(&__where, static_cast<unsigned long>(__x >> 32)))
+ return static_cast<int>(63 - (__where + 32));
+ if (_BitScanReverse(&__where, static_cast<unsigned long>(__x)))
+ return static_cast<int>(63 - __where);
+#endif
+ return 64; // Undefined Behavior.
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int __libcpp_popcount(unsigned __x) {
+ static_assert(sizeof(unsigned) == 4, "");
+ return __popcnt(__x);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int __libcpp_popcount(unsigned long __x) {
+ static_assert(sizeof(unsigned long) == 4, "");
+ return __popcnt(__x);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int __libcpp_popcount(unsigned long long __x) {
+ static_assert(sizeof(unsigned long long) == 8, "");
+#if defined(_M_IX86)
+ return __popcnt(__x) + __popcnt(__x >> 32);
+#else
+ return __popcnt64(__x);
+#endif
+}
+
+#endif // _LIBCPP_COMPILER_MSVC
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___BITS
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__bsd_locale_defaults.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__bsd_locale_defaults.h
new file mode 100644
index 0000000000..f537aa0ed2
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__bsd_locale_defaults.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
+//
+//===----------------------------------------------------------------------===//
+// The BSDs have lots of *_l functions. We don't want to define those symbols
+// on other platforms though, for fear of conflicts with user code. So here,
+// we will define the mapping from an internal macro to the real BSD symbol.
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_BSD_LOCALE_DEFAULTS_H
+#define _LIBCPP_BSD_LOCALE_DEFAULTS_H
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#define __libcpp_mb_cur_max_l(loc) MB_CUR_MAX_L(loc)
+#define __libcpp_btowc_l(ch, loc) btowc_l(ch, loc)
+#define __libcpp_wctob_l(wch, loc) wctob_l(wch, loc)
+#define __libcpp_wcsnrtombs_l(dst, src, nwc, len, ps, loc) wcsnrtombs_l(dst, src, nwc, len, ps, loc)
+#define __libcpp_wcrtomb_l(src, wc, ps, loc) wcrtomb_l(src, wc, ps, loc)
+#define __libcpp_mbsnrtowcs_l(dst, src, nms, len, ps, loc) mbsnrtowcs_l(dst, src, nms, len, ps, loc)
+#define __libcpp_mbrtowc_l(pwc, s, n, ps, l) mbrtowc_l(pwc, s, n, ps, l)
+#define __libcpp_mbtowc_l(pwc, pmb, max, l) mbtowc_l(pwc, pmb, max, l)
+#define __libcpp_mbrlen_l(s, n, ps, l) mbrlen_l(s, n, ps, l)
+#define __libcpp_localeconv_l(l) localeconv_l(l)
+#define __libcpp_mbsrtowcs_l(dest, src, len, ps, l) mbsrtowcs_l(dest, src, len, ps, l)
+// Workaround for Visual Studio preprocessor bug - explicitly mention all non-variadic parameters.
+#define __libcpp_snprintf_l(__s, __n, __l, __f, ...) snprintf_l(__s, __n, __l, __f, ##__VA_ARGS__)
+#define __libcpp_asprintf_l(__ret, __l, __f, ...) asprintf_l(__ret, __l, __f, ##__VA_ARGS__)
+#define __libcpp_sscanf_l(__s, __l, __f, ...) sscanf_l(__s, __l, __f, ##__VA_ARGS__)
+
+#endif // _LIBCPP_BSD_LOCALE_DEFAULTS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__bsd_locale_fallbacks.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__bsd_locale_fallbacks.h
new file mode 100644
index 0000000000..ceb1407d52
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__bsd_locale_fallbacks.h
@@ -0,0 +1,143 @@
+// -*- 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
+//
+//===----------------------------------------------------------------------===//
+// The BSDs have lots of *_l functions. This file provides reimplementations
+// of those functions for non-BSD platforms.
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H
+#define _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H
+
+#include <memory>
+#include <stdarg.h>
+#include <stdlib.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+inline _LIBCPP_INLINE_VISIBILITY
+decltype(MB_CUR_MAX) __libcpp_mb_cur_max_l(locale_t __l)
+{
+ __libcpp_locale_guard __current(__l);
+ return MB_CUR_MAX;
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+inline _LIBCPP_INLINE_VISIBILITY
+wint_t __libcpp_btowc_l(int __c, locale_t __l)
+{
+ __libcpp_locale_guard __current(__l);
+ return btowc(__c);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+int __libcpp_wctob_l(wint_t __c, locale_t __l)
+{
+ __libcpp_locale_guard __current(__l);
+ return wctob(__c);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+size_t __libcpp_wcsnrtombs_l(char *__dest, const wchar_t **__src, size_t __nwc,
+ size_t __len, mbstate_t *__ps, locale_t __l)
+{
+ __libcpp_locale_guard __current(__l);
+ return wcsnrtombs(__dest, __src, __nwc, __len, __ps);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+size_t __libcpp_wcrtomb_l(char *__s, wchar_t __wc, mbstate_t *__ps, locale_t __l)
+{
+ __libcpp_locale_guard __current(__l);
+ return wcrtomb(__s, __wc, __ps);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+size_t __libcpp_mbsnrtowcs_l(wchar_t * __dest, const char **__src, size_t __nms,
+ size_t __len, mbstate_t *__ps, locale_t __l)
+{
+ __libcpp_locale_guard __current(__l);
+ return mbsnrtowcs(__dest, __src, __nms, __len, __ps);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+size_t __libcpp_mbrtowc_l(wchar_t *__pwc, const char *__s, size_t __n,
+ mbstate_t *__ps, locale_t __l)
+{
+ __libcpp_locale_guard __current(__l);
+ return mbrtowc(__pwc, __s, __n, __ps);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+int __libcpp_mbtowc_l(wchar_t *__pwc, const char *__pmb, size_t __max, locale_t __l)
+{
+ __libcpp_locale_guard __current(__l);
+ return mbtowc(__pwc, __pmb, __max);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+size_t __libcpp_mbrlen_l(const char *__s, size_t __n, mbstate_t *__ps, locale_t __l)
+{
+ __libcpp_locale_guard __current(__l);
+ return mbrlen(__s, __n, __ps);
+}
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+inline _LIBCPP_INLINE_VISIBILITY
+lconv *__libcpp_localeconv_l(locale_t __l)
+{
+ __libcpp_locale_guard __current(__l);
+ return localeconv();
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+inline _LIBCPP_INLINE_VISIBILITY
+size_t __libcpp_mbsrtowcs_l(wchar_t *__dest, const char **__src, size_t __len,
+ mbstate_t *__ps, locale_t __l)
+{
+ __libcpp_locale_guard __current(__l);
+ return mbsrtowcs(__dest, __src, __len, __ps);
+}
+#endif
+
+inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 4, 5)
+int __libcpp_snprintf_l(char *__s, size_t __n, locale_t __l, const char *__format, ...) {
+ va_list __va;
+ va_start(__va, __format);
+ __libcpp_locale_guard __current(__l);
+ int __res = vsnprintf(__s, __n, __format, __va);
+ va_end(__va);
+ return __res;
+}
+
+inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4)
+int __libcpp_asprintf_l(char **__s, locale_t __l, const char *__format, ...) {
+ va_list __va;
+ va_start(__va, __format);
+ __libcpp_locale_guard __current(__l);
+ int __res = vasprintf(__s, __format, __va);
+ va_end(__va);
+ return __res;
+}
+
+inline _LIBCPP_ATTRIBUTE_FORMAT(__scanf__, 3, 4)
+int __libcpp_sscanf_l(const char *__s, locale_t __l, const char *__format, ...) {
+ va_list __va;
+ va_start(__va, __format);
+ __libcpp_locale_guard __current(__l);
+ int __res = vsscanf(__s, __format, __va);
+ va_end(__va);
+ return __res;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__charconv/chars_format.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__charconv/chars_format.h
new file mode 100644
index 0000000000..0875079e6c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__charconv/chars_format.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___CHARCONV_CHARS_FORMAT_H
+#define _LIBCPP___CHARCONV_CHARS_FORMAT_H
+
+#include <__config>
+#include <__utility/to_underlying.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifndef _LIBCPP_CXX03_LANG
+
+enum class _LIBCPP_ENUM_VIS chars_format
+{
+ scientific = 0x1,
+ fixed = 0x2,
+ hex = 0x4,
+ 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;
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CHARCONV_CHARS_FORMAT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__charconv/from_chars_result.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__charconv/from_chars_result.h
new file mode 100644
index 0000000000..2cc3c11ef6
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__charconv/from_chars_result.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___CHARCONV_FROM_CHARS_RESULT_H
+#define _LIBCPP___CHARCONV_FROM_CHARS_RESULT_H
+
+#include <__config>
+#include <__errc>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifndef _LIBCPP_CXX03_LANG
+
+struct _LIBCPP_TYPE_VIS from_chars_result
+{
+ const char* ptr;
+ errc ec;
+# if _LIBCPP_STD_VER > 17
+ _LIBCPP_HIDE_FROM_ABI friend bool operator==(const from_chars_result&, const from_chars_result&) = default;
+# endif
+};
+
+#endif // _LIBCPP_CXX03_LANG
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CHARCONV_FROM_CHARS_RESULT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__charconv/to_chars_result.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__charconv/to_chars_result.h
new file mode 100644
index 0000000000..b4bc6ac263
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__charconv/to_chars_result.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___CHARCONV_TO_CHARS_RESULT_H
+#define _LIBCPP___CHARCONV_TO_CHARS_RESULT_H
+
+#include <__config>
+#include <__errc>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifndef _LIBCPP_CXX03_LANG
+
+struct _LIBCPP_TYPE_VIS to_chars_result
+{
+ char* ptr;
+ errc ec;
+# if _LIBCPP_STD_VER > 17
+ _LIBCPP_HIDE_FROM_ABI friend bool operator==(const to_chars_result&, const to_chars_result&) = default;
+# endif
+};
+
+#endif // _LIBCPP_CXX03_LANG
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CHARCONV_TO_CHARS_RESULT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/calendar.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/calendar.h
new file mode 100644
index 0000000000..0320d50cf8
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/calendar.h
@@ -0,0 +1,1285 @@
+// -*- 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___CHRONO_CALENDAR_H
+#define _LIBCPP___CHRONO_CALENDAR_H
+
+#include <__chrono/duration.h>
+#include <__chrono/system_clock.h>
+#include <__chrono/time_point.h>
+#include <__config>
+#include <limits>
+#include <ratio>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+#if _LIBCPP_STD_VER > 17
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace chrono
+{
+
+struct local_t {};
+template<class Duration>
+using local_time = time_point<local_t, Duration>;
+using local_seconds = local_time<seconds>;
+using local_days = local_time<days>;
+
+struct last_spec { explicit last_spec() = default; };
+
+class day {
+private:
+ unsigned char __d;
+public:
+ day() = default;
+ explicit inline constexpr day(unsigned __val) noexcept : __d(static_cast<unsigned char>(__val)) {}
+ inline constexpr day& operator++() noexcept { ++__d; return *this; }
+ inline constexpr day operator++(int) noexcept { day __tmp = *this; ++(*this); return __tmp; }
+ inline constexpr day& operator--() noexcept { --__d; return *this; }
+ inline constexpr day operator--(int) noexcept { day __tmp = *this; --(*this); return __tmp; }
+ constexpr day& operator+=(const days& __dd) noexcept;
+ constexpr day& operator-=(const days& __dd) noexcept;
+ explicit inline constexpr operator unsigned() const noexcept { return __d; }
+ inline constexpr bool ok() const noexcept { return __d >= 1 && __d <= 31; }
+ };
+
+
+inline constexpr
+bool operator==(const day& __lhs, const day& __rhs) noexcept
+{ return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); }
+
+inline constexpr
+bool operator!=(const day& __lhs, const day& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+inline constexpr
+bool operator< (const day& __lhs, const day& __rhs) noexcept
+{ return static_cast<unsigned>(__lhs) < static_cast<unsigned>(__rhs); }
+
+inline constexpr
+bool operator> (const day& __lhs, const day& __rhs) noexcept
+{ return __rhs < __lhs; }
+
+inline constexpr
+bool operator<=(const day& __lhs, const day& __rhs) noexcept
+{ return !(__rhs < __lhs);}
+
+inline constexpr
+bool operator>=(const day& __lhs, const day& __rhs) noexcept
+{ return !(__lhs < __rhs); }
+
+inline constexpr
+day operator+ (const day& __lhs, const days& __rhs) noexcept
+{ return day(static_cast<unsigned>(__lhs) + __rhs.count()); }
+
+inline constexpr
+day operator+ (const days& __lhs, const day& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+inline constexpr
+day operator- (const day& __lhs, const days& __rhs) noexcept
+{ return __lhs + -__rhs; }
+
+inline constexpr
+days operator-(const day& __lhs, const day& __rhs) noexcept
+{ return days(static_cast<int>(static_cast<unsigned>(__lhs)) -
+ static_cast<int>(static_cast<unsigned>(__rhs))); }
+
+inline constexpr day& day::operator+=(const days& __dd) noexcept
+{ *this = *this + __dd; return *this; }
+
+inline constexpr day& day::operator-=(const days& __dd) noexcept
+{ *this = *this - __dd; return *this; }
+
+
+class month {
+private:
+ unsigned char __m;
+public:
+ month() = default;
+ explicit inline constexpr month(unsigned __val) noexcept : __m(static_cast<unsigned char>(__val)) {}
+ inline constexpr month& operator++() noexcept { ++__m; return *this; }
+ inline constexpr month operator++(int) noexcept { month __tmp = *this; ++(*this); return __tmp; }
+ inline constexpr month& operator--() noexcept { --__m; return *this; }
+ inline constexpr month operator--(int) noexcept { month __tmp = *this; --(*this); return __tmp; }
+ constexpr month& operator+=(const months& __m1) noexcept;
+ constexpr month& operator-=(const months& __m1) noexcept;
+ explicit inline constexpr operator unsigned() const noexcept { return __m; }
+ inline constexpr bool ok() const noexcept { return __m >= 1 && __m <= 12; }
+};
+
+
+inline constexpr
+bool operator==(const month& __lhs, const month& __rhs) noexcept
+{ return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); }
+
+inline constexpr
+bool operator!=(const month& __lhs, const month& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+inline constexpr
+bool operator< (const month& __lhs, const month& __rhs) noexcept
+{ return static_cast<unsigned>(__lhs) < static_cast<unsigned>(__rhs); }
+
+inline constexpr
+bool operator> (const month& __lhs, const month& __rhs) noexcept
+{ return __rhs < __lhs; }
+
+inline constexpr
+bool operator<=(const month& __lhs, const month& __rhs) noexcept
+{ return !(__rhs < __lhs); }
+
+inline constexpr
+bool operator>=(const month& __lhs, const month& __rhs) noexcept
+{ return !(__lhs < __rhs); }
+
+inline constexpr
+month operator+ (const month& __lhs, const months& __rhs) noexcept
+{
+ auto const __mu = static_cast<long long>(static_cast<unsigned>(__lhs)) + (__rhs.count() - 1);
+ auto const __yr = (__mu >= 0 ? __mu : __mu - 11) / 12;
+ return month{static_cast<unsigned>(__mu - __yr * 12 + 1)};
+}
+
+inline constexpr
+month operator+ (const months& __lhs, const month& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+inline constexpr
+month operator- (const month& __lhs, const months& __rhs) noexcept
+{ return __lhs + -__rhs; }
+
+inline constexpr
+months operator-(const month& __lhs, const month& __rhs) noexcept
+{
+ auto const __dm = static_cast<unsigned>(__lhs) - static_cast<unsigned>(__rhs);
+ return months(__dm <= 11 ? __dm : __dm + 12);
+}
+
+inline constexpr month& month::operator+=(const months& __dm) noexcept
+{ *this = *this + __dm; return *this; }
+
+inline constexpr month& month::operator-=(const months& __dm) noexcept
+{ *this = *this - __dm; return *this; }
+
+
+class year {
+private:
+ short __y;
+public:
+ year() = default;
+ explicit inline constexpr year(int __val) noexcept : __y(static_cast<short>(__val)) {}
+
+ inline constexpr year& operator++() noexcept { ++__y; return *this; }
+ inline constexpr year operator++(int) noexcept { year __tmp = *this; ++(*this); return __tmp; }
+ inline constexpr year& operator--() noexcept { --__y; return *this; }
+ inline constexpr year operator--(int) noexcept { year __tmp = *this; --(*this); return __tmp; }
+ constexpr year& operator+=(const years& __dy) noexcept;
+ constexpr year& operator-=(const years& __dy) noexcept;
+ inline constexpr year operator+() const noexcept { return *this; }
+ inline constexpr year operator-() const noexcept { return year{-__y}; }
+
+ inline constexpr bool is_leap() const noexcept { return __y % 4 == 0 && (__y % 100 != 0 || __y % 400 == 0); }
+ explicit inline constexpr operator int() const noexcept { return __y; }
+ constexpr bool ok() const noexcept;
+ static inline constexpr year min() noexcept { return year{-32767}; }
+ static inline constexpr year max() noexcept { return year{ 32767}; }
+};
+
+
+inline constexpr
+bool operator==(const year& __lhs, const year& __rhs) noexcept
+{ return static_cast<int>(__lhs) == static_cast<int>(__rhs); }
+
+inline constexpr
+bool operator!=(const year& __lhs, const year& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+inline constexpr
+bool operator< (const year& __lhs, const year& __rhs) noexcept
+{ return static_cast<int>(__lhs) < static_cast<int>(__rhs); }
+
+inline constexpr
+bool operator> (const year& __lhs, const year& __rhs) noexcept
+{ return __rhs < __lhs; }
+
+inline constexpr
+bool operator<=(const year& __lhs, const year& __rhs) noexcept
+{ return !(__rhs < __lhs); }
+
+inline constexpr
+bool operator>=(const year& __lhs, const year& __rhs) noexcept
+{ return !(__lhs < __rhs); }
+
+inline constexpr
+year operator+ (const year& __lhs, const years& __rhs) noexcept
+{ return year(static_cast<int>(__lhs) + __rhs.count()); }
+
+inline constexpr
+year operator+ (const years& __lhs, const year& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+inline constexpr
+year operator- (const year& __lhs, const years& __rhs) noexcept
+{ return __lhs + -__rhs; }
+
+inline constexpr
+years operator-(const year& __lhs, const year& __rhs) noexcept
+{ return years{static_cast<int>(__lhs) - static_cast<int>(__rhs)}; }
+
+
+inline constexpr year& year::operator+=(const years& __dy) noexcept
+{ *this = *this + __dy; return *this; }
+
+inline constexpr year& year::operator-=(const years& __dy) noexcept
+{ *this = *this - __dy; return *this; }
+
+inline constexpr bool year::ok() const noexcept
+{ return static_cast<int>(min()) <= __y && __y <= static_cast<int>(max()); }
+
+class weekday_indexed;
+class weekday_last;
+
+class weekday {
+private:
+ unsigned char __wd;
+ static constexpr unsigned char __weekday_from_days(int __days) noexcept;
+public:
+ weekday() = default;
+ inline explicit constexpr weekday(unsigned __val) noexcept : __wd(static_cast<unsigned char>(__val == 7 ? 0 : __val)) {}
+ inline constexpr weekday(const sys_days& __sysd) noexcept
+ : __wd(__weekday_from_days(__sysd.time_since_epoch().count())) {}
+ inline explicit constexpr weekday(const local_days& __locd) noexcept
+ : __wd(__weekday_from_days(__locd.time_since_epoch().count())) {}
+
+ inline constexpr weekday& operator++() noexcept { __wd = (__wd == 6 ? 0 : __wd + 1); return *this; }
+ inline constexpr weekday operator++(int) noexcept { weekday __tmp = *this; ++(*this); return __tmp; }
+ inline constexpr weekday& operator--() noexcept { __wd = (__wd == 0 ? 6 : __wd - 1); return *this; }
+ inline constexpr weekday operator--(int) noexcept { weekday __tmp = *this; --(*this); return __tmp; }
+ constexpr weekday& operator+=(const days& __dd) noexcept;
+ constexpr weekday& operator-=(const days& __dd) noexcept;
+ inline constexpr unsigned c_encoding() const noexcept { return __wd; }
+ inline constexpr unsigned iso_encoding() const noexcept { return __wd == 0u ? 7 : __wd; }
+ inline constexpr bool ok() const noexcept { return __wd <= 6; }
+ constexpr weekday_indexed operator[](unsigned __index) const noexcept;
+ constexpr weekday_last operator[](last_spec) const noexcept;
+};
+
+
+// https://howardhinnant.github.io/date_algorithms.html#weekday_from_days
+inline constexpr
+unsigned char weekday::__weekday_from_days(int __days) noexcept
+{
+ return static_cast<unsigned char>(
+ static_cast<unsigned>(__days >= -4 ? (__days+4) % 7 : (__days+5) % 7 + 6)
+ );
+}
+
+inline constexpr
+bool operator==(const weekday& __lhs, const weekday& __rhs) noexcept
+{ return __lhs.c_encoding() == __rhs.c_encoding(); }
+
+inline constexpr
+bool operator!=(const weekday& __lhs, const weekday& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+inline constexpr
+bool operator< (const weekday& __lhs, const weekday& __rhs) noexcept
+{ return __lhs.c_encoding() < __rhs.c_encoding(); }
+
+inline constexpr
+bool operator> (const weekday& __lhs, const weekday& __rhs) noexcept
+{ return __rhs < __lhs; }
+
+inline constexpr
+bool operator<=(const weekday& __lhs, const weekday& __rhs) noexcept
+{ return !(__rhs < __lhs);}
+
+inline constexpr
+bool operator>=(const weekday& __lhs, const weekday& __rhs) noexcept
+{ return !(__lhs < __rhs); }
+
+constexpr weekday operator+(const weekday& __lhs, const days& __rhs) noexcept
+{
+ auto const __mu = static_cast<long long>(__lhs.c_encoding()) + __rhs.count();
+ auto const __yr = (__mu >= 0 ? __mu : __mu - 6) / 7;
+ return weekday{static_cast<unsigned>(__mu - __yr * 7)};
+}
+
+constexpr weekday operator+(const days& __lhs, const weekday& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+constexpr weekday operator-(const weekday& __lhs, const days& __rhs) noexcept
+{ return __lhs + -__rhs; }
+
+constexpr days operator-(const weekday& __lhs, const weekday& __rhs) noexcept
+{
+ const int __wdu = __lhs.c_encoding() - __rhs.c_encoding();
+ const int __wk = (__wdu >= 0 ? __wdu : __wdu-6) / 7;
+ return days{__wdu - __wk * 7};
+}
+
+inline constexpr weekday& weekday::operator+=(const days& __dd) noexcept
+{ *this = *this + __dd; return *this; }
+
+inline constexpr weekday& weekday::operator-=(const days& __dd) noexcept
+{ *this = *this - __dd; return *this; }
+
+
+class weekday_indexed {
+private:
+ chrono::weekday __wd;
+ unsigned char __idx;
+public:
+ weekday_indexed() = default;
+ inline constexpr weekday_indexed(const chrono::weekday& __wdval, unsigned __idxval) noexcept
+ : __wd{__wdval}, __idx(__idxval) {}
+ 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; }
+};
+
+inline constexpr
+bool operator==(const weekday_indexed& __lhs, const weekday_indexed& __rhs) noexcept
+{ return __lhs.weekday() == __rhs.weekday() && __lhs.index() == __rhs.index(); }
+
+inline constexpr
+bool operator!=(const weekday_indexed& __lhs, const weekday_indexed& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+
+class weekday_last {
+private:
+ chrono::weekday __wd;
+public:
+ explicit constexpr weekday_last(const chrono::weekday& __val) noexcept
+ : __wd{__val} {}
+ constexpr chrono::weekday weekday() const noexcept { return __wd; }
+ constexpr bool ok() const noexcept { return __wd.ok(); }
+};
+
+inline constexpr
+bool operator==(const weekday_last& __lhs, const weekday_last& __rhs) noexcept
+{ return __lhs.weekday() == __rhs.weekday(); }
+
+inline constexpr
+bool operator!=(const weekday_last& __lhs, const weekday_last& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+inline constexpr
+weekday_indexed weekday::operator[](unsigned __index) const noexcept { return weekday_indexed{*this, __index}; }
+
+inline constexpr
+weekday_last weekday::operator[](last_spec) const noexcept { return weekday_last{*this}; }
+
+
+inline constexpr last_spec last{};
+inline constexpr weekday Sunday{0};
+inline constexpr weekday Monday{1};
+inline constexpr weekday Tuesday{2};
+inline constexpr weekday Wednesday{3};
+inline constexpr weekday Thursday{4};
+inline constexpr weekday Friday{5};
+inline constexpr weekday Saturday{6};
+
+inline constexpr month January{1};
+inline constexpr month February{2};
+inline constexpr month March{3};
+inline constexpr month April{4};
+inline constexpr month May{5};
+inline constexpr month June{6};
+inline constexpr month July{7};
+inline constexpr month August{8};
+inline constexpr month September{9};
+inline constexpr month October{10};
+inline constexpr month November{11};
+inline constexpr month December{12};
+
+
+class month_day {
+private:
+ chrono::month __m;
+ chrono::day __d;
+public:
+ month_day() = default;
+ constexpr month_day(const chrono::month& __mval, const chrono::day& __dval) noexcept
+ : __m{__mval}, __d{__dval} {}
+ inline constexpr chrono::month month() const noexcept { return __m; }
+ inline constexpr chrono::day day() const noexcept { return __d; }
+ constexpr bool ok() const noexcept;
+};
+
+inline constexpr
+bool month_day::ok() const noexcept
+{
+ if (!__m.ok()) return false;
+ const unsigned __dval = static_cast<unsigned>(__d);
+ if (__dval < 1 || __dval > 31) return false;
+ if (__dval <= 29) return true;
+// Now we've got either 30 or 31
+ const unsigned __mval = static_cast<unsigned>(__m);
+ if (__mval == 2) return false;
+ if (__mval == 4 || __mval == 6 || __mval == 9 || __mval == 11)
+ return __dval == 30;
+ return true;
+}
+
+inline constexpr
+bool operator==(const month_day& __lhs, const month_day& __rhs) noexcept
+{ return __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); }
+
+inline constexpr
+bool operator!=(const month_day& __lhs, const month_day& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+inline constexpr
+month_day operator/(const month& __lhs, const day& __rhs) noexcept
+{ return month_day{__lhs, __rhs}; }
+
+constexpr
+month_day operator/(const day& __lhs, const month& __rhs) noexcept
+{ return __rhs / __lhs; }
+
+inline constexpr
+month_day operator/(const month& __lhs, int __rhs) noexcept
+{ return __lhs / day(__rhs); }
+
+constexpr
+month_day operator/(int __lhs, const day& __rhs) noexcept
+{ return month(__lhs) / __rhs; }
+
+constexpr
+month_day operator/(const day& __lhs, int __rhs) noexcept
+{ return month(__rhs) / __lhs; }
+
+
+inline constexpr
+bool operator< (const month_day& __lhs, const month_day& __rhs) noexcept
+{ return __lhs.month() != __rhs.month() ? __lhs.month() < __rhs.month() : __lhs.day() < __rhs.day(); }
+
+inline constexpr
+bool operator> (const month_day& __lhs, const month_day& __rhs) noexcept
+{ return __rhs < __lhs; }
+
+inline constexpr
+bool operator<=(const month_day& __lhs, const month_day& __rhs) noexcept
+{ return !(__rhs < __lhs);}
+
+inline constexpr
+bool operator>=(const month_day& __lhs, const month_day& __rhs) noexcept
+{ return !(__lhs < __rhs); }
+
+
+
+class month_day_last {
+private:
+ chrono::month __m;
+public:
+ explicit constexpr month_day_last(const chrono::month& __val) noexcept
+ : __m{__val} {}
+ inline constexpr chrono::month month() const noexcept { return __m; }
+ inline constexpr bool ok() const noexcept { return __m.ok(); }
+};
+
+inline constexpr
+bool operator==(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
+{ return __lhs.month() == __rhs.month(); }
+
+inline constexpr
+bool operator!=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+inline constexpr
+bool operator< (const month_day_last& __lhs, const month_day_last& __rhs) noexcept
+{ return __lhs.month() < __rhs.month(); }
+
+inline constexpr
+bool operator> (const month_day_last& __lhs, const month_day_last& __rhs) noexcept
+{ return __rhs < __lhs; }
+
+inline constexpr
+bool operator<=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
+{ return !(__rhs < __lhs);}
+
+inline constexpr
+bool operator>=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
+{ return !(__lhs < __rhs); }
+
+inline constexpr
+month_day_last operator/(const month& __lhs, last_spec) noexcept
+{ return month_day_last{__lhs}; }
+
+inline constexpr
+month_day_last operator/(last_spec, const month& __rhs) noexcept
+{ return month_day_last{__rhs}; }
+
+inline constexpr
+month_day_last operator/(int __lhs, last_spec) noexcept
+{ return month_day_last{month(__lhs)}; }
+
+inline constexpr
+month_day_last operator/(last_spec, int __rhs) noexcept
+{ return month_day_last{month(__rhs)}; }
+
+
+class month_weekday {
+private:
+ chrono::month __m;
+ chrono::weekday_indexed __wdi;
+public:
+ constexpr month_weekday(const chrono::month& __mval, const chrono::weekday_indexed& __wdival) noexcept
+ : __m{__mval}, __wdi{__wdival} {}
+ inline constexpr chrono::month month() const noexcept { return __m; }
+ inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi; }
+ inline constexpr bool ok() const noexcept { return __m.ok() && __wdi.ok(); }
+};
+
+inline constexpr
+bool operator==(const month_weekday& __lhs, const month_weekday& __rhs) noexcept
+{ return __lhs.month() == __rhs.month() && __lhs.weekday_indexed() == __rhs.weekday_indexed(); }
+
+inline constexpr
+bool operator!=(const month_weekday& __lhs, const month_weekday& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+inline constexpr
+month_weekday operator/(const month& __lhs, const weekday_indexed& __rhs) noexcept
+{ return month_weekday{__lhs, __rhs}; }
+
+inline constexpr
+month_weekday operator/(int __lhs, const weekday_indexed& __rhs) noexcept
+{ return month_weekday{month(__lhs), __rhs}; }
+
+inline constexpr
+month_weekday operator/(const weekday_indexed& __lhs, const month& __rhs) noexcept
+{ return month_weekday{__rhs, __lhs}; }
+
+inline constexpr
+month_weekday operator/(const weekday_indexed& __lhs, int __rhs) noexcept
+{ return month_weekday{month(__rhs), __lhs}; }
+
+
+class month_weekday_last {
+ chrono::month __m;
+ chrono::weekday_last __wdl;
+ public:
+ constexpr month_weekday_last(const chrono::month& __mval, const chrono::weekday_last& __wdlval) noexcept
+ : __m{__mval}, __wdl{__wdlval} {}
+ inline constexpr chrono::month month() const noexcept { return __m; }
+ inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl; }
+ inline constexpr bool ok() const noexcept { return __m.ok() && __wdl.ok(); }
+};
+
+inline constexpr
+bool operator==(const month_weekday_last& __lhs, const month_weekday_last& __rhs) noexcept
+{ return __lhs.month() == __rhs.month() && __lhs.weekday_last() == __rhs.weekday_last(); }
+
+inline constexpr
+bool operator!=(const month_weekday_last& __lhs, const month_weekday_last& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+
+inline constexpr
+month_weekday_last operator/(const month& __lhs, const weekday_last& __rhs) noexcept
+{ return month_weekday_last{__lhs, __rhs}; }
+
+inline constexpr
+month_weekday_last operator/(int __lhs, const weekday_last& __rhs) noexcept
+{ return month_weekday_last{month(__lhs), __rhs}; }
+
+inline constexpr
+month_weekday_last operator/(const weekday_last& __lhs, const month& __rhs) noexcept
+{ return month_weekday_last{__rhs, __lhs}; }
+
+inline constexpr
+month_weekday_last operator/(const weekday_last& __lhs, int __rhs) noexcept
+{ return month_weekday_last{month(__rhs), __lhs}; }
+
+
+class year_month {
+ chrono::year __y;
+ chrono::month __m;
+public:
+ year_month() = default;
+ constexpr year_month(const chrono::year& __yval, const chrono::month& __mval) noexcept
+ : __y{__yval}, __m{__mval} {}
+ inline constexpr chrono::year year() const noexcept { return __y; }
+ inline constexpr chrono::month month() const noexcept { return __m; }
+ inline constexpr year_month& operator+=(const months& __dm) noexcept { this->__m += __dm; return *this; }
+ inline constexpr year_month& operator-=(const months& __dm) noexcept { this->__m -= __dm; return *this; }
+ inline constexpr year_month& operator+=(const years& __dy) noexcept { this->__y += __dy; return *this; }
+ inline constexpr year_month& operator-=(const years& __dy) noexcept { this->__y -= __dy; return *this; }
+ inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok(); }
+};
+
+inline constexpr
+year_month operator/(const year& __y, const month& __m) noexcept { return year_month{__y, __m}; }
+
+inline constexpr
+year_month operator/(const year& __y, int __m) noexcept { return year_month{__y, month(__m)}; }
+
+inline constexpr
+bool operator==(const year_month& __lhs, const year_month& __rhs) noexcept
+{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month(); }
+
+inline constexpr
+bool operator!=(const year_month& __lhs, const year_month& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+inline constexpr
+bool operator< (const year_month& __lhs, const year_month& __rhs) noexcept
+{ return __lhs.year() != __rhs.year() ? __lhs.year() < __rhs.year() : __lhs.month() < __rhs.month(); }
+
+inline constexpr
+bool operator> (const year_month& __lhs, const year_month& __rhs) noexcept
+{ return __rhs < __lhs; }
+
+inline constexpr
+bool operator<=(const year_month& __lhs, const year_month& __rhs) noexcept
+{ return !(__rhs < __lhs);}
+
+inline constexpr
+bool operator>=(const year_month& __lhs, const year_month& __rhs) noexcept
+{ return !(__lhs < __rhs); }
+
+constexpr year_month operator+(const year_month& __lhs, const months& __rhs) noexcept
+{
+ int __dmi = static_cast<int>(static_cast<unsigned>(__lhs.month())) - 1 + __rhs.count();
+ const int __dy = (__dmi >= 0 ? __dmi : __dmi-11) / 12;
+ __dmi = __dmi - __dy * 12 + 1;
+ return (__lhs.year() + years(__dy)) / month(static_cast<unsigned>(__dmi));
+}
+
+constexpr year_month operator+(const months& __lhs, const year_month& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+constexpr year_month operator+(const year_month& __lhs, const years& __rhs) noexcept
+{ return (__lhs.year() + __rhs) / __lhs.month(); }
+
+constexpr year_month operator+(const years& __lhs, const year_month& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+constexpr months operator-(const year_month& __lhs, const year_month& __rhs) noexcept
+{ return (__lhs.year() - __rhs.year()) + months(static_cast<unsigned>(__lhs.month()) - static_cast<unsigned>(__rhs.month())); }
+
+constexpr year_month operator-(const year_month& __lhs, const months& __rhs) noexcept
+{ return __lhs + -__rhs; }
+
+constexpr year_month operator-(const year_month& __lhs, const years& __rhs) noexcept
+{ return __lhs + -__rhs; }
+
+class year_month_day_last;
+
+class year_month_day {
+private:
+ chrono::year __y;
+ chrono::month __m;
+ chrono::day __d;
+public:
+ year_month_day() = default;
+ inline constexpr year_month_day(
+ const chrono::year& __yval, const chrono::month& __mval, const chrono::day& __dval) noexcept
+ : __y{__yval}, __m{__mval}, __d{__dval} {}
+ constexpr year_month_day(const year_month_day_last& __ymdl) noexcept;
+ inline constexpr year_month_day(const sys_days& __sysd) noexcept
+ : year_month_day(__from_days(__sysd.time_since_epoch())) {}
+ inline explicit constexpr year_month_day(const local_days& __locd) noexcept
+ : year_month_day(__from_days(__locd.time_since_epoch())) {}
+
+ constexpr year_month_day& operator+=(const months& __dm) noexcept;
+ constexpr year_month_day& operator-=(const months& __dm) noexcept;
+ constexpr year_month_day& operator+=(const years& __dy) noexcept;
+ constexpr year_month_day& operator-=(const years& __dy) noexcept;
+
+ inline constexpr chrono::year year() const noexcept { return __y; }
+ inline constexpr chrono::month month() const noexcept { return __m; }
+ inline constexpr chrono::day day() const noexcept { return __d; }
+ inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
+ inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
+
+ constexpr bool ok() const noexcept;
+
+ static constexpr year_month_day __from_days(days __d) noexcept;
+ constexpr days __to_days() const noexcept;
+};
+
+
+// https://howardhinnant.github.io/date_algorithms.html#civil_from_days
+inline constexpr
+year_month_day
+year_month_day::__from_days(days __d) noexcept
+{
+ 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]
+ const unsigned __yoe = (__doe - __doe/1460 + __doe/36524 - __doe/146096) / 365; // [0, 399]
+ const int __yr = static_cast<int>(__yoe) + __era * 400;
+ const unsigned __doy = __doe - (365 * __yoe + __yoe/4 - __yoe/100); // [0, 365]
+ const unsigned __mp = (5 * __doy + 2)/153; // [0, 11]
+ const unsigned __dy = __doy - (153 * __mp + 2)/5 + 1; // [1, 31]
+ const unsigned __mth = __mp + (__mp < 10 ? 3 : -9); // [1, 12]
+ return year_month_day{chrono::year{__yr + (__mth <= 2)}, chrono::month{__mth}, chrono::day{__dy}};
+}
+
+// https://howardhinnant.github.io/date_algorithms.html#days_from_civil
+inline constexpr days year_month_day::__to_days() const noexcept
+{
+ 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);
+ const unsigned __dy = static_cast<unsigned>(__d);
+
+ const int __era = (__yr >= 0 ? __yr : __yr - 399) / 400;
+ const unsigned __yoe = static_cast<unsigned>(__yr - __era * 400); // [0, 399]
+ const unsigned __doy = (153 * (__mth + (__mth > 2 ? -3 : 9)) + 2) / 5 + __dy-1; // [0, 365]
+ const unsigned __doe = __yoe * 365 + __yoe/4 - __yoe/100 + __doy; // [0, 146096]
+ return days{__era * 146097 + static_cast<int>(__doe) - 719468};
+}
+
+inline constexpr
+bool operator==(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
+{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); }
+
+inline constexpr
+bool operator!=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+inline constexpr
+bool operator< (const year_month_day& __lhs, const year_month_day& __rhs) noexcept
+{
+ if (__lhs.year() < __rhs.year()) return true;
+ if (__lhs.year() > __rhs.year()) return false;
+ if (__lhs.month() < __rhs.month()) return true;
+ if (__lhs.month() > __rhs.month()) return false;
+ return __lhs.day() < __rhs.day();
+}
+
+inline constexpr
+bool operator> (const year_month_day& __lhs, const year_month_day& __rhs) noexcept
+{ return __rhs < __lhs; }
+
+inline constexpr
+bool operator<=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
+{ return !(__rhs < __lhs);}
+
+inline constexpr
+bool operator>=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
+{ return !(__lhs < __rhs); }
+
+inline constexpr
+year_month_day operator/(const year_month& __lhs, const day& __rhs) noexcept
+{ return year_month_day{__lhs.year(), __lhs.month(), __rhs}; }
+
+inline constexpr
+year_month_day operator/(const year_month& __lhs, int __rhs) noexcept
+{ return __lhs / day(__rhs); }
+
+inline constexpr
+year_month_day operator/(const year& __lhs, const month_day& __rhs) noexcept
+{ return __lhs / __rhs.month() / __rhs.day(); }
+
+inline constexpr
+year_month_day operator/(int __lhs, const month_day& __rhs) noexcept
+{ return year(__lhs) / __rhs; }
+
+inline constexpr
+year_month_day operator/(const month_day& __lhs, const year& __rhs) noexcept
+{ return __rhs / __lhs; }
+
+inline constexpr
+year_month_day operator/(const month_day& __lhs, int __rhs) noexcept
+{ return year(__rhs) / __lhs; }
+
+
+inline constexpr
+year_month_day operator+(const year_month_day& __lhs, const months& __rhs) noexcept
+{ return (__lhs.year()/__lhs.month() + __rhs)/__lhs.day(); }
+
+inline constexpr
+year_month_day operator+(const months& __lhs, const year_month_day& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+inline constexpr
+year_month_day operator-(const year_month_day& __lhs, const months& __rhs) noexcept
+{ return __lhs + -__rhs; }
+
+inline constexpr
+year_month_day operator+(const year_month_day& __lhs, const years& __rhs) noexcept
+{ return (__lhs.year() + __rhs) / __lhs.month() / __lhs.day(); }
+
+inline constexpr
+year_month_day operator+(const years& __lhs, const year_month_day& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+inline constexpr
+year_month_day operator-(const year_month_day& __lhs, const years& __rhs) noexcept
+{ return __lhs + -__rhs; }
+
+inline constexpr year_month_day& year_month_day::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
+inline constexpr year_month_day& year_month_day::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
+inline constexpr year_month_day& year_month_day::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; }
+inline constexpr year_month_day& year_month_day::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; }
+
+class year_month_day_last {
+private:
+ chrono::year __y;
+ chrono::month_day_last __mdl;
+public:
+ constexpr year_month_day_last(const year& __yval, const month_day_last& __mdlval) noexcept
+ : __y{__yval}, __mdl{__mdlval} {}
+
+ constexpr year_month_day_last& operator+=(const months& __m) noexcept;
+ constexpr year_month_day_last& operator-=(const months& __m) noexcept;
+ constexpr year_month_day_last& operator+=(const years& __y) noexcept;
+ constexpr year_month_day_last& operator-=(const years& __y) noexcept;
+
+ inline constexpr chrono::year year() const noexcept { return __y; }
+ inline constexpr chrono::month month() const noexcept { return __mdl.month(); }
+ inline constexpr chrono::month_day_last month_day_last() const noexcept { return __mdl; }
+ constexpr chrono::day day() const noexcept;
+ inline constexpr operator sys_days() const noexcept { return sys_days{year()/month()/day()}; }
+ inline explicit constexpr operator local_days() const noexcept { return local_days{year()/month()/day()}; }
+ inline constexpr bool ok() const noexcept { return __y.ok() && __mdl.ok(); }
+};
+
+inline constexpr
+chrono::day year_month_day_last::day() const noexcept
+{
+ constexpr chrono::day __d[] =
+ {
+ chrono::day(31), chrono::day(28), chrono::day(31),
+ chrono::day(30), chrono::day(31), chrono::day(30),
+ chrono::day(31), chrono::day(31), chrono::day(30),
+ chrono::day(31), chrono::day(30), chrono::day(31)
+ };
+ return (month() != February || !__y.is_leap()) && month().ok() ?
+ __d[static_cast<unsigned>(month()) - 1] : chrono::day{29};
+}
+
+inline constexpr
+bool operator==(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
+{ return __lhs.year() == __rhs.year() && __lhs.month_day_last() == __rhs.month_day_last(); }
+
+inline constexpr
+bool operator!=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+inline constexpr
+bool operator< (const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
+{
+ if (__lhs.year() < __rhs.year()) return true;
+ if (__lhs.year() > __rhs.year()) return false;
+ return __lhs.month_day_last() < __rhs.month_day_last();
+}
+
+inline constexpr
+bool operator> (const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
+{ return __rhs < __lhs; }
+
+inline constexpr
+bool operator<=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
+{ return !(__rhs < __lhs);}
+
+inline constexpr
+bool operator>=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
+{ return !(__lhs < __rhs); }
+
+inline constexpr year_month_day_last operator/(const year_month& __lhs, last_spec) noexcept
+{ return year_month_day_last{__lhs.year(), month_day_last{__lhs.month()}}; }
+
+inline constexpr year_month_day_last operator/(const year& __lhs, const month_day_last& __rhs) noexcept
+{ return year_month_day_last{__lhs, __rhs}; }
+
+inline constexpr year_month_day_last operator/(int __lhs, const month_day_last& __rhs) noexcept
+{ return year_month_day_last{year{__lhs}, __rhs}; }
+
+inline constexpr year_month_day_last operator/(const month_day_last& __lhs, const year& __rhs) noexcept
+{ return __rhs / __lhs; }
+
+inline constexpr year_month_day_last operator/(const month_day_last& __lhs, int __rhs) noexcept
+{ return year{__rhs} / __lhs; }
+
+
+inline constexpr
+year_month_day_last operator+(const year_month_day_last& __lhs, const months& __rhs) noexcept
+{ return (__lhs.year() / __lhs.month() + __rhs) / last; }
+
+inline constexpr
+year_month_day_last operator+(const months& __lhs, const year_month_day_last& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+inline constexpr
+year_month_day_last operator-(const year_month_day_last& __lhs, const months& __rhs) noexcept
+{ return __lhs + (-__rhs); }
+
+inline constexpr
+year_month_day_last operator+(const year_month_day_last& __lhs, const years& __rhs) noexcept
+{ return year_month_day_last{__lhs.year() + __rhs, __lhs.month_day_last()}; }
+
+inline constexpr
+year_month_day_last operator+(const years& __lhs, const year_month_day_last& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+inline constexpr
+year_month_day_last operator-(const year_month_day_last& __lhs, const years& __rhs) noexcept
+{ return __lhs + (-__rhs); }
+
+inline constexpr year_month_day_last& year_month_day_last::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
+inline constexpr year_month_day_last& year_month_day_last::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
+inline constexpr year_month_day_last& year_month_day_last::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; }
+inline constexpr year_month_day_last& year_month_day_last::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; }
+
+inline constexpr year_month_day::year_month_day(const year_month_day_last& __ymdl) noexcept
+ : __y{__ymdl.year()}, __m{__ymdl.month()}, __d{__ymdl.day()} {}
+
+inline constexpr bool year_month_day::ok() const noexcept
+{
+ if (!__y.ok() || !__m.ok()) return false;
+ return chrono::day{1} <= __d && __d <= (__y / __m / last).day();
+}
+
+class year_month_weekday {
+ chrono::year __y;
+ chrono::month __m;
+ chrono::weekday_indexed __wdi;
+public:
+ year_month_weekday() = default;
+ constexpr year_month_weekday(const chrono::year& __yval, const chrono::month& __mval,
+ const chrono::weekday_indexed& __wdival) noexcept
+ : __y{__yval}, __m{__mval}, __wdi{__wdival} {}
+ constexpr year_month_weekday(const sys_days& __sysd) noexcept
+ : year_month_weekday(__from_days(__sysd.time_since_epoch())) {}
+ inline explicit constexpr year_month_weekday(const local_days& __locd) noexcept
+ : year_month_weekday(__from_days(__locd.time_since_epoch())) {}
+ constexpr year_month_weekday& operator+=(const months& m) noexcept;
+ constexpr year_month_weekday& operator-=(const months& m) noexcept;
+ constexpr year_month_weekday& operator+=(const years& y) noexcept;
+ constexpr year_month_weekday& operator-=(const years& y) noexcept;
+
+ inline constexpr chrono::year year() const noexcept { return __y; }
+ inline constexpr chrono::month month() const noexcept { return __m; }
+ inline constexpr chrono::weekday weekday() const noexcept { return __wdi.weekday(); }
+ inline constexpr unsigned index() const noexcept { return __wdi.index(); }
+ inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi; }
+
+ inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
+ inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
+ inline constexpr bool ok() const noexcept
+ {
+ if (!__y.ok() || !__m.ok() || !__wdi.ok()) return false;
+ if (__wdi.index() <= 4) return true;
+ auto __nth_weekday_day =
+ __wdi.weekday() -
+ chrono::weekday{static_cast<sys_days>(__y / __m / 1)} +
+ days{(__wdi.index() - 1) * 7 + 1};
+ return static_cast<unsigned>(__nth_weekday_day.count()) <=
+ static_cast<unsigned>((__y / __m / last).day());
+ }
+
+ static constexpr year_month_weekday __from_days(days __d) noexcept;
+ constexpr days __to_days() const noexcept;
+};
+
+inline constexpr
+year_month_weekday year_month_weekday::__from_days(days __d) noexcept
+{
+ const sys_days __sysd{__d};
+ const chrono::weekday __wd = chrono::weekday(__sysd);
+ const year_month_day __ymd = year_month_day(__sysd);
+ return year_month_weekday{__ymd.year(), __ymd.month(),
+ __wd[(static_cast<unsigned>(__ymd.day())-1)/7+1]};
+}
+
+inline constexpr
+days year_month_weekday::__to_days() const noexcept
+{
+ const sys_days __sysd = sys_days(__y/__m/1);
+ return (__sysd + (__wdi.weekday() - chrono::weekday(__sysd) + days{(__wdi.index()-1)*7}))
+ .time_since_epoch();
+}
+
+inline constexpr
+bool operator==(const year_month_weekday& __lhs, const year_month_weekday& __rhs) noexcept
+{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.weekday_indexed() == __rhs.weekday_indexed(); }
+
+inline constexpr
+bool operator!=(const year_month_weekday& __lhs, const year_month_weekday& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+inline constexpr
+year_month_weekday operator/(const year_month& __lhs, const weekday_indexed& __rhs) noexcept
+{ return year_month_weekday{__lhs.year(), __lhs.month(), __rhs}; }
+
+inline constexpr
+year_month_weekday operator/(const year& __lhs, const month_weekday& __rhs) noexcept
+{ return year_month_weekday{__lhs, __rhs.month(), __rhs.weekday_indexed()}; }
+
+inline constexpr
+year_month_weekday operator/(int __lhs, const month_weekday& __rhs) noexcept
+{ return year(__lhs) / __rhs; }
+
+inline constexpr
+year_month_weekday operator/(const month_weekday& __lhs, const year& __rhs) noexcept
+{ return __rhs / __lhs; }
+
+inline constexpr
+year_month_weekday operator/(const month_weekday& __lhs, int __rhs) noexcept
+{ return year(__rhs) / __lhs; }
+
+
+inline constexpr
+year_month_weekday operator+(const year_month_weekday& __lhs, const months& __rhs) noexcept
+{ return (__lhs.year() / __lhs.month() + __rhs) / __lhs.weekday_indexed(); }
+
+inline constexpr
+year_month_weekday operator+(const months& __lhs, const year_month_weekday& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+inline constexpr
+year_month_weekday operator-(const year_month_weekday& __lhs, const months& __rhs) noexcept
+{ return __lhs + (-__rhs); }
+
+inline constexpr
+year_month_weekday operator+(const year_month_weekday& __lhs, const years& __rhs) noexcept
+{ return year_month_weekday{__lhs.year() + __rhs, __lhs.month(), __lhs.weekday_indexed()}; }
+
+inline constexpr
+year_month_weekday operator+(const years& __lhs, const year_month_weekday& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+inline constexpr
+year_month_weekday operator-(const year_month_weekday& __lhs, const years& __rhs) noexcept
+{ return __lhs + (-__rhs); }
+
+
+inline constexpr year_month_weekday& year_month_weekday::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
+inline constexpr year_month_weekday& year_month_weekday::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
+inline constexpr year_month_weekday& year_month_weekday::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; }
+inline constexpr year_month_weekday& year_month_weekday::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; }
+
+class year_month_weekday_last {
+private:
+ chrono::year __y;
+ chrono::month __m;
+ chrono::weekday_last __wdl;
+public:
+ constexpr year_month_weekday_last(const chrono::year& __yval, const chrono::month& __mval,
+ const chrono::weekday_last& __wdlval) noexcept
+ : __y{__yval}, __m{__mval}, __wdl{__wdlval} {}
+ constexpr year_month_weekday_last& operator+=(const months& __dm) noexcept;
+ constexpr year_month_weekday_last& operator-=(const months& __dm) noexcept;
+ constexpr year_month_weekday_last& operator+=(const years& __dy) noexcept;
+ constexpr year_month_weekday_last& operator-=(const years& __dy) noexcept;
+
+ inline constexpr chrono::year year() const noexcept { return __y; }
+ inline constexpr chrono::month month() const noexcept { return __m; }
+ inline constexpr chrono::weekday weekday() const noexcept { return __wdl.weekday(); }
+ inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl; }
+ inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
+ inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
+ inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok() && __wdl.ok(); }
+
+ constexpr days __to_days() const noexcept;
+
+};
+
+inline constexpr
+days year_month_weekday_last::__to_days() const noexcept
+{
+ const sys_days __last = sys_days{__y/__m/last};
+ return (__last - (chrono::weekday{__last} - __wdl.weekday())).time_since_epoch();
+
+}
+
+inline constexpr
+bool operator==(const year_month_weekday_last& __lhs, const year_month_weekday_last& __rhs) noexcept
+{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.weekday_last() == __rhs.weekday_last(); }
+
+inline constexpr
+bool operator!=(const year_month_weekday_last& __lhs, const year_month_weekday_last& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+
+inline constexpr
+year_month_weekday_last operator/(const year_month& __lhs, const weekday_last& __rhs) noexcept
+{ return year_month_weekday_last{__lhs.year(), __lhs.month(), __rhs}; }
+
+inline constexpr
+year_month_weekday_last operator/(const year& __lhs, const month_weekday_last& __rhs) noexcept
+{ return year_month_weekday_last{__lhs, __rhs.month(), __rhs.weekday_last()}; }
+
+inline constexpr
+year_month_weekday_last operator/(int __lhs, const month_weekday_last& __rhs) noexcept
+{ return year(__lhs) / __rhs; }
+
+inline constexpr
+year_month_weekday_last operator/(const month_weekday_last& __lhs, const year& __rhs) noexcept
+{ return __rhs / __lhs; }
+
+inline constexpr
+year_month_weekday_last operator/(const month_weekday_last& __lhs, int __rhs) noexcept
+{ return year(__rhs) / __lhs; }
+
+
+inline constexpr
+year_month_weekday_last operator+(const year_month_weekday_last& __lhs, const months& __rhs) noexcept
+{ return (__lhs.year() / __lhs.month() + __rhs) / __lhs.weekday_last(); }
+
+inline constexpr
+year_month_weekday_last operator+(const months& __lhs, const year_month_weekday_last& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+inline constexpr
+year_month_weekday_last operator-(const year_month_weekday_last& __lhs, const months& __rhs) noexcept
+{ return __lhs + (-__rhs); }
+
+inline constexpr
+year_month_weekday_last operator+(const year_month_weekday_last& __lhs, const years& __rhs) noexcept
+{ return year_month_weekday_last{__lhs.year() + __rhs, __lhs.month(), __lhs.weekday_last()}; }
+
+inline constexpr
+year_month_weekday_last operator+(const years& __lhs, const year_month_weekday_last& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+inline constexpr
+year_month_weekday_last operator-(const year_month_weekday_last& __lhs, const years& __rhs) noexcept
+{ return __lhs + (-__rhs); }
+
+inline constexpr year_month_weekday_last& year_month_weekday_last::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
+inline constexpr year_month_weekday_last& year_month_weekday_last::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
+inline constexpr year_month_weekday_last& year_month_weekday_last::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; }
+inline constexpr year_month_weekday_last& year_month_weekday_last::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; }
+
+
+template <class _Duration>
+class hh_mm_ss
+{
+private:
+ static_assert(__is_duration<_Duration>::value, "template parameter of hh_mm_ss must be a std::chrono::duration");
+ using __CommonType = common_type_t<_Duration, chrono::seconds>;
+
+ static constexpr uint64_t __pow10(unsigned __exp)
+ {
+ uint64_t __ret = 1;
+ for (unsigned __i = 0; __i < __exp; ++__i)
+ __ret *= 10U;
+ return __ret;
+ }
+
+ static constexpr unsigned __width(uint64_t __n, uint64_t __d = 10, unsigned __w = 0)
+ {
+ if (__n >= 2 && __d != 0 && __w < 19)
+ return 1 + __width(__n, __d % __n * 10, __w+1);
+ return 0;
+ }
+
+public:
+ static unsigned constexpr fractional_width = __width(__CommonType::period::den) < 19 ?
+ __width(__CommonType::period::den) : 6u;
+ using precision = duration<typename __CommonType::rep, ratio<1, __pow10(fractional_width)>>;
+
+ constexpr hh_mm_ss() noexcept : hh_mm_ss{_Duration::zero()} {}
+
+ constexpr explicit hh_mm_ss(_Duration __d) noexcept :
+ __is_neg(__d < _Duration(0)),
+ __h(duration_cast<chrono::hours> (abs(__d))),
+ __m(duration_cast<chrono::minutes>(abs(__d) - hours())),
+ __s(duration_cast<chrono::seconds>(abs(__d) - hours() - minutes())),
+ __f(duration_cast<precision> (abs(__d) - hours() - minutes() - seconds()))
+ {}
+
+ constexpr bool is_negative() const noexcept { return __is_neg; }
+ constexpr chrono::hours hours() const noexcept { return __h; }
+ constexpr chrono::minutes minutes() const noexcept { return __m; }
+ constexpr chrono::seconds seconds() const noexcept { return __s; }
+ constexpr precision subseconds() const noexcept { return __f; }
+
+ constexpr precision to_duration() const noexcept
+ {
+ auto __dur = __h + __m + __s + __f;
+ return __is_neg ? -__dur : __dur;
+ }
+
+ constexpr explicit operator precision() const noexcept { return to_duration(); }
+
+private:
+ bool __is_neg;
+ chrono::hours __h;
+ chrono::minutes __m;
+ chrono::seconds __s;
+ precision __f;
+};
+
+constexpr bool is_am(const hours& __h) noexcept { return __h >= hours( 0) && __h < hours(12); }
+constexpr bool is_pm(const hours& __h) noexcept { return __h >= hours(12) && __h < hours(24); }
+
+constexpr hours make12(const hours& __h) noexcept
+{
+ if (__h == hours( 0)) return hours(12);
+ else if (__h <= hours(12)) return __h;
+ else return __h - hours(12);
+}
+
+constexpr hours make24(const hours& __h, bool __is_pm) noexcept
+{
+ if (__is_pm)
+ return __h == hours(12) ? __h : __h + hours(12);
+ else
+ return __h == hours(12) ? hours(0) : __h;
+}
+
+} // namespace chrono
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( push )
+#pragma warning ( disable : 4455)
+#endif
+
+inline namespace literals
+{
+ inline namespace chrono_literals
+ {
+ constexpr chrono::day operator ""d(unsigned long long __d) noexcept
+ {
+ return chrono::day(static_cast<unsigned>(__d));
+ }
+
+ constexpr chrono::year operator ""y(unsigned long long __y) noexcept
+ {
+ return chrono::year(static_cast<int>(__y));
+ }
+} // namespace chrono_literals
+} // namespace literals
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( pop )
+#endif
+
+namespace chrono { // hoist the literals into namespace std::chrono
+ using namespace literals::chrono_literals;
+} // namespace chrono
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___CHRONO_CALENDAR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/convert_to_timespec.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/convert_to_timespec.h
new file mode 100644
index 0000000000..e8631d135f
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/convert_to_timespec.h
@@ -0,0 +1,55 @@
+// -*- 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___CHRONO_CONVERT_TO_TIMESPEC_H
+#define _LIBCPP___CHRONO_CONVERT_TO_TIMESPEC_H
+
+#include <__chrono/duration.h>
+#include <__config>
+#include <limits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// Convert a nanoseconds duration to the given TimeSpec type, which must have
+// the same properties as std::timespec.
+template <class _TimeSpec>
+_LIBCPP_HIDE_FROM_ABI inline
+_TimeSpec __convert_to_timespec(const chrono::nanoseconds& __ns)
+{
+ using namespace chrono;
+ seconds __s = duration_cast<seconds>(__ns);
+ _TimeSpec __ts;
+ typedef decltype(__ts.tv_sec) __ts_sec;
+ const __ts_sec __ts_sec_max = numeric_limits<__ts_sec>::max();
+
+ if (__s.count() < __ts_sec_max)
+ {
+ __ts.tv_sec = static_cast<__ts_sec>(__s.count());
+ __ts.tv_nsec = static_cast<decltype(__ts.tv_nsec)>((__ns - __s).count());
+ }
+ else
+ {
+ __ts.tv_sec = __ts_sec_max;
+ __ts.tv_nsec = 999999999; // (10^9 - 1)
+ }
+
+ return __ts;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___CHRONO_CONVERT_TO_TIMESPEC_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/duration.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/duration.h
new file mode 100644
index 0000000000..452543b069
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/duration.h
@@ -0,0 +1,625 @@
+// -*- 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___CHRONO_DURATION_H
+#define _LIBCPP___CHRONO_DURATION_H
+
+#include <__config>
+#include <limits>
+#include <ratio>
+#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 chrono
+{
+
+template <class _Rep, class _Period = ratio<1> > class _LIBCPP_TEMPLATE_VIS duration;
+
+template <class _Tp>
+struct __is_duration : false_type {};
+
+template <class _Rep, class _Period>
+struct __is_duration<duration<_Rep, _Period> > : true_type {};
+
+template <class _Rep, class _Period>
+struct __is_duration<const duration<_Rep, _Period> > : true_type {};
+
+template <class _Rep, class _Period>
+struct __is_duration<volatile duration<_Rep, _Period> > : true_type {};
+
+template <class _Rep, class _Period>
+struct __is_duration<const volatile duration<_Rep, _Period> > : true_type {};
+
+} // namespace chrono
+
+template <class _Rep1, class _Period1, class _Rep2, class _Period2>
+struct _LIBCPP_TEMPLATE_VIS common_type<chrono::duration<_Rep1, _Period1>,
+ chrono::duration<_Rep2, _Period2> >
+{
+ typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type,
+ typename __ratio_gcd<_Period1, _Period2>::type> type;
+};
+
+namespace chrono {
+
+// duration_cast
+
+template <class _FromDuration, class _ToDuration,
+ class _Period = typename ratio_divide<typename _FromDuration::period, typename _ToDuration::period>::type,
+ bool = _Period::num == 1,
+ bool = _Period::den == 1>
+struct __duration_cast;
+
+template <class _FromDuration, class _ToDuration, class _Period>
+struct __duration_cast<_FromDuration, _ToDuration, _Period, true, true>
+{
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ _ToDuration operator()(const _FromDuration& __fd) const
+ {
+ return _ToDuration(static_cast<typename _ToDuration::rep>(__fd.count()));
+ }
+};
+
+template <class _FromDuration, class _ToDuration, class _Period>
+struct __duration_cast<_FromDuration, _ToDuration, _Period, true, false>
+{
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ _ToDuration operator()(const _FromDuration& __fd) const
+ {
+ typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct;
+ return _ToDuration(static_cast<typename _ToDuration::rep>(
+ static_cast<_Ct>(__fd.count()) / static_cast<_Ct>(_Period::den)));
+ }
+};
+
+template <class _FromDuration, class _ToDuration, class _Period>
+struct __duration_cast<_FromDuration, _ToDuration, _Period, false, true>
+{
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ _ToDuration operator()(const _FromDuration& __fd) const
+ {
+ typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct;
+ return _ToDuration(static_cast<typename _ToDuration::rep>(
+ static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num)));
+ }
+};
+
+template <class _FromDuration, class _ToDuration, class _Period>
+struct __duration_cast<_FromDuration, _ToDuration, _Period, false, false>
+{
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ _ToDuration operator()(const _FromDuration& __fd) const
+ {
+ typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct;
+ return _ToDuration(static_cast<typename _ToDuration::rep>(
+ static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num)
+ / static_cast<_Ct>(_Period::den)));
+ }
+};
+
+template <class _ToDuration, class _Rep, class _Period>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+typename enable_if
+<
+ __is_duration<_ToDuration>::value,
+ _ToDuration
+>::type
+duration_cast(const duration<_Rep, _Period>& __fd)
+{
+ return __duration_cast<duration<_Rep, _Period>, _ToDuration>()(__fd);
+}
+
+template <class _Rep>
+struct _LIBCPP_TEMPLATE_VIS treat_as_floating_point : is_floating_point<_Rep> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Rep>
+inline constexpr bool treat_as_floating_point_v = treat_as_floating_point<_Rep>::value;
+#endif
+
+template <class _Rep>
+struct _LIBCPP_TEMPLATE_VIS duration_values
+{
+public:
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep zero() _NOEXCEPT {return _Rep(0);}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep max() _NOEXCEPT {return numeric_limits<_Rep>::max();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep min() _NOEXCEPT {return numeric_limits<_Rep>::lowest();}
+};
+
+#if _LIBCPP_STD_VER > 14
+template <class _ToDuration, class _Rep, class _Period>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename enable_if
+<
+ __is_duration<_ToDuration>::value,
+ _ToDuration
+>::type
+floor(const duration<_Rep, _Period>& __d)
+{
+ _ToDuration __t = duration_cast<_ToDuration>(__d);
+ if (__t > __d)
+ __t = __t - _ToDuration{1};
+ return __t;
+}
+
+template <class _ToDuration, class _Rep, class _Period>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename enable_if
+<
+ __is_duration<_ToDuration>::value,
+ _ToDuration
+>::type
+ceil(const duration<_Rep, _Period>& __d)
+{
+ _ToDuration __t = duration_cast<_ToDuration>(__d);
+ if (__t < __d)
+ __t = __t + _ToDuration{1};
+ return __t;
+}
+
+template <class _ToDuration, class _Rep, class _Period>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename enable_if
+<
+ __is_duration<_ToDuration>::value,
+ _ToDuration
+>::type
+round(const duration<_Rep, _Period>& __d)
+{
+ _ToDuration __lower = floor<_ToDuration>(__d);
+ _ToDuration __upper = __lower + _ToDuration{1};
+ auto __lowerDiff = __d - __lower;
+ auto __upperDiff = __upper - __d;
+ if (__lowerDiff < __upperDiff)
+ return __lower;
+ if (__lowerDiff > __upperDiff)
+ return __upper;
+ return __lower.count() & 1 ? __upper : __lower;
+}
+#endif
+
+// duration
+
+template <class _Rep, class _Period>
+class _LIBCPP_TEMPLATE_VIS duration
+{
+ static_assert(!__is_duration<_Rep>::value, "A duration representation can not be a duration");
+ static_assert(__is_ratio<_Period>::value, "Second template parameter of duration must be a std::ratio");
+ static_assert(_Period::num > 0, "duration period must be positive");
+
+ template <class _R1, class _R2>
+ struct __no_overflow
+ {
+ private:
+ static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value;
+ static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value;
+ static const intmax_t __n1 = _R1::num / __gcd_n1_n2;
+ static const intmax_t __d1 = _R1::den / __gcd_d1_d2;
+ static const intmax_t __n2 = _R2::num / __gcd_n1_n2;
+ static const intmax_t __d2 = _R2::den / __gcd_d1_d2;
+ static const intmax_t max = -((intmax_t(1) << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1);
+
+ template <intmax_t _Xp, intmax_t _Yp, bool __overflow>
+ struct __mul // __overflow == false
+ {
+ static const intmax_t value = _Xp * _Yp;
+ };
+
+ template <intmax_t _Xp, intmax_t _Yp>
+ struct __mul<_Xp, _Yp, true>
+ {
+ static const intmax_t value = 1;
+ };
+
+ public:
+ static const bool value = (__n1 <= max / __d2) && (__n2 <= max / __d1);
+ typedef ratio<__mul<__n1, __d2, !value>::value,
+ __mul<__n2, __d1, !value>::value> type;
+ };
+
+public:
+ typedef _Rep rep;
+ typedef typename _Period::type period;
+private:
+ rep __rep_;
+public:
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+#ifndef _LIBCPP_CXX03_LANG
+ duration() = default;
+#else
+ duration() {}
+#endif
+
+ template <class _Rep2>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ explicit duration(const _Rep2& __r,
+ typename enable_if
+ <
+ is_convertible<const _Rep2&, rep>::value &&
+ (treat_as_floating_point<rep>::value ||
+ !treat_as_floating_point<_Rep2>::value)
+ >::type* = nullptr)
+ : __rep_(__r) {}
+
+ // conversions
+ template <class _Rep2, class _Period2>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ duration(const duration<_Rep2, _Period2>& __d,
+ typename enable_if
+ <
+ __no_overflow<_Period2, period>::value && (
+ treat_as_floating_point<rep>::value ||
+ (__no_overflow<_Period2, period>::type::den == 1 &&
+ !treat_as_floating_point<_Rep2>::value))
+ >::type* = nullptr)
+ : __rep_(chrono::duration_cast<duration>(__d).count()) {}
+
+ // observer
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR rep count() const {return __rep_;}
+
+ // arithmetic
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type<duration>::type operator+() const {return typename common_type<duration>::type(*this);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type<duration>::type operator-() const {return typename common_type<duration>::type(-__rep_);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator++() {++__rep_; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration operator++(int) {return duration(__rep_++);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator--() {--__rep_; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration operator--(int) {return duration(__rep_--);}
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator+=(const duration& __d) {__rep_ += __d.count(); return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator-=(const duration& __d) {__rep_ -= __d.count(); return *this;}
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator*=(const rep& rhs) {__rep_ *= rhs; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator/=(const rep& rhs) {__rep_ /= rhs; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator%=(const rep& rhs) {__rep_ %= rhs; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator%=(const duration& rhs) {__rep_ %= rhs.count(); return *this;}
+
+ // special values
+
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration zero() _NOEXCEPT {return duration(duration_values<rep>::zero());}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration min() _NOEXCEPT {return duration(duration_values<rep>::min());}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration max() _NOEXCEPT {return duration(duration_values<rep>::max());}
+};
+
+typedef duration<long long, nano> nanoseconds;
+typedef duration<long long, micro> microseconds;
+typedef duration<long long, milli> milliseconds;
+typedef duration<long long > seconds;
+typedef duration< long, ratio< 60> > minutes;
+typedef duration< long, ratio<3600> > hours;
+#if _LIBCPP_STD_VER > 17
+typedef duration< int, ratio_multiply<ratio<24>, hours::period>> days;
+typedef duration< int, ratio_multiply<ratio<7>, days::period>> weeks;
+typedef duration< int, ratio_multiply<ratio<146097, 400>, days::period>> years;
+typedef duration< int, ratio_divide<years::period, ratio<12>>> months;
+#endif
+// Duration ==
+
+template <class _LhsDuration, class _RhsDuration>
+struct __duration_eq
+{
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const
+ {
+ typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct;
+ return _Ct(__lhs).count() == _Ct(__rhs).count();
+ }
+};
+
+template <class _LhsDuration>
+struct __duration_eq<_LhsDuration, _LhsDuration>
+{
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const
+ {return __lhs.count() == __rhs.count();}
+};
+
+template <class _Rep1, class _Period1, class _Rep2, class _Period2>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+bool
+operator==(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
+{
+ return __duration_eq<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs);
+}
+
+// Duration !=
+
+template <class _Rep1, class _Period1, class _Rep2, class _Period2>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+bool
+operator!=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
+{
+ return !(__lhs == __rhs);
+}
+
+// Duration <
+
+template <class _LhsDuration, class _RhsDuration>
+struct __duration_lt
+{
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const
+ {
+ typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct;
+ return _Ct(__lhs).count() < _Ct(__rhs).count();
+ }
+};
+
+template <class _LhsDuration>
+struct __duration_lt<_LhsDuration, _LhsDuration>
+{
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const
+ {return __lhs.count() < __rhs.count();}
+};
+
+template <class _Rep1, class _Period1, class _Rep2, class _Period2>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+bool
+operator< (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
+{
+ return __duration_lt<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs);
+}
+
+// Duration >
+
+template <class _Rep1, class _Period1, class _Rep2, class _Period2>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+bool
+operator> (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
+{
+ return __rhs < __lhs;
+}
+
+// Duration <=
+
+template <class _Rep1, class _Period1, class _Rep2, class _Period2>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+bool
+operator<=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
+{
+ return !(__rhs < __lhs);
+}
+
+// Duration >=
+
+template <class _Rep1, class _Period1, class _Rep2, class _Period2>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+bool
+operator>=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
+{
+ return !(__lhs < __rhs);
+}
+
+// Duration +
+
+template <class _Rep1, class _Period1, class _Rep2, class _Period2>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
+operator+(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
+{
+ typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;
+ return _Cd(_Cd(__lhs).count() + _Cd(__rhs).count());
+}
+
+// Duration -
+
+template <class _Rep1, class _Period1, class _Rep2, class _Period2>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
+operator-(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
+{
+ typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;
+ return _Cd(_Cd(__lhs).count() - _Cd(__rhs).count());
+}
+
+// Duration *
+
+template <class _Rep1, class _Period, class _Rep2>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+typename enable_if
+<
+ is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value,
+ duration<typename common_type<_Rep1, _Rep2>::type, _Period>
+>::type
+operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
+{
+ typedef typename common_type<_Rep1, _Rep2>::type _Cr;
+ typedef duration<_Cr, _Period> _Cd;
+ return _Cd(_Cd(__d).count() * static_cast<_Cr>(__s));
+}
+
+template <class _Rep1, class _Period, class _Rep2>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+typename enable_if
+<
+ is_convertible<_Rep1, typename common_type<_Rep1, _Rep2>::type>::value,
+ duration<typename common_type<_Rep1, _Rep2>::type, _Period>
+>::type
+operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d)
+{
+ return __d * __s;
+}
+
+// Duration /
+
+template <class _Rep1, class _Period, class _Rep2>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+typename enable_if
+<
+ !__is_duration<_Rep2>::value &&
+ is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value,
+ duration<typename common_type<_Rep1, _Rep2>::type, _Period>
+>::type
+operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
+{
+ typedef typename common_type<_Rep1, _Rep2>::type _Cr;
+ typedef duration<_Cr, _Period> _Cd;
+ return _Cd(_Cd(__d).count() / static_cast<_Cr>(__s));
+}
+
+template <class _Rep1, class _Period1, class _Rep2, class _Period2>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+typename common_type<_Rep1, _Rep2>::type
+operator/(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
+{
+ typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Ct;
+ return _Ct(__lhs).count() / _Ct(__rhs).count();
+}
+
+// Duration %
+
+template <class _Rep1, class _Period, class _Rep2>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+typename enable_if
+<
+ !__is_duration<_Rep2>::value &&
+ is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value,
+ duration<typename common_type<_Rep1, _Rep2>::type, _Period>
+>::type
+operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
+{
+ typedef typename common_type<_Rep1, _Rep2>::type _Cr;
+ typedef duration<_Cr, _Period> _Cd;
+ return _Cd(_Cd(__d).count() % static_cast<_Cr>(__s));
+}
+
+template <class _Rep1, class _Period1, class _Rep2, class _Period2>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
+operator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
+{
+ typedef typename common_type<_Rep1, _Rep2>::type _Cr;
+ typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;
+ return _Cd(static_cast<_Cr>(_Cd(__lhs).count()) % static_cast<_Cr>(_Cd(__rhs).count()));
+}
+
+} // namespace chrono
+
+#if _LIBCPP_STD_VER > 11
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( push )
+#pragma warning ( disable : 4455)
+#endif
+
+// Suffixes for duration literals [time.duration.literals]
+inline namespace literals
+{
+ inline namespace chrono_literals
+ {
+
+ constexpr chrono::hours operator""h(unsigned long long __h)
+ {
+ return chrono::hours(static_cast<chrono::hours::rep>(__h));
+ }
+
+ constexpr chrono::duration<long double, ratio<3600,1>> operator""h(long double __h)
+ {
+ return chrono::duration<long double, ratio<3600,1>>(__h);
+ }
+
+
+ constexpr chrono::minutes operator""min(unsigned long long __m)
+ {
+ return chrono::minutes(static_cast<chrono::minutes::rep>(__m));
+ }
+
+ constexpr chrono::duration<long double, ratio<60,1>> operator""min(long double __m)
+ {
+ return chrono::duration<long double, ratio<60,1>> (__m);
+ }
+
+
+ constexpr chrono::seconds operator""s(unsigned long long __s)
+ {
+ return chrono::seconds(static_cast<chrono::seconds::rep>(__s));
+ }
+
+ constexpr chrono::duration<long double> operator""s(long double __s)
+ {
+ return chrono::duration<long double> (__s);
+ }
+
+
+ constexpr chrono::milliseconds operator""ms(unsigned long long __ms)
+ {
+ return chrono::milliseconds(static_cast<chrono::milliseconds::rep>(__ms));
+ }
+
+ constexpr chrono::duration<long double, milli> operator""ms(long double __ms)
+ {
+ return chrono::duration<long double, milli>(__ms);
+ }
+
+
+ constexpr chrono::microseconds operator""us(unsigned long long __us)
+ {
+ return chrono::microseconds(static_cast<chrono::microseconds::rep>(__us));
+ }
+
+ constexpr chrono::duration<long double, micro> operator""us(long double __us)
+ {
+ return chrono::duration<long double, micro> (__us);
+ }
+
+
+ constexpr chrono::nanoseconds operator""ns(unsigned long long __ns)
+ {
+ return chrono::nanoseconds(static_cast<chrono::nanoseconds::rep>(__ns));
+ }
+
+ constexpr chrono::duration<long double, nano> operator""ns(long double __ns)
+ {
+ return chrono::duration<long double, nano> (__ns);
+ }
+
+} // namespace chrono_literals
+} // namespace literals
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( pop )
+#endif
+
+namespace chrono { // hoist the literals into namespace std::chrono
+ using namespace literals::chrono_literals;
+} // namespace chrono
+
+#endif // _LIBCPP_STD_VER > 11
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___CHRONO_DURATION_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/file_clock.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/file_clock.h
new file mode 100644
index 0000000000..b8e08e78ba
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/file_clock.h
@@ -0,0 +1,85 @@
+// -*- 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___CHRONO_FILE_CLOCK_H
+#define _LIBCPP___CHRONO_FILE_CLOCK_H
+
+#include <__availability>
+#include <__chrono/duration.h>
+#include <__chrono/system_clock.h>
+#include <__chrono/time_point.h>
+#include <__config>
+#include <ratio>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
+struct _FilesystemClock;
+_LIBCPP_END_NAMESPACE_FILESYSTEM
+#endif // !_LIBCPP_CXX03_LANG
+
+#if _LIBCPP_STD_VER > 17
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace chrono
+{
+
+// [time.clock.file], type file_clock
+using file_clock = _VSTD_FS::_FilesystemClock;
+
+template<class _Duration>
+using file_time = time_point<file_clock, _Duration>;
+
+} // namespace chrono
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17
+
+#ifndef _LIBCPP_CXX03_LANG
+_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
+struct _FilesystemClock {
+#if !defined(_LIBCPP_HAS_NO_INT128)
+ typedef __int128_t rep;
+ typedef nano period;
+#else
+ typedef long long rep;
+ typedef nano period;
+#endif
+
+ typedef chrono::duration<rep, period> duration;
+ typedef chrono::time_point<_FilesystemClock> time_point;
+
+ _LIBCPP_EXPORTED_FROM_ABI
+ static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = false;
+
+ _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_FUNC_VIS static time_point now() noexcept;
+
+#if _LIBCPP_STD_VER > 17
+ template <class _Duration>
+ _LIBCPP_HIDE_FROM_ABI
+ static chrono::sys_time<_Duration> to_sys(const chrono::file_time<_Duration>& __t) {
+ return chrono::sys_time<_Duration>(__t.time_since_epoch());
+ }
+
+ template <class _Duration>
+ _LIBCPP_HIDE_FROM_ABI
+ static chrono::file_time<_Duration> from_sys(const chrono::sys_time<_Duration>& __t) {
+ return chrono::file_time<_Duration>(__t.time_since_epoch());
+ }
+#endif // _LIBCPP_STD_VER > 17
+};
+_LIBCPP_END_NAMESPACE_FILESYSTEM
+#endif // !_LIBCPP_CXX03_LANG
+
+#endif // _LIBCPP___CHRONO_FILE_CLOCK_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/high_resolution_clock.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/high_resolution_clock.h
new file mode 100644
index 0000000000..778ff44f3d
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/high_resolution_clock.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___CHRONO_HIGH_RESOLUTION_CLOCK_H
+#define _LIBCPP___CHRONO_HIGH_RESOLUTION_CLOCK_H
+
+#include <__chrono/steady_clock.h>
+#include <__chrono/system_clock.h>
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace chrono
+{
+
+#ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK
+typedef steady_clock high_resolution_clock;
+#else
+typedef system_clock high_resolution_clock;
+#endif
+
+} // namespace chrono
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CHRONO_HIGH_RESOLUTION_CLOCK_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/steady_clock.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/steady_clock.h
new file mode 100644
index 0000000000..657e5eef6c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/steady_clock.h
@@ -0,0 +1,44 @@
+// -*- 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___CHRONO_STEADY_CLOCK_H
+#define _LIBCPP___CHRONO_STEADY_CLOCK_H
+
+#include <__chrono/duration.h>
+#include <__chrono/time_point.h>
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace chrono
+{
+
+#ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK
+class _LIBCPP_TYPE_VIS steady_clock
+{
+public:
+ typedef nanoseconds duration;
+ typedef duration::rep rep;
+ typedef duration::period period;
+ typedef chrono::time_point<steady_clock, duration> time_point;
+ static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = true;
+
+ static time_point now() _NOEXCEPT;
+};
+#endif
+
+} // namespace chrono
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CHRONO_STEADY_CLOCK_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/system_clock.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/system_clock.h
new file mode 100644
index 0000000000..2922b78a74
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/system_clock.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___CHRONO_SYSTEM_CLOCK_H
+#define _LIBCPP___CHRONO_SYSTEM_CLOCK_H
+
+#include <__chrono/duration.h>
+#include <__chrono/time_point.h>
+#include <__config>
+#include <ctime>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace chrono
+{
+
+class _LIBCPP_TYPE_VIS system_clock
+{
+public:
+ typedef microseconds duration;
+ typedef duration::rep rep;
+ typedef duration::period period;
+ typedef chrono::time_point<system_clock> time_point;
+ static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = false;
+
+ static time_point now() _NOEXCEPT;
+ static time_t to_time_t (const time_point& __t) _NOEXCEPT;
+ static time_point from_time_t(time_t __t) _NOEXCEPT;
+};
+
+#if _LIBCPP_STD_VER > 17
+
+template <class _Duration>
+using sys_time = time_point<system_clock, _Duration>;
+using sys_seconds = sys_time<seconds>;
+using sys_days = sys_time<days>;
+
+#endif
+
+} // namespace chrono
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CHRONO_SYSTEM_CLOCK_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/time_point.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/time_point.h
new file mode 100644
index 0000000000..ac2d347a0d
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__chrono/time_point.h
@@ -0,0 +1,249 @@
+// -*- 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___CHRONO_TIME_POINT_H
+#define _LIBCPP___CHRONO_TIME_POINT_H
+
+#include <__chrono/duration.h>
+#include <__config>
+#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
+
+namespace chrono
+{
+
+template <class _Clock, class _Duration = typename _Clock::duration>
+class _LIBCPP_TEMPLATE_VIS time_point
+{
+ static_assert(__is_duration<_Duration>::value,
+ "Second template parameter of time_point must be a std::chrono::duration");
+public:
+ typedef _Clock clock;
+ typedef _Duration duration;
+ typedef typename duration::rep rep;
+ typedef typename duration::period period;
+private:
+ duration __d_;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 time_point() : __d_(duration::zero()) {}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit time_point(const duration& __d) : __d_(__d) {}
+
+ // conversions
+ template <class _Duration2>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ time_point(const time_point<clock, _Duration2>& t,
+ typename enable_if
+ <
+ is_convertible<_Duration2, duration>::value
+ >::type* = nullptr)
+ : __d_(t.time_since_epoch()) {}
+
+ // observer
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 duration time_since_epoch() const {return __d_;}
+
+ // arithmetic
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 time_point& operator+=(const duration& __d) {__d_ += __d; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 time_point& operator-=(const duration& __d) {__d_ -= __d; return *this;}
+
+ // special values
+
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR time_point min() _NOEXCEPT {return time_point(duration::min());}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR time_point max() _NOEXCEPT {return time_point(duration::max());}
+};
+
+} // namespace chrono
+
+template <class _Clock, class _Duration1, class _Duration2>
+struct _LIBCPP_TEMPLATE_VIS common_type<chrono::time_point<_Clock, _Duration1>,
+ chrono::time_point<_Clock, _Duration2> >
+{
+ typedef chrono::time_point<_Clock, typename common_type<_Duration1, _Duration2>::type> type;
+};
+
+namespace chrono {
+
+template <class _ToDuration, class _Clock, class _Duration>
+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>(chrono::duration_cast<_ToDuration>(__t.time_since_epoch()));
+}
+
+#if _LIBCPP_STD_VER > 14
+template <class _ToDuration, class _Clock, class _Duration>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename enable_if
+<
+ __is_duration<_ToDuration>::value,
+ time_point<_Clock, _ToDuration>
+>::type
+floor(const time_point<_Clock, _Duration>& __t)
+{
+ return time_point<_Clock, _ToDuration>{floor<_ToDuration>(__t.time_since_epoch())};
+}
+
+template <class _ToDuration, class _Clock, class _Duration>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename enable_if
+<
+ __is_duration<_ToDuration>::value,
+ time_point<_Clock, _ToDuration>
+>::type
+ceil(const time_point<_Clock, _Duration>& __t)
+{
+ return time_point<_Clock, _ToDuration>{ceil<_ToDuration>(__t.time_since_epoch())};
+}
+
+template <class _ToDuration, class _Clock, class _Duration>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename enable_if
+<
+ __is_duration<_ToDuration>::value,
+ time_point<_Clock, _ToDuration>
+>::type
+round(const time_point<_Clock, _Duration>& __t)
+{
+ return time_point<_Clock, _ToDuration>{round<_ToDuration>(__t.time_since_epoch())};
+}
+
+template <class _Rep, class _Period>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename enable_if
+<
+ numeric_limits<_Rep>::is_signed,
+ duration<_Rep, _Period>
+>::type
+abs(duration<_Rep, _Period> __d)
+{
+ return __d >= __d.zero() ? +__d : -__d;
+}
+#endif // _LIBCPP_STD_VER > 14
+
+// time_point ==
+
+template <class _Clock, class _Duration1, class _Duration2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator==(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
+{
+ return __lhs.time_since_epoch() == __rhs.time_since_epoch();
+}
+
+// time_point !=
+
+template <class _Clock, class _Duration1, class _Duration2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator!=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
+{
+ return !(__lhs == __rhs);
+}
+
+// time_point <
+
+template <class _Clock, class _Duration1, class _Duration2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator<(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
+{
+ return __lhs.time_since_epoch() < __rhs.time_since_epoch();
+}
+
+// time_point >
+
+template <class _Clock, class _Duration1, class _Duration2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
+{
+ return __rhs < __lhs;
+}
+
+// time_point <=
+
+template <class _Clock, class _Duration1, class _Duration2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator<=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
+{
+ return !(__rhs < __lhs);
+}
+
+// time_point >=
+
+template <class _Clock, class _Duration1, class _Duration2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator>=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
+{
+ return !(__lhs < __rhs);
+}
+
+// time_point operator+(time_point x, duration y);
+
+template <class _Clock, class _Duration1, class _Rep2, class _Period2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>
+operator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
+{
+ typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Tr;
+ return _Tr (__lhs.time_since_epoch() + __rhs);
+}
+
+// time_point operator+(duration x, time_point y);
+
+template <class _Rep1, class _Period1, class _Clock, class _Duration2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+time_point<_Clock, typename common_type<duration<_Rep1, _Period1>, _Duration2>::type>
+operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
+{
+ return __rhs + __lhs;
+}
+
+// time_point operator-(time_point x, duration y);
+
+template <class _Clock, class _Duration1, class _Rep2, class _Period2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>
+operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
+{
+ typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Ret;
+ return _Ret(__lhs.time_since_epoch() -__rhs);
+}
+
+// duration operator-(time_point x, time_point y);
+
+template <class _Clock, class _Duration1, class _Duration2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+typename common_type<_Duration1, _Duration2>::type
+operator-(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
+{
+ return __lhs.time_since_epoch() - __rhs.time_since_epoch();
+}
+
+} // namespace chrono
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___CHRONO_TIME_POINT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/common_comparison_category.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/common_comparison_category.h
new file mode 100644
index 0000000000..deab171846
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/common_comparison_category.h
@@ -0,0 +1,94 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___COMPARE_COMMON_COMPARISON_CATEGORY_H
+#define _LIBCPP___COMPARE_COMMON_COMPARISON_CATEGORY_H
+
+#include <__compare/ordering.h>
+#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 > 17
+
+namespace __comp_detail {
+
+enum _ClassifyCompCategory : unsigned {
+ _None,
+ _PartialOrd,
+ _WeakOrd,
+ _StrongOrd,
+ _CCC_Size
+};
+
+template <class _Tp>
+_LIBCPP_HIDE_FROM_ABI
+constexpr _ClassifyCompCategory __type_to_enum() noexcept {
+ if (is_same_v<_Tp, partial_ordering>)
+ return _PartialOrd;
+ if (is_same_v<_Tp, weak_ordering>)
+ return _WeakOrd;
+ if (is_same_v<_Tp, strong_ordering>)
+ return _StrongOrd;
+ return _None;
+}
+
+template <size_t _Size>
+_LIBCPP_HIDE_FROM_ABI
+constexpr _ClassifyCompCategory
+__compute_comp_type(const _ClassifyCompCategory (&__types)[_Size]) {
+ int __seen[_CCC_Size] = {};
+ for (auto __type : __types)
+ ++__seen[__type];
+ if (__seen[_None])
+ return _None;
+ if (__seen[_PartialOrd])
+ return _PartialOrd;
+ if (__seen[_WeakOrd])
+ return _WeakOrd;
+ return _StrongOrd;
+}
+
+template <class ..._Ts, bool _False = false>
+_LIBCPP_HIDE_FROM_ABI
+constexpr auto __get_comp_type() {
+ using _CCC = _ClassifyCompCategory;
+ 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 == _PartialOrd)
+ return partial_ordering::equivalent;
+ else if constexpr (_Cat == _WeakOrd)
+ return weak_ordering::equivalent;
+ else if constexpr (_Cat == _StrongOrd)
+ return strong_ordering::equivalent;
+ else
+ static_assert(_False, "unhandled case");
+}
+} // namespace __comp_detail
+
+// [cmp.common], common comparison category type
+template<class... _Ts>
+struct _LIBCPP_TEMPLATE_VIS common_comparison_category {
+ using type = decltype(__comp_detail::__get_comp_type<_Ts...>());
+};
+
+template<class... _Ts>
+using common_comparison_category_t = typename common_comparison_category<_Ts...>::type;
+
+#endif // _LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___COMPARE_COMMON_COMPARISON_CATEGORY_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/compare_partial_order_fallback.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/compare_partial_order_fallback.h
new file mode 100644
index 0000000000..b1fd5e82bb
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/compare_partial_order_fallback.h
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___COMPARE_COMPARE_PARTIAL_ORDER_FALLBACK
+#define _LIBCPP___COMPARE_COMPARE_PARTIAL_ORDER_FALLBACK
+
+#include <__compare/ordering.h>
+#include <__compare/partial_order.h>
+#include <__config>
+#include <__utility/forward.h>
+#include <__utility/priority_tag.h>
+#include <type_traits>
+
+#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [cmp.alg]
+namespace __compare_partial_order_fallback {
+ struct __fn {
+ template<class _Tp, class _Up>
+ requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto
+ __go(_Tp&& __t, _Up&& __u, __priority_tag<1>)
+ noexcept(noexcept(_VSTD::partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
+ -> decltype( _VSTD::partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))
+ { return _VSTD::partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)); }
+
+ template<class _Tp, class _Up>
+ requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto
+ __go(_Tp&& __t, _Up&& __u, __priority_tag<0>)
+ noexcept(noexcept(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? partial_ordering::equivalent :
+ _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? partial_ordering::less :
+ _VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t) ? partial_ordering::greater :
+ partial_ordering::unordered))
+ -> decltype( _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? partial_ordering::equivalent :
+ _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? partial_ordering::less :
+ _VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t) ? partial_ordering::greater :
+ partial_ordering::unordered)
+ {
+ return _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? partial_ordering::equivalent :
+ _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? partial_ordering::less :
+ _VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t) ? partial_ordering::greater :
+ partial_ordering::unordered;
+ }
+
+ template<class _Tp, class _Up>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const
+ noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>())))
+ -> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()))
+ { return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()); }
+ };
+} // namespace __compare_partial_order_fallback
+
+inline namespace __cpo {
+ inline constexpr auto compare_partial_order_fallback = __compare_partial_order_fallback::__fn{};
+} // namespace __cpo
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___COMPARE_COMPARE_PARTIAL_ORDER_FALLBACK
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/compare_strong_order_fallback.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/compare_strong_order_fallback.h
new file mode 100644
index 0000000000..9365a1ef03
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/compare_strong_order_fallback.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___COMPARE_COMPARE_STRONG_ORDER_FALLBACK
+#define _LIBCPP___COMPARE_COMPARE_STRONG_ORDER_FALLBACK
+
+#include <__compare/ordering.h>
+#include <__compare/strong_order.h>
+#include <__config>
+#include <__utility/forward.h>
+#include <__utility/priority_tag.h>
+#include <type_traits>
+
+#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [cmp.alg]
+namespace __compare_strong_order_fallback {
+ struct __fn {
+ template<class _Tp, class _Up>
+ requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto
+ __go(_Tp&& __t, _Up&& __u, __priority_tag<1>)
+ noexcept(noexcept(_VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
+ -> decltype( _VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))
+ { return _VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)); }
+
+ template<class _Tp, class _Up>
+ requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto
+ __go(_Tp&& __t, _Up&& __u, __priority_tag<0>)
+ noexcept(noexcept(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? strong_ordering::equal :
+ _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? strong_ordering::less :
+ strong_ordering::greater))
+ -> decltype( _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? strong_ordering::equal :
+ _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? strong_ordering::less :
+ strong_ordering::greater)
+ {
+ return _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? strong_ordering::equal :
+ _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? strong_ordering::less :
+ strong_ordering::greater;
+ }
+
+ template<class _Tp, class _Up>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const
+ noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>())))
+ -> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()))
+ { return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()); }
+ };
+} // namespace __compare_strong_order_fallback
+
+inline namespace __cpo {
+ inline constexpr auto compare_strong_order_fallback = __compare_strong_order_fallback::__fn{};
+} // namespace __cpo
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___COMPARE_COMPARE_STRONG_ORDER_FALLBACK
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/compare_three_way.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/compare_three_way.h
new file mode 100644
index 0000000000..25563bb7fe
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/compare_three_way.h
@@ -0,0 +1,41 @@
+// -*- 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___COMPARE_COMPARE_THREE_WAY_H
+#define _LIBCPP___COMPARE_COMPARE_THREE_WAY_H
+
+#include <__compare/three_way_comparable.h>
+#include <__config>
+#include <__utility/forward.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+struct _LIBCPP_TEMPLATE_VIS compare_three_way
+{
+ template<class _T1, class _T2>
+ requires three_way_comparable_with<_T1, _T2>
+ constexpr _LIBCPP_HIDE_FROM_ABI
+ auto operator()(_T1&& __t, _T2&& __u) const
+ noexcept(noexcept(_VSTD::forward<_T1>(__t) <=> _VSTD::forward<_T2>(__u)))
+ { return _VSTD::forward<_T1>(__t) <=> _VSTD::forward<_T2>(__u); }
+
+ using is_transparent = void;
+};
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___COMPARE_COMPARE_THREE_WAY_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/compare_three_way_result.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/compare_three_way_result.h
new file mode 100644
index 0000000000..7b03597ab1
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/compare_three_way_result.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___COMPARE_COMPARE_THREE_WAY_RESULT_H
+#define _LIBCPP___COMPARE_COMPARE_THREE_WAY_RESULT_H
+
+#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 > 17
+
+template<class, class, class>
+struct _LIBCPP_HIDE_FROM_ABI __compare_three_way_result { };
+
+template<class _Tp, class _Up>
+struct _LIBCPP_HIDE_FROM_ABI __compare_three_way_result<_Tp, _Up, decltype(
+ declval<__make_const_lvalue_ref<_Tp>>() <=> declval<__make_const_lvalue_ref<_Up>>(), void()
+)> {
+ using type = decltype(declval<__make_const_lvalue_ref<_Tp>>() <=> declval<__make_const_lvalue_ref<_Up>>());
+};
+
+template<class _Tp, class _Up = _Tp>
+struct _LIBCPP_TEMPLATE_VIS compare_three_way_result : __compare_three_way_result<_Tp, _Up, void> { };
+
+template<class _Tp, class _Up = _Tp>
+using compare_three_way_result_t = typename compare_three_way_result<_Tp, _Up>::type;
+
+#endif // _LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___COMPARE_COMPARE_THREE_WAY_RESULT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/compare_weak_order_fallback.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/compare_weak_order_fallback.h
new file mode 100644
index 0000000000..160e45ecb5
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/compare_weak_order_fallback.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___COMPARE_COMPARE_WEAK_ORDER_FALLBACK
+#define _LIBCPP___COMPARE_COMPARE_WEAK_ORDER_FALLBACK
+
+#include <__compare/ordering.h>
+#include <__compare/weak_order.h>
+#include <__config>
+#include <__utility/forward.h>
+#include <__utility/priority_tag.h>
+#include <type_traits>
+
+#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [cmp.alg]
+namespace __compare_weak_order_fallback {
+ struct __fn {
+ template<class _Tp, class _Up>
+ requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto
+ __go(_Tp&& __t, _Up&& __u, __priority_tag<1>)
+ noexcept(noexcept(_VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
+ -> decltype( _VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))
+ { return _VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)); }
+
+ template<class _Tp, class _Up>
+ requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto
+ __go(_Tp&& __t, _Up&& __u, __priority_tag<0>)
+ noexcept(noexcept(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? weak_ordering::equivalent :
+ _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? weak_ordering::less :
+ weak_ordering::greater))
+ -> decltype( _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? weak_ordering::equivalent :
+ _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? weak_ordering::less :
+ weak_ordering::greater)
+ {
+ return _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? weak_ordering::equivalent :
+ _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? weak_ordering::less :
+ weak_ordering::greater;
+ }
+
+ template<class _Tp, class _Up>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const
+ noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>())))
+ -> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()))
+ { return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()); }
+ };
+} // namespace __compare_weak_order_fallback
+
+inline namespace __cpo {
+ inline constexpr auto compare_weak_order_fallback = __compare_weak_order_fallback::__fn{};
+} // namespace __cpo
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___COMPARE_COMPARE_WEAK_ORDER_FALLBACK
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/is_eq.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/is_eq.h
new file mode 100644
index 0000000000..78e5c70a33
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/is_eq.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___COMPARE_IS_EQ_H
+#define _LIBCPP___COMPARE_IS_EQ_H
+
+#include <__compare/ordering.h>
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_SPACESHIP_OPERATOR)
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr bool is_eq(partial_ordering __c) noexcept { return __c == 0; }
+_LIBCPP_HIDE_FROM_ABI inline constexpr bool is_neq(partial_ordering __c) noexcept { return __c != 0; }
+_LIBCPP_HIDE_FROM_ABI inline constexpr bool is_lt(partial_ordering __c) noexcept { return __c < 0; }
+_LIBCPP_HIDE_FROM_ABI inline constexpr bool is_lteq(partial_ordering __c) noexcept { return __c <= 0; }
+_LIBCPP_HIDE_FROM_ABI inline constexpr bool is_gt(partial_ordering __c) noexcept { return __c > 0; }
+_LIBCPP_HIDE_FROM_ABI inline constexpr bool is_gteq(partial_ordering __c) noexcept { return __c >= 0; }
+
+#endif // _LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___COMPARE_IS_EQ_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/ordering.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/ordering.h
new file mode 100644
index 0000000000..337b562fd9
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/ordering.h
@@ -0,0 +1,330 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___COMPARE_ORDERING_H
+#define _LIBCPP___COMPARE_ORDERING_H
+
+#include <__config>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if defined(_MSC_VER) && !defined(__clang__)
+// Omit inline namespace __y1, as MSVC2019 fails to find ordering classes
+// inside the inlined namespace when compiling the <=> operators.
+// See CROWDFUNDING-6 for the details.
+namespace std {
+#else
+_LIBCPP_BEGIN_NAMESPACE_STD
+#endif
+
+#if _LIBCPP_STD_VER > 17
+
+// exposition only
+enum class _LIBCPP_ENUM_VIS _OrdResult : signed char {
+ __less = -1,
+ __equiv = 0,
+ __greater = 1
+};
+
+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_HIDE_FROM_ABI _LIBCPP_CONSTEVAL
+ _CmpUnspecifiedParam(int _CmpUnspecifiedParam::*) noexcept {}
+
+ template<class _Tp, class = enable_if_t<!__one_of_v<_Tp, int, partial_ordering, weak_ordering, strong_ordering>>>
+ _CmpUnspecifiedParam(_Tp) = delete;
+};
+
+class partial_ordering {
+ using _ValueT = signed char;
+
+ _LIBCPP_HIDE_FROM_ABI
+ explicit constexpr partial_ordering(_OrdResult __v) noexcept
+ : __value_(_ValueT(__v)) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ explicit constexpr partial_ordering(_NCmpResult __v) noexcept
+ : __value_(_ValueT(__v)) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr bool __is_ordered() const noexcept {
+ return __value_ != _ValueT(_NCmpResult::__unordered);
+ }
+public:
+ // valid values
+ static const partial_ordering less;
+ static const partial_ordering equivalent;
+ static const partial_ordering greater;
+ static const partial_ordering unordered;
+
+ // comparisons
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator==(partial_ordering, partial_ordering) noexcept = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v.__is_ordered() && __v.__value_ == 0;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator< (partial_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v.__is_ordered() && __v.__value_ < 0;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v.__is_ordered() && __v.__value_ <= 0;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator> (partial_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v.__is_ordered() && __v.__value_ > 0;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v.__is_ordered() && __v.__value_ >= 0;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator< (_CmpUnspecifiedParam, partial_ordering __v) noexcept {
+ return __v.__is_ordered() && 0 < __v.__value_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator<=(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
+ return __v.__is_ordered() && 0 <= __v.__value_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator> (_CmpUnspecifiedParam, partial_ordering __v) noexcept {
+ return __v.__is_ordered() && 0 > __v.__value_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
+ return __v.__is_ordered() && 0 >= __v.__value_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr partial_ordering operator<=>(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ 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_;
+};
+
+inline constexpr partial_ordering partial_ordering::less(_OrdResult::__less);
+inline constexpr partial_ordering partial_ordering::equivalent(_OrdResult::__equiv);
+inline constexpr partial_ordering partial_ordering::greater(_OrdResult::__greater);
+inline constexpr partial_ordering partial_ordering::unordered(_NCmpResult ::__unordered);
+
+class weak_ordering {
+ using _ValueT = signed char;
+
+ _LIBCPP_HIDE_FROM_ABI
+ explicit constexpr weak_ordering(_OrdResult __v) noexcept : __value_(_ValueT(__v)) {}
+
+public:
+ static const weak_ordering less;
+ static const weak_ordering equivalent;
+ static const weak_ordering greater;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr operator partial_ordering() const noexcept {
+ return __value_ == 0 ? partial_ordering::equivalent
+ : (__value_ < 0 ? partial_ordering::less : partial_ordering::greater);
+ }
+
+ // comparisons
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator==(weak_ordering, weak_ordering) noexcept = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator==(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v.__value_ == 0;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator< (weak_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v.__value_ < 0;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator<=(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v.__value_ <= 0;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator> (weak_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v.__value_ > 0;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator>=(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v.__value_ >= 0;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator< (_CmpUnspecifiedParam, weak_ordering __v) noexcept {
+ return 0 < __v.__value_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator<=(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
+ return 0 <= __v.__value_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator> (_CmpUnspecifiedParam, weak_ordering __v) noexcept {
+ return 0 > __v.__value_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator>=(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
+ return 0 >= __v.__value_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr weak_ordering operator<=>(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ 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_;
+};
+
+inline constexpr weak_ordering weak_ordering::less(_OrdResult::__less);
+inline constexpr weak_ordering weak_ordering::equivalent(_OrdResult::__equiv);
+inline constexpr weak_ordering weak_ordering::greater(_OrdResult::__greater);
+
+class strong_ordering {
+ using _ValueT = signed char;
+
+ _LIBCPP_HIDE_FROM_ABI
+ explicit constexpr strong_ordering(_OrdResult __v) noexcept : __value_(_ValueT(__v)) {}
+
+public:
+ static const strong_ordering less;
+ static const strong_ordering equal;
+ static const strong_ordering equivalent;
+ static const strong_ordering greater;
+
+ // conversions
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr operator partial_ordering() const noexcept {
+ return __value_ == 0 ? partial_ordering::equivalent
+ : (__value_ < 0 ? partial_ordering::less : partial_ordering::greater);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr operator weak_ordering() const noexcept {
+ return __value_ == 0 ? weak_ordering::equivalent
+ : (__value_ < 0 ? weak_ordering::less : weak_ordering::greater);
+ }
+
+ // comparisons
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator==(strong_ordering, strong_ordering) noexcept = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator==(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v.__value_ == 0;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator< (strong_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v.__value_ < 0;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator<=(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v.__value_ <= 0;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator> (strong_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v.__value_ > 0;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator>=(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v.__value_ >= 0;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator< (_CmpUnspecifiedParam, strong_ordering __v) noexcept {
+ return 0 < __v.__value_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator<=(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
+ return 0 <= __v.__value_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator> (_CmpUnspecifiedParam, strong_ordering __v) noexcept {
+ return 0 > __v.__value_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator>=(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
+ return 0 >= __v.__value_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr strong_ordering operator<=>(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ 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_;
+};
+
+inline constexpr strong_ordering strong_ordering::less(_OrdResult::__less);
+inline constexpr strong_ordering strong_ordering::equal(_OrdResult::__equiv);
+inline constexpr strong_ordering strong_ordering::equivalent(_OrdResult::__equiv);
+inline constexpr strong_ordering strong_ordering::greater(_OrdResult::__greater);
+
+#endif // _LIBCPP_STD_VER > 17
+
+#if defined(_MSC_VER) && !defined(__clang__)
+}
+#else
+_LIBCPP_END_NAMESPACE_STD
+#endif
+
+#endif // _LIBCPP___COMPARE_ORDERING_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/partial_order.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/partial_order.h
new file mode 100644
index 0000000000..ad29701875
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/partial_order.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___COMPARE_PARTIAL_ORDER
+#define _LIBCPP___COMPARE_PARTIAL_ORDER
+
+#include <__compare/compare_three_way.h>
+#include <__compare/ordering.h>
+#include <__compare/weak_order.h>
+#include <__config>
+#include <__utility/forward.h>
+#include <__utility/priority_tag.h>
+#include <type_traits>
+
+#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [cmp.alg]
+namespace __partial_order {
+ struct __fn {
+ template<class _Tp, class _Up>
+ requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto
+ __go(_Tp&& __t, _Up&& __u, __priority_tag<2>)
+ noexcept(noexcept(partial_ordering(partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))))
+ -> decltype( partial_ordering(partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
+ { return partial_ordering(partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); }
+
+ template<class _Tp, class _Up>
+ requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto
+ __go(_Tp&& __t, _Up&& __u, __priority_tag<1>)
+ noexcept(noexcept(partial_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))))
+ -> decltype( partial_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
+ { return partial_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); }
+
+ template<class _Tp, class _Up>
+ requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto
+ __go(_Tp&& __t, _Up&& __u, __priority_tag<0>)
+ noexcept(noexcept(partial_ordering(_VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))))
+ -> decltype( partial_ordering(_VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
+ { return partial_ordering(_VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); }
+
+ template<class _Tp, class _Up>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const
+ noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>())))
+ -> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>()))
+ { return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>()); }
+ };
+} // namespace __partial_order
+
+inline namespace __cpo {
+ inline constexpr auto partial_order = __partial_order::__fn{};
+} // namespace __cpo
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___COMPARE_PARTIAL_ORDER
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/strong_order.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/strong_order.h
new file mode 100644
index 0000000000..49a6106663
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/strong_order.h
@@ -0,0 +1,136 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___COMPARE_STRONG_ORDER
+#define _LIBCPP___COMPARE_STRONG_ORDER
+
+#include <__bit/bit_cast.h>
+#include <__compare/compare_three_way.h>
+#include <__compare/ordering.h>
+#include <__config>
+#include <__utility/forward.h>
+#include <__utility/priority_tag.h>
+#include <cmath>
+#include <cstdint>
+#include <limits>
+#include <type_traits>
+
+#ifndef _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_CONCEPTS)
+
+// [cmp.alg]
+namespace __strong_order {
+ struct __fn {
+ template<class _Tp, class _Up>
+ requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto
+ __go(_Tp&& __t, _Up&& __u, __priority_tag<2>)
+ noexcept(noexcept(strong_ordering(strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))))
+ -> decltype( strong_ordering(strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
+ { return strong_ordering(strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); }
+
+ template<class _Tp, class _Up, class _Dp = decay_t<_Tp>>
+ requires is_same_v<_Dp, decay_t<_Up>> && is_floating_point_v<_Dp>
+ _LIBCPP_HIDE_FROM_ABI static constexpr strong_ordering
+ __go(_Tp&& __t, _Up&& __u, __priority_tag<1>) noexcept
+ {
+ if constexpr (numeric_limits<_Dp>::is_iec559 && sizeof(_Dp) == sizeof(int32_t)) {
+ int32_t __rx = _VSTD::bit_cast<int32_t>(__t);
+ int32_t __ry = _VSTD::bit_cast<int32_t>(__u);
+ __rx = (__rx < 0) ? (numeric_limits<int32_t>::min() - __rx - 1) : __rx;
+ __ry = (__ry < 0) ? (numeric_limits<int32_t>::min() - __ry - 1) : __ry;
+ return (__rx <=> __ry);
+ } else if constexpr (numeric_limits<_Dp>::is_iec559 && sizeof(_Dp) == sizeof(int64_t)) {
+ int64_t __rx = _VSTD::bit_cast<int64_t>(__t);
+ int64_t __ry = _VSTD::bit_cast<int64_t>(__u);
+ __rx = (__rx < 0) ? (numeric_limits<int64_t>::min() - __rx - 1) : __rx;
+ __ry = (__ry < 0) ? (numeric_limits<int64_t>::min() - __ry - 1) : __ry;
+ return (__rx <=> __ry);
+ } else if (__t < __u) {
+ return strong_ordering::less;
+ } else if (__t > __u) {
+ return strong_ordering::greater;
+ } else if (__t == __u) {
+ if constexpr (numeric_limits<_Dp>::radix == 2) {
+ return _VSTD::signbit(__u) <=> _VSTD::signbit(__t);
+ } else {
+ // This is bullet 3 of the IEEE754 algorithm, relevant
+ // only for decimal floating-point;
+ // see https://stackoverflow.com/questions/69068075/
+ if (__t == 0 || _VSTD::isinf(__t)) {
+ return _VSTD::signbit(__u) <=> _VSTD::signbit(__t);
+ } else {
+ int __texp, __uexp;
+ (void)_VSTD::frexp(__t, &__texp);
+ (void)_VSTD::frexp(__u, &__uexp);
+ return (__t < 0) ? (__texp <=> __uexp) : (__uexp <=> __texp);
+ }
+ }
+ } else {
+ // They're unordered, so one of them must be a NAN.
+ // The order is -QNAN, -SNAN, numbers, +SNAN, +QNAN.
+ bool __t_is_nan = _VSTD::isnan(__t);
+ bool __u_is_nan = _VSTD::isnan(__u);
+ bool __t_is_negative = _VSTD::signbit(__t);
+ bool __u_is_negative = _VSTD::signbit(__u);
+ using _IntType = conditional_t<
+ sizeof(__t) == sizeof(int32_t), int32_t, conditional_t<
+ sizeof(__t) == sizeof(int64_t), int64_t, void>
+ >;
+ if constexpr (is_same_v<_IntType, void>) {
+ static_assert(sizeof(_Dp) == 0, "std::strong_order is unimplemented for this floating-point type");
+ } else if (__t_is_nan && __u_is_nan) {
+ // Order by sign bit, then by "payload bits" (we'll just use bit_cast).
+ if (__t_is_negative != __u_is_negative) {
+ return (__u_is_negative <=> __t_is_negative);
+ } else {
+ return _VSTD::bit_cast<_IntType>(__t) <=> _VSTD::bit_cast<_IntType>(__u);
+ }
+ } else if (__t_is_nan) {
+ return __t_is_negative ? strong_ordering::less : strong_ordering::greater;
+ } else {
+ return __u_is_negative ? strong_ordering::greater : strong_ordering::less;
+ }
+ }
+ }
+
+ template<class _Tp, class _Up>
+ requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto
+ __go(_Tp&& __t, _Up&& __u, __priority_tag<0>)
+ noexcept(noexcept(strong_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))))
+ -> decltype( strong_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
+ { return strong_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); }
+
+ template<class _Tp, class _Up>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const
+ noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>())))
+ -> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>()))
+ { return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>()); }
+ };
+} // namespace __strong_order
+
+inline namespace __cpo {
+ inline constexpr auto strong_order = __strong_order::__fn{};
+} // namespace __cpo
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___COMPARE_STRONG_ORDER
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/synth_three_way.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/synth_three_way.h
new file mode 100644
index 0000000000..f55edd4876
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/synth_three_way.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___COMPARE_SYNTH_THREE_WAY_H
+#define _LIBCPP___COMPARE_SYNTH_THREE_WAY_H
+
+#include <__compare/ordering.h>
+#include <__compare/three_way_comparable.h>
+#include <__concepts/boolean_testable.h>
+#include <__config>
+#include <__utility/declval.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [expos.only.func]
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way =
+ []<class _Tp, class _Up>(const _Tp& __t, const _Up& __u)
+ requires requires {
+ { __t < __u } -> __boolean_testable;
+ { __u < __t } -> __boolean_testable;
+ }
+ {
+ if constexpr (three_way_comparable_with<_Tp, _Up>) {
+ return __t <=> __u;
+ } else {
+ if (__t < __u) return weak_ordering::less;
+ if (__u < __t) return weak_ordering::greater;
+ return weak_ordering::equivalent;
+ }
+ };
+
+template <class _Tp, class _Up = _Tp>
+using __synth_three_way_result = decltype(__synth_three_way(declval<_Tp&>(), declval<_Up&>()));
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___COMPARE_SYNTH_THREE_WAY_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/three_way_comparable.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/three_way_comparable.h
new file mode 100644
index 0000000000..f17382e430
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/three_way_comparable.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___COMPARE_THREE_WAY_COMPARABLE_H
+#define _LIBCPP___COMPARE_THREE_WAY_COMPARABLE_H
+
+#include <__compare/common_comparison_category.h>
+#include <__compare/ordering.h>
+#include <__concepts/common_reference_with.h>
+#include <__concepts/equality_comparable.h>
+#include <__concepts/same_as.h>
+#include <__concepts/totally_ordered.h>
+#include <__config>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+template<class _Tp, class _Cat>
+concept __compares_as =
+ same_as<common_comparison_category_t<_Tp, _Cat>, _Cat>;
+
+template<class _Tp, class _Cat = partial_ordering>
+concept three_way_comparable =
+ __weakly_equality_comparable_with<_Tp, _Tp> &&
+ __partially_ordered_with<_Tp, _Tp> &&
+ requires(__make_const_lvalue_ref<_Tp> __a, __make_const_lvalue_ref<_Tp> __b) {
+ { __a <=> __b } -> __compares_as<_Cat>;
+ };
+
+template<class _Tp, class _Up, class _Cat = partial_ordering>
+concept three_way_comparable_with =
+ three_way_comparable<_Tp, _Cat> &&
+ three_way_comparable<_Up, _Cat> &&
+ common_reference_with<__make_const_lvalue_ref<_Tp>, __make_const_lvalue_ref<_Up>> &&
+ three_way_comparable<common_reference_t<__make_const_lvalue_ref<_Tp>, __make_const_lvalue_ref<_Up>>, _Cat> &&
+ __weakly_equality_comparable_with<_Tp, _Up> &&
+ __partially_ordered_with<_Tp, _Up> &&
+ requires(__make_const_lvalue_ref<_Tp> __t, __make_const_lvalue_ref<_Up> __u) {
+ { __t <=> __u } -> __compares_as<_Cat>;
+ { __u <=> __t } -> __compares_as<_Cat>;
+ };
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___COMPARE_THREE_WAY_COMPARABLE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/weak_order.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/weak_order.h
new file mode 100644
index 0000000000..725ac831e6
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__compare/weak_order.h
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___COMPARE_WEAK_ORDER
+#define _LIBCPP___COMPARE_WEAK_ORDER
+
+#include <__compare/compare_three_way.h>
+#include <__compare/ordering.h>
+#include <__compare/strong_order.h>
+#include <__config>
+#include <__utility/forward.h>
+#include <__utility/priority_tag.h>
+#include <cmath>
+#include <type_traits>
+
+#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [cmp.alg]
+namespace __weak_order {
+ struct __fn {
+ template<class _Tp, class _Up>
+ requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto
+ __go(_Tp&& __t, _Up&& __u, __priority_tag<3>)
+ noexcept(noexcept(weak_ordering(weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))))
+ -> decltype( weak_ordering(weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
+ { return weak_ordering(weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); }
+
+ template<class _Tp, class _Up, class _Dp = decay_t<_Tp>>
+ requires is_same_v<_Dp, decay_t<_Up>> && is_floating_point_v<_Dp>
+ _LIBCPP_HIDE_FROM_ABI static constexpr weak_ordering
+ __go(_Tp&& __t, _Up&& __u, __priority_tag<2>) noexcept
+ {
+ partial_ordering __po = (__t <=> __u);
+ if (__po == partial_ordering::less) {
+ return weak_ordering::less;
+ } else if (__po == partial_ordering::equivalent) {
+ return weak_ordering::equivalent;
+ } else if (__po == partial_ordering::greater) {
+ return weak_ordering::greater;
+ } else {
+ // Otherwise, at least one of them is a NaN.
+ bool __t_is_nan = _VSTD::isnan(__t);
+ bool __u_is_nan = _VSTD::isnan(__u);
+ bool __t_is_negative = _VSTD::signbit(__t);
+ bool __u_is_negative = _VSTD::signbit(__u);
+ if (__t_is_nan && __u_is_nan) {
+ return (__u_is_negative <=> __t_is_negative);
+ } else if (__t_is_nan) {
+ return __t_is_negative ? weak_ordering::less : weak_ordering::greater;
+ } else {
+ return __u_is_negative ? weak_ordering::greater : weak_ordering::less;
+ }
+ }
+ }
+
+ template<class _Tp, class _Up>
+ requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto
+ __go(_Tp&& __t, _Up&& __u, __priority_tag<1>)
+ noexcept(noexcept(weak_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))))
+ -> decltype( weak_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
+ { return weak_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); }
+
+ template<class _Tp, class _Up>
+ requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto
+ __go(_Tp&& __t, _Up&& __u, __priority_tag<0>)
+ noexcept(noexcept(weak_ordering(_VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))))
+ -> decltype( weak_ordering(_VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
+ { return weak_ordering(_VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); }
+
+ template<class _Tp, class _Up>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const
+ noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<3>())))
+ -> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<3>()))
+ { return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<3>()); }
+ };
+} // namespace __weak_order
+
+inline namespace __cpo {
+ inline constexpr auto weak_order = __weak_order::__fn{};
+} // namespace __cpo
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___COMPARE_WEAK_ORDER
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/arithmetic.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/arithmetic.h
new file mode 100644
index 0000000000..e1ec8fcc1b
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/arithmetic.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___CONCEPTS_ARITHMETIC_H
+#define _LIBCPP___CONCEPTS_ARITHMETIC_H
+
+#include <__config>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [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 helpers for the internal type traits for the fundamental types.
+
+template <class _Tp>
+concept __libcpp_unsigned_integer = __libcpp_is_unsigned_integer<_Tp>::value;
+template <class _Tp>
+concept __libcpp_not_integral = !is_integral_v<_Tp>;
+template <class _Tp>
+concept __libcpp_signed_integer = __libcpp_is_signed_integer<_Tp>::value;
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CONCEPTS_ARITHMETIC_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/assignable.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/assignable.h
new file mode 100644
index 0000000000..4d8a230ff4
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/assignable.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___CONCEPTS_ASSIGNABLE_H
+#define _LIBCPP___CONCEPTS_ASSIGNABLE_H
+
+#include <__concepts/common_reference_with.h>
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__utility/forward.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [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>;
+ };
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CONCEPTS_ASSIGNABLE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/boolean_testable.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/boolean_testable.h
new file mode 100644
index 0000000000..89f66201e6
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/boolean_testable.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___CONCEPTS_BOOLEAN_TESTABLE_H
+#define _LIBCPP___CONCEPTS_BOOLEAN_TESTABLE_H
+
+#include <__concepts/convertible_to.h>
+#include <__config>
+#include <__utility/forward.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [concepts.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) {
+ { !_VSTD::forward<_Tp>(__t) } -> __boolean_testable_impl;
+};
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CONCEPTS_BOOLEAN_TESTABLE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/class_or_enum.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/class_or_enum.h
new file mode 100644
index 0000000000..729e444b39
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/class_or_enum.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___CONCEPTS_CLASS_OR_ENUM_H
+#define _LIBCPP___CONCEPTS_CLASS_OR_ENUM_H
+
+#include <__config>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// 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>;
+
+// Work around Clang bug https://llvm.org/PR52970
+// TODO: remove this workaround once libc++ no longer has to support Clang 13 (it was fixed in Clang 14).
+template<class _Tp>
+concept __workaround_52970 = is_class_v<__uncvref_t<_Tp>> || is_union_v<__uncvref_t<_Tp>>;
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CONCEPTS_CLASS_OR_ENUM_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/common_reference_with.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/common_reference_with.h
new file mode 100644
index 0000000000..bb5801a8c1
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/common_reference_with.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___CONCEPTS_COMMON_REFERENCE_WITH_H
+#define _LIBCPP___CONCEPTS_COMMON_REFERENCE_WITH_H
+
+#include <__concepts/convertible_to.h>
+#include <__concepts/same_as.h>
+#include <__config>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [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>>;
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CONCEPTS_COMMON_REFERENCE_WITH_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/common_with.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/common_with.h
new file mode 100644
index 0000000000..2b7cb836d6
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/common_with.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___CONCEPTS_COMMON_WITH_H
+#define _LIBCPP___CONCEPTS_COMMON_WITH_H
+
+#include <__concepts/common_reference_with.h>
+#include <__concepts/same_as.h>
+#include <__config>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [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>>>;
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CONCEPTS_COMMON_WITH_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/constructible.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/constructible.h
new file mode 100644
index 0000000000..f537108623
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/constructible.h
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___CONCEPTS_CONSTRUCTIBLE_H
+#define _LIBCPP___CONCEPTS_CONSTRUCTIBLE_H
+
+#include <__concepts/convertible_to.h>
+#include <__concepts/destructible.h>
+#include <__config>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [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>;
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CONCEPTS_CONSTRUCTIBLE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/convertible_to.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/convertible_to.h
new file mode 100644
index 0000000000..6bf19228a4
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/convertible_to.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___CONCEPTS_CONVERTIBLE_TO_H
+#define _LIBCPP___CONCEPTS_CONVERTIBLE_TO_H
+
+#include <__config>
+#include <__utility/declval.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [concept.convertible]
+
+template<class _From, class _To>
+concept convertible_to =
+ is_convertible_v<_From, _To> &&
+ requires {
+ static_cast<_To>(declval<_From>());
+ };
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CONCEPTS_CONVERTIBLE_TO_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/copyable.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/copyable.h
new file mode 100644
index 0000000000..8d5f28abc4
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/copyable.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___CONCEPTS_COPYABLE_H
+#define _LIBCPP___CONCEPTS_COPYABLE_H
+
+#include <__concepts/assignable.h>
+#include <__concepts/constructible.h>
+#include <__concepts/movable.h>
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [concepts.object]
+
+template<class _Tp>
+concept copyable =
+ copy_constructible<_Tp> &&
+ movable<_Tp> &&
+ assignable_from<_Tp&, _Tp&> &&
+ assignable_from<_Tp&, const _Tp&> &&
+ assignable_from<_Tp&, const _Tp>;
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CONCEPTS_COPYABLE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/derived_from.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/derived_from.h
new file mode 100644
index 0000000000..b91ce13fe4
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/derived_from.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___CONCEPTS_DERIVED_FROM_H
+#define _LIBCPP___CONCEPTS_DERIVED_FROM_H
+
+#include <__config>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [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*>;
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CONCEPTS_DERIVED_FROM_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/destructible.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/destructible.h
new file mode 100644
index 0000000000..429e82ee93
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/destructible.h
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___CONCEPTS_DESTRUCTIBLE_H
+#define _LIBCPP___CONCEPTS_DESTRUCTIBLE_H
+
+#include <__config>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [concept.destructible]
+
+template<class _Tp>
+concept destructible = is_nothrow_destructible_v<_Tp>;
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CONCEPTS_DESTRUCTIBLE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/different_from.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/different_from.h
new file mode 100644
index 0000000000..f882205d4a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/different_from.h
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___CONCEPTS_DIFFERENT_FROM_H
+#define _LIBCPP___CONCEPTS_DIFFERENT_FROM_H
+
+#include <__concepts/same_as.h>
+#include <__config>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+template<class _Tp, class _Up>
+concept __different_from = !same_as<remove_cvref_t<_Tp>, remove_cvref_t<_Up>>;
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CONCEPTS_DIFFERENT_FROM_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/equality_comparable.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/equality_comparable.h
new file mode 100644
index 0000000000..36ac870b6b
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/equality_comparable.h
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___CONCEPTS_EQUALITY_COMPARABLE_H
+#define _LIBCPP___CONCEPTS_EQUALITY_COMPARABLE_H
+
+#include <__concepts/boolean_testable.h>
+#include <__concepts/common_reference_with.h>
+#include <__config>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [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>;
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CONCEPTS_EQUALITY_COMPARABLE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/invocable.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/invocable.h
new file mode 100644
index 0000000000..8a669f1f18
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/invocable.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___CONCEPTS_INVOCABLE_H
+#define _LIBCPP___CONCEPTS_INVOCABLE_H
+
+#include <__config>
+#include <__functional/invoke.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
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [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...>;
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CONCEPTS_INVOCABLE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/movable.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/movable.h
new file mode 100644
index 0000000000..53e36ebc3f
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/movable.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___CONCEPTS_MOVABLE_H
+#define _LIBCPP___CONCEPTS_MOVABLE_H
+
+#include <__concepts/assignable.h>
+#include <__concepts/constructible.h>
+#include <__concepts/swappable.h>
+#include <__config>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [concepts.object]
+
+template<class _Tp>
+concept movable =
+ is_object_v<_Tp> &&
+ move_constructible<_Tp> &&
+ assignable_from<_Tp&, _Tp> &&
+ swappable<_Tp>;
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CONCEPTS_MOVABLE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/predicate.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/predicate.h
new file mode 100644
index 0000000000..04cdd97f95
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/predicate.h
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___CONCEPTS_PREDICATE_H
+#define _LIBCPP___CONCEPTS_PREDICATE_H
+
+#include <__concepts/boolean_testable.h>
+#include <__concepts/invocable.h>
+#include <__config>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [concept.predicate]
+
+template<class _Fn, class... _Args>
+concept predicate =
+ regular_invocable<_Fn, _Args...> && __boolean_testable<invoke_result_t<_Fn, _Args...>>;
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CONCEPTS_PREDICATE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/regular.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/regular.h
new file mode 100644
index 0000000000..63c9fb3ce3
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/regular.h
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___CONCEPTS_REGULAR_H
+#define _LIBCPP___CONCEPTS_REGULAR_H
+
+#include <__concepts/equality_comparable.h>
+#include <__concepts/semiregular.h>
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [concept.object]
+
+template<class _Tp>
+concept regular = semiregular<_Tp> && equality_comparable<_Tp>;
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CONCEPTS_REGULAR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/relation.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/relation.h
new file mode 100644
index 0000000000..1d687559e4
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/relation.h
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___CONCEPTS_RELATION_H
+#define _LIBCPP___CONCEPTS_RELATION_H
+
+#include <__concepts/predicate.h>
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [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>;
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CONCEPTS_RELATION_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/same_as.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/same_as.h
new file mode 100644
index 0000000000..1337193c93
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/same_as.h
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___CONCEPTS_SAME_AS_H
+#define _LIBCPP___CONCEPTS_SAME_AS_H
+
+#include <__config>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [concept.same]
+
+template<class _Tp, class _Up>
+concept __same_as_impl = _IsSame<_Tp, _Up>::value;
+
+template<class _Tp, class _Up>
+concept same_as = __same_as_impl<_Tp, _Up> && __same_as_impl<_Up, _Tp>;
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CONCEPTS_SAME_AS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/semiregular.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/semiregular.h
new file mode 100644
index 0000000000..eac5ec2872
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/semiregular.h
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___CONCEPTS_SEMIREGULAR_H
+#define _LIBCPP___CONCEPTS_SEMIREGULAR_H
+
+#include <__concepts/constructible.h>
+#include <__concepts/copyable.h>
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [concept.object]
+
+template<class _Tp>
+concept semiregular = copyable<_Tp> && default_initializable<_Tp>;
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CONCEPTS_SEMIREGULAR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/swappable.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/swappable.h
new file mode 100644
index 0000000000..866e9f7dfd
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/swappable.h
@@ -0,0 +1,116 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___CONCEPTS_SWAPPABLE_H
+#define _LIBCPP___CONCEPTS_SWAPPABLE_H
+
+#include <__concepts/assignable.h>
+#include <__concepts/class_or_enum.h>
+#include <__concepts/common_reference_with.h>
+#include <__concepts/constructible.h>
+#include <__config>
+#include <__utility/exchange.h>
+#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_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [concept.swappable]
+
+namespace ranges {
+namespace __swap {
+
+ template<class _Tp>
+ void swap(_Tp&, _Tp&) = delete;
+
+ 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 __swap
+
+inline namespace __cpo {
+ inline constexpr auto swap = __swap::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+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));
+ };
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CONCEPTS_SWAPPABLE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/totally_ordered.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/totally_ordered.h
new file mode 100644
index 0000000000..5ede92ad08
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__concepts/totally_ordered.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___CONCEPTS_TOTALLY_ORDERED_H
+#define _LIBCPP___CONCEPTS_TOTALLY_ORDERED_H
+
+#include <__concepts/boolean_testable.h>
+#include <__concepts/equality_comparable.h>
+#include <__config>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [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>;
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CONCEPTS_TOTALLY_ORDERED_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__config b/contrib/libs/cxxsupp/libcxxmsvc/include/__config
new file mode 100644
index 0000000000..83c45fbe43
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__config
@@ -0,0 +1,1551 @@
+// -*- 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_CONFIG
+#define _LIBCPP_CONFIG
+#include <__wrappers_config>
+
+#if defined(_MSC_VER) && !defined(__clang__)
+# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
+# endif
+#endif
+
+#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
+# pragma GCC system_header
+#endif
+
+// Move outside #ifdef __cplusplus because this needs to work in both C and C++ headers.
+#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
+# 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)
+#define _LIBCPP_COMPILER_MSVC
+
+#if _MSVC_LANG == 201705L
+# define _LIBCPP_STD_VER 20
+#elif _MSVC_LANG == 201703L
+# define _LIBCPP_STD_VER 17
+#else
+# define _LIBCPP_STD_VER 14
+#endif
+
+#define Y_UCRT_INCLUDE_NEXT(x) <Y_UCRT_INCLUDE/x>
+#define Y_MSVC_INCLUDE_NEXT(x) <Y_MSVC_INCLUDE/x>
+#elif defined(__IBMCPP__)
+#define _LIBCPP_COMPILER_IBM
+#endif
+
+#ifdef __cplusplus
+
+#define _LIBCPP_VERSION 15000
+
+#if __STDC_HOSTED__ == 0
+# define _LIBCPP_FREESTANDING
+#endif
+
+#ifndef _LIBCPP_STD_VER
+# if __cplusplus <= 201103L
+# define _LIBCPP_STD_VER 11
+# elif __cplusplus <= 201402L
+# define _LIBCPP_STD_VER 14
+# elif __cplusplus <= 201703L
+# define _LIBCPP_STD_VER 17
+# elif __cplusplus <= 202002L
+# define _LIBCPP_STD_VER 20
+# else
+# define _LIBCPP_STD_VER 22 // current year, or date of c++2b ratification
+# endif
+#endif // _LIBCPP_STD_VER
+
+#if defined(__ELF__)
+# define _LIBCPP_OBJECT_FORMAT_ELF 1
+#elif defined(__MACH__)
+# define _LIBCPP_OBJECT_FORMAT_MACHO 1
+#elif defined(_WIN32) || defined(__CYGWIN__)
+# define _LIBCPP_OBJECT_FORMAT_COFF 1
+#elif defined(__wasm__)
+# define _LIBCPP_OBJECT_FORMAT_WASM 1
+#else
+ // ... add new file formats here ...
+#endif
+
+#if _LIBCPP_ABI_VERSION >= 2
+// Change short string representation so that string data starts at offset 0,
+// improving its alignment in some cases.
+# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
+// Fix deque iterator type in order to support incomplete types.
+# define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
+// Fix undefined behavior in how std::list stores its linked nodes.
+# define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
+// Fix undefined behavior in how __tree stores its end and parent nodes.
+# define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
+// Fix undefined behavior in how __hash_table stores its pointer types.
+# define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB
+# define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
+# define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_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
+// Override the default return value of exception::what() for
+// bad_function_call::what() with a string that is specific to
+// bad_function_call (see http://wg21.link/LWG2233). This is an ABI break
+// because it changes the vtable layout of bad_function_call.
+# define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
+// 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
+// Unstable attempt to provide a more optimized std::function
+#ifdef __EMSCRIPTEN__
+// XXX EMSCRIPTEN https://github.com/emscripten-core/emscripten/issues/11022
+//# define _LIBCPP_ABI_OPTIMIZED_FUNCTION
+#else
+# define _LIBCPP_ABI_OPTIMIZED_FUNCTION
+#endif
+// 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
+// Enable clang::trivial_abi on std::unique_ptr.
+# define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI
+// Enable clang::trivial_abi on std::shared_ptr and std::weak_ptr
+# define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI
+// std::random_device holds some state when it uses an implementation that gets
+// entropy from a file (see _LIBCPP_USING_DEV_RANDOM). When switching from this
+// implementation to another one on a platform that has already shipped
+// std::random_device, one needs to retain the same object layout to remain ABI
+// compatible. This switch removes these workarounds for platforms that don't care
+// about ABI compatibility.
+# define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT
+// Remove basic_string common base
+# define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON
+// Remove vector base class
+# define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON
+#elif _LIBCPP_ABI_VERSION == 1
+# if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
+// Enable compiling copies of now inline methods into the dylib to support
+// applications compiled against older libraries. This is unnecessary with
+// COFF dllexport semantics, since dllexport forces a non-inline definition
+// of inline functions to be emitted anyway. Our own non-inline copy would
+// conflict with the dllexport-emitted copy, so we disable it.
+# define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
+# endif
+// Feature macros for disabling pre ABI v1 features. All of these options
+// are deprecated.
+# if defined(__FreeBSD__)
+# define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
+# endif
+#endif
+
+#if defined(_LIBCPP_BUILDING_LIBRARY) || _LIBCPP_ABI_VERSION >= 2
+// Enable additional explicit instantiations of iostreams components. This
+// reduces the number of weak definitions generated in programs that use
+// iostreams by providing a single strong definition in the shared library.
+# define _LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1
+
+// 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
+#endif
+
+#define _LIBCPP_TOSTRING2(x) #x
+#define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
+
+#if __cplusplus < 201103L && !defined(_LIBCPP_COMPILER_MSVC)
+#define _LIBCPP_CXX03_LANG
+#endif
+
+#ifndef __has_attribute
+#define __has_attribute(__x) 0
+#endif
+
+#ifndef __has_builtin
+#define __has_builtin(__x) 0
+#endif
+
+#ifndef __has_extension
+#define __has_extension(__x) 0
+#endif
+
+#ifndef __has_feature
+#define __has_feature(__x) 0
+#endif
+
+#ifndef __has_cpp_attribute
+#define __has_cpp_attribute(__x) 0
+#endif
+
+// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
+// the compiler and '1' otherwise.
+#ifndef __is_identifier
+#define __is_identifier(__x) 1
+#endif
+
+#ifndef __has_declspec_attribute
+#define __has_declspec_attribute(__x) 0
+#endif
+
+#define __has_keyword(__x) !(__is_identifier(__x))
+
+#ifndef __has_include
+#define __has_include(...) 0
+#endif
+
+#if defined(_LIBCPP_COMPILER_GCC) && __cplusplus < 201103L
+#error "libc++ does not support using GCC with C++03. Please enable C++11"
+#endif
+
+// FIXME: ABI detection should be done via compiler builtin macros. This
+// is just a placeholder until Clang implements such macros. For now assume
+// that Windows compilers pretending to be MSVC++ target the Microsoft ABI,
+// and allow the user to explicitly specify the ABI to handle cases where this
+// heuristic falls short.
+#if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT)
+# error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined"
+#elif defined(_LIBCPP_ABI_FORCE_ITANIUM)
+# define _LIBCPP_ABI_ITANIUM
+#elif defined(_LIBCPP_ABI_FORCE_MICROSOFT)
+# define _LIBCPP_ABI_MICROSOFT
+#else
+# if defined(_WIN32) && defined(_MSC_VER)
+# define _LIBCPP_ABI_MICROSOFT
+# else
+# define _LIBCPP_ABI_ITANIUM
+# endif
+#endif
+
+#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
+# define _LIBCPP_ABI_VCRUNTIME
+#endif
+
+// Need to detect which libc we're using if we're on Linux.
+#if defined(__linux__)
+# include <features.h>
+# if defined(__GLIBC_PREREQ)
+# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
+# else
+# define _LIBCPP_GLIBC_PREREQ(a, b) 0
+# endif // defined(__GLIBC_PREREQ)
+#endif // defined(__linux__)
+
+#if defined(__MVS__)
+# include <features.h> // for __NATIVE_ASCII_F
+#endif
+
+#ifdef __LITTLE_ENDIAN__
+# if __LITTLE_ENDIAN__
+# define _LIBCPP_LITTLE_ENDIAN
+# endif // __LITTLE_ENDIAN__
+#endif // __LITTLE_ENDIAN__
+
+#ifdef __BIG_ENDIAN__
+# if __BIG_ENDIAN__
+# define _LIBCPP_BIG_ENDIAN
+# endif // __BIG_ENDIAN__
+#endif // __BIG_ENDIAN__
+
+#ifdef __BYTE_ORDER__
+# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+# define _LIBCPP_LITTLE_ENDIAN
+# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+# define _LIBCPP_BIG_ENDIAN
+# endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#endif // __BYTE_ORDER__
+
+#ifdef __FreeBSD__
+# include <sys/endian.h>
+# include <osreldate.h>
+# if _BYTE_ORDER == _LITTLE_ENDIAN
+# define _LIBCPP_LITTLE_ENDIAN
+# else // _BYTE_ORDER == _LITTLE_ENDIAN
+# define _LIBCPP_BIG_ENDIAN
+# endif // _BYTE_ORDER == _LITTLE_ENDIAN
+#endif // __FreeBSD__
+
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+# include <sys/endian.h>
+# if _BYTE_ORDER == _LITTLE_ENDIAN
+# define _LIBCPP_LITTLE_ENDIAN
+# else // _BYTE_ORDER == _LITTLE_ENDIAN
+# define _LIBCPP_BIG_ENDIAN
+# endif // _BYTE_ORDER == _LITTLE_ENDIAN
+#endif // defined(__NetBSD__) || defined(__OpenBSD__)
+
+#if defined(_WIN32)
+# define _LIBCPP_WIN32API
+# define _LIBCPP_LITTLE_ENDIAN
+# define _LIBCPP_SHORT_WCHAR 1
+// Both MinGW and native MSVC provide a "MSVC"-like environment
+# define _LIBCPP_MSVCRT_LIKE
+// If mingw not explicitly detected, assume using MS C runtime only if
+// a MS compatibility version is specified.
+# if defined(_MSC_VER) && !defined(__MINGW32__)
+# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
+# endif
+# if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
+# define _LIBCPP_HAS_BITSCAN64
+# endif
+# define _LIBCPP_HAS_OPEN_WITH_WCHAR
+# if defined(_LIBCPP_MSVCRT)
+# define _LIBCPP_HAS_QUICK_EXIT
+# endif
+
+// Some CRT APIs are unavailable to store apps
+# if defined(WINAPI_FAMILY)
+# include <winapifamily.h>
+# if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && \
+ (!defined(WINAPI_PARTITION_SYSTEM) || \
+ !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_SYSTEM))
+# define _LIBCPP_WINDOWS_STORE_APP
+# endif
+# endif
+#endif // defined(_WIN32)
+
+#ifdef __sun__
+# include <sys/isa_defs.h>
+# ifdef _LITTLE_ENDIAN
+# define _LIBCPP_LITTLE_ENDIAN
+# else
+# define _LIBCPP_BIG_ENDIAN
+# endif
+#endif // __sun__
+
+#if defined(_AIX) && !defined(__64BIT__)
+ // The size of wchar is 2 byte on 32-bit mode on AIX.
+# define _LIBCPP_SHORT_WCHAR 1
+#endif
+
+// Libc++ supports various implementations of std::random_device.
+//
+// _LIBCPP_USING_DEV_RANDOM
+// Read entropy from the given file, by default `/dev/urandom`.
+// If a token is provided, it is assumed to be the path to a file
+// to read entropy from. This is the default behavior if nothing
+// else is specified. This implementation requires storing state
+// inside `std::random_device`.
+//
+// _LIBCPP_USING_ARC4_RANDOM
+// Use arc4random(). This allows obtaining random data even when
+// using sandboxing mechanisms. On some platforms like Apple, this
+// is the recommended source of entropy for user-space programs.
+// When this option is used, the token passed to `std::random_device`'s
+// constructor *must* be "/dev/urandom" -- anything else is an error.
+//
+// _LIBCPP_USING_GETENTROPY
+// Use getentropy().
+// When this option is used, the token passed to `std::random_device`'s
+// constructor *must* be "/dev/urandom" -- anything else is an error.
+//
+// _LIBCPP_USING_FUCHSIA_CPRNG
+// Use Fuchsia's zx_cprng_draw() system call, which is specified to
+// deliver high-quality entropy and cannot fail.
+// When this option is used, the token passed to `std::random_device`'s
+// constructor *must* be "/dev/urandom" -- anything else is an error.
+//
+// _LIBCPP_USING_NACL_RANDOM
+// NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access,
+// including accesses to the special files under `/dev`. This implementation
+// uses the NaCL syscall `nacl_secure_random_init()` to get entropy.
+// When this option is used, the token passed to `std::random_device`'s
+// constructor *must* be "/dev/urandom" -- anything else is an error.
+//
+// _LIBCPP_USING_WIN32_RANDOM
+// Use rand_s(), for use on Windows.
+// When this option is used, the token passed to `std::random_device`'s
+// constructor *must* be "/dev/urandom" -- anything else is an error.
+#if defined(__OpenBSD__) || defined(__APPLE__)
+# define _LIBCPP_USING_ARC4_RANDOM
+#elif defined(__wasi__)
+# define _LIBCPP_USING_GETENTROPY
+#elif defined(__Fuchsia__)
+# define _LIBCPP_USING_FUCHSIA_CPRNG
+#elif defined(__native_client__)
+# define _LIBCPP_USING_NACL_RANDOM
+#elif defined(_LIBCPP_WIN32API)
+# define _LIBCPP_USING_WIN32_RANDOM
+#else
+# define _LIBCPP_USING_DEV_RANDOM
+#endif
+
+#if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
+# include <endian.h>
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+# define _LIBCPP_LITTLE_ENDIAN
+# elif __BYTE_ORDER == __BIG_ENDIAN
+# define _LIBCPP_BIG_ENDIAN
+# else // __BYTE_ORDER == __BIG_ENDIAN
+# error unable to determine endian
+# endif
+#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")))
+#else
+# define _LIBCPP_NO_CFI
+#endif
+
+// If the compiler supports using_if_exists, pretend we have those functions and they'll
+// be picked up if the C library provides them.
+//
+// TODO: Once we drop support for Clang 12, we can assume the compiler supports using_if_exists
+// for platforms that don't have a conforming C11 library, so we can drop this whole thing.
+#if __has_attribute(using_if_exists)
+# define _LIBCPP_HAS_TIMESPEC_GET
+# define _LIBCPP_HAS_QUICK_EXIT
+# ifndef _LIBCPP_MSVCRT
+# define _LIBCPP_HAS_ALIGNED_ALLOC
+# endif
+#else
+#if (defined(__ISO_C_VISIBLE) && (__ISO_C_VISIBLE >= 2011)) || __cplusplus >= 201103L
+# if defined(__FreeBSD__)
+# define _LIBCPP_HAS_ALIGNED_ALLOC
+# define _LIBCPP_HAS_QUICK_EXIT
+# if __FreeBSD_version >= 1300064 || \
+ (__FreeBSD_version >= 1201504 && __FreeBSD_version < 1300000)
+# define _LIBCPP_HAS_TIMESPEC_GET
+# endif
+# elif defined(__BIONIC__)
+# if __ANDROID_API__ >= 21
+# define _LIBCPP_HAS_QUICK_EXIT
+# endif
+# if __ANDROID_API__ >= 28
+# define _LIBCPP_HAS_ALIGNED_ALLOC
+# endif
+# if __ANDROID_API__ >= 29
+# define _LIBCPP_HAS_TIMESPEC_GET
+# endif
+# elif defined(__Fuchsia__) || defined(__wasi__) || defined(__NetBSD__)
+# define _LIBCPP_HAS_ALIGNED_ALLOC
+# define _LIBCPP_HAS_QUICK_EXIT
+# define _LIBCPP_HAS_TIMESPEC_GET
+# elif defined(__OpenBSD__)
+# define _LIBCPP_HAS_ALIGNED_ALLOC
+# define _LIBCPP_HAS_TIMESPEC_GET
+# elif defined(__linux__)
+# if !defined(_LIBCPP_HAS_MUSL_LIBC)
+# if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
+# define _LIBCPP_HAS_QUICK_EXIT
+# endif
+# if _LIBCPP_GLIBC_PREREQ(2, 17)
+# define _LIBCPP_HAS_ALIGNED_ALLOC
+# define _LIBCPP_HAS_TIMESPEC_GET
+# endif
+# else // defined(_LIBCPP_HAS_MUSL_LIBC)
+# define _LIBCPP_HAS_ALIGNED_ALLOC
+# 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 ((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
+# endif // __APPLE__
+#endif
+#endif // __has_attribute(using_if_exists)
+
+#ifndef _LIBCPP_CXX03_LANG
+# define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp)
+#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"
+#endif
+
+#define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)
+
+#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
+#endif
+#if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \
+ (!defined(__arm__) || __ARM_ARCH_7K__ >= 2)
+# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
+#endif
+
+#if __has_feature(cxx_alignas)
+# define _ALIGNAS_TYPE(x) alignas(x)
+# define _ALIGNAS(x) alignas(x)
+#else
+# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
+# define _ALIGNAS(x) __attribute__((__aligned__(x)))
+#endif
+
+#if __cplusplus < 201103L
+typedef __char16_t char16_t;
+typedef __char32_t char32_t;
+#endif
+
+#if !__has_feature(cxx_exceptions)
+# define _LIBCPP_NO_EXCEPTIONS
+#endif
+
+#if !(__has_feature(cxx_strong_enums))
+#define _LIBCPP_HAS_NO_STRONG_ENUMS
+#endif
+
+#if __has_feature(cxx_attributes)
+# define _LIBCPP_NORETURN [[noreturn]]
+#else
+# define _LIBCPP_NORETURN __attribute__ ((noreturn))
+#endif
+
+#ifdef _LIBCPP_CXX03_LANG
+# define nullptr __nullptr
+#endif
+
+// Objective-C++ features (opt-in)
+#if __has_feature(objc_arc)
+#define _LIBCPP_HAS_OBJC_ARC
+#endif
+
+#if __has_feature(objc_arc_weak)
+#define _LIBCPP_HAS_OBJC_ARC_WEAK
+#endif
+
+#if __has_extension(blocks)
+# define _LIBCPP_HAS_EXTENSION_BLOCKS
+#endif
+
+#if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__)
+# define _LIBCPP_HAS_BLOCKS_RUNTIME
+#endif
+
+#if !(__has_feature(cxx_noexcept))
+#define _LIBCPP_HAS_NO_NOEXCEPT
+#endif
+
+#if !__has_feature(address_sanitizer)
+#define _LIBCPP_HAS_NO_ASAN
+#endif
+
+// Allow for build-time disabling of unsigned integer sanitization
+#if __has_attribute(no_sanitize)
+#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
+#endif
+
+#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
+
+#define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
+
+#elif defined(_LIBCPP_COMPILER_GCC)
+
+#define _ALIGNAS(x) __attribute__((__aligned__(x)))
+#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
+
+#define _LIBCPP_NORETURN __attribute__((noreturn))
+
+#if !defined(__EXCEPTIONS)
+# define _LIBCPP_NO_EXCEPTIONS
+#endif
+
+#if !defined(__SANITIZE_ADDRESS__)
+#define _LIBCPP_HAS_NO_ASAN
+#endif
+
+#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
+
+#define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
+
+#elif defined(_LIBCPP_COMPILER_MSVC)
+
+#define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x))
+
+#if _MSC_VER < 1900
+#error "MSVC versions prior to Visual Studio 2015 are not supported"
+#endif
+
+#define _LIBCPP_HAS_IS_FINAL
+#define __alignof__ __alignof
+#define _LIBCPP_NORETURN __declspec(noreturn)
+#define _ALIGNAS(x) __declspec(align(x))
+#define _ALIGNAS_TYPE(x) alignas(x)
+
+#define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
+#define _LIBCPP_IS_LITERAL(T) __is_literal_type(T)
+#undef __has_feature
+#define __has_feature(x) __has_feature_##x
+#define __has_feature_is_standard_layout 1
+#define __has_feature_is_trivially_copyable 1
+#define __has_feature_is_trivial 1
+#define __has_feature_is_pod 1
+#define __has_feature_cxx_noexcept 1
+#define __has_feature_has_nothrow_assign 1
+#define __has_feature_is_union 1
+#define __has_feature_is_class 1
+#define __has_feature_is_enum 1
+#define __has_feature_is_convertible_to 1
+#define __has_feature_is_empty 1
+#define __has_feature_is_polymorphic 1
+#define __has_feature_has_virtual_destructor 1
+#define __has_feature_cxx_reference_qualified_functions 1
+#define __has_feature_is_constructible 1
+#define __has_feature_is_trivially_constructible 1
+#define __has_feature_is_trivially_assignable 1
+#define __has_feature_is_convertible_to 1
+#define __has_feature_has_trivial_constructor 1
+#define __has_feature_has_trivial_destructor 1
+#define __has_feature_has_nothrow_constructor 1
+#define __has_feature_has_nothrow_copy 1
+#define __has_feature_cxx_explicit_conversions 1
+
+#undef __has_builtin
+#define __has_builtin(x) __has_builtin_##x
+#define __has_builtin___builtin_addressof 1
+#if defined(_MSC_VER) && defined(__CUDACC__)
+ // nvcc fails to compile __builtin_is_constant_evaluated() at the time
+# define _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED 1
+#else
+# define __has_builtin___builtin_is_constant_evaluated 1
+#endif
+
+#define _LIBCPP_WEAK
+
+#define _LIBCPP_HAS_NO_ASAN
+
+#define _LIBCPP_ALWAYS_INLINE __forceinline
+
+#define _LIBCPP_HAS_NO_VECTOR_EXTENSION
+
+#define _LIBCPP_DISABLE_EXTENSION_WARNING
+
+#elif defined(_LIBCPP_COMPILER_IBM)
+
+#define _ALIGNAS(x) __attribute__((__aligned__(x)))
+#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
+#define _ATTRIBUTE(x) __attribute__((x))
+#define _LIBCPP_NORETURN __attribute__((noreturn))
+
+#define _LIBCPP_HAS_NO_UNICODE_CHARS
+
+#if defined(_AIX)
+#define __MULTILOCALE_API
+#endif
+
+#define _LIBCPP_HAS_NO_ASAN
+
+#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
+
+#define _LIBCPP_HAS_NO_VECTOR_EXTENSION
+
+#define _LIBCPP_DISABLE_EXTENSION_WARNING
+
+#endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM]
+
+#if defined(_LIBCPP_OBJECT_FORMAT_COFF)
+
+#ifdef _DLL
+# define _LIBCPP_CRT_FUNC __declspec(dllimport)
+#else
+# define _LIBCPP_CRT_FUNC
+#endif
+
+#if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+# define _LIBCPP_DLL_VIS
+# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
+# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
+# define _LIBCPP_OVERRIDABLE_FUNC_VIS
+# define _LIBCPP_EXPORTED_FROM_ABI
+#elif defined(_LIBCPP_BUILDING_LIBRARY)
+# define _LIBCPP_DLL_VIS __declspec(dllexport)
+# if defined(__MINGW32__)
+# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
+# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
+# else
+# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
+# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
+# endif
+# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS
+# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport)
+#else
+# define _LIBCPP_DLL_VIS __declspec(dllimport)
+# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
+# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
+# define _LIBCPP_OVERRIDABLE_FUNC_VIS
+# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport)
+#endif
+
+#define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS
+#define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS
+#define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS
+#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)
+
+#ifndef _LIBCPP_HIDDEN
+# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+# define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
+# else
+# define _LIBCPP_HIDDEN
+# endif
+#endif
+
+#ifndef _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+// The inline should be removed once PR32114 is resolved
+# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN
+# else
+# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+# endif
+#endif
+
+#ifndef _LIBCPP_FUNC_VIS
+# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+# define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default")))
+# else
+# define _LIBCPP_FUNC_VIS
+# endif
+#endif
+
+#ifndef _LIBCPP_TYPE_VIS
+# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+# define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default")))
+# else
+# define _LIBCPP_TYPE_VIS
+# endif
+#endif
+
+#ifndef _LIBCPP_TEMPLATE_VIS
+# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+# if __has_attribute(__type_visibility__)
+# define _LIBCPP_TEMPLATE_VIS __attribute__ ((__type_visibility__("default")))
+# else
+# define _LIBCPP_TEMPLATE_VIS __attribute__ ((__visibility__("default")))
+# endif
+# else
+# define _LIBCPP_TEMPLATE_VIS
+# 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")))
+# else
+# define _LIBCPP_EXPORTED_FROM_ABI
+# endif
+#endif
+
+#ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
+#define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS
+#endif
+
+#ifndef _LIBCPP_EXCEPTION_ABI
+# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+# define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
+# else
+# define _LIBCPP_EXCEPTION_ABI
+# endif
+#endif
+
+#ifndef _LIBCPP_ENUM_VIS
+# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
+# define _LIBCPP_ENUM_VIS __attribute__ ((__type_visibility__("default")))
+# else
+# define _LIBCPP_ENUM_VIS
+# endif
+#endif
+
+#ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
+# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default")))
+# else
+# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
+# endif
+#endif
+
+#ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
+#define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
+#endif
+
+#if __has_attribute(internal_linkage)
+# define _LIBCPP_INTERNAL_LINKAGE __attribute__ ((internal_linkage))
+#else
+# define _LIBCPP_INTERNAL_LINKAGE _LIBCPP_ALWAYS_INLINE
+#endif
+
+#if __has_attribute(exclude_from_explicit_instantiation)
+# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__ ((__exclude_from_explicit_instantiation__))
+#else
+ // Try to approximate the effect of exclude_from_explicit_instantiation
+ // (which is that entities are not assumed to be provided by explicit
+ // template instantiations in the dylib) by always inlining those entities.
+#ifdef _LIBCPP_COMPILER_MSVC
+# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
+#else
+# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
+#endif
+#endif
+
+#ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU
+# ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT
+# define _LIBCPP_HIDE_FROM_ABI_PER_TU 0
+# else
+# define _LIBCPP_HIDE_FROM_ABI_PER_TU 1
+# endif
+#endif
+
+#ifndef _LIBCPP_HIDE_FROM_ABI
+# if _LIBCPP_HIDE_FROM_ABI_PER_TU
+# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE
+# else
+# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
+# endif
+#endif
+
+#ifdef _LIBCPP_BUILDING_LIBRARY
+# if _LIBCPP_ABI_VERSION > 1
+# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
+# else
+# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+# endif
+#else
+# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
+#endif
+
+// Just so we can migrate to the new macros gradually.
+#define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
+
+// Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect.
+#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE {
+#define _LIBCPP_END_NAMESPACE_STD } }
+#define _VSTD std
+_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 14
+#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
+ _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem {
+#else
+#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
+ _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem {
+#endif
+
+#define _LIBCPP_END_NAMESPACE_FILESYSTEM \
+ _LIBCPP_END_NAMESPACE_STD } }
+
+#define _VSTD_FS std::__fs::filesystem
+
+#if __has_attribute(__enable_if__)
+# define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, "")))
+#endif
+
+#ifndef _LIBCPP_HAS_NO_NOEXCEPT
+# define _NOEXCEPT noexcept
+# define _NOEXCEPT_(x) noexcept(x)
+#else
+# define _NOEXCEPT throw()
+# define _NOEXCEPT_(x)
+#endif
+
+#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
+typedef unsigned short char16_t;
+typedef unsigned int char32_t;
+#endif
+
+#ifndef __SIZEOF_INT128__
+#define _LIBCPP_HAS_NO_INT128
+#endif
+
+#ifdef _LIBCPP_CXX03_LANG
+# define static_assert(...) _Static_assert(__VA_ARGS__)
+# define decltype(...) __decltype(__VA_ARGS__)
+#endif // _LIBCPP_CXX03_LANG
+
+#ifdef _LIBCPP_CXX03_LANG
+# define _LIBCPP_CONSTEXPR
+#else
+# define _LIBCPP_CONSTEXPR constexpr
+#endif
+
+#ifndef __cpp_consteval
+# define _LIBCPP_CONSTEVAL _LIBCPP_CONSTEXPR
+#else
+# define _LIBCPP_CONSTEVAL consteval
+#endif
+
+#if _LIBCPP_STD_VER <= 17 || !defined(__cpp_concepts) || __cpp_concepts < 201907L
+#define _LIBCPP_HAS_NO_CONCEPTS
+#endif
+
+#ifdef __GNUC__
+# define _LIBCPP_NOALIAS __attribute__((__malloc__))
+#else
+# define _LIBCPP_NOALIAS
+#endif
+
+#if __has_attribute(using_if_exists)
+# define _LIBCPP_USING_IF_EXISTS __attribute__((using_if_exists))
+#else
+# define _LIBCPP_USING_IF_EXISTS
+#endif
+
+#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
+# define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx
+# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
+ __lx __v_; \
+ _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \
+ _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
+ _LIBCPP_INLINE_VISIBILITY operator int() const {return __v_;} \
+ };
+#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
+
+// _LIBCPP_DEBUG potential values:
+// - undefined: No assertions. This is the default.
+// - 0: Basic assertions
+// - 1: Basic assertions + iterator validity checks + unspecified behavior randomization.
+# if !defined(_LIBCPP_DEBUG)
+# define _LIBCPP_DEBUG_LEVEL 0
+# elif _LIBCPP_DEBUG == 0
+# define _LIBCPP_DEBUG_LEVEL 1
+# elif _LIBCPP_DEBUG == 1
+# define _LIBCPP_DEBUG_LEVEL 2
+# else
+# error Supported values for _LIBCPP_DEBUG are 0 and 1
+# endif
+
+# if _LIBCPP_DEBUG_LEVEL >= 2 && !defined(_LIBCPP_CXX03_LANG)
+# define _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY
+# endif
+
+# if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY)
+# if defined(_LIBCPP_CXX03_LANG)
+# error Support for unspecified stability is only for C++11 and higher
+# endif
+# define _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last) \
+ do { \
+ if (!__builtin_is_constant_evaluated()) \
+ _VSTD::shuffle(__first, __last, __libcpp_debug_randomizer()); \
+ } while (false)
+# else
+# define _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last) \
+ do { \
+ } while (false)
+# endif
+
+// 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) || \
+ defined(__sun__) || defined(__NetBSD__)
+#define _LIBCPP_LOCALE__L_EXTENSIONS 1
+#endif
+
+#ifdef __FreeBSD__
+#define _DECLARE_C99_LDBL_MATH 1
+#endif
+
+// If we are getting operator new from the MSVC CRT, then allocation overloads
+// for align_val_t were added in 19.12, aka VS 2017 version 15.3.
+#if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
+# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
+#elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new)
+ // We're deferring to Microsoft's STL to provide aligned new et al. We don't
+ // have it unless the language feature test macro is defined.
+# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
+#elif defined(__MVS__)
+# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
+#endif
+
+#if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || \
+ (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606)
+# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
+#endif
+
+#if defined(__APPLE__) || defined(__FreeBSD__)
+#define _LIBCPP_HAS_DEFAULTRUNELOCALE
+#endif
+
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)
+#define _LIBCPP_WCTYPE_IS_MASK
+#endif
+
+#if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t)
+#define _LIBCPP_HAS_NO_CHAR8_T
+#endif
+
+// Deprecation macros.
+//
+// Deprecations warnings are always enabled, except when users explicitly opt-out
+// by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS.
+#if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
+# if __has_attribute(deprecated)
+# define _LIBCPP_DEPRECATED __attribute__ ((deprecated))
+# elif _LIBCPP_STD_VER > 11
+# define _LIBCPP_DEPRECATED [[deprecated]]
+# else
+# define _LIBCPP_DEPRECATED
+# endif
+#else
+# define _LIBCPP_DEPRECATED
+#endif
+
+#if !defined(_LIBCPP_CXX03_LANG)
+# define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
+#else
+# define _LIBCPP_DEPRECATED_IN_CXX11
+#endif
+
+#if _LIBCPP_STD_VER > 11
+# define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED
+#else
+# define _LIBCPP_DEPRECATED_IN_CXX14
+#endif
+
+#if _LIBCPP_STD_VER > 14
+# define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
+#else
+# define _LIBCPP_DEPRECATED_IN_CXX17
+#endif
+
+#if _LIBCPP_STD_VER > 17
+# define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED
+#else
+# define _LIBCPP_DEPRECATED_IN_CXX20
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_CHAR8_T)
+# define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED
+#else
+# define _LIBCPP_DEPRECATED_WITH_CHAR8_T
+#endif
+
+#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
+# define _LIBCPP_EXPLICIT_AFTER_CXX11
+#else
+# define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit
+#endif
+
+#if _LIBCPP_STD_VER > 11
+# define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
+#else
+# define _LIBCPP_CONSTEXPR_AFTER_CXX11
+#endif
+
+#if _LIBCPP_STD_VER > 14
+# define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
+#else
+# define _LIBCPP_CONSTEXPR_AFTER_CXX14
+#endif
+
+#if _LIBCPP_STD_VER > 17
+# define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr
+#else
+# define _LIBCPP_CONSTEXPR_AFTER_CXX17
+#endif
+
+#if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC)
+# define _LIBCPP_NODISCARD [[nodiscard]]
+#elif defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_CXX03_LANG)
+# define _LIBCPP_NODISCARD [[clang::warn_unused_result]]
+#else
+// We can't use GCC's [[gnu::warn_unused_result]] and
+// __attribute__((warn_unused_result)), because GCC does not silence them via
+// (void) cast.
+# define _LIBCPP_NODISCARD
+#endif
+
+// _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not
+// specified as such as an extension.
+#if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
+# define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD
+#else
+# define _LIBCPP_NODISCARD_EXT
+#endif
+
+#if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && \
+ (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD))
+# define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD
+#else
+# define _LIBCPP_NODISCARD_AFTER_CXX17
+#endif
+
+#if __has_attribute(no_destroy)
+# define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__))
+#else
+# define _LIBCPP_NO_DESTROY
+#endif
+
+#ifndef _LIBCPP_HAS_NO_ASAN
+extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
+ const void *, const void *, const void *, const void *);
+#endif
+
+// Try to find out if RTTI is disabled.
+#if defined(_LIBCPP_COMPILER_CLANG_BASED) && !__has_feature(cxx_rtti)
+# define _LIBCPP_NO_RTTI
+#elif defined(__GNUC__) && !defined(__GXX_RTTI)
+# define _LIBCPP_NO_RTTI
+#elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI)
+# define _LIBCPP_NO_RTTI
+#endif
+
+#ifndef _LIBCPP_WEAK
+#define _LIBCPP_WEAK __attribute__((__weak__))
+#endif
+
+// Thread API
+#if !defined(_LIBCPP_HAS_NO_THREADS) && \
+ !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \
+ !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \
+ !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+# if defined(__FreeBSD__) || \
+ defined(__wasi__) || \
+ defined(__NetBSD__) || \
+ defined(__OpenBSD__) || \
+ defined(__NuttX__) || \
+ defined(__linux__) || \
+ defined(__GNU__) || \
+ defined(__APPLE__) || \
+ defined(__sun__) || \
+ defined(__MVS__) || \
+ defined(_AIX) || \
+ defined(__CYGWIN__)
+# define _LIBCPP_HAS_THREAD_API_PTHREAD
+# elif defined(__Fuchsia__)
+ // TODO(44575): Switch to C11 thread API when possible.
+# define _LIBCPP_HAS_THREAD_API_PTHREAD
+# elif defined(_LIBCPP_WIN32API)
+# define _LIBCPP_HAS_THREAD_API_WIN32
+# else
+# error "No thread API"
+# endif // _LIBCPP_HAS_THREAD_API
+#endif // _LIBCPP_HAS_NO_THREADS
+
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
+#if defined(__ANDROID__) && __ANDROID_API__ >= 30
+#define _LIBCPP_HAS_COND_CLOCKWAIT
+#elif defined(_LIBCPP_GLIBC_PREREQ)
+#if _LIBCPP_GLIBC_PREREQ(2, 30)
+#define _LIBCPP_HAS_COND_CLOCKWAIT
+#endif
+#endif
+#endif
+
+#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
+#error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \
+ _LIBCPP_HAS_NO_THREADS is not defined.
+#endif
+
+#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+#error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \
+ _LIBCPP_HAS_NO_THREADS is defined.
+#endif
+
+#if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
+#error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
+ _LIBCPP_HAS_NO_THREADS is defined.
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__)
+#define __STDCPP_THREADS__ 1
+#endif
+
+// The glibc and Bionic implementation of pthreads implements
+// pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32
+// mutexes have no destroy mechanism.
+//
+// This optimization can't be performed on Apple platforms, where
+// pthread_mutex_destroy can allow the kernel to release resources.
+// See https://llvm.org/D64298 for details.
+//
+// TODO(EricWF): Enable this optimization on Bionic after speaking to their
+// respective stakeholders.
+#if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) \
+ || (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) \
+ || defined(_LIBCPP_HAS_THREAD_API_WIN32)
+# define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION
+#endif
+
+// Destroying a condvar is a nop on Windows.
+//
+// This optimization can't be performed on Apple platforms, where
+// pthread_cond_destroy can allow the kernel to release resources.
+// See https://llvm.org/D64298 for details.
+//
+// TODO(EricWF): This is potentially true for some pthread implementations
+// as well.
+#if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || \
+ defined(_LIBCPP_HAS_THREAD_API_WIN32)
+# define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION
+#endif
+
+// Some systems do not provide gets() in their C library, for security reasons.
+#if defined(_LIBCPP_MSVCRT) || \
+ (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || \
+ defined(__OpenBSD__)
+# define _LIBCPP_C_HAS_NO_GETS
+#endif
+
+#if defined(__BIONIC__) || defined(__NuttX__) || \
+ defined(__Fuchsia__) || defined(__wasi__) || \
+ defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__)
+#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
+#endif
+
+#if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic)
+# define _LIBCPP_HAS_C_ATOMIC_IMP
+#elif defined(_LIBCPP_COMPILER_GCC)
+# define _LIBCPP_HAS_GCC_ATOMIC_IMP
+#endif
+
+#if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && \
+ !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \
+ !defined(_LIBCPP_COMPILER_MSVC) && \
+ !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP)
+# define _LIBCPP_HAS_NO_ATOMIC_HEADER
+#else
+# ifndef _LIBCPP_ATOMIC_FLAG_TYPE
+# define _LIBCPP_ATOMIC_FLAG_TYPE bool
+# endif
+# ifdef _LIBCPP_FREESTANDING
+# define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS
+# endif
+#endif
+
+#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
+#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
+#endif
+
+#if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS)
+# if defined(__clang__) && __has_attribute(acquire_capability)
+// Work around the attribute handling in clang. When both __declspec and
+// __attribute__ are present, the processing goes awry preventing the definition
+// of the types. In MinGW mode, __declspec evaluates to __attribute__, and thus
+// combining the two does work.
+# if !defined(_MSC_VER)
+# define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
+# endif
+# endif
+#endif
+
+#ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
+# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))
+#else
+# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
+#endif
+
+#if _LIBCPP_STD_VER > 17 && (!defined(_MSC_VER) || _MSC_VER >= 1929)
+# define _LIBCPP_CONSTINIT constinit
+#elif __has_attribute(require_constant_initialization)
+# define _LIBCPP_CONSTINIT __attribute__((__require_constant_initialization__))
+#else
+# define _LIBCPP_CONSTINIT
+#endif
+
+#if !__has_builtin(__builtin_is_constant_evaluated) || (defined(_LIBCPP_COMPILER_GCC) && _GNUC_VER < 900) || __CUDACC_VER_MAJOR__ == 10
+#define _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED
+#endif
+
+#if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
+# define _LIBCPP_DIAGNOSE_WARNING(...) \
+ __attribute__((diagnose_if(__VA_ARGS__, "warning")))
+# define _LIBCPP_DIAGNOSE_ERROR(...) \
+ __attribute__((diagnose_if(__VA_ARGS__, "error")))
+#else
+# define _LIBCPP_DIAGNOSE_WARNING(...)
+# define _LIBCPP_DIAGNOSE_ERROR(...)
+#endif
+
+// Use a function like macro to imply that it must be followed by a semicolon
+#if _LIBCPP_STD_VER > 14 && __has_cpp_attribute(fallthrough)
+# define _LIBCPP_FALLTHROUGH() [[fallthrough]]
+#elif __has_cpp_attribute(clang::fallthrough)
+# define _LIBCPP_FALLTHROUGH() [[clang::fallthrough]]
+#elif __has_attribute(__fallthrough__)
+# define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__))
+#else
+# define _LIBCPP_FALLTHROUGH() ((void)0)
+#endif
+
+#if defined(_LIBCPP_COMPILER_CLANG_BASED)
+# define _LIBCPP_REINITIALIZES_OBJECT [[clang::reinitializes]]
+#else
+# define _LIBCPP_REINITIALIZES_OBJECT
+#endif
+
+#if __has_attribute(__nodebug__) && !defined(__CUDACC__)
+#define _LIBCPP_NODEBUG __attribute__((__nodebug__))
+#else
+#define _LIBCPP_NODEBUG
+#endif
+
+#if __has_attribute(__standalone_debug__)
+#define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__))
+#else
+#define _LIBCPP_STANDALONE_DEBUG
+#endif
+
+#if __has_attribute(__preferred_name__)
+#define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x)))
+#else
+#define _LIBCPP_PREFERRED_NAME(x)
+#endif
+
+// We often repeat things just for handling wide characters in the library.
+// When wide characters are disabled, it can be useful to have a quick way of
+// disabling it without having to resort to #if-#endif, which has a larger
+// impact on readability.
+#if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
+# define _LIBCPP_IF_WIDE_CHARACTERS(...)
+#else
+# define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__
+#endif
+
+#if defined(_LIBCPP_ABI_MICROSOFT) && \
+ (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases)) && \
+ !defined(__CUDACC__)
+# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
+#else
+# define _LIBCPP_DECLSPEC_EMPTY_BASES
+#endif
+
+#if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES)
+#define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
+#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_impl_coroutine) || __cpp_impl_coroutine < 201902L
+#define _LIBCPP_HAS_NO_CXX20_COROUTINES
+#endif
+
+// Yandex-specific: We build our own libc++, so it has everything available
+#define _LIBCPP_DISABLE_AVAILABILITY
+// End of Yandex-specific
+
+#if defined(_LIBCPP_COMPILER_IBM) || defined(__CUDACC__)
+#define _LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO
+#endif
+
+#if defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
+# define _LIBCPP_PUSH_MACROS
+# define _LIBCPP_POP_MACROS
+#else
+ // Don't warn about macro conflicts when we can restore them at the
+ // end of the header.
+# ifndef _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
+# define _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
+# endif
+# if defined(_LIBCPP_COMPILER_MSVC)
+# define _LIBCPP_PUSH_MACROS \
+ __pragma(push_macro("min")) \
+ __pragma(push_macro("max"))
+# define _LIBCPP_POP_MACROS \
+ __pragma(pop_macro("min")) \
+ __pragma(pop_macro("max"))
+# else
+# define _LIBCPP_PUSH_MACROS \
+ _Pragma("push_macro(\"min\")") \
+ _Pragma("push_macro(\"max\")")
+# define _LIBCPP_POP_MACROS \
+ _Pragma("pop_macro(\"min\")") \
+ _Pragma("pop_macro(\"max\")")
+# endif
+#endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
+
+#ifndef _LIBCPP_NO_AUTO_LINK
+# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
+# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+# pragma comment(lib, "c++.lib")
+# else
+# pragma comment(lib, "libc++.lib")
+# endif
+# endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
+#endif // _LIBCPP_NO_AUTO_LINK
+
+// 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.
+//
+// Not all platforms support this, but it helps avoid fd-leaks on platforms that
+// do.
+#if defined(__BIONIC__)
+# define _LIBCPP_FOPEN_CLOEXEC_MODE "e"
+#else
+# define _LIBCPP_FOPEN_CLOEXEC_MODE
+#endif
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#define _LIBCPP_BUILTIN_CONSTANT_P(x) false
+#else
+#define _LIBCPP_BUILTIN_CONSTANT_P(x) __builtin_constant_p(x)
+#endif
+
+// Support for _FILE_OFFSET_BITS=64 landed gradually in Android, so the full set
+// of functions used in cstdio may not be available for low API levels when
+// using 64-bit file offsets on LP32.
+#if defined(__BIONIC__) && defined(__USE_FILE_OFFSET64) && __ANDROID_API__ < 24
+#define _LIBCPP_HAS_NO_FGETPOS_FSETPOS
+#endif
+
+#if __has_attribute(init_priority)
+ // TODO: Remove this once we drop support for building libc++ with old Clangs
+# if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1200) || \
+ (defined(__apple_build_version__) && __apple_build_version__ < 13000000)
+# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101)))
+# else
+# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(100)))
+# endif
+#else
+# define _LIBCPP_INIT_PRIORITY_MAX
+#endif
+
+#if defined(__GNUC__) || defined(__clang__)
+ // The attribute uses 1-based indices for ordinary and static member functions.
+ // The attribute uses 2-based indices for non-static member functions.
+# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \
+ __attribute__((__format__(archetype, format_string_index, first_format_arg_index)))
+#else
+# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */
+#endif
+
+#if __has_cpp_attribute(msvc::no_unique_address)
+ // MSVC implements [[no_unique_address]] as a silent no-op currently.
+ // (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.)
+ // However, MSVC implements [[msvc::no_unique_address]] which does what
+ // [[no_unique_address]] is supposed to do, in general.
+
+ // Clang-cl does not yet (14.0) implement either [[no_unique_address]] or
+ // [[msvc::no_unique_address]] though. If/when it does implement
+ // [[msvc::no_unique_address]], this should be preferred though.
+# define _LIBCPP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
+#elif __has_cpp_attribute(no_unique_address)
+# define _LIBCPP_NO_UNIQUE_ADDRESS [[no_unique_address]]
+#else
+# define _LIBCPP_NO_UNIQUE_ADDRESS /* nothing */
+ // Note that this can be replaced by #error as soon as clang-cl
+ // implements msvc::no_unique_address, since there should be no C++20
+ // compiler that doesn't support one of the two attributes at that point.
+ // We geenrally don't want to use this macro outside of C++20-only code,
+ // because using it conditionally in one language version only would make
+ // the ABI inconsistent.
+#endif
+
+#if __has_cpp_attribute(msvc::no_unique_address)
+ // MSVC implements [[no_unique_address]] as a silent no-op currently.
+ // (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.)
+ // However, MSVC implements [[msvc::no_unique_address]] which does what
+ // [[no_unique_address]] is supposed to do, in general.
+
+ // Clang-cl does not yet (14.0) implement either [[no_unique_address]] or
+ // [[msvc::no_unique_address]] though. If/when it does implement
+ // [[msvc::no_unique_address]], this should be preferred though.
+# define _LIBCPP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
+#elif __has_cpp_attribute(no_unique_address)
+# define _LIBCPP_NO_UNIQUE_ADDRESS [[no_unique_address]]
+#else
+# define _LIBCPP_NO_UNIQUE_ADDRESS /* nothing */
+ // Note that this can be replaced by #error as soon as clang-cl
+ // implements msvc::no_unique_address, since there should be no C++20
+ // compiler that doesn't support one of the two attributes at that point.
+ // We generally don't want to use this macro outside of C++20-only code,
+ // because using it conditionally in one language version only would make
+ // the ABI inconsistent.
+#endif
+
+#ifdef _LIBCPP_COMPILER_CLANG_BASED
+# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
+# define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
+# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(clang diagnostic ignored str))
+# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
+#elif defined(_LIBCPP_COMPILER_GCC)
+# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
+# define _LIBCPP_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
+# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
+# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(GCC diagnostic ignored str))
+#else
+# define _LIBCPP_DIAGNOSTIC_PUSH
+# define _LIBCPP_DIAGNOSTIC_POP
+# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
+# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
+#endif
+
+#endif // __cplusplus
+
+#endif // _LIBCPP_CONFIG
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__coroutine/coroutine_handle.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__coroutine/coroutine_handle.h
new file mode 100644
index 0000000000..4bf3237892
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__coroutine/coroutine_handle.h
@@ -0,0 +1,202 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___COROUTINE_COROUTINE_HANDLE_H
+#define _LIBCPP___COROUTINE_COROUTINE_HANDLE_H
+
+#include <__assert>
+#include <__config>
+#include <__functional/hash.h>
+#include <__memory/addressof.h>
+#include <compare>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// [coroutine.handle]
+template <class _Promise = void>
+struct _LIBCPP_TEMPLATE_VIS coroutine_handle;
+
+template <>
+struct _LIBCPP_TEMPLATE_VIS coroutine_handle<void> {
+public:
+ // [coroutine.handle.con], construct/reset
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr coroutine_handle() noexcept = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr coroutine_handle(nullptr_t) noexcept {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ coroutine_handle& operator=(nullptr_t) noexcept {
+ __handle_ = nullptr;
+ return *this;
+ }
+
+ // [coroutine.handle.export.import], export/import
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr void* address() const noexcept { return __handle_; }
+
+ _LIBCPP_HIDE_FROM_ABI
+ static constexpr coroutine_handle from_address(void* __addr) noexcept {
+ coroutine_handle __tmp;
+ __tmp.__handle_ = __addr;
+ return __tmp;
+ }
+
+ // [coroutine.handle.observers], observers
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit operator bool() const noexcept {
+ return __handle_ != nullptr;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ bool done() const {
+ _LIBCPP_ASSERT(__is_suspended(), "done() can be called only on suspended coroutines");
+ return __builtin_coro_done(__handle_);
+ }
+
+ // [coroutine.handle.resumption], resumption
+ _LIBCPP_HIDE_FROM_ABI
+ void operator()() const { resume(); }
+
+ _LIBCPP_HIDE_FROM_ABI
+ void resume() const {
+ _LIBCPP_ASSERT(__is_suspended(), "resume() can be called only on suspended coroutines");
+ _LIBCPP_ASSERT(!done(), "resume() has undefined behavior when the coroutine is done");
+ __builtin_coro_resume(__handle_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ void destroy() const {
+ _LIBCPP_ASSERT(__is_suspended(), "destroy() can be called only on suspended coroutines");
+ __builtin_coro_destroy(__handle_);
+ }
+
+private:
+ bool __is_suspended() const {
+ // FIXME actually implement a check for if the coro is suspended.
+ return __handle_ != nullptr;
+ }
+
+ void* __handle_ = nullptr;
+};
+
+// [coroutine.handle.compare]
+inline _LIBCPP_HIDE_FROM_ABI
+constexpr bool operator==(coroutine_handle<> __x, coroutine_handle<> __y) noexcept {
+ return __x.address() == __y.address();
+}
+inline _LIBCPP_HIDE_FROM_ABI
+constexpr strong_ordering operator<=>(coroutine_handle<> __x, coroutine_handle<> __y) noexcept {
+ return compare_three_way()(__x.address(), __y.address());
+}
+
+template <class _Promise>
+struct _LIBCPP_TEMPLATE_VIS coroutine_handle {
+public:
+ // [coroutine.handle.con], construct/reset
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr coroutine_handle() noexcept = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr coroutine_handle(nullptr_t) noexcept {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ static coroutine_handle from_promise(_Promise& __promise) {
+ using _RawPromise = typename remove_cv<_Promise>::type;
+ coroutine_handle __tmp;
+ __tmp.__handle_ =
+ __builtin_coro_promise(_VSTD::addressof(const_cast<_RawPromise&>(__promise)), alignof(_Promise), true);
+ return __tmp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ coroutine_handle& operator=(nullptr_t) noexcept {
+ __handle_ = nullptr;
+ return *this;
+ }
+
+ // [coroutine.handle.export.import], export/import
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr void* address() const noexcept { return __handle_; }
+
+ _LIBCPP_HIDE_FROM_ABI
+ static constexpr coroutine_handle from_address(void* __addr) noexcept {
+ coroutine_handle __tmp;
+ __tmp.__handle_ = __addr;
+ return __tmp;
+ }
+
+ // [coroutine.handle.conv], conversion
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr operator coroutine_handle<>() const noexcept {
+ return coroutine_handle<>::from_address(address());
+ }
+
+ // [coroutine.handle.observers], observers
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit operator bool() const noexcept {
+ return __handle_ != nullptr;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ bool done() const {
+ _LIBCPP_ASSERT(__is_suspended(), "done() can be called only on suspended coroutines");
+ return __builtin_coro_done(__handle_);
+ }
+
+ // [coroutine.handle.resumption], resumption
+ _LIBCPP_HIDE_FROM_ABI
+ void operator()() const { resume(); }
+
+ _LIBCPP_HIDE_FROM_ABI
+ void resume() const {
+ _LIBCPP_ASSERT(__is_suspended(), "resume() can be called only on suspended coroutines");
+ _LIBCPP_ASSERT(!done(), "resume() has undefined behavior when the coroutine is done");
+ __builtin_coro_resume(__handle_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ void destroy() const {
+ _LIBCPP_ASSERT(__is_suspended(), "destroy() can be called only on suspended coroutines");
+ __builtin_coro_destroy(__handle_);
+ }
+
+ // [coroutine.handle.promise], promise access
+ _LIBCPP_HIDE_FROM_ABI
+ _Promise& promise() const {
+ return *static_cast<_Promise*>(__builtin_coro_promise(this->__handle_, alignof(_Promise), false));
+ }
+
+private:
+ bool __is_suspended() const {
+ // FIXME actually implement a check for if the coro is suspended.
+ return __handle_ != nullptr;
+ }
+ void* __handle_ = nullptr;
+};
+
+// [coroutine.handle.hash]
+template <class _Tp>
+struct hash<coroutine_handle<_Tp>> {
+ _LIBCPP_HIDE_FROM_ABI
+ size_t operator()(const coroutine_handle<_Tp>& __v) const noexcept { return hash<void*>()(__v.address()); }
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // __LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
+
+#endif // _LIBCPP___COROUTINE_COROUTINE_HANDLE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__coroutine/coroutine_traits.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__coroutine/coroutine_traits.h
new file mode 100644
index 0000000000..0a5229b459
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__coroutine/coroutine_traits.h
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___COROUTINE_COROUTINE_TRAITS_H
+#define _LIBCPP___COROUTINE_COROUTINE_TRAITS_H
+
+#include <__config>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// [coroutine.traits]
+// [coroutine.traits.primary]
+// The header <coroutine> defined the primary template coroutine_traits such that
+// if ArgTypes is a parameter pack of types and if the qualified-id R::promise_type
+// is valid and denotes a type ([temp.deduct]), then coroutine_traits<R, ArgTypes...>
+// has the following publicly accessible memebr:
+//
+// using promise_type = typename R::promise_type;
+//
+// Otherwise, coroutine_traits<R, ArgTypes...> has no members.
+template <class _Tp, class = void>
+struct __coroutine_traits_sfinae {};
+
+template <class _Tp>
+struct __coroutine_traits_sfinae<
+ _Tp, typename __void_t<typename _Tp::promise_type>::type>
+{
+ using promise_type = typename _Tp::promise_type;
+};
+
+template <class _Ret, class... _Args>
+struct coroutine_traits
+ : public __coroutine_traits_sfinae<_Ret>
+{
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // __LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
+
+#endif // _LIBCPP___COROUTINE_COROUTINE_TRAITS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__coroutine/noop_coroutine_handle.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__coroutine/noop_coroutine_handle.h
new file mode 100644
index 0000000000..7a2c672057
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__coroutine/noop_coroutine_handle.h
@@ -0,0 +1,112 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___COROUTINE_NOOP_COROUTINE_HANDLE_H
+#define _LIBCPP___COROUTINE_NOOP_COROUTINE_HANDLE_H
+
+#include <__config>
+#include <__coroutine/coroutine_handle.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if __has_builtin(__builtin_coro_noop) || defined(_LIBCPP_COMPILER_GCC)
+
+// [coroutine.noop]
+// [coroutine.promise.noop]
+struct noop_coroutine_promise {};
+
+// [coroutine.handle.noop]
+template <>
+struct _LIBCPP_TEMPLATE_VIS coroutine_handle<noop_coroutine_promise> {
+public:
+ // [coroutine.handle.noop.conv], conversion
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr operator coroutine_handle<>() const noexcept {
+ return coroutine_handle<>::from_address(address());
+ }
+
+ // [coroutine.handle.noop.observers], observers
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit operator bool() const noexcept { return true; }
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr bool done() const noexcept { return false; }
+
+ // [coroutine.handle.noop.resumption], resumption
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr void operator()() const noexcept {}
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr void resume() const noexcept {}
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr void destroy() const noexcept {}
+
+ // [coroutine.handle.noop.promise], promise access
+ _LIBCPP_HIDE_FROM_ABI
+ noop_coroutine_promise& promise() const noexcept {
+ return *static_cast<noop_coroutine_promise*>(
+ __builtin_coro_promise(this->__handle_, alignof(noop_coroutine_promise), false));
+ }
+
+ // [coroutine.handle.noop.address], address
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr void* address() const noexcept { return __handle_; }
+
+private:
+ _LIBCPP_HIDE_FROM_ABI
+ friend coroutine_handle<noop_coroutine_promise> noop_coroutine() noexcept;
+
+#if __has_builtin(__builtin_coro_noop)
+ _LIBCPP_HIDE_FROM_ABI coroutine_handle() noexcept {
+ this->__handle_ = __builtin_coro_noop();
+ }
+
+ void* __handle_ = nullptr;
+
+#elif defined(_LIBCPP_COMPILER_GCC)
+ // GCC doesn't implement __builtin_coro_noop().
+ // Construct the coroutine frame manually instead.
+ struct __noop_coroutine_frame_ty_ {
+ static void __dummy_resume_destroy_func() { }
+
+ void (*__resume_)() = __dummy_resume_destroy_func;
+ void (*__destroy_)() = __dummy_resume_destroy_func;
+ struct noop_coroutine_promise __promise_;
+ };
+
+ static __noop_coroutine_frame_ty_ __noop_coroutine_frame_;
+
+ void* __handle_ = &__noop_coroutine_frame_;
+
+ _LIBCPP_HIDE_FROM_ABI coroutine_handle() noexcept = default;
+
+#endif // __has_builtin(__builtin_coro_noop)
+};
+
+using noop_coroutine_handle = coroutine_handle<noop_coroutine_promise>;
+
+#if defined(_LIBCPP_COMPILER_GCC)
+inline noop_coroutine_handle::__noop_coroutine_frame_ty_
+ noop_coroutine_handle::__noop_coroutine_frame_{};
+#endif
+
+// [coroutine.noop.coroutine]
+inline _LIBCPP_HIDE_FROM_ABI
+noop_coroutine_handle noop_coroutine() noexcept { return noop_coroutine_handle(); }
+
+#endif // __has_builtin(__builtin_coro_noop) || defined(_LIBCPP_COMPILER_GCC)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // __LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
+
+#endif // _LIBCPP___COROUTINE_NOOP_COROUTINE_HANDLE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__coroutine/trivial_awaitables.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__coroutine/trivial_awaitables.h
new file mode 100644
index 0000000000..31399ab29a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__coroutine/trivial_awaitables.h
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___COROUTINE_TRIVIAL_AWAITABLES_H
+#define __LIBCPP___COROUTINE_TRIVIAL_AWAITABLES_H
+
+#include <__config>
+#include <__coroutine/coroutine_handle.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// [coroutine.trivial.awaitables]
+struct suspend_never {
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr bool await_ready() const noexcept { return true; }
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr void await_suspend(coroutine_handle<>) const noexcept {}
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr void await_resume() const noexcept {}
+};
+
+struct suspend_always {
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr bool await_ready() const noexcept { return false; }
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr void await_suspend(coroutine_handle<>) const noexcept {}
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr void await_resume() const noexcept {}
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // __LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
+
+#endif // __LIBCPP___COROUTINE_TRIVIAL_AWAITABLES_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__debug b/contrib/libs/cxxsupp/libcxxmsvc/include/__debug
new file mode 100644
index 0000000000..b7677a22c8
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__debug
@@ -0,0 +1,232 @@
+// -*- 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_DEBUG_H
+#define _LIBCPP_DEBUG_H
+
+#include <__assert>
+#include <__config>
+#include <iosfwd>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_DEBUG_LEVEL >= 1 || defined(_LIBCPP_BUILDING_LIBRARY)
+# include <cstddef>
+# include <cstdio>
+# include <cstdlib>
+#endif
+
+#if _LIBCPP_DEBUG_LEVEL == 0 || _LIBCPP_DEBUG_LEVEL == 1
+# define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0)
+#elif _LIBCPP_DEBUG_LEVEL == 2
+# define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(::std::__libcpp_is_constant_evaluated() || (x), m)
+#else
+# error _LIBCPP_DEBUG_LEVEL must be one of 0, 1, 2
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_DEBUG_LEVEL == 2 || defined(_LIBCPP_BUILDING_LIBRARY)
+
+struct _LIBCPP_TYPE_VIS __c_node;
+
+struct _LIBCPP_TYPE_VIS __i_node
+{
+ void* __i_;
+ __i_node* __next_;
+ __c_node* __c_;
+
+ __i_node(const __i_node&) = delete;
+ __i_node& operator=(const __i_node&) = delete;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __i_node(void* __i, __i_node* __next, __c_node* __c)
+ : __i_(__i), __next_(__next), __c_(__c) {}
+ ~__i_node();
+};
+
+struct _LIBCPP_TYPE_VIS __c_node
+{
+ void* __c_;
+ __c_node* __next_;
+ __i_node** beg_;
+ __i_node** end_;
+ __i_node** cap_;
+
+ __c_node(const __c_node&) = delete;
+ __c_node& operator=(const __c_node&) = delete;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __c_node(void* __c, __c_node* __next)
+ : __c_(__c), __next_(__next), beg_(nullptr), end_(nullptr), cap_(nullptr) {}
+ virtual ~__c_node();
+
+ virtual bool __dereferenceable(const void*) const = 0;
+ virtual bool __decrementable(const void*) const = 0;
+ virtual bool __addable(const void*, ptrdiff_t) const = 0;
+ virtual bool __subscriptable(const void*, ptrdiff_t) const = 0;
+
+ void __add(__i_node* __i);
+ _LIBCPP_HIDDEN void __remove(__i_node* __i);
+};
+
+template <class _Cont>
+struct _C_node
+ : public __c_node
+{
+ _C_node(void* __c, __c_node* __n)
+ : __c_node(__c, __n) {}
+
+ virtual bool __dereferenceable(const void*) const;
+ virtual bool __decrementable(const void*) const;
+ virtual bool __addable(const void*, ptrdiff_t) const;
+ virtual bool __subscriptable(const void*, ptrdiff_t) const;
+};
+
+template <class _Cont>
+inline bool
+_C_node<_Cont>::__dereferenceable(const void* __i) const
+{
+ typedef typename _Cont::const_iterator iterator;
+ const iterator* __j = static_cast<const iterator*>(__i);
+ _Cont* _Cp = static_cast<_Cont*>(__c_);
+ return _Cp->__dereferenceable(__j);
+}
+
+template <class _Cont>
+inline bool
+_C_node<_Cont>::__decrementable(const void* __i) const
+{
+ typedef typename _Cont::const_iterator iterator;
+ const iterator* __j = static_cast<const iterator*>(__i);
+ _Cont* _Cp = static_cast<_Cont*>(__c_);
+ return _Cp->__decrementable(__j);
+}
+
+template <class _Cont>
+inline bool
+_C_node<_Cont>::__addable(const void* __i, ptrdiff_t __n) const
+{
+ typedef typename _Cont::const_iterator iterator;
+ const iterator* __j = static_cast<const iterator*>(__i);
+ _Cont* _Cp = static_cast<_Cont*>(__c_);
+ return _Cp->__addable(__j, __n);
+}
+
+template <class _Cont>
+inline bool
+_C_node<_Cont>::__subscriptable(const void* __i, ptrdiff_t __n) const
+{
+ typedef typename _Cont::const_iterator iterator;
+ const iterator* __j = static_cast<const iterator*>(__i);
+ _Cont* _Cp = static_cast<_Cont*>(__c_);
+ return _Cp->__subscriptable(__j, __n);
+}
+
+class _LIBCPP_TYPE_VIS __libcpp_db
+{
+ __c_node** __cbeg_;
+ __c_node** __cend_;
+ size_t __csz_;
+ __i_node** __ibeg_;
+ __i_node** __iend_;
+ size_t __isz_;
+
+ __libcpp_db();
+public:
+ __libcpp_db(const __libcpp_db&) = delete;
+ __libcpp_db& operator=(const __libcpp_db&) = delete;
+
+ ~__libcpp_db();
+
+ class __db_c_iterator;
+ class __db_c_const_iterator;
+ class __db_i_iterator;
+ class __db_i_const_iterator;
+
+ __db_c_const_iterator __c_end() const;
+ __db_i_const_iterator __i_end() const;
+
+ typedef __c_node*(_InsertConstruct)(void*, void*, __c_node*);
+
+ template <class _Cont>
+ _LIBCPP_INLINE_VISIBILITY static __c_node* __create_C_node(void *__mem, void *__c, __c_node *__next) {
+ return ::new (__mem) _C_node<_Cont>(__c, __next);
+ }
+
+ template <class _Cont>
+ _LIBCPP_INLINE_VISIBILITY
+ void __insert_c(_Cont* __c)
+ {
+ __insert_c(static_cast<void*>(__c), &__create_C_node<_Cont>);
+ }
+
+ void __insert_i(void* __i);
+ void __insert_c(void* __c, _InsertConstruct* __fn);
+ void __erase_c(void* __c);
+
+ void __insert_ic(void* __i, const void* __c);
+ void __iterator_copy(void* __i, const void* __i0);
+ void __erase_i(void* __i);
+
+ void* __find_c_from_i(void* __i) const;
+ void __invalidate_all(void* __c);
+ __c_node* __find_c_and_lock(void* __c) const;
+ __c_node* __find_c(void* __c) const;
+ void unlock() const;
+
+ void swap(void* __c1, void* __c2);
+
+
+ bool __dereferenceable(const void* __i) const;
+ bool __decrementable(const void* __i) const;
+ bool __addable(const void* __i, ptrdiff_t __n) const;
+ bool __subscriptable(const void* __i, ptrdiff_t __n) const;
+ bool __less_than_comparable(const void* __i, const void* __j) const;
+private:
+ _LIBCPP_HIDDEN
+ __i_node* __insert_iterator(void* __i);
+ _LIBCPP_HIDDEN
+ __i_node* __find_iterator(const void* __i) const;
+
+ friend _LIBCPP_FUNC_VIS __libcpp_db* __get_db();
+};
+
+_LIBCPP_FUNC_VIS __libcpp_db* __get_db();
+_LIBCPP_FUNC_VIS const __libcpp_db* __get_const_db();
+
+
+#endif // _LIBCPP_DEBUG_LEVEL == 2 || defined(_LIBCPP_BUILDING_LIBRARY)
+
+template <class _Tp>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_insert_c(_Tp* __c) {
+#if _LIBCPP_DEBUG_LEVEL == 2
+ if (!__libcpp_is_constant_evaluated())
+ __get_db()->__insert_c(__c);
+#else
+ (void)(__c);
+#endif
+}
+
+template <class _Tp>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_insert_i(_Tp* __i) {
+#if _LIBCPP_DEBUG_LEVEL == 2
+ if (!__libcpp_is_constant_evaluated())
+ __get_db()->__insert_i(__i);
+#else
+ (void)(__i);
+#endif
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_DEBUG_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__errc b/contrib/libs/cxxsupp/libcxxmsvc/include/__errc
new file mode 100644
index 0000000000..17bbe0e2af
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__errc
@@ -0,0 +1,217 @@
+// -*- 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___ERRC
+#define _LIBCPP___ERRC
+
+/*
+ system_error synopsis
+
+namespace std
+{
+
+enum class errc
+{
+ address_family_not_supported, // EAFNOSUPPORT
+ address_in_use, // EADDRINUSE
+ address_not_available, // EADDRNOTAVAIL
+ already_connected, // EISCONN
+ argument_list_too_long, // E2BIG
+ argument_out_of_domain, // EDOM
+ bad_address, // EFAULT
+ bad_file_descriptor, // EBADF
+ bad_message, // EBADMSG
+ broken_pipe, // EPIPE
+ connection_aborted, // ECONNABORTED
+ connection_already_in_progress, // EALREADY
+ connection_refused, // ECONNREFUSED
+ connection_reset, // ECONNRESET
+ cross_device_link, // EXDEV
+ destination_address_required, // EDESTADDRREQ
+ device_or_resource_busy, // EBUSY
+ directory_not_empty, // ENOTEMPTY
+ executable_format_error, // ENOEXEC
+ file_exists, // EEXIST
+ file_too_large, // EFBIG
+ filename_too_long, // ENAMETOOLONG
+ function_not_supported, // ENOSYS
+ host_unreachable, // EHOSTUNREACH
+ identifier_removed, // EIDRM
+ illegal_byte_sequence, // EILSEQ
+ inappropriate_io_control_operation, // ENOTTY
+ interrupted, // EINTR
+ invalid_argument, // EINVAL
+ invalid_seek, // ESPIPE
+ io_error, // EIO
+ is_a_directory, // EISDIR
+ message_size, // EMSGSIZE
+ network_down, // ENETDOWN
+ network_reset, // ENETRESET
+ network_unreachable, // ENETUNREACH
+ no_buffer_space, // ENOBUFS
+ no_child_process, // ECHILD
+ no_link, // ENOLINK
+ no_lock_available, // ENOLCK
+ no_message_available, // ENODATA
+ no_message, // ENOMSG
+ no_protocol_option, // ENOPROTOOPT
+ no_space_on_device, // ENOSPC
+ no_stream_resources, // ENOSR
+ no_such_device_or_address, // ENXIO
+ no_such_device, // ENODEV
+ no_such_file_or_directory, // ENOENT
+ no_such_process, // ESRCH
+ not_a_directory, // ENOTDIR
+ not_a_socket, // ENOTSOCK
+ not_a_stream, // ENOSTR
+ not_connected, // ENOTCONN
+ not_enough_memory, // ENOMEM
+ not_supported, // ENOTSUP
+ operation_canceled, // ECANCELED
+ operation_in_progress, // EINPROGRESS
+ operation_not_permitted, // EPERM
+ operation_not_supported, // EOPNOTSUPP
+ operation_would_block, // EWOULDBLOCK
+ owner_dead, // EOWNERDEAD
+ permission_denied, // EACCES
+ protocol_error, // EPROTO
+ protocol_not_supported, // EPROTONOSUPPORT
+ read_only_file_system, // EROFS
+ resource_deadlock_would_occur, // EDEADLK
+ resource_unavailable_try_again, // EAGAIN
+ result_out_of_range, // ERANGE
+ state_not_recoverable, // ENOTRECOVERABLE
+ stream_timeout, // ETIME
+ text_file_busy, // ETXTBSY
+ timed_out, // ETIMEDOUT
+ too_many_files_open_in_system, // ENFILE
+ too_many_files_open, // EMFILE
+ too_many_links, // EMLINK
+ too_many_symbolic_link_levels, // ELOOP
+ value_too_large, // EOVERFLOW
+ wrong_protocol_type // EPROTOTYPE
+};
+
+*/
+
+#include <__config>
+#include <cerrno>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// Some error codes are not present on all platforms, so we provide equivalents
+// for them:
+
+//enum class errc
+_LIBCPP_DECLARE_STRONG_ENUM(errc)
+{
+ address_family_not_supported = EAFNOSUPPORT,
+ address_in_use = EADDRINUSE,
+ address_not_available = EADDRNOTAVAIL,
+ already_connected = EISCONN,
+ argument_list_too_long = E2BIG,
+ argument_out_of_domain = EDOM,
+ bad_address = EFAULT,
+ bad_file_descriptor = EBADF,
+ bad_message = EBADMSG,
+ broken_pipe = EPIPE,
+ connection_aborted = ECONNABORTED,
+ connection_already_in_progress = EALREADY,
+ connection_refused = ECONNREFUSED,
+ connection_reset = ECONNRESET,
+ cross_device_link = EXDEV,
+ destination_address_required = EDESTADDRREQ,
+ device_or_resource_busy = EBUSY,
+ directory_not_empty = ENOTEMPTY,
+ executable_format_error = ENOEXEC,
+ file_exists = EEXIST,
+ file_too_large = EFBIG,
+ filename_too_long = ENAMETOOLONG,
+ function_not_supported = ENOSYS,
+ host_unreachable = EHOSTUNREACH,
+ identifier_removed = EIDRM,
+ illegal_byte_sequence = EILSEQ,
+ inappropriate_io_control_operation = ENOTTY,
+ interrupted = EINTR,
+ invalid_argument = EINVAL,
+ invalid_seek = ESPIPE,
+ io_error = EIO,
+ is_a_directory = EISDIR,
+ message_size = EMSGSIZE,
+ network_down = ENETDOWN,
+ network_reset = ENETRESET,
+ network_unreachable = ENETUNREACH,
+ no_buffer_space = ENOBUFS,
+ no_child_process = ECHILD,
+ no_link = ENOLINK,
+ no_lock_available = ENOLCK,
+#ifdef ENODATA
+ no_message_available = ENODATA,
+#else
+ no_message_available = ENOMSG,
+#endif
+ no_message = ENOMSG,
+ no_protocol_option = ENOPROTOOPT,
+ no_space_on_device = ENOSPC,
+#ifdef ENOSR
+ no_stream_resources = ENOSR,
+#else
+ no_stream_resources = ENOMEM,
+#endif
+ no_such_device_or_address = ENXIO,
+ no_such_device = ENODEV,
+ no_such_file_or_directory = ENOENT,
+ no_such_process = ESRCH,
+ not_a_directory = ENOTDIR,
+ not_a_socket = ENOTSOCK,
+#ifdef ENOSTR
+ not_a_stream = ENOSTR,
+#else
+ not_a_stream = EINVAL,
+#endif
+ not_connected = ENOTCONN,
+ not_enough_memory = ENOMEM,
+ not_supported = ENOTSUP,
+ operation_canceled = ECANCELED,
+ operation_in_progress = EINPROGRESS,
+ operation_not_permitted = EPERM,
+ operation_not_supported = EOPNOTSUPP,
+ operation_would_block = EWOULDBLOCK,
+ owner_dead = EOWNERDEAD,
+ permission_denied = EACCES,
+ protocol_error = EPROTO,
+ protocol_not_supported = EPROTONOSUPPORT,
+ read_only_file_system = EROFS,
+ resource_deadlock_would_occur = EDEADLK,
+ resource_unavailable_try_again = EAGAIN,
+ result_out_of_range = ERANGE,
+ state_not_recoverable = ENOTRECOVERABLE,
+#ifdef ETIME
+ stream_timeout = ETIME,
+#else
+ stream_timeout = ETIMEDOUT,
+#endif
+ text_file_busy = ETXTBSY,
+ timed_out = ETIMEDOUT,
+ too_many_files_open_in_system = ENFILE,
+ too_many_files_open = EMFILE,
+ too_many_links = EMLINK,
+ too_many_symbolic_link_levels = ELOOP,
+ value_too_large = EOVERFLOW,
+ wrong_protocol_type = EPROTOTYPE
+};
+_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(errc)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ERRC
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/copy_options.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/copy_options.h
new file mode 100644
index 0000000000..2e037403f6
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/copy_options.h
@@ -0,0 +1,84 @@
+// -*- 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___FILESYSTEM_COPY_OPTIONS_H
+#define _LIBCPP___FILESYSTEM_COPY_OPTIONS_H
+
+#include <__availability>
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+
+_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
+
+_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH
+
+enum class _LIBCPP_ENUM_VIS copy_options : unsigned short {
+ none = 0,
+ skip_existing = 1,
+ overwrite_existing = 2,
+ update_existing = 4,
+ recursive = 8,
+ copy_symlinks = 16,
+ skip_symlinks = 32,
+ directories_only = 64,
+ create_symlinks = 128,
+ create_hard_links = 256,
+ __in_recursive_copy = 512,
+};
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr copy_options operator&(copy_options _LHS, copy_options _RHS) {
+ return static_cast<copy_options>(static_cast<unsigned short>(_LHS) &
+ static_cast<unsigned short>(_RHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr copy_options operator|(copy_options _LHS, copy_options _RHS) {
+ return static_cast<copy_options>(static_cast<unsigned short>(_LHS) |
+ static_cast<unsigned short>(_RHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr copy_options operator^(copy_options _LHS, copy_options _RHS) {
+ return static_cast<copy_options>(static_cast<unsigned short>(_LHS) ^
+ static_cast<unsigned short>(_RHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr copy_options operator~(copy_options _LHS) {
+ return static_cast<copy_options>(~static_cast<unsigned short>(_LHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline copy_options& operator&=(copy_options& _LHS, copy_options _RHS) {
+ return _LHS = _LHS & _RHS;
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline copy_options& operator|=(copy_options& _LHS, copy_options _RHS) {
+ return _LHS = _LHS | _RHS;
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline copy_options& operator^=(copy_options& _LHS, copy_options _RHS) {
+ return _LHS = _LHS ^ _RHS;
+}
+
+_LIBCPP_AVAILABILITY_FILESYSTEM_POP
+
+_LIBCPP_END_NAMESPACE_FILESYSTEM
+
+#endif // _LIBCPP_CXX03_LANG
+
+#endif // _LIBCPP___FILESYSTEM_COPY_OPTIONS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/directory_entry.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/directory_entry.h
new file mode 100644
index 0000000000..a1f18add81
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/directory_entry.h
@@ -0,0 +1,516 @@
+// -*- 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___FILESYSTEM_DIRECTORY_ENTRY_H
+#define _LIBCPP___FILESYSTEM_DIRECTORY_ENTRY_H
+
+#include <__availability>
+#include <__config>
+#include <__errc>
+#include <__filesystem/file_status.h>
+#include <__filesystem/file_time_type.h>
+#include <__filesystem/file_type.h>
+#include <__filesystem/filesystem_error.h>
+#include <__filesystem/operations.h>
+#include <__filesystem/path.h>
+#include <__filesystem/perms.h>
+#include <__utility/unreachable.h>
+#include <chrono>
+#include <cstdint>
+#include <cstdlib>
+#include <iosfwd>
+#include <system_error>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+#ifndef _LIBCPP_CXX03_LANG
+
+_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
+
+_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH
+
+
+class directory_entry {
+ typedef _VSTD_FS::path _Path;
+
+public:
+ // constructors and destructors
+ directory_entry() noexcept = default;
+ directory_entry(directory_entry const&) = default;
+ directory_entry(directory_entry&&) noexcept = default;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit directory_entry(_Path const& __p) : __p_(__p) {
+ error_code __ec;
+ __refresh(&__ec);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ directory_entry(_Path const& __p, error_code& __ec) : __p_(__p) {
+ __refresh(&__ec);
+ }
+
+ ~directory_entry() {}
+
+ directory_entry& operator=(directory_entry const&) = default;
+ directory_entry& operator=(directory_entry&&) noexcept = default;
+
+ _LIBCPP_INLINE_VISIBILITY
+ void assign(_Path const& __p) {
+ __p_ = __p;
+ error_code __ec;
+ __refresh(&__ec);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void assign(_Path const& __p, error_code& __ec) {
+ __p_ = __p;
+ __refresh(&__ec);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void replace_filename(_Path const& __p) {
+ __p_.replace_filename(__p);
+ error_code __ec;
+ __refresh(&__ec);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void replace_filename(_Path const& __p, error_code& __ec) {
+ __p_ = __p_.parent_path() / __p;
+ __refresh(&__ec);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void refresh() { __refresh(); }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void refresh(error_code& __ec) noexcept { __refresh(&__ec); }
+
+ _LIBCPP_INLINE_VISIBILITY
+ _Path const& path() const noexcept { return __p_; }
+
+ _LIBCPP_INLINE_VISIBILITY
+ operator const _Path&() const noexcept { return __p_; }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool exists() const { return _VSTD_FS::exists(file_status{__get_ft()}); }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool exists(error_code& __ec) const noexcept {
+ return _VSTD_FS::exists(file_status{__get_ft(&__ec)});
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool is_block_file() const { return __get_ft() == file_type::block; }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool is_block_file(error_code& __ec) const noexcept {
+ return __get_ft(&__ec) == file_type::block;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool is_character_file() const { return __get_ft() == file_type::character; }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool is_character_file(error_code& __ec) const noexcept {
+ return __get_ft(&__ec) == file_type::character;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool is_directory() const { return __get_ft() == file_type::directory; }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool is_directory(error_code& __ec) const noexcept {
+ return __get_ft(&__ec) == file_type::directory;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool is_fifo() const { return __get_ft() == file_type::fifo; }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool is_fifo(error_code& __ec) const noexcept {
+ return __get_ft(&__ec) == file_type::fifo;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool is_other() const { return _VSTD_FS::is_other(file_status{__get_ft()}); }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool is_other(error_code& __ec) const noexcept {
+ return _VSTD_FS::is_other(file_status{__get_ft(&__ec)});
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool is_regular_file() const { return __get_ft() == file_type::regular; }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool is_regular_file(error_code& __ec) const noexcept {
+ return __get_ft(&__ec) == file_type::regular;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool is_socket() const { return __get_ft() == file_type::socket; }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool is_socket(error_code& __ec) const noexcept {
+ return __get_ft(&__ec) == file_type::socket;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool is_symlink() const { return __get_sym_ft() == file_type::symlink; }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool is_symlink(error_code& __ec) const noexcept {
+ return __get_sym_ft(&__ec) == file_type::symlink;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ uintmax_t file_size() const { return __get_size(); }
+
+ _LIBCPP_INLINE_VISIBILITY
+ uintmax_t file_size(error_code& __ec) const noexcept {
+ return __get_size(&__ec);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ uintmax_t hard_link_count() const { return __get_nlink(); }
+
+ _LIBCPP_INLINE_VISIBILITY
+ uintmax_t hard_link_count(error_code& __ec) const noexcept {
+ return __get_nlink(&__ec);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ file_time_type last_write_time() const { return __get_write_time(); }
+
+ _LIBCPP_INLINE_VISIBILITY
+ file_time_type last_write_time(error_code& __ec) const noexcept {
+ return __get_write_time(&__ec);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ file_status status() const { return __get_status(); }
+
+ _LIBCPP_INLINE_VISIBILITY
+ file_status status(error_code& __ec) const noexcept {
+ return __get_status(&__ec);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ file_status symlink_status() const { return __get_symlink_status(); }
+
+ _LIBCPP_INLINE_VISIBILITY
+ file_status symlink_status(error_code& __ec) const noexcept {
+ return __get_symlink_status(&__ec);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator<(directory_entry const& __rhs) const noexcept {
+ return __p_ < __rhs.__p_;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator==(directory_entry const& __rhs) const noexcept {
+ return __p_ == __rhs.__p_;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(directory_entry const& __rhs) const noexcept {
+ return __p_ != __rhs.__p_;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator<=(directory_entry const& __rhs) const noexcept {
+ return __p_ <= __rhs.__p_;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator>(directory_entry const& __rhs) const noexcept {
+ return __p_ > __rhs.__p_;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator>=(directory_entry const& __rhs) const noexcept {
+ return __p_ >= __rhs.__p_;
+ }
+
+ template <class _CharT, class _Traits>
+ _LIBCPP_INLINE_VISIBILITY
+ friend basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const directory_entry& __d) {
+ return __os << __d.path();
+ }
+
+private:
+ friend class directory_iterator;
+ friend class recursive_directory_iterator;
+ friend class __dir_stream;
+
+ enum _CacheType : unsigned char {
+ _Empty,
+ _IterSymlink,
+ _IterNonSymlink,
+ _RefreshSymlink,
+ _RefreshSymlinkUnresolved,
+ _RefreshNonSymlink
+ };
+
+ struct __cached_data {
+ uintmax_t __size_;
+ uintmax_t __nlink_;
+ file_time_type __write_time_;
+ perms __sym_perms_;
+ perms __non_sym_perms_;
+ file_type __type_;
+ _CacheType __cache_type_;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __cached_data() noexcept { __reset(); }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __reset() {
+ __cache_type_ = _Empty;
+ __type_ = file_type::none;
+ __sym_perms_ = __non_sym_perms_ = perms::unknown;
+ __size_ = __nlink_ = uintmax_t(-1);
+ __write_time_ = file_time_type::min();
+ }
+ };
+
+ _LIBCPP_INLINE_VISIBILITY
+ static __cached_data __create_iter_result(file_type __ft) {
+ __cached_data __data;
+ __data.__type_ = __ft;
+ __data.__cache_type_ = [&]() {
+ switch (__ft) {
+ case file_type::none:
+ return _Empty;
+ case file_type::symlink:
+ return _IterSymlink;
+ default:
+ return _IterNonSymlink;
+ }
+ }();
+ return __data;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __assign_iter_entry(_Path&& __p, __cached_data __dt) {
+ __p_ = _VSTD::move(__p);
+ __data_ = __dt;
+ }
+
+ _LIBCPP_FUNC_VIS
+ error_code __do_refresh() noexcept;
+
+ _LIBCPP_INLINE_VISIBILITY
+ static bool __is_dne_error(error_code const& __ec) {
+ if (!__ec)
+ return true;
+ switch (static_cast<errc>(__ec.value())) {
+ case errc::no_such_file_or_directory:
+ case errc::not_a_directory:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __handle_error(const char* __msg, error_code* __dest_ec,
+ error_code const& __ec, bool __allow_dne = false) const {
+ if (__dest_ec) {
+ *__dest_ec = __ec;
+ return;
+ }
+ if (__ec && (!__allow_dne || !__is_dne_error(__ec)))
+ __throw_filesystem_error(__msg, __p_, __ec);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __refresh(error_code* __ec = nullptr) {
+ __handle_error("in directory_entry::refresh", __ec, __do_refresh(),
+ /*allow_dne*/ true);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ file_type __get_sym_ft(error_code* __ec = nullptr) const {
+ switch (__data_.__cache_type_) {
+ case _Empty:
+ return __symlink_status(__p_, __ec).type();
+ case _IterSymlink:
+ case _RefreshSymlink:
+ case _RefreshSymlinkUnresolved:
+ if (__ec)
+ __ec->clear();
+ return file_type::symlink;
+ case _IterNonSymlink:
+ case _RefreshNonSymlink:
+ file_status __st(__data_.__type_);
+ if (__ec && !_VSTD_FS::exists(__st))
+ *__ec = make_error_code(errc::no_such_file_or_directory);
+ else if (__ec)
+ __ec->clear();
+ return __data_.__type_;
+ }
+ __libcpp_unreachable();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ file_type __get_ft(error_code* __ec = nullptr) const {
+ switch (__data_.__cache_type_) {
+ case _Empty:
+ case _IterSymlink:
+ case _RefreshSymlinkUnresolved:
+ return __status(__p_, __ec).type();
+ case _IterNonSymlink:
+ case _RefreshNonSymlink:
+ case _RefreshSymlink: {
+ file_status __st(__data_.__type_);
+ if (__ec && !_VSTD_FS::exists(__st))
+ *__ec = make_error_code(errc::no_such_file_or_directory);
+ else if (__ec)
+ __ec->clear();
+ return __data_.__type_;
+ }
+ }
+ __libcpp_unreachable();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ file_status __get_status(error_code* __ec = nullptr) const {
+ switch (__data_.__cache_type_) {
+ case _Empty:
+ case _IterNonSymlink:
+ case _IterSymlink:
+ case _RefreshSymlinkUnresolved:
+ return __status(__p_, __ec);
+ case _RefreshNonSymlink:
+ case _RefreshSymlink:
+ return file_status(__get_ft(__ec), __data_.__non_sym_perms_);
+ }
+ __libcpp_unreachable();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ file_status __get_symlink_status(error_code* __ec = nullptr) const {
+ switch (__data_.__cache_type_) {
+ case _Empty:
+ case _IterNonSymlink:
+ case _IterSymlink:
+ return __symlink_status(__p_, __ec);
+ case _RefreshNonSymlink:
+ return file_status(__get_sym_ft(__ec), __data_.__non_sym_perms_);
+ case _RefreshSymlink:
+ case _RefreshSymlinkUnresolved:
+ return file_status(__get_sym_ft(__ec), __data_.__sym_perms_);
+ }
+ __libcpp_unreachable();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ uintmax_t __get_size(error_code* __ec = nullptr) const {
+ switch (__data_.__cache_type_) {
+ case _Empty:
+ case _IterNonSymlink:
+ case _IterSymlink:
+ case _RefreshSymlinkUnresolved:
+ return _VSTD_FS::__file_size(__p_, __ec);
+ case _RefreshSymlink:
+ case _RefreshNonSymlink: {
+ error_code __m_ec;
+ file_status __st(__get_ft(&__m_ec));
+ __handle_error("in directory_entry::file_size", __ec, __m_ec);
+ if (_VSTD_FS::exists(__st) && !_VSTD_FS::is_regular_file(__st)) {
+ errc __err_kind = _VSTD_FS::is_directory(__st) ? errc::is_a_directory
+ : errc::not_supported;
+ __handle_error("in directory_entry::file_size", __ec,
+ make_error_code(__err_kind));
+ }
+ return __data_.__size_;
+ }
+ }
+ __libcpp_unreachable();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ uintmax_t __get_nlink(error_code* __ec = nullptr) const {
+ switch (__data_.__cache_type_) {
+ case _Empty:
+ case _IterNonSymlink:
+ case _IterSymlink:
+ case _RefreshSymlinkUnresolved:
+ return _VSTD_FS::__hard_link_count(__p_, __ec);
+ case _RefreshSymlink:
+ case _RefreshNonSymlink: {
+ error_code __m_ec;
+ (void)__get_ft(&__m_ec);
+ __handle_error("in directory_entry::hard_link_count", __ec, __m_ec);
+ return __data_.__nlink_;
+ }
+ }
+ __libcpp_unreachable();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ file_time_type __get_write_time(error_code* __ec = nullptr) const {
+ switch (__data_.__cache_type_) {
+ case _Empty:
+ case _IterNonSymlink:
+ case _IterSymlink:
+ case _RefreshSymlinkUnresolved:
+ return _VSTD_FS::__last_write_time(__p_, __ec);
+ case _RefreshSymlink:
+ case _RefreshNonSymlink: {
+ error_code __m_ec;
+ file_status __st(__get_ft(&__m_ec));
+ __handle_error("in directory_entry::last_write_time", __ec, __m_ec);
+ if (_VSTD_FS::exists(__st) &&
+ __data_.__write_time_ == file_time_type::min())
+ __handle_error("in directory_entry::last_write_time", __ec,
+ make_error_code(errc::value_too_large));
+ return __data_.__write_time_;
+ }
+ }
+ __libcpp_unreachable();
+ }
+
+private:
+ _Path __p_;
+ __cached_data __data_;
+};
+
+class __dir_element_proxy {
+public:
+ inline _LIBCPP_INLINE_VISIBILITY directory_entry operator*() {
+ return _VSTD::move(__elem_);
+ }
+
+private:
+ friend class directory_iterator;
+ friend class recursive_directory_iterator;
+ explicit __dir_element_proxy(directory_entry const& __e) : __elem_(__e) {}
+ __dir_element_proxy(__dir_element_proxy&& __o)
+ : __elem_(_VSTD::move(__o.__elem_)) {}
+ directory_entry __elem_;
+};
+
+_LIBCPP_AVAILABILITY_FILESYSTEM_POP
+
+_LIBCPP_END_NAMESPACE_FILESYSTEM
+
+#endif // _LIBCPP_CXX03_LANG
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___FILESYSTEM_DIRECTORY_ENTRY_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/directory_iterator.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/directory_iterator.h
new file mode 100644
index 0000000000..87bbbfac71
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/directory_iterator.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___FILESYSTEM_DIRECTORY_ITERATOR_H
+#define _LIBCPP___FILESYSTEM_DIRECTORY_ITERATOR_H
+
+#include <__assert>
+#include <__availability>
+#include <__config>
+#include <__filesystem/directory_entry.h>
+#include <__filesystem/directory_options.h>
+#include <__filesystem/path.h>
+#include <__iterator/iterator_traits.h>
+#include <__memory/shared_ptr.h>
+#include <__ranges/enable_borrowed_range.h>
+#include <__ranges/enable_view.h>
+#include <cstddef>
+#include <system_error>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+
+_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
+
+_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH
+
+class _LIBCPP_HIDDEN __dir_stream;
+class directory_iterator {
+public:
+ typedef directory_entry value_type;
+ typedef ptrdiff_t difference_type;
+ typedef value_type const* pointer;
+ typedef value_type const& reference;
+ typedef input_iterator_tag iterator_category;
+
+public:
+ //ctor & dtor
+ directory_iterator() noexcept {}
+
+ explicit directory_iterator(const path& __p)
+ : directory_iterator(__p, nullptr) {}
+
+ directory_iterator(const path& __p, directory_options __opts)
+ : directory_iterator(__p, nullptr, __opts) {}
+
+ directory_iterator(const path& __p, error_code& __ec)
+ : directory_iterator(__p, &__ec) {}
+
+ directory_iterator(const path& __p, directory_options __opts,
+ error_code& __ec)
+ : directory_iterator(__p, &__ec, __opts) {}
+
+ directory_iterator(const directory_iterator&) = default;
+ directory_iterator(directory_iterator&&) = default;
+ directory_iterator& operator=(const directory_iterator&) = default;
+
+ directory_iterator& operator=(directory_iterator&& __o) noexcept {
+ // non-default implementation provided to support self-move assign.
+ if (this != &__o) {
+ __imp_ = _VSTD::move(__o.__imp_);
+ }
+ return *this;
+ }
+
+ ~directory_iterator() = default;
+
+ const directory_entry& operator*() const {
+ _LIBCPP_ASSERT(__imp_, "The end iterator cannot be dereferenced");
+ return __dereference();
+ }
+
+ const directory_entry* operator->() const { return &**this; }
+
+ directory_iterator& operator++() { return __increment(); }
+
+ __dir_element_proxy operator++(int) {
+ __dir_element_proxy __p(**this);
+ __increment();
+ return __p;
+ }
+
+ directory_iterator& increment(error_code& __ec) { return __increment(&__ec); }
+
+private:
+ inline _LIBCPP_INLINE_VISIBILITY friend bool
+ operator==(const directory_iterator& __lhs,
+ const directory_iterator& __rhs) noexcept;
+
+ // construct the dir_stream
+ _LIBCPP_FUNC_VIS
+ directory_iterator(const path&, error_code*,
+ directory_options = directory_options::none);
+
+ _LIBCPP_FUNC_VIS
+ directory_iterator& __increment(error_code* __ec = nullptr);
+
+ _LIBCPP_FUNC_VIS
+ const directory_entry& __dereference() const;
+
+private:
+ shared_ptr<__dir_stream> __imp_;
+};
+
+inline _LIBCPP_INLINE_VISIBILITY bool
+operator==(const directory_iterator& __lhs,
+ const directory_iterator& __rhs) noexcept {
+ return __lhs.__imp_ == __rhs.__imp_;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool
+operator!=(const directory_iterator& __lhs,
+ const directory_iterator& __rhs) noexcept {
+ return !(__lhs == __rhs);
+}
+
+// enable directory_iterator range-based for statements
+inline _LIBCPP_INLINE_VISIBILITY directory_iterator
+begin(directory_iterator __iter) noexcept {
+ return __iter;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY directory_iterator
+end(directory_iterator) noexcept {
+ return directory_iterator();
+}
+
+_LIBCPP_AVAILABILITY_FILESYSTEM_POP
+
+_LIBCPP_END_NAMESPACE_FILESYSTEM
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+template <>
+_LIBCPP_AVAILABILITY_FILESYSTEM
+inline constexpr bool _VSTD::ranges::enable_borrowed_range<_VSTD_FS::directory_iterator> = true;
+
+template <>
+_LIBCPP_AVAILABILITY_FILESYSTEM
+inline constexpr bool _VSTD::ranges::enable_view<_VSTD_FS::directory_iterator> = true;
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+#endif // _LIBCPP_CXX03_LANG
+
+#endif // _LIBCPP___FILESYSTEM_DIRECTORY_ITERATOR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/directory_options.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/directory_options.h
new file mode 100644
index 0000000000..d3f8cc1deb
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/directory_options.h
@@ -0,0 +1,82 @@
+// -*- 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___FILESYSTEM_DIRECTORY_OPTIONS_H
+#define _LIBCPP___FILESYSTEM_DIRECTORY_OPTIONS_H
+
+#include <__availability>
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+
+_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
+
+_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH
+
+enum class _LIBCPP_ENUM_VIS directory_options : unsigned char {
+ none = 0,
+ follow_directory_symlink = 1,
+ skip_permission_denied = 2
+};
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr directory_options operator&(directory_options _LHS,
+ directory_options _RHS) {
+ return static_cast<directory_options>(static_cast<unsigned char>(_LHS) &
+ static_cast<unsigned char>(_RHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr directory_options operator|(directory_options _LHS,
+ directory_options _RHS) {
+ return static_cast<directory_options>(static_cast<unsigned char>(_LHS) |
+ static_cast<unsigned char>(_RHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr directory_options operator^(directory_options _LHS,
+ directory_options _RHS) {
+ return static_cast<directory_options>(static_cast<unsigned char>(_LHS) ^
+ static_cast<unsigned char>(_RHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr directory_options operator~(directory_options _LHS) {
+ return static_cast<directory_options>(~static_cast<unsigned char>(_LHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline directory_options& operator&=(directory_options& _LHS,
+ directory_options _RHS) {
+ return _LHS = _LHS & _RHS;
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline directory_options& operator|=(directory_options& _LHS,
+ directory_options _RHS) {
+ return _LHS = _LHS | _RHS;
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline directory_options& operator^=(directory_options& _LHS,
+ directory_options _RHS) {
+ return _LHS = _LHS ^ _RHS;
+}
+
+_LIBCPP_AVAILABILITY_FILESYSTEM_POP
+
+_LIBCPP_END_NAMESPACE_FILESYSTEM
+
+#endif // _LIBCPP_CXX03_LANG
+
+#endif // _LIBCPP___FILESYSTEM_DIRECTORY_OPTIONS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/file_status.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/file_status.h
new file mode 100644
index 0000000000..ac3f6cbed9
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/file_status.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___FILESYSTEM_FILE_STATUS_H
+#define _LIBCPP___FILESYSTEM_FILE_STATUS_H
+
+#include <__availability>
+#include <__config>
+#include <__filesystem/file_type.h>
+#include <__filesystem/perms.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+
+_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
+
+_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH
+
+class _LIBCPP_TYPE_VIS file_status {
+public:
+ // constructors
+ _LIBCPP_INLINE_VISIBILITY
+ file_status() noexcept : file_status(file_type::none) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit file_status(file_type __ft, perms __prms = perms::unknown) noexcept
+ : __ft_(__ft),
+ __prms_(__prms) {}
+
+ file_status(const file_status&) noexcept = default;
+ file_status(file_status&&) noexcept = default;
+
+ _LIBCPP_INLINE_VISIBILITY
+ ~file_status() {}
+
+ file_status& operator=(const file_status&) noexcept = default;
+ file_status& operator=(file_status&&) noexcept = default;
+
+ // observers
+ _LIBCPP_INLINE_VISIBILITY
+ file_type type() const noexcept { return __ft_; }
+
+ _LIBCPP_INLINE_VISIBILITY
+ perms permissions() const noexcept { return __prms_; }
+
+ // modifiers
+ _LIBCPP_INLINE_VISIBILITY
+ void type(file_type __ft) noexcept { __ft_ = __ft; }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void permissions(perms __p) noexcept { __prms_ = __p; }
+
+private:
+ file_type __ft_;
+ perms __prms_;
+};
+
+_LIBCPP_AVAILABILITY_FILESYSTEM_POP
+
+_LIBCPP_END_NAMESPACE_FILESYSTEM
+
+#endif // _LIBCPP_CXX03_LANG
+
+#endif // _LIBCPP___FILESYSTEM_FILE_STATUS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/file_time_type.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/file_time_type.h
new file mode 100644
index 0000000000..620b5ec8d3
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/file_time_type.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___FILESYSTEM_FILE_TIME_TYPE_H
+#define _LIBCPP___FILESYSTEM_FILE_TIME_TYPE_H
+
+#include <__availability>
+#include <__config>
+#include <chrono>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+
+_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
+
+typedef chrono::time_point<_FilesystemClock> file_time_type;
+
+_LIBCPP_END_NAMESPACE_FILESYSTEM
+
+#endif // _LIBCPP_CXX03_LANG
+
+#endif // _LIBCPP___FILESYSTEM_FILE_TIME_TYPE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/file_type.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/file_type.h
new file mode 100644
index 0000000000..c756a05c84
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/file_type.h
@@ -0,0 +1,43 @@
+// -*- 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___FILESYSTEM_FILE_TYPE_H
+#define _LIBCPP___FILESYSTEM_FILE_TYPE_H
+
+#include <__availability>
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+
+_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
+
+// 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,
+ regular = 1,
+ directory = 2,
+ symlink = 3,
+ block = 4,
+ character = 5,
+ fifo = 6,
+ socket = 7,
+ unknown = 8
+};
+
+_LIBCPP_END_NAMESPACE_FILESYSTEM
+
+#endif // _LIBCPP_CXX03_LANG
+
+#endif // _LIBCPP___FILESYSTEM_FILE_TYPE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/filesystem_error.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/filesystem_error.h
new file mode 100644
index 0000000000..e32b14c1b7
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/filesystem_error.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___FILESYSTEM_FILESYSTEM_ERROR_H
+#define _LIBCPP___FILESYSTEM_FILESYSTEM_ERROR_H
+
+#include <__availability>
+#include <__config>
+#include <__filesystem/path.h>
+#include <__memory/shared_ptr.h>
+#include <iosfwd>
+#include <new>
+#include <system_error>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+
+_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
+
+class _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_EXCEPTION_ABI filesystem_error : public system_error {
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ filesystem_error(const string& __what, error_code __ec)
+ : system_error(__ec, __what),
+ __storage_(make_shared<_Storage>(path(), path())) {
+ __create_what(0);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ filesystem_error(const string& __what, const path& __p1, error_code __ec)
+ : system_error(__ec, __what),
+ __storage_(make_shared<_Storage>(__p1, path())) {
+ __create_what(1);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ filesystem_error(const string& __what, const path& __p1, const path& __p2,
+ error_code __ec)
+ : system_error(__ec, __what),
+ __storage_(make_shared<_Storage>(__p1, __p2)) {
+ __create_what(2);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ const path& path1() const noexcept { return __storage_->__p1_; }
+
+ _LIBCPP_INLINE_VISIBILITY
+ const path& path2() const noexcept { return __storage_->__p2_; }
+
+ filesystem_error(const filesystem_error&) = default;
+ ~filesystem_error() override; // key function
+
+ _LIBCPP_INLINE_VISIBILITY
+ const char* what() const noexcept override {
+ return __storage_->__what_.c_str();
+ }
+
+ void __create_what(int __num_paths);
+
+private:
+ struct _LIBCPP_HIDDEN _Storage {
+ _LIBCPP_INLINE_VISIBILITY
+ _Storage(const path& __p1, const path& __p2) : __p1_(__p1), __p2_(__p2) {}
+
+ path __p1_;
+ path __p2_;
+ string __what_;
+ };
+ shared_ptr<_Storage> __storage_;
+};
+
+// TODO(ldionne): We need to pop the pragma and push it again after
+// filesystem_error to work around PR41078.
+_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH
+
+template <class... _Args>
+_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
+#ifndef _LIBCPP_NO_EXCEPTIONS
+void __throw_filesystem_error(_Args&&... __args) {
+ throw filesystem_error(_VSTD::forward<_Args>(__args)...);
+}
+#else
+void __throw_filesystem_error(_Args&&...) {
+ _VSTD::abort();
+}
+#endif
+_LIBCPP_AVAILABILITY_FILESYSTEM_POP
+
+_LIBCPP_END_NAMESPACE_FILESYSTEM
+
+#endif // _LIBCPP_CXX03_LANG
+
+#endif // _LIBCPP___FILESYSTEM_FILESYSTEM_ERROR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/operations.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/operations.h
new file mode 100644
index 0000000000..894c501d4a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/operations.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___FILESYSTEM_OPERATIONS_H
+#define _LIBCPP___FILESYSTEM_OPERATIONS_H
+
+#include <__availability>
+#include <__config>
+#include <__filesystem/copy_options.h>
+#include <__filesystem/file_status.h>
+#include <__filesystem/file_time_type.h>
+#include <__filesystem/file_type.h>
+#include <__filesystem/path.h>
+#include <__filesystem/perm_options.h>
+#include <__filesystem/perms.h>
+#include <__filesystem/space_info.h>
+#include <chrono>
+#include <cstdint>
+#include <system_error>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+
+_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
+
+_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH
+
+_LIBCPP_FUNC_VIS path __absolute(const path&, error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS path __canonical(const path&, error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS bool __copy_file(const path& __from, const path& __to, copy_options __opt, error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS void __copy_symlink(const path& __existing_symlink, const path& __new_symlink, error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS void __copy(const path& __from, const path& __to, copy_options __opt, error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS bool __create_directories(const path& p, error_code* ec = nullptr);
+_LIBCPP_FUNC_VIS void __create_directory_symlink(const path& __to, const path& __new_symlink, error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS bool __create_directory(const path& p, error_code* ec = nullptr);
+_LIBCPP_FUNC_VIS bool __create_directory(const path& p, const path& attributes, error_code* ec = nullptr);
+_LIBCPP_FUNC_VIS void __create_hard_link(const path& __to, const path& __new_hard_link, error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS void __create_symlink(const path& __to, const path& __new_symlink, error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS path __current_path(error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS void __current_path(const path&, error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS bool __equivalent(const path&, const path&, error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS file_status __status(const path&, error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS uintmax_t __file_size(const path&, error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS uintmax_t __hard_link_count(const path&, error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS file_status __symlink_status(const path&, error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS file_time_type __last_write_time(const path& p, error_code* ec = nullptr);
+_LIBCPP_FUNC_VIS void __last_write_time(const path& p, file_time_type new_time, error_code* ec = nullptr);
+_LIBCPP_FUNC_VIS path __weakly_canonical(path const& __p, error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS path __read_symlink(const path& p, error_code* ec = nullptr);
+_LIBCPP_FUNC_VIS uintmax_t __remove_all(const path& p, error_code* ec = nullptr);
+_LIBCPP_FUNC_VIS bool __remove(const path& p, error_code* ec = nullptr);
+_LIBCPP_FUNC_VIS void __rename(const path& from, const path& to, error_code* ec = nullptr);
+_LIBCPP_FUNC_VIS void __resize_file(const path& p, uintmax_t size, error_code* ec = nullptr);
+_LIBCPP_FUNC_VIS path __temp_directory_path(error_code* __ec = nullptr);
+
+inline _LIBCPP_HIDE_FROM_ABI path absolute(const path& __p) { return __absolute(__p); }
+inline _LIBCPP_HIDE_FROM_ABI path absolute(const path& __p, error_code& __ec) { return __absolute(__p, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI path canonical(const path& __p) { return __canonical(__p); }
+inline _LIBCPP_HIDE_FROM_ABI path canonical(const path& __p, error_code& __ec) { return __canonical(__p, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI bool copy_file(const path& __from, const path& __to) { return __copy_file(__from, __to, copy_options::none); }
+inline _LIBCPP_HIDE_FROM_ABI bool copy_file(const path& __from, const path& __to, error_code& __ec) { return __copy_file(__from, __to, copy_options::none, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI bool copy_file(const path& __from, const path& __to, copy_options __opt) { return __copy_file(__from, __to, __opt); }
+inline _LIBCPP_HIDE_FROM_ABI bool copy_file(const path& __from, const path& __to, copy_options __opt, error_code& __ec) { return __copy_file(__from, __to, __opt, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI void copy_symlink(const path& __from, const path& __to) { __copy_symlink(__from, __to); }
+inline _LIBCPP_HIDE_FROM_ABI void copy_symlink(const path& __from, const path& __to, error_code& __ec) noexcept { __copy_symlink(__from, __to, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI void copy(const path& __from, const path& __to) { __copy(__from, __to, copy_options::none); }
+inline _LIBCPP_HIDE_FROM_ABI void copy(const path& __from, const path& __to, error_code& __ec) { __copy(__from, __to, copy_options::none, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI void copy(const path& __from, const path& __to, copy_options __opt) { __copy(__from, __to, __opt); }
+inline _LIBCPP_HIDE_FROM_ABI void copy(const path& __from, const path& __to, copy_options __opt, error_code& __ec) { __copy(__from, __to, __opt, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI bool create_directories(const path& __p) { return __create_directories(__p); }
+inline _LIBCPP_HIDE_FROM_ABI bool create_directories(const path& __p, error_code& __ec) { return __create_directories(__p, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI void create_directory_symlink(const path& __target, const path& __link) { __create_directory_symlink(__target, __link); }
+inline _LIBCPP_HIDE_FROM_ABI void create_directory_symlink(const path& __target, const path& __link, error_code& __ec) noexcept { __create_directory_symlink(__target, __link, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI bool create_directory(const path& __p) { return __create_directory(__p); }
+inline _LIBCPP_HIDE_FROM_ABI bool create_directory(const path& __p, error_code& __ec) noexcept { return __create_directory(__p, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI bool create_directory(const path& __p, const path& __attrs) { return __create_directory(__p, __attrs); }
+inline _LIBCPP_HIDE_FROM_ABI bool create_directory(const path& __p, const path& __attrs, error_code& __ec) noexcept { return __create_directory(__p, __attrs, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI void create_hard_link(const path& __target, const path& __link) { __create_hard_link(__target, __link); }
+inline _LIBCPP_HIDE_FROM_ABI void create_hard_link(const path& __target, const path& __link, error_code& __ec) noexcept { __create_hard_link(__target, __link, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI void create_symlink(const path& __target, const path& __link) { __create_symlink(__target, __link); }
+inline _LIBCPP_HIDE_FROM_ABI void create_symlink(const path& __target, const path& __link, error_code& __ec) noexcept { return __create_symlink(__target, __link, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI path current_path() { return __current_path(); }
+inline _LIBCPP_HIDE_FROM_ABI path current_path(error_code& __ec) { return __current_path(&__ec); }
+inline _LIBCPP_HIDE_FROM_ABI void current_path(const path& __p) { __current_path(__p); }
+inline _LIBCPP_HIDE_FROM_ABI void current_path(const path& __p, error_code& __ec) noexcept { __current_path(__p, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI bool equivalent(const path& __p1, const path& __p2) { return __equivalent(__p1, __p2); }
+inline _LIBCPP_HIDE_FROM_ABI bool equivalent(const path& __p1, const path& __p2, error_code& __ec) noexcept { return __equivalent(__p1, __p2, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI bool status_known(file_status __s) noexcept { return __s.type() != file_type::none; }
+inline _LIBCPP_HIDE_FROM_ABI bool exists(file_status __s) noexcept { return status_known(__s) && __s.type() != file_type::not_found; }
+inline _LIBCPP_HIDE_FROM_ABI bool exists(const path& __p) { return exists(__status(__p)); }
+
+inline _LIBCPP_INLINE_VISIBILITY bool exists(const path& __p, error_code& __ec) noexcept {
+ auto __s = __status(__p, &__ec);
+ if (status_known(__s))
+ __ec.clear();
+ return exists(__s);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI uintmax_t file_size(const path& __p) { return __file_size(__p); }
+inline _LIBCPP_HIDE_FROM_ABI uintmax_t file_size(const path& __p, error_code& __ec) noexcept { return __file_size(__p, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI uintmax_t hard_link_count(const path& __p) { return __hard_link_count(__p); }
+inline _LIBCPP_HIDE_FROM_ABI uintmax_t hard_link_count(const path& __p, error_code& __ec) noexcept { return __hard_link_count(__p, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_block_file(file_status __s) noexcept { return __s.type() == file_type::block; }
+inline _LIBCPP_HIDE_FROM_ABI bool is_block_file(const path& __p) { return is_block_file(__status(__p)); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_block_file(const path& __p, error_code& __ec) noexcept { return is_block_file(__status(__p, &__ec)); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_character_file(file_status __s) noexcept { return __s.type() == file_type::character; }
+inline _LIBCPP_HIDE_FROM_ABI bool is_character_file(const path& __p) { return is_character_file(__status(__p)); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_character_file(const path& __p, error_code& __ec) noexcept { return is_character_file(__status(__p, &__ec)); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_directory(file_status __s) noexcept { return __s.type() == file_type::directory; }
+inline _LIBCPP_HIDE_FROM_ABI bool is_directory(const path& __p) { return is_directory(__status(__p)); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_directory(const path& __p, error_code& __ec) noexcept { return is_directory(__status(__p, &__ec)); }
+_LIBCPP_FUNC_VIS bool __fs_is_empty(const path& p, error_code* ec = nullptr);
+inline _LIBCPP_HIDE_FROM_ABI bool is_empty(const path& __p) { return __fs_is_empty(__p); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_empty(const path& __p, error_code& __ec) { return __fs_is_empty(__p, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_fifo(file_status __s) noexcept { return __s.type() == file_type::fifo; }
+inline _LIBCPP_HIDE_FROM_ABI bool is_fifo(const path& __p) { return is_fifo(__status(__p)); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_fifo(const path& __p, error_code& __ec) noexcept { return is_fifo(__status(__p, &__ec)); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_regular_file(file_status __s) noexcept { return __s.type() == file_type::regular; }
+inline _LIBCPP_HIDE_FROM_ABI bool is_regular_file(const path& __p) { return is_regular_file(__status(__p)); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_regular_file(const path& __p, error_code& __ec) noexcept { return is_regular_file(__status(__p, &__ec)); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_symlink(file_status __s) noexcept { return __s.type() == file_type::symlink; }
+inline _LIBCPP_HIDE_FROM_ABI bool is_symlink(const path& __p) { return is_symlink(__symlink_status(__p)); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_symlink(const path& __p, error_code& __ec) noexcept { return is_symlink(__symlink_status(__p, &__ec)); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_other(file_status __s) noexcept { return exists(__s) && !is_regular_file(__s) && !is_directory(__s) && !is_symlink(__s); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_other(const path& __p) { return is_other(__status(__p)); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_other(const path& __p, error_code& __ec) noexcept { return is_other(__status(__p, &__ec)); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_socket(file_status __s) noexcept { return __s.type() == file_type::socket; }
+inline _LIBCPP_HIDE_FROM_ABI bool is_socket(const path& __p) { return is_socket(__status(__p)); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_socket(const path& __p, error_code& __ec) noexcept { return is_socket(__status(__p, &__ec)); }
+inline _LIBCPP_HIDE_FROM_ABI file_time_type last_write_time(const path& __p) { return __last_write_time(__p); }
+inline _LIBCPP_HIDE_FROM_ABI file_time_type last_write_time(const path& __p, error_code& __ec) noexcept { return __last_write_time(__p, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI void last_write_time(const path& __p, file_time_type __t) { __last_write_time(__p, __t); }
+inline _LIBCPP_HIDE_FROM_ABI void last_write_time(const path& __p, file_time_type __t, error_code& __ec) noexcept { __last_write_time(__p, __t, &__ec); }
+_LIBCPP_FUNC_VIS void __permissions(const path&, perms, perm_options, error_code* = nullptr);
+inline _LIBCPP_HIDE_FROM_ABI void permissions(const path& __p, perms __prms, perm_options __opts = perm_options::replace) { __permissions(__p, __prms, __opts); }
+inline _LIBCPP_HIDE_FROM_ABI void permissions(const path& __p, perms __prms, error_code& __ec) noexcept { __permissions(__p, __prms, perm_options::replace, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI void permissions(const path& __p, perms __prms, perm_options __opts, error_code& __ec) { __permissions(__p, __prms, __opts, &__ec); }
+
+inline _LIBCPP_INLINE_VISIBILITY path proximate(const path& __p, const path& __base, error_code& __ec) {
+ path __tmp = __weakly_canonical(__p, &__ec);
+ if (__ec)
+ return {};
+ path __tmp_base = __weakly_canonical(__base, &__ec);
+ if (__ec)
+ return {};
+ return __tmp.lexically_proximate(__tmp_base);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI path proximate(const path& __p, error_code& __ec) { return proximate(__p, current_path(), __ec); }
+inline _LIBCPP_HIDE_FROM_ABI path proximate(const path& __p, const path& __base = current_path()) { return __weakly_canonical(__p).lexically_proximate(__weakly_canonical(__base)); }
+inline _LIBCPP_HIDE_FROM_ABI path read_symlink(const path& __p) { return __read_symlink(__p); }
+inline _LIBCPP_HIDE_FROM_ABI path read_symlink(const path& __p, error_code& __ec) { return __read_symlink(__p, &__ec); }
+
+inline _LIBCPP_INLINE_VISIBILITY path relative(const path& __p, const path& __base, error_code& __ec) {
+ path __tmp = __weakly_canonical(__p, &__ec);
+ if (__ec)
+ return path();
+ path __tmpbase = __weakly_canonical(__base, &__ec);
+ if (__ec)
+ return path();
+ return __tmp.lexically_relative(__tmpbase);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI path relative(const path& __p, error_code& __ec) { return relative(__p, current_path(), __ec); }
+inline _LIBCPP_HIDE_FROM_ABI path relative(const path& __p, const path& __base = current_path()) { return __weakly_canonical(__p).lexically_relative(__weakly_canonical(__base)); }
+inline _LIBCPP_HIDE_FROM_ABI uintmax_t remove_all(const path& __p) { return __remove_all(__p); }
+inline _LIBCPP_HIDE_FROM_ABI uintmax_t remove_all(const path& __p, error_code& __ec) { return __remove_all(__p, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI bool remove(const path& __p) { return __remove(__p); }
+inline _LIBCPP_HIDE_FROM_ABI bool remove(const path& __p, error_code& __ec) noexcept { return __remove(__p, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI void rename(const path& __from, const path& __to) { return __rename(__from, __to); }
+inline _LIBCPP_HIDE_FROM_ABI void rename(const path& __from, const path& __to, error_code& __ec) noexcept { return __rename(__from, __to, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI void resize_file(const path& __p, uintmax_t __ns) { return __resize_file(__p, __ns); }
+inline _LIBCPP_HIDE_FROM_ABI void resize_file(const path& __p, uintmax_t __ns, error_code& __ec) noexcept { return __resize_file(__p, __ns, &__ec); }
+_LIBCPP_FUNC_VIS space_info __space(const path&, error_code* __ec = nullptr);
+inline _LIBCPP_HIDE_FROM_ABI space_info space(const path& __p) { return __space(__p); }
+inline _LIBCPP_HIDE_FROM_ABI space_info space(const path& __p, error_code& __ec) noexcept { return __space(__p, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI file_status status(const path& __p) { return __status(__p); }
+inline _LIBCPP_HIDE_FROM_ABI file_status status(const path& __p, error_code& __ec) noexcept { return __status(__p, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI file_status symlink_status(const path& __p) { return __symlink_status(__p); }
+inline _LIBCPP_HIDE_FROM_ABI file_status symlink_status(const path& __p, error_code& __ec) noexcept { return __symlink_status(__p, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI path temp_directory_path() { return __temp_directory_path(); }
+inline _LIBCPP_HIDE_FROM_ABI path temp_directory_path(error_code& __ec) { return __temp_directory_path(&__ec); }
+inline _LIBCPP_HIDE_FROM_ABI path weakly_canonical(path const& __p) { return __weakly_canonical(__p); }
+inline _LIBCPP_HIDE_FROM_ABI path weakly_canonical(path const& __p, error_code& __ec) { return __weakly_canonical(__p, &__ec); }
+
+_LIBCPP_AVAILABILITY_FILESYSTEM_POP
+
+_LIBCPP_END_NAMESPACE_FILESYSTEM
+
+#endif // _LIBCPP_CXX03_LANG
+
+#endif // _LIBCPP___FILESYSTEM_OPERATIONS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/path.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/path.h
new file mode 100644
index 0000000000..6b4b1ae9ba
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/path.h
@@ -0,0 +1,1024 @@
+// -*- 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___FILESYSTEM_PATH_H
+#define _LIBCPP___FILESYSTEM_PATH_H
+
+#include <__algorithm/replace.h>
+#include <__algorithm/replace_copy.h>
+#include <__availability>
+#include <__config>
+#include <__iterator/back_insert_iterator.h>
+#include <__iterator/iterator_traits.h>
+#include <cstddef>
+#include <string>
+#include <string_view>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# include <iomanip> // for quoted
+# include <locale>
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+
+_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
+
+_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH
+
+template <class _Tp>
+struct __can_convert_char {
+ static const bool value = false;
+};
+template <class _Tp>
+struct __can_convert_char<const _Tp> : public __can_convert_char<_Tp> {};
+template <>
+struct __can_convert_char<char> {
+ static const bool value = true;
+ using __char_type = char;
+};
+template <>
+struct __can_convert_char<wchar_t> {
+ static const bool value = true;
+ using __char_type = wchar_t;
+};
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
+template <>
+struct __can_convert_char<char8_t> {
+ static const bool value = true;
+ using __char_type = char8_t;
+};
+#endif
+template <>
+struct __can_convert_char<char16_t> {
+ static const bool value = true;
+ using __char_type = char16_t;
+};
+template <>
+struct __can_convert_char<char32_t> {
+ static const bool value = true;
+ using __char_type = char32_t;
+};
+
+template <class _ECharT>
+typename enable_if<__can_convert_char<_ECharT>::value, bool>::type
+__is_separator(_ECharT __e) {
+#if defined(_LIBCPP_WIN32API)
+ return __e == _ECharT('/') || __e == _ECharT('\\');
+#else
+ return __e == _ECharT('/');
+#endif
+}
+
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
+typedef u8string __u8_string;
+#else
+typedef string __u8_string;
+#endif
+
+struct _NullSentinel {};
+
+template <class _Tp>
+using _Void = void;
+
+template <class _Tp, class = void>
+struct __is_pathable_string : public false_type {};
+
+template <class _ECharT, class _Traits, class _Alloc>
+struct __is_pathable_string<
+ basic_string<_ECharT, _Traits, _Alloc>,
+ _Void<typename __can_convert_char<_ECharT>::__char_type> >
+ : public __can_convert_char<_ECharT> {
+ using _Str = basic_string<_ECharT, _Traits, _Alloc>;
+ using _Base = __can_convert_char<_ECharT>;
+ static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); }
+ static _ECharT const* __range_end(_Str const& __s) {
+ return __s.data() + __s.length();
+ }
+ static _ECharT __first_or_null(_Str const& __s) {
+ return __s.empty() ? _ECharT{} : __s[0];
+ }
+};
+
+template <class _ECharT, class _Traits>
+struct __is_pathable_string<
+ basic_string_view<_ECharT, _Traits>,
+ _Void<typename __can_convert_char<_ECharT>::__char_type> >
+ : public __can_convert_char<_ECharT> {
+ using _Str = basic_string_view<_ECharT, _Traits>;
+ using _Base = __can_convert_char<_ECharT>;
+ static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); }
+ static _ECharT const* __range_end(_Str const& __s) {
+ return __s.data() + __s.length();
+ }
+ static _ECharT __first_or_null(_Str const& __s) {
+ return __s.empty() ? _ECharT{} : __s[0];
+ }
+};
+
+template <class _Source, class _DS = typename decay<_Source>::type,
+ class _UnqualPtrType =
+ typename remove_const<typename remove_pointer<_DS>::type>::type,
+ bool _IsCharPtr = is_pointer<_DS>::value&&
+ __can_convert_char<_UnqualPtrType>::value>
+struct __is_pathable_char_array : false_type {};
+
+template <class _Source, class _ECharT, class _UPtr>
+struct __is_pathable_char_array<_Source, _ECharT*, _UPtr, true>
+ : __can_convert_char<typename remove_const<_ECharT>::type> {
+ using _Base = __can_convert_char<typename remove_const<_ECharT>::type>;
+
+ static _ECharT const* __range_begin(const _ECharT* __b) { return __b; }
+ static _ECharT const* __range_end(const _ECharT* __b) {
+ using _Iter = const _ECharT*;
+ const _ECharT __sentinel = _ECharT{};
+ _Iter __e = __b;
+ for (; *__e != __sentinel; ++__e)
+ ;
+ return __e;
+ }
+
+ static _ECharT __first_or_null(const _ECharT* __b) { return *__b; }
+};
+
+template <class _Iter, bool _IsIt = __is_cpp17_input_iterator<_Iter>::value,
+ class = void>
+struct __is_pathable_iter : false_type {};
+
+template <class _Iter>
+struct __is_pathable_iter<
+ _Iter, true,
+ _Void<typename __can_convert_char<
+ typename iterator_traits<_Iter>::value_type>::__char_type> >
+ : __can_convert_char<typename iterator_traits<_Iter>::value_type> {
+ using _ECharT = typename iterator_traits<_Iter>::value_type;
+ using _Base = __can_convert_char<_ECharT>;
+
+ static _Iter __range_begin(_Iter __b) { return __b; }
+ static _NullSentinel __range_end(_Iter) { return _NullSentinel{}; }
+
+ static _ECharT __first_or_null(_Iter __b) { return *__b; }
+};
+
+template <class _Tp, bool _IsStringT = __is_pathable_string<_Tp>::value,
+ bool _IsCharIterT = __is_pathable_char_array<_Tp>::value,
+ bool _IsIterT = !_IsCharIterT && __is_pathable_iter<_Tp>::value>
+struct __is_pathable : false_type {
+ static_assert(!_IsStringT && !_IsCharIterT && !_IsIterT, "Must all be false");
+};
+
+template <class _Tp>
+struct __is_pathable<_Tp, true, false, false> : __is_pathable_string<_Tp> {};
+
+template <class _Tp>
+struct __is_pathable<_Tp, false, true, false> : __is_pathable_char_array<_Tp> {
+};
+
+template <class _Tp>
+struct __is_pathable<_Tp, false, false, true> : __is_pathable_iter<_Tp> {};
+
+#if defined(_LIBCPP_WIN32API)
+typedef wstring __path_string;
+typedef wchar_t __path_value;
+#else
+typedef string __path_string;
+typedef char __path_value;
+#endif
+
+#if defined(_LIBCPP_WIN32API)
+_LIBCPP_FUNC_VIS
+size_t __wide_to_char(const wstring&, char*, size_t);
+_LIBCPP_FUNC_VIS
+size_t __char_to_wide(const string&, wchar_t*, size_t);
+#endif
+
+template <class _ECharT>
+struct _PathCVT;
+
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+template <class _ECharT>
+struct _PathCVT {
+ static_assert(__can_convert_char<_ECharT>::value,
+ "Char type not convertible");
+
+ typedef __narrow_to_utf8<sizeof(_ECharT) * __CHAR_BIT__> _Narrower;
+#if defined(_LIBCPP_WIN32API)
+ typedef __widen_from_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Widener;
+#endif
+
+ static void __append_range(__path_string& __dest, _ECharT const* __b,
+ _ECharT const* __e) {
+#if defined(_LIBCPP_WIN32API)
+ string __utf8;
+ _Narrower()(back_inserter(__utf8), __b, __e);
+ _Widener()(back_inserter(__dest), __utf8.data(), __utf8.data() + __utf8.size());
+#else
+ _Narrower()(back_inserter(__dest), __b, __e);
+#endif
+ }
+
+ template <class _Iter>
+ static void __append_range(__path_string& __dest, _Iter __b, _Iter __e) {
+ static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload");
+ if (__b == __e)
+ return;
+ basic_string<_ECharT> __tmp(__b, __e);
+#if defined(_LIBCPP_WIN32API)
+ string __utf8;
+ _Narrower()(back_inserter(__utf8), __tmp.data(),
+ __tmp.data() + __tmp.length());
+ _Widener()(back_inserter(__dest), __utf8.data(), __utf8.data() + __utf8.size());
+#else
+ _Narrower()(back_inserter(__dest), __tmp.data(),
+ __tmp.data() + __tmp.length());
+#endif
+ }
+
+ template <class _Iter>
+ static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) {
+ static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload");
+ const _ECharT __sentinel = _ECharT{};
+ if (*__b == __sentinel)
+ return;
+ basic_string<_ECharT> __tmp;
+ for (; *__b != __sentinel; ++__b)
+ __tmp.push_back(*__b);
+#if defined(_LIBCPP_WIN32API)
+ string __utf8;
+ _Narrower()(back_inserter(__utf8), __tmp.data(),
+ __tmp.data() + __tmp.length());
+ _Widener()(back_inserter(__dest), __utf8.data(), __utf8.data() + __utf8.size());
+#else
+ _Narrower()(back_inserter(__dest), __tmp.data(),
+ __tmp.data() + __tmp.length());
+#endif
+ }
+
+ template <class _Source>
+ static void __append_source(__path_string& __dest, _Source const& __s) {
+ using _Traits = __is_pathable<_Source>;
+ __append_range(__dest, _Traits::__range_begin(__s),
+ _Traits::__range_end(__s));
+ }
+};
+#endif // !_LIBCPP_HAS_NO_LOCALIZATION
+
+template <>
+struct _PathCVT<__path_value> {
+
+ template <class _Iter>
+ static typename enable_if<__is_exactly_cpp17_input_iterator<_Iter>::value>::type
+ __append_range(__path_string& __dest, _Iter __b, _Iter __e) {
+ for (; __b != __e; ++__b)
+ __dest.push_back(*__b);
+ }
+
+ 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(__b, __e);
+ }
+
+ template <class _Iter>
+ static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) {
+ const char __sentinel = char{};
+ for (; *__b != __sentinel; ++__b)
+ __dest.push_back(*__b);
+ }
+
+ template <class _Source>
+ static void __append_source(__path_string& __dest, _Source const& __s) {
+ using _Traits = __is_pathable<_Source>;
+ __append_range(__dest, _Traits::__range_begin(__s),
+ _Traits::__range_end(__s));
+ }
+};
+
+#if defined(_LIBCPP_WIN32API)
+template <>
+struct _PathCVT<char> {
+
+ static void
+ __append_string(__path_string& __dest, const basic_string<char> &__str) {
+ size_t __size = __char_to_wide(__str, nullptr, 0);
+ size_t __pos = __dest.size();
+ __dest.resize(__pos + __size);
+ __char_to_wide(__str, const_cast<__path_value*>(__dest.data()) + __pos, __size);
+ }
+
+ template <class _Iter>
+ static typename enable_if<__is_exactly_cpp17_input_iterator<_Iter>::value>::type
+ __append_range(__path_string& __dest, _Iter __b, _Iter __e) {
+ basic_string<char> __tmp(__b, __e);
+ __append_string(__dest, __tmp);
+ }
+
+ template <class _Iter>
+ static typename enable_if<__is_cpp17_forward_iterator<_Iter>::value>::type
+ __append_range(__path_string& __dest, _Iter __b, _Iter __e) {
+ basic_string<char> __tmp(__b, __e);
+ __append_string(__dest, __tmp);
+ }
+
+ template <class _Iter>
+ static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) {
+ const char __sentinel = char{};
+ basic_string<char> __tmp;
+ for (; *__b != __sentinel; ++__b)
+ __tmp.push_back(*__b);
+ __append_string(__dest, __tmp);
+ }
+
+ template <class _Source>
+ static void __append_source(__path_string& __dest, _Source const& __s) {
+ using _Traits = __is_pathable<_Source>;
+ __append_range(__dest, _Traits::__range_begin(__s),
+ _Traits::__range_end(__s));
+ }
+};
+
+template <class _ECharT>
+struct _PathExport {
+ typedef __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Narrower;
+ typedef __widen_from_utf8<sizeof(_ECharT) * __CHAR_BIT__> _Widener;
+
+ template <class _Str>
+ static void __append(_Str& __dest, const __path_string& __src) {
+ string __utf8;
+ _Narrower()(back_inserter(__utf8), __src.data(), __src.data() + __src.size());
+ _Widener()(back_inserter(__dest), __utf8.data(), __utf8.data() + __utf8.size());
+ }
+};
+
+template <>
+struct _PathExport<char> {
+ template <class _Str>
+ static void __append(_Str& __dest, const __path_string& __src) {
+ size_t __size = __wide_to_char(__src, nullptr, 0);
+ size_t __pos = __dest.size();
+ __dest.resize(__size);
+ __wide_to_char(__src, const_cast<char*>(__dest.data()) + __pos, __size);
+ }
+};
+
+template <>
+struct _PathExport<wchar_t> {
+ template <class _Str>
+ static void __append(_Str& __dest, const __path_string& __src) {
+ __dest.append(__src.begin(), __src.end());
+ }
+};
+
+template <>
+struct _PathExport<char16_t> {
+ template <class _Str>
+ static void __append(_Str& __dest, const __path_string& __src) {
+ __dest.append(__src.begin(), __src.end());
+ }
+};
+
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
+template <>
+struct _PathExport<char8_t> {
+ typedef __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Narrower;
+
+ template <class _Str>
+ static void __append(_Str& __dest, const __path_string& __src) {
+ _Narrower()(back_inserter(__dest), __src.data(), __src.data() + __src.size());
+ }
+};
+#endif /* !_LIBCPP_HAS_NO_CHAR8_T */
+#endif /* _LIBCPP_WIN32API */
+
+class _LIBCPP_TYPE_VIS path {
+ template <class _SourceOrIter, class _Tp = path&>
+ using _EnableIfPathable =
+ typename enable_if<__is_pathable<_SourceOrIter>::value, _Tp>::type;
+
+ template <class _Tp>
+ using _SourceChar = typename __is_pathable<_Tp>::__char_type;
+
+ template <class _Tp>
+ using _SourceCVT = _PathCVT<_SourceChar<_Tp> >;
+
+public:
+#if defined(_LIBCPP_WIN32API)
+ typedef wchar_t value_type;
+ static constexpr value_type preferred_separator = L'\\';
+#else
+ typedef char value_type;
+ static constexpr value_type preferred_separator = '/';
+#endif
+ typedef basic_string<value_type> string_type;
+ typedef basic_string_view<value_type> __string_view;
+
+ enum _LIBCPP_ENUM_VIS format : unsigned char {
+ auto_format,
+ native_format,
+ generic_format
+ };
+
+ // constructors and destructor
+ _LIBCPP_INLINE_VISIBILITY path() noexcept {}
+ _LIBCPP_INLINE_VISIBILITY path(const path& __p) : __pn_(__p.__pn_) {}
+ _LIBCPP_INLINE_VISIBILITY path(path&& __p) noexcept
+ : __pn_(_VSTD::move(__p.__pn_)) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ path(string_type&& __s, format = format::auto_format) noexcept
+ : __pn_(_VSTD::move(__s)) {}
+
+ template <class _Source, class = _EnableIfPathable<_Source, void> >
+ path(const _Source& __src, format = format::auto_format) {
+ _SourceCVT<_Source>::__append_source(__pn_, __src);
+ }
+
+ template <class _InputIt>
+ path(_InputIt __first, _InputIt __last, format = format::auto_format) {
+ typedef typename iterator_traits<_InputIt>::value_type _ItVal;
+ _PathCVT<_ItVal>::__append_range(__pn_, __first, __last);
+ }
+
+/*
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+ // TODO Implement locale conversions.
+ template <class _Source, class = _EnableIfPathable<_Source, void> >
+ path(const _Source& __src, const locale& __loc, format = format::auto_format);
+ template <class _InputIt>
+ path(_InputIt __first, _InputIt _last, const locale& __loc,
+ format = format::auto_format);
+#endif
+*/
+
+ _LIBCPP_INLINE_VISIBILITY
+ ~path() = default;
+
+ // assignments
+ _LIBCPP_INLINE_VISIBILITY
+ path& operator=(const path& __p) {
+ __pn_ = __p.__pn_;
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ path& operator=(path&& __p) noexcept {
+ __pn_ = _VSTD::move(__p.__pn_);
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ path& operator=(string_type&& __s) noexcept {
+ __pn_ = _VSTD::move(__s);
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ path& assign(string_type&& __s) noexcept {
+ __pn_ = _VSTD::move(__s);
+ return *this;
+ }
+
+ template <class _Source>
+ _LIBCPP_INLINE_VISIBILITY _EnableIfPathable<_Source>
+ operator=(const _Source& __src) {
+ return this->assign(__src);
+ }
+
+ template <class _Source>
+ _EnableIfPathable<_Source> assign(const _Source& __src) {
+ __pn_.clear();
+ _SourceCVT<_Source>::__append_source(__pn_, __src);
+ return *this;
+ }
+
+ template <class _InputIt>
+ path& assign(_InputIt __first, _InputIt __last) {
+ typedef typename iterator_traits<_InputIt>::value_type _ItVal;
+ __pn_.clear();
+ _PathCVT<_ItVal>::__append_range(__pn_, __first, __last);
+ return *this;
+ }
+
+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 != __string_view(root_name().__pn_))) {
+ __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_;
+ return *this;
+ }
+ if (has_filename())
+ __pn_ += preferred_separator;
+ __pn_ += __p.native();
+ return *this;
+ }
+
+ // FIXME: Use _LIBCPP_DIAGNOSE_WARNING to produce a diagnostic when __src
+ // is known at compile time to be "/' since the user almost certainly intended
+ // to append a separator instead of overwriting the path with "/"
+ template <class _Source>
+ _LIBCPP_INLINE_VISIBILITY _EnableIfPathable<_Source>
+ operator/=(const _Source& __src) {
+ return this->append(__src);
+ }
+
+ template <class _Source>
+ _EnableIfPathable<_Source> append(const _Source& __src) {
+ using _Traits = __is_pathable<_Source>;
+ using _CVT = _PathCVT<_SourceChar<_Source> >;
+ bool __source_is_absolute = __is_separator(_Traits::__first_or_null(__src));
+ if (__source_is_absolute)
+ __pn_.clear();
+ else if (has_filename())
+ __pn_ += preferred_separator;
+ _CVT::__append_source(__pn_, __src);
+ return *this;
+ }
+
+ template <class _InputIt>
+ path& append(_InputIt __first, _InputIt __last) {
+ typedef typename iterator_traits<_InputIt>::value_type _ItVal;
+ static_assert(__can_convert_char<_ItVal>::value, "Must convertible");
+ using _CVT = _PathCVT<_ItVal>;
+ 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
+ path& operator+=(const path& __x) {
+ __pn_ += __x.__pn_;
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ path& operator+=(const string_type& __x) {
+ __pn_ += __x;
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ path& operator+=(__string_view __x) {
+ __pn_ += __x;
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ path& operator+=(const value_type* __x) {
+ __pn_ += __x;
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ path& operator+=(value_type __x) {
+ __pn_ += __x;
+ return *this;
+ }
+
+ template <class _ECharT>
+ typename enable_if<__can_convert_char<_ECharT>::value, path&>::type
+ operator+=(_ECharT __x) {
+ _PathCVT<_ECharT>::__append_source(__pn_,
+ basic_string_view<_ECharT>(&__x, 1));
+ return *this;
+ }
+
+ template <class _Source>
+ _EnableIfPathable<_Source> operator+=(const _Source& __x) {
+ return this->concat(__x);
+ }
+
+ template <class _Source>
+ _EnableIfPathable<_Source> concat(const _Source& __x) {
+ _SourceCVT<_Source>::__append_source(__pn_, __x);
+ return *this;
+ }
+
+ template <class _InputIt>
+ path& concat(_InputIt __first, _InputIt __last) {
+ typedef typename iterator_traits<_InputIt>::value_type _ItVal;
+ _PathCVT<_ItVal>::__append_range(__pn_, __first, __last);
+ return *this;
+ }
+
+ // modifiers
+ _LIBCPP_INLINE_VISIBILITY
+ void clear() noexcept { __pn_.clear(); }
+
+ path& make_preferred() {
+#if defined(_LIBCPP_WIN32API)
+ _VSTD::replace(__pn_.begin(), __pn_.end(), L'/', L'\\');
+#endif
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ path& remove_filename() {
+ auto __fname = __filename();
+ if (!__fname.empty())
+ __pn_.erase(__fname.data() - __pn_.data());
+ return *this;
+ }
+
+ path& replace_filename(const path& __replacement) {
+ remove_filename();
+ return (*this /= __replacement);
+ }
+
+ path& replace_extension(const path& __replacement = path());
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(path& __rhs) noexcept { __pn_.swap(__rhs.__pn_); }
+
+ // private helper to allow reserving memory in the path
+ _LIBCPP_INLINE_VISIBILITY
+ void __reserve(size_t __s) { __pn_.reserve(__s); }
+
+ // native format observers
+ _LIBCPP_INLINE_VISIBILITY
+ const string_type& native() const noexcept { return __pn_; }
+
+ _LIBCPP_INLINE_VISIBILITY
+ const value_type* c_str() const noexcept { return __pn_.c_str(); }
+
+ _LIBCPP_INLINE_VISIBILITY operator string_type() const { return __pn_; }
+
+#if defined(_LIBCPP_WIN32API)
+ _LIBCPP_INLINE_VISIBILITY _VSTD::wstring 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>,
+ class _Allocator = allocator<_ECharT> >
+ basic_string<_ECharT, _Traits, _Allocator>
+ string(const _Allocator& __a = _Allocator()) const {
+ using _Str = basic_string<_ECharT, _Traits, _Allocator>;
+ _Str __s(__a);
+ __s.reserve(__pn_.size());
+ _PathExport<_ECharT>::__append(__s, __pn_);
+ return __s;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY _VSTD::string string() const {
+ return string<char>();
+ }
+ _LIBCPP_INLINE_VISIBILITY __u8_string u8string() const {
+ using _CVT = __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__>;
+ __u8_string __s;
+ __s.reserve(__pn_.size());
+ _CVT()(back_inserter(__s), __pn_.data(), __pn_.data() + __pn_.size());
+ return __s;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY _VSTD::u16string u16string() const {
+ return string<char16_t>();
+ }
+ _LIBCPP_INLINE_VISIBILITY _VSTD::u32string u32string() const {
+ return string<char32_t>();
+ }
+
+ // generic format observers
+ template <class _ECharT, class _Traits = char_traits<_ECharT>,
+ class _Allocator = allocator<_ECharT> >
+ basic_string<_ECharT, _Traits, _Allocator>
+ generic_string(const _Allocator& __a = _Allocator()) const {
+ 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 {
+ __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_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_; }
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+ template <class _ECharT, class _Traits = char_traits<_ECharT>,
+ class _Allocator = allocator<_ECharT> >
+ basic_string<_ECharT, _Traits, _Allocator>
+ string(const _Allocator& __a = _Allocator()) const {
+ using _CVT = __widen_from_utf8<sizeof(_ECharT) * __CHAR_BIT__>;
+ using _Str = basic_string<_ECharT, _Traits, _Allocator>;
+ _Str __s(__a);
+ __s.reserve(__pn_.size());
+ _CVT()(back_inserter(__s), __pn_.data(), __pn_.data() + __pn_.size());
+ return __s;
+ }
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ _LIBCPP_INLINE_VISIBILITY _VSTD::wstring wstring() const {
+ return string<wchar_t>();
+ }
+#endif
+ _LIBCPP_INLINE_VISIBILITY _VSTD::u16string u16string() const {
+ return string<char16_t>();
+ }
+ _LIBCPP_INLINE_VISIBILITY _VSTD::u32string u32string() const {
+ return string<char32_t>();
+ }
+#endif /* !_LIBCPP_HAS_NO_LOCALIZATION */
+
+ // generic format observers
+ _VSTD::string generic_string() const { return __pn_; }
+#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_; }
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+ template <class _ECharT, class _Traits = char_traits<_ECharT>,
+ class _Allocator = allocator<_ECharT> >
+ basic_string<_ECharT, _Traits, _Allocator>
+ generic_string(const _Allocator& __a = _Allocator()) const {
+ return string<_ECharT, _Traits, _Allocator>(__a);
+ }
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ _VSTD::wstring generic_wstring() const { return string<wchar_t>(); }
+#endif
+ _VSTD::u16string generic_u16string() const { return string<char16_t>(); }
+ _VSTD::u32string generic_u32string() const { return string<char32_t>(); }
+#endif /* !_LIBCPP_HAS_NO_LOCALIZATION */
+#endif /* !_LIBCPP_WIN32API */
+
+private:
+ int __compare(__string_view) const;
+ __string_view __root_name() const;
+ __string_view __root_directory() const;
+ __string_view __root_path_raw() const;
+ __string_view __relative_path() const;
+ __string_view __parent_path() const;
+ __string_view __filename() const;
+ __string_view __stem() const;
+ __string_view __extension() const;
+
+public:
+ // compare
+ _LIBCPP_INLINE_VISIBILITY int compare(const path& __p) const noexcept {
+ return __compare(__p.__pn_);
+ }
+ _LIBCPP_INLINE_VISIBILITY int compare(const string_type& __s) const {
+ return __compare(__s);
+ }
+ _LIBCPP_INLINE_VISIBILITY int compare(__string_view __s) const {
+ return __compare(__s);
+ }
+ _LIBCPP_INLINE_VISIBILITY int compare(const value_type* __s) const {
+ return __compare(__s);
+ }
+
+ // decomposition
+ _LIBCPP_INLINE_VISIBILITY path root_name() const {
+ return string_type(__root_name());
+ }
+ _LIBCPP_INLINE_VISIBILITY path root_directory() const {
+ 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());
+ }
+ _LIBCPP_INLINE_VISIBILITY path parent_path() const {
+ return string_type(__parent_path());
+ }
+ _LIBCPP_INLINE_VISIBILITY path filename() const {
+ return string_type(__filename());
+ }
+ _LIBCPP_INLINE_VISIBILITY path stem() const { return string_type(__stem()); }
+ _LIBCPP_INLINE_VISIBILITY path extension() const {
+ return string_type(__extension());
+ }
+
+ // query
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY bool
+ empty() const noexcept {
+ return __pn_.empty();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY bool has_root_name() const {
+ return !__root_name().empty();
+ }
+ _LIBCPP_INLINE_VISIBILITY bool has_root_directory() const {
+ return !__root_directory().empty();
+ }
+ _LIBCPP_INLINE_VISIBILITY bool has_root_path() const {
+ return !__root_path_raw().empty();
+ }
+ _LIBCPP_INLINE_VISIBILITY bool has_relative_path() const {
+ return !__relative_path().empty();
+ }
+ _LIBCPP_INLINE_VISIBILITY bool has_parent_path() const {
+ return !__parent_path().empty();
+ }
+ _LIBCPP_INLINE_VISIBILITY bool has_filename() const {
+ return !__filename().empty();
+ }
+ _LIBCPP_INLINE_VISIBILITY bool has_stem() const { return !__stem().empty(); }
+ _LIBCPP_INLINE_VISIBILITY bool has_extension() const {
+ return !__extension().empty();
+ }
+
+ _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(); }
+
+ // relative paths
+ path lexically_normal() const;
+ path lexically_relative(const path& __base) const;
+
+ _LIBCPP_INLINE_VISIBILITY path lexically_proximate(const path& __base) const {
+ path __result = this->lexically_relative(__base);
+ if (__result.native().empty())
+ return *this;
+ return __result;
+ }
+
+ // iterators
+ class _LIBCPP_TYPE_VIS iterator;
+ typedef iterator const_iterator;
+
+ iterator begin() const;
+ iterator end() const;
+
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+ template <class _CharT, class _Traits>
+ _LIBCPP_INLINE_VISIBILITY friend
+ typename enable_if<is_same<_CharT, value_type>::value &&
+ is_same<_Traits, char_traits<value_type> >::value,
+ basic_ostream<_CharT, _Traits>&>::type
+ operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) {
+ __os << _VSTD::__quoted(__p.native());
+ return __os;
+ }
+
+ template <class _CharT, class _Traits>
+ _LIBCPP_INLINE_VISIBILITY friend
+ typename enable_if<!is_same<_CharT, value_type>::value ||
+ !is_same<_Traits, char_traits<value_type> >::value,
+ basic_ostream<_CharT, _Traits>&>::type
+ operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) {
+ __os << _VSTD::__quoted(__p.string<_CharT, _Traits>());
+ return __os;
+ }
+
+ template <class _CharT, class _Traits>
+ _LIBCPP_INLINE_VISIBILITY friend basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is, path& __p) {
+ basic_string<_CharT, _Traits> __tmp;
+ __is >> __quoted(__tmp);
+ __p = __tmp;
+ return __is;
+ }
+#endif // !_LIBCPP_HAS_NO_LOCALIZATION
+
+ friend _LIBCPP_INLINE_VISIBILITY bool operator==(const path& __lhs, const path& __rhs) noexcept {
+ return __lhs.__compare(__rhs.__pn_) == 0;
+ }
+ friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const path& __lhs, const path& __rhs) noexcept {
+ return __lhs.__compare(__rhs.__pn_) != 0;
+ }
+ friend _LIBCPP_INLINE_VISIBILITY bool operator<(const path& __lhs, const path& __rhs) noexcept {
+ return __lhs.__compare(__rhs.__pn_) < 0;
+ }
+ friend _LIBCPP_INLINE_VISIBILITY bool operator<=(const path& __lhs, const path& __rhs) noexcept {
+ return __lhs.__compare(__rhs.__pn_) <= 0;
+ }
+ friend _LIBCPP_INLINE_VISIBILITY bool operator>(const path& __lhs, const path& __rhs) noexcept {
+ return __lhs.__compare(__rhs.__pn_) > 0;
+ }
+ friend _LIBCPP_INLINE_VISIBILITY bool operator>=(const path& __lhs, const path& __rhs) noexcept {
+ return __lhs.__compare(__rhs.__pn_) >= 0;
+ }
+
+ friend _LIBCPP_INLINE_VISIBILITY path operator/(const path& __lhs,
+ const path& __rhs) {
+ path __result(__lhs);
+ __result /= __rhs;
+ return __result;
+ }
+private:
+ inline _LIBCPP_INLINE_VISIBILITY path&
+ __assign_view(__string_view const& __s) noexcept {
+ __pn_ = string_type(__s);
+ return *this;
+ }
+ string_type __pn_;
+};
+
+inline _LIBCPP_INLINE_VISIBILITY void swap(path& __lhs, path& __rhs) noexcept {
+ __lhs.swap(__rhs);
+}
+
+_LIBCPP_FUNC_VIS
+size_t hash_value(const path& __p) noexcept;
+
+_LIBCPP_AVAILABILITY_FILESYSTEM_POP
+
+_LIBCPP_END_NAMESPACE_FILESYSTEM
+
+#endif // _LIBCPP_CXX03_LANG
+
+#endif // _LIBCPP___FILESYSTEM_PATH_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/path_iterator.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/path_iterator.h
new file mode 100644
index 0000000000..6f2baf8f7a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/path_iterator.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___FILESYSTEM_PATH_ITERATOR_H
+#define _LIBCPP___FILESYSTEM_PATH_ITERATOR_H
+
+#include <__assert>
+#include <__availability>
+#include <__config>
+#include <__filesystem/path.h>
+#include <__iterator/iterator_traits.h>
+#include <cstddef>
+#include <string>
+#include <string_view>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+
+_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
+
+_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH
+
+class _LIBCPP_TYPE_VIS path::iterator {
+public:
+ enum _ParserState : unsigned char {
+ _Singular,
+ _BeforeBegin,
+ _InRootName,
+ _InRootDir,
+ _InFilenames,
+ _InTrailingSep,
+ _AtEnd
+ };
+
+public:
+ typedef input_iterator_tag iterator_category;
+ typedef bidirectional_iterator_tag iterator_concept;
+
+ typedef path value_type;
+ typedef ptrdiff_t difference_type;
+ typedef const path* pointer;
+ typedef path reference;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ iterator()
+ : __stashed_elem_(), __path_ptr_(nullptr), __entry_(),
+ __state_(_Singular) {}
+
+ iterator(const iterator&) = default;
+ ~iterator() = default;
+
+ iterator& operator=(const iterator&) = default;
+
+ _LIBCPP_INLINE_VISIBILITY
+ reference operator*() const { return __stashed_elem_; }
+
+ _LIBCPP_INLINE_VISIBILITY
+ pointer operator->() const { return &__stashed_elem_; }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator& operator++() {
+ _LIBCPP_ASSERT(__state_ != _Singular,
+ "attempting to increment a singular iterator");
+ _LIBCPP_ASSERT(__state_ != _AtEnd,
+ "attempting to increment the end iterator");
+ return __increment();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator operator++(int) {
+ iterator __it(*this);
+ this->operator++();
+ return __it;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator& operator--() {
+ _LIBCPP_ASSERT(__state_ != _Singular,
+ "attempting to decrement a singular iterator");
+ _LIBCPP_ASSERT(__entry_.data() != __path_ptr_->native().data(),
+ "attempting to decrement the begin iterator");
+ return __decrement();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator operator--(int) {
+ iterator __it(*this);
+ this->operator--();
+ return __it;
+ }
+
+private:
+ friend class path;
+
+ inline _LIBCPP_INLINE_VISIBILITY friend bool operator==(const iterator&,
+ const iterator&);
+
+ iterator& __increment();
+ iterator& __decrement();
+
+ path __stashed_elem_;
+ const path* __path_ptr_;
+ path::__string_view __entry_;
+ _ParserState __state_;
+};
+
+inline _LIBCPP_INLINE_VISIBILITY bool operator==(const path::iterator& __lhs,
+ const path::iterator& __rhs) {
+ return __lhs.__path_ptr_ == __rhs.__path_ptr_ &&
+ __lhs.__entry_.data() == __rhs.__entry_.data();
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const path::iterator& __lhs,
+ const path::iterator& __rhs) {
+ return !(__lhs == __rhs);
+}
+
+_LIBCPP_AVAILABILITY_FILESYSTEM_POP
+
+_LIBCPP_END_NAMESPACE_FILESYSTEM
+
+#endif // _LIBCPP_CXX03_LANG
+
+#endif // _LIBCPP___FILESYSTEM_PATH_ITERATOR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/perm_options.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/perm_options.h
new file mode 100644
index 0000000000..f7580a2473
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/perm_options.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___FILESYSTEM_PERM_OPTIONS_H
+#define _LIBCPP___FILESYSTEM_PERM_OPTIONS_H
+
+#include <__availability>
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+
+_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
+
+_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH
+
+enum class _LIBCPP_ENUM_VIS perm_options : unsigned char {
+ replace = 1,
+ add = 2,
+ remove = 4,
+ nofollow = 8
+};
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr perm_options operator&(perm_options _LHS, perm_options _RHS) {
+ return static_cast<perm_options>(static_cast<unsigned>(_LHS) &
+ static_cast<unsigned>(_RHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr perm_options operator|(perm_options _LHS, perm_options _RHS) {
+ return static_cast<perm_options>(static_cast<unsigned>(_LHS) |
+ static_cast<unsigned>(_RHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr perm_options operator^(perm_options _LHS, perm_options _RHS) {
+ return static_cast<perm_options>(static_cast<unsigned>(_LHS) ^
+ static_cast<unsigned>(_RHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr perm_options operator~(perm_options _LHS) {
+ return static_cast<perm_options>(~static_cast<unsigned>(_LHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline perm_options& operator&=(perm_options& _LHS, perm_options _RHS) {
+ return _LHS = _LHS & _RHS;
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline perm_options& operator|=(perm_options& _LHS, perm_options _RHS) {
+ return _LHS = _LHS | _RHS;
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline perm_options& operator^=(perm_options& _LHS, perm_options _RHS) {
+ return _LHS = _LHS ^ _RHS;
+}
+
+_LIBCPP_AVAILABILITY_FILESYSTEM_POP
+
+_LIBCPP_END_NAMESPACE_FILESYSTEM
+
+#endif // _LIBCPP_CXX03_LANG
+
+#endif // _LIBCPP___FILESYSTEM_PERM_OPTIONS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/perms.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/perms.h
new file mode 100644
index 0000000000..0e5c7ed8d2
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/perms.h
@@ -0,0 +1,95 @@
+// -*- 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___FILESYSTEM_PERMS_H
+#define _LIBCPP___FILESYSTEM_PERMS_H
+
+#include <__availability>
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+
+_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
+
+_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH
+
+// 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,
+
+ owner_read = 0400,
+ owner_write = 0200,
+ owner_exec = 0100,
+ owner_all = 0700,
+
+ group_read = 040,
+ group_write = 020,
+ group_exec = 010,
+ group_all = 070,
+
+ others_read = 04,
+ others_write = 02,
+ others_exec = 01,
+ others_all = 07,
+
+ all = 0777,
+
+ set_uid = 04000,
+ set_gid = 02000,
+ sticky_bit = 01000,
+ mask = 07777,
+ unknown = 0xFFFF,
+};
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr perms operator&(perms _LHS, perms _RHS) {
+ return static_cast<perms>(static_cast<unsigned>(_LHS) &
+ static_cast<unsigned>(_RHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr perms operator|(perms _LHS, perms _RHS) {
+ return static_cast<perms>(static_cast<unsigned>(_LHS) |
+ static_cast<unsigned>(_RHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr perms operator^(perms _LHS, perms _RHS) {
+ return static_cast<perms>(static_cast<unsigned>(_LHS) ^
+ static_cast<unsigned>(_RHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr perms operator~(perms _LHS) {
+ return static_cast<perms>(~static_cast<unsigned>(_LHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline perms& operator&=(perms& _LHS, perms _RHS) { return _LHS = _LHS & _RHS; }
+
+_LIBCPP_INLINE_VISIBILITY
+inline perms& operator|=(perms& _LHS, perms _RHS) { return _LHS = _LHS | _RHS; }
+
+_LIBCPP_INLINE_VISIBILITY
+inline perms& operator^=(perms& _LHS, perms _RHS) { return _LHS = _LHS ^ _RHS; }
+
+_LIBCPP_AVAILABILITY_FILESYSTEM_POP
+
+_LIBCPP_END_NAMESPACE_FILESYSTEM
+
+#endif // _LIBCPP_CXX03_LANG
+
+#endif // _LIBCPP___FILESYSTEM_PERMS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/recursive_directory_iterator.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/recursive_directory_iterator.h
new file mode 100644
index 0000000000..95360376fc
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/recursive_directory_iterator.h
@@ -0,0 +1,185 @@
+// -*- 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___FILESYSTEM_RECURSIVE_DIRECTORY_ITERATOR_H
+#define _LIBCPP___FILESYSTEM_RECURSIVE_DIRECTORY_ITERATOR_H
+
+#include <__availability>
+#include <__config>
+#include <__filesystem/directory_entry.h>
+#include <__filesystem/directory_options.h>
+#include <__filesystem/path.h>
+#include <__iterator/iterator_traits.h>
+#include <__memory/shared_ptr.h>
+#include <__ranges/enable_borrowed_range.h>
+#include <__ranges/enable_view.h>
+#include <cstddef>
+#include <system_error>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+
+_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
+
+_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH
+
+class recursive_directory_iterator {
+public:
+ using value_type = directory_entry;
+ using difference_type = ptrdiff_t;
+ using pointer = directory_entry const*;
+ using reference = directory_entry const&;
+ using iterator_category = input_iterator_tag;
+
+public:
+ // constructors and destructor
+ _LIBCPP_INLINE_VISIBILITY
+ recursive_directory_iterator() noexcept : __rec_(false) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit recursive_directory_iterator(
+ const path& __p, directory_options __xoptions = directory_options::none)
+ : recursive_directory_iterator(__p, __xoptions, nullptr) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ recursive_directory_iterator(const path& __p, directory_options __xoptions,
+ error_code& __ec)
+ : recursive_directory_iterator(__p, __xoptions, &__ec) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ recursive_directory_iterator(const path& __p, error_code& __ec)
+ : recursive_directory_iterator(__p, directory_options::none, &__ec) {}
+
+ recursive_directory_iterator(const recursive_directory_iterator&) = default;
+ recursive_directory_iterator(recursive_directory_iterator&&) = default;
+
+ recursive_directory_iterator&
+ operator=(const recursive_directory_iterator&) = default;
+
+ _LIBCPP_INLINE_VISIBILITY
+ recursive_directory_iterator&
+ operator=(recursive_directory_iterator&& __o) noexcept {
+ // non-default implementation provided to support self-move assign.
+ if (this != &__o) {
+ __imp_ = _VSTD::move(__o.__imp_);
+ __rec_ = __o.__rec_;
+ }
+ return *this;
+ }
+
+ ~recursive_directory_iterator() = default;
+
+ _LIBCPP_INLINE_VISIBILITY
+ const directory_entry& operator*() const { return __dereference(); }
+
+ _LIBCPP_INLINE_VISIBILITY
+ const directory_entry* operator->() const { return &__dereference(); }
+
+ recursive_directory_iterator& operator++() { return __increment(); }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __dir_element_proxy operator++(int) {
+ __dir_element_proxy __p(**this);
+ __increment();
+ return __p;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ recursive_directory_iterator& increment(error_code& __ec) {
+ return __increment(&__ec);
+ }
+
+ _LIBCPP_FUNC_VIS directory_options options() const;
+ _LIBCPP_FUNC_VIS int depth() const;
+
+ _LIBCPP_INLINE_VISIBILITY
+ void pop() { __pop(); }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void pop(error_code& __ec) { __pop(&__ec); }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool recursion_pending() const { return __rec_; }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void disable_recursion_pending() { __rec_ = false; }
+
+private:
+ _LIBCPP_FUNC_VIS
+ recursive_directory_iterator(const path& __p, directory_options __opt,
+ error_code* __ec);
+
+ _LIBCPP_FUNC_VIS
+ const directory_entry& __dereference() const;
+
+ _LIBCPP_FUNC_VIS
+ bool __try_recursion(error_code* __ec);
+
+ _LIBCPP_FUNC_VIS
+ void __advance(error_code* __ec = nullptr);
+
+ _LIBCPP_FUNC_VIS
+ recursive_directory_iterator& __increment(error_code* __ec = nullptr);
+
+ _LIBCPP_FUNC_VIS
+ void __pop(error_code* __ec = nullptr);
+
+ inline _LIBCPP_INLINE_VISIBILITY friend bool
+ operator==(const recursive_directory_iterator&,
+ const recursive_directory_iterator&) noexcept;
+
+ struct _LIBCPP_HIDDEN __shared_imp;
+ shared_ptr<__shared_imp> __imp_;
+ bool __rec_;
+}; // class recursive_directory_iterator
+
+inline _LIBCPP_INLINE_VISIBILITY bool
+operator==(const recursive_directory_iterator& __lhs,
+ const recursive_directory_iterator& __rhs) noexcept {
+ return __lhs.__imp_ == __rhs.__imp_;
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline bool operator!=(const recursive_directory_iterator& __lhs,
+ const recursive_directory_iterator& __rhs) noexcept {
+ return !(__lhs == __rhs);
+}
+// enable recursive_directory_iterator range-based for statements
+inline _LIBCPP_INLINE_VISIBILITY recursive_directory_iterator
+begin(recursive_directory_iterator __iter) noexcept {
+ return __iter;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY recursive_directory_iterator
+end(recursive_directory_iterator) noexcept {
+ return recursive_directory_iterator();
+}
+
+_LIBCPP_AVAILABILITY_FILESYSTEM_POP
+
+_LIBCPP_END_NAMESPACE_FILESYSTEM
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+template <>
+_LIBCPP_AVAILABILITY_FILESYSTEM
+inline constexpr bool _VSTD::ranges::enable_borrowed_range<_VSTD_FS::recursive_directory_iterator> = true;
+
+template <>
+_LIBCPP_AVAILABILITY_FILESYSTEM
+inline constexpr bool _VSTD::ranges::enable_view<_VSTD_FS::recursive_directory_iterator> = true;
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+#endif // _LIBCPP_CXX03_LANG
+
+#endif // _LIBCPP___FILESYSTEM_RECURSIVE_DIRECTORY_ITERATOR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/space_info.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/space_info.h
new file mode 100644
index 0000000000..d7dc03af75
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/space_info.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___FILESYSTEM_SPACE_INFO_H
+#define _LIBCPP___FILESYSTEM_SPACE_INFO_H
+
+#include <__availability>
+#include <__config>
+#include <cstdint>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+
+_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
+
+_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH
+
+struct _LIBCPP_TYPE_VIS space_info {
+ uintmax_t capacity;
+ uintmax_t free;
+ uintmax_t available;
+};
+
+_LIBCPP_AVAILABILITY_FILESYSTEM_POP
+
+_LIBCPP_END_NAMESPACE_FILESYSTEM
+
+#endif // _LIBCPP_CXX03_LANG
+
+#endif // _LIBCPP___FILESYSTEM_SPACE_INFO_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/u8path.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/u8path.h
new file mode 100644
index 0000000000..ee25521f28
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__filesystem/u8path.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___FILESYSTEM_U8PATH_H
+#define _LIBCPP___FILESYSTEM_U8PATH_H
+
+#include <__availability>
+#include <__config>
+#include <__filesystem/path.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+
+_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
+
+_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH
+
+template <class _InputIt>
+_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_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,
+ "u8path(Iter, Iter) requires Iter have a value_type of type 'char'"
+ " or 'char8_t'");
+#if defined(_LIBCPP_WIN32API)
+ string __tmp(__f, __l);
+ using _CVT = __widen_from_utf8<sizeof(wchar_t) * __CHAR_BIT__>;
+ _VSTD::wstring __w;
+ __w.reserve(__tmp.size());
+ _CVT()(back_inserter(__w), __tmp.data(), __tmp.data() + __tmp.size());
+ return path(__w);
+#else
+ return path(__f, __l);
+#endif /* !_LIBCPP_WIN32API */
+}
+
+#if defined(_LIBCPP_WIN32API)
+template <class _InputIt>
+_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_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,
+ "u8path(Iter, Iter) requires Iter have a value_type of type 'char'"
+ " or 'char8_t'");
+ string __tmp;
+ const char __sentinel = char{};
+ for (; *__f != __sentinel; ++__f)
+ __tmp.push_back(*__f);
+ using _CVT = __widen_from_utf8<sizeof(wchar_t) * __CHAR_BIT__>;
+ _VSTD::wstring __w;
+ __w.reserve(__tmp.size());
+ _CVT()(back_inserter(__w), __tmp.data(), __tmp.data() + __tmp.size());
+ return path(__w);
+}
+#endif /* _LIBCPP_WIN32API */
+
+template <class _Source>
+_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_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,
+ "u8path(Source const&) requires Source have a character type of type "
+ "'char' or 'char8_t'");
+#if defined(_LIBCPP_WIN32API)
+ using _Traits = __is_pathable<_Source>;
+ return u8path(_VSTD::__unwrap_iter(_Traits::__range_begin(__s)), _VSTD::__unwrap_iter(_Traits::__range_end(__s)));
+#else
+ return path(__s);
+#endif
+}
+
+_LIBCPP_AVAILABILITY_FILESYSTEM_POP
+
+_LIBCPP_END_NAMESPACE_FILESYSTEM
+
+#endif // _LIBCPP_CXX03_LANG
+
+#endif // _LIBCPP___FILESYSTEM_U8PATH_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_arg.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_arg.h
new file mode 100644
index 0000000000..443c9e359a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_arg.h
@@ -0,0 +1,288 @@
+// -*- 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_ARG_H
+#define _LIBCPP___FORMAT_FORMAT_ARG_H
+
+#include <__assert>
+#include <__concepts/arithmetic.h>
+#include <__config>
+#include <__format/format_error.h>
+#include <__format/format_fwd.h>
+#include <__format/format_parse_context.h>
+#include <__memory/addressof.h>
+#include <__utility/unreachable.h>
+#include <__variant/monostate.h>
+#include <string>
+#include <string_view>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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)
+
+namespace __format {
+/// The type stored in @ref basic_format_arg.
+///
+/// @note The 128-bit types are unconditionally in the list to avoid the values
+/// of the enums to depend on the availability of 128-bit integers.
+enum class _LIBCPP_ENUM_VIS __arg_t : uint8_t {
+ __none,
+ __boolean,
+ __char_type,
+ __int,
+ __long_long,
+ __i128,
+ __unsigned,
+ __unsigned_long_long,
+ __u128,
+ __float,
+ __double,
+ __long_double,
+ __const_char_type_ptr,
+ __string_view,
+ __ptr,
+ __handle
+};
+} // namespace __format
+
+template <class _Visitor, class _Context>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT decltype(auto)
+visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) {
+ switch (__arg.__type_) {
+ case __format::__arg_t::__none:
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), monostate{});
+ case __format::__arg_t::__boolean:
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__boolean);
+ case __format::__arg_t::__char_type:
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__char_type);
+ case __format::__arg_t::__int:
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__int);
+ case __format::__arg_t::__long_long:
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__long_long);
+ case __format::__arg_t::__i128:
+#ifndef _LIBCPP_HAS_NO_INT128
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__i128);
+#else
+ __libcpp_unreachable();
+#endif
+ case __format::__arg_t::__unsigned:
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__unsigned);
+ case __format::__arg_t::__unsigned_long_long:
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis),
+ __arg.__unsigned_long_long);
+ case __format::__arg_t::__u128:
+#ifndef _LIBCPP_HAS_NO_INT128
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__u128);
+#else
+ __libcpp_unreachable();
+#endif
+ case __format::__arg_t::__float:
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__float);
+ case __format::__arg_t::__double:
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__double);
+ case __format::__arg_t::__long_double:
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__long_double);
+ case __format::__arg_t::__const_char_type_ptr:
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis),
+ __arg.__const_char_type_ptr);
+ case __format::__arg_t::__string_view:
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__string_view);
+ case __format::__arg_t::__ptr:
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__ptr);
+ case __format::__arg_t::__handle:
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__handle);
+ }
+ __libcpp_unreachable();
+}
+
+template <class _Context>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_arg {
+public:
+ class _LIBCPP_TEMPLATE_VIS handle;
+
+ _LIBCPP_HIDE_FROM_ABI basic_format_arg() noexcept
+ : __type_{__format::__arg_t::__none} {}
+
+ _LIBCPP_HIDE_FROM_ABI explicit operator bool() const noexcept {
+ return __type_ != __format::__arg_t::__none;
+ }
+
+private:
+ using char_type = typename _Context::char_type;
+
+ // TODO FMT Implement constrain [format.arg]/4
+ // Constraints: The template specialization
+ // typename Context::template formatter_type<T>
+ // meets the Formatter requirements ([formatter.requirements]). The extent
+ // to which an implementation determines that the specialization meets the
+ // Formatter requirements is unspecified, except that as a minimum the
+ // expression
+ // typename Context::template formatter_type<T>()
+ // .format(declval<const T&>(), declval<Context&>())
+ // shall be well-formed when treated as an unevaluated operand.
+
+ template <class _Ctx, class... _Args>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT friend __format_arg_store<_Ctx, _Args...>
+ make_format_args(const _Args&...);
+
+ template <class _Visitor, class _Ctx>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT friend decltype(auto)
+ visit_format_arg(_Visitor&& __vis, basic_format_arg<_Ctx> __arg);
+
+ union {
+ bool __boolean;
+ char_type __char_type;
+ int __int;
+ unsigned __unsigned;
+ long long __long_long;
+ unsigned long long __unsigned_long_long;
+#ifndef _LIBCPP_HAS_NO_INT128
+ __int128_t __i128;
+ __uint128_t __u128;
+#endif
+ float __float;
+ double __double;
+ long double __long_double;
+ const char_type* __const_char_type_ptr;
+ basic_string_view<char_type> __string_view;
+ const void* __ptr;
+ handle __handle;
+ };
+ __format::__arg_t __type_;
+
+ _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(bool __v) noexcept
+ : __boolean(__v), __type_(__format::__arg_t::__boolean) {}
+
+ template <class _Tp>
+ _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(_Tp __v) noexcept
+ requires(same_as<_Tp, char_type> ||
+ (same_as<_Tp, char> && same_as<char_type, wchar_t>))
+ : __char_type(__v), __type_(__format::__arg_t::__char_type) {}
+
+ template <__libcpp_signed_integer _Tp>
+ _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(_Tp __v) noexcept {
+ if constexpr (sizeof(_Tp) <= sizeof(int)) {
+ __int = static_cast<int>(__v);
+ __type_ = __format::__arg_t::__int;
+ } else if constexpr (sizeof(_Tp) <= sizeof(long long)) {
+ __long_long = static_cast<long long>(__v);
+ __type_ = __format::__arg_t::__long_long;
+ }
+#ifndef _LIBCPP_HAS_NO_INT128
+ else if constexpr (sizeof(_Tp) == sizeof(__int128_t)) {
+ __i128 = __v;
+ __type_ = __format::__arg_t::__i128;
+ }
+#endif
+ else
+ static_assert(sizeof(_Tp) == 0, "An unsupported signed integer was used");
+ }
+
+ template <__libcpp_unsigned_integer _Tp>
+ _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(_Tp __v) noexcept {
+ if constexpr (sizeof(_Tp) <= sizeof(unsigned)) {
+ __unsigned = static_cast<unsigned>(__v);
+ __type_ = __format::__arg_t::__unsigned;
+ } else if constexpr (sizeof(_Tp) <= sizeof(unsigned long long)) {
+ __unsigned_long_long = static_cast<unsigned long long>(__v);
+ __type_ = __format::__arg_t::__unsigned_long_long;
+ }
+#ifndef _LIBCPP_HAS_NO_INT128
+ else if constexpr (sizeof(_Tp) == sizeof(__int128_t)) {
+ __u128 = __v;
+ __type_ = __format::__arg_t::__u128;
+ }
+#endif
+ else
+ static_assert(sizeof(_Tp) == 0,
+ "An unsupported unsigned integer was used");
+ }
+
+ _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(float __v) noexcept
+ : __float(__v), __type_(__format::__arg_t::__float) {}
+
+ _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(double __v) noexcept
+ : __double(__v), __type_(__format::__arg_t::__double) {}
+
+ _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(long double __v) noexcept
+ : __long_double(__v), __type_(__format::__arg_t::__long_double) {}
+
+ // Note not a 'noexcept' function.
+ _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(const char_type* __s)
+ : __const_char_type_ptr(__s),
+ __type_(__format::__arg_t::__const_char_type_ptr) {
+ _LIBCPP_ASSERT(__s, "Used a nullptr argument to initialize a C-string");
+ }
+
+ template <class _Traits>
+ _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(
+ basic_string_view<char_type, _Traits> __s) noexcept
+ : __string_view{__s.data(), __s.size()},
+ __type_(__format::__arg_t::__string_view) {}
+
+ template <class _Traits, class _Allocator>
+ _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(
+ const basic_string<char_type, _Traits, _Allocator>& __s) noexcept
+ : __string_view{__s.data(), __s.size()},
+ __type_(__format::__arg_t::__string_view) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ explicit basic_format_arg(nullptr_t) noexcept
+ : __ptr(nullptr), __type_(__format::__arg_t::__ptr) {}
+
+ template <class _Tp>
+ requires is_void_v<_Tp> _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(_Tp* __p) noexcept
+ : __ptr(__p), __type_(__format::__arg_t::__ptr) {}
+
+ template <__libcpp_not_integral _Tp>
+ _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(const _Tp& __v) noexcept
+ : __handle(__v), __type_(__format::__arg_t::__handle) {}
+};
+
+template <class _Context>
+class _LIBCPP_TEMPLATE_VIS basic_format_arg<_Context>::handle {
+ friend class basic_format_arg<_Context>;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI
+ void format(basic_format_parse_context<char_type>& __parse_ctx, _Context& __ctx) const {
+ __format_(__parse_ctx, __ctx, __ptr_);
+ }
+
+private:
+ const void* __ptr_;
+ void (*__format_)(basic_format_parse_context<char_type>&, _Context&, const void*);
+
+ template <class _Tp>
+ _LIBCPP_HIDE_FROM_ABI explicit handle(const _Tp& __v) noexcept
+ : __ptr_(_VSTD::addressof(__v)),
+ __format_([](basic_format_parse_context<char_type>& __parse_ctx, _Context& __ctx, const void* __ptr) {
+ typename _Context::template formatter_type<_Tp> __f;
+ __parse_ctx.advance_to(__f.parse(__parse_ctx));
+ __ctx.advance_to(__f.format(*static_cast<const _Tp*>(__ptr), __ctx));
+ }) {}
+};
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMAT_ARG_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_args.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_args.h
new file mode 100644
index 0000000000..2739d1131b
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_args.h
@@ -0,0 +1,66 @@
+// -*- 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_ARGS_H
+#define _LIBCPP___FORMAT_FORMAT_ARGS_H
+
+#include <__availability>
+#include <__config>
+#include <__format/format_fwd.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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)
+
+template <class _Context>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_args {
+public:
+ // TODO FMT Implement [format.args]/5
+ // [Note 1: Implementations are encouraged to optimize the representation of
+ // basic_format_args for small number of formatting arguments by storing
+ // indices of type alternatives separately from values and packing the
+ // former. - end note]
+ // Note: Change __format_arg_store to use a built-in array.
+ _LIBCPP_HIDE_FROM_ABI basic_format_args() noexcept = default;
+
+ template <class... _Args>
+ _LIBCPP_HIDE_FROM_ABI basic_format_args(
+ const __format_arg_store<_Context, _Args...>& __store) noexcept
+ : __size_(sizeof...(_Args)), __data_(__store.__args.data()) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ basic_format_arg<_Context> get(size_t __id) const noexcept {
+ return __id < __size_ ? __data_[__id] : basic_format_arg<_Context>{};
+ }
+
+ _LIBCPP_HIDE_FROM_ABI size_t __size() const noexcept { return __size_; }
+
+private:
+ size_t __size_{0};
+ const basic_format_arg<_Context>* __data_{nullptr};
+};
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMAT_ARGS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_context.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_context.h
new file mode 100644
index 0000000000..d4bc35decd
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_context.h
@@ -0,0 +1,160 @@
+// -*- 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_CONTEXT_H
+#define _LIBCPP___FORMAT_FORMAT_CONTEXT_H
+
+#include <__availability>
+#include <__config>
+#include <__format/format_args.h>
+#include <__format/format_fwd.h>
+#include <__iterator/back_insert_iterator.h>
+#include <__iterator/concepts.h>
+#include <concepts>
+
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+#include <locale>
+#include <optional>
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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)
+
+template <class _OutIt, class _CharT>
+requires output_iterator<_OutIt, const _CharT&>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_context;
+
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+/**
+ * Helper to create a basic_format_context.
+ *
+ * This is needed since the constructor is private.
+ */
+template <class _OutIt, class _CharT>
+_LIBCPP_HIDE_FROM_ABI basic_format_context<_OutIt, _CharT>
+__format_context_create(
+ _OutIt __out_it,
+ basic_format_args<basic_format_context<_OutIt, _CharT>> __args,
+ optional<_VSTD::locale>&& __loc = nullopt) {
+ return _VSTD::basic_format_context(_VSTD::move(__out_it), __args,
+ _VSTD::move(__loc));
+}
+#else
+template <class _OutIt, class _CharT>
+_LIBCPP_HIDE_FROM_ABI basic_format_context<_OutIt, _CharT>
+__format_context_create(
+ _OutIt __out_it,
+ basic_format_args<basic_format_context<_OutIt, _CharT>> __args) {
+ return _VSTD::basic_format_context(_VSTD::move(__out_it), __args);
+}
+#endif
+
+// TODO FMT Implement [format.context]/4
+// [Note 1: For a given type charT, implementations are encouraged to provide a
+// single instantiation of basic_format_context for appending to
+// basic_string<charT>, vector<charT>, or any other container with contiguous
+// storage by wrapping those in temporary objects with a uniform interface
+// (such as a span<charT>) and polymorphic reallocation. - end note]
+
+using format_context = basic_format_context<back_insert_iterator<string>, char>;
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+using wformat_context = basic_format_context<back_insert_iterator<wstring>, wchar_t>;
+#endif
+
+template <class _OutIt, class _CharT>
+requires output_iterator<_OutIt, const _CharT&>
+class
+ // clang-format off
+ _LIBCPP_TEMPLATE_VIS
+ _LIBCPP_AVAILABILITY_FORMAT
+ _LIBCPP_PREFERRED_NAME(format_context)
+ _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wformat_context))
+ // clang-format on
+ basic_format_context {
+public:
+ using iterator = _OutIt;
+ using char_type = _CharT;
+ template <class _Tp>
+ using formatter_type = formatter<_Tp, _CharT>;
+
+ basic_format_context(const basic_format_context&) = delete;
+ basic_format_context& operator=(const basic_format_context&) = delete;
+
+ _LIBCPP_HIDE_FROM_ABI basic_format_arg<basic_format_context>
+ arg(size_t __id) const noexcept {
+ return __args_.get(__id);
+ }
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+ _LIBCPP_HIDE_FROM_ABI _VSTD::locale locale() {
+ if (!__loc_)
+ __loc_ = _VSTD::locale{};
+ return *__loc_;
+ }
+#endif
+ _LIBCPP_HIDE_FROM_ABI iterator out() { return __out_it_; }
+ _LIBCPP_HIDE_FROM_ABI void advance_to(iterator __it) { __out_it_ = __it; }
+
+private:
+ iterator __out_it_;
+ basic_format_args<basic_format_context> __args_;
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+
+ // The Standard doesn't specify how the locale is stored.
+ // [format.context]/6
+ // std::locale locale();
+ // Returns: The locale passed to the formatting function if the latter
+ // takes one, and std::locale() otherwise.
+ // This is done by storing the locale of the constructor in this optional. If
+ // locale() is called and the optional has no value the value will be created.
+ // This allows the implementation to lazily create the locale.
+ // TODO FMT Validate whether lazy creation is the best solution.
+ optional<_VSTD::locale> __loc_;
+
+ template <class __OutIt, class __CharT>
+ friend _LIBCPP_HIDE_FROM_ABI basic_format_context<__OutIt, __CharT>
+ __format_context_create(__OutIt, basic_format_args<basic_format_context<__OutIt, __CharT>>,
+ optional<_VSTD::locale>&&);
+
+ // Note: the Standard doesn't specify the required constructors.
+ _LIBCPP_HIDE_FROM_ABI
+ explicit basic_format_context(_OutIt __out_it,
+ basic_format_args<basic_format_context> __args,
+ optional<_VSTD::locale>&& __loc)
+ : __out_it_(_VSTD::move(__out_it)), __args_(__args),
+ __loc_(_VSTD::move(__loc)) {}
+#else
+ template <class __OutIt, class __CharT>
+ friend _LIBCPP_HIDE_FROM_ABI basic_format_context<__OutIt, __CharT>
+ __format_context_create(__OutIt, basic_format_args<basic_format_context<__OutIt, __CharT>>);
+
+ _LIBCPP_HIDE_FROM_ABI
+ explicit basic_format_context(_OutIt __out_it,
+ basic_format_args<basic_format_context> __args)
+ : __out_it_(_VSTD::move(__out_it)), __args_(__args) {}
+#endif
+};
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMAT_CONTEXT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_error.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_error.h
new file mode 100644
index 0000000000..67ff41cbc3
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_error.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___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_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
+
+#endif // _LIBCPP___FORMAT_FORMAT_ERROR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_fwd.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_fwd.h
new file mode 100644
index 0000000000..9421aa8788
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_fwd.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___FORMAT_FORMAT_FWD_H
+#define _LIBCPP___FORMAT_FORMAT_FWD_H
+
+#include <__availability>
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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)
+
+template <class _Context>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_arg;
+
+template <class _Context, class... _Args>
+struct _LIBCPP_TEMPLATE_VIS __format_arg_store;
+
+template <class _Tp, class _CharT = char>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter;
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMAT_FWD_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_parse_context.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_parse_context.h
new file mode 100644
index 0000000000..d16859cc65
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_parse_context.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___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_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>;
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+using wformat_parse_context = basic_format_parse_context<wchar_t>;
+#endif
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMAT_PARSE_CONTEXT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_string.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_string.h
new file mode 100644
index 0000000000..32af6609e7
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_string.h
@@ -0,0 +1,169 @@
+// -*- 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_STRING_H
+#define _LIBCPP___FORMAT_FORMAT_STRING_H
+
+#include <__assert>
+#include <__config>
+#include <__format/format_error.h>
+#include <cstddef>
+#include <cstdint>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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)
+
+namespace __format {
+
+template <class _CharT>
+struct _LIBCPP_TEMPLATE_VIS __parse_number_result {
+ const _CharT* __ptr;
+ uint32_t __value;
+};
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr __parse_number_result<_CharT>
+__parse_number(const _CharT* __begin, const _CharT* __end);
+
+/**
+ * The maximum value of a numeric argument.
+ *
+ * This is used for:
+ * * arg-id
+ * * width as value or arg-id.
+ * * precision as value or arg-id.
+ *
+ * The value is compatible with the maximum formatting width and precision
+ * using the `%*` syntax on a 32-bit system.
+ */
+inline constexpr uint32_t __number_max = INT32_MAX;
+
+namespace __detail {
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr __parse_number_result<_CharT>
+__parse_zero(const _CharT* __begin, const _CharT*, auto& __parse_ctx) {
+ __parse_ctx.check_arg_id(0);
+ return {++__begin, 0}; // can never be larger than the maximum.
+}
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr __parse_number_result<_CharT>
+__parse_automatic(const _CharT* __begin, const _CharT*, auto& __parse_ctx) {
+ size_t __value = __parse_ctx.next_arg_id();
+ _LIBCPP_ASSERT(__value <= __number_max,
+ "Compilers don't support this number of arguments");
+
+ return {__begin, uint32_t(__value)};
+}
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr __parse_number_result<_CharT>
+__parse_manual(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {
+ __parse_number_result<_CharT> __r = __parse_number(__begin, __end);
+ __parse_ctx.check_arg_id(__r.__value);
+ return __r;
+}
+
+} // namespace __detail
+
+/**
+ * Parses a number.
+ *
+ * The number is used for the 31-bit values @em width and @em precision. This
+ * allows a maximum value of 2147483647.
+ */
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr __parse_number_result<_CharT>
+__parse_number(const _CharT* __begin, const _CharT* __end_input) {
+ static_assert(__format::__number_max == INT32_MAX,
+ "The algorithm is implemented based on this value.");
+ /*
+ * Limit the input to 9 digits, otherwise we need two checks during every
+ * iteration:
+ * - Are we at the end of the input?
+ * - Does the value exceed width of an uint32_t? (Switching to uint64_t would
+ * have the same issue, but with a higher maximum.)
+ */
+ const _CharT* __end = __end_input - __begin > 9 ? __begin + 9 : __end_input;
+ uint32_t __value = *__begin - _CharT('0');
+ while (++__begin != __end) {
+ if (*__begin < _CharT('0') || *__begin > _CharT('9'))
+ return {__begin, __value};
+
+ __value = __value * 10 + *__begin - _CharT('0');
+ }
+
+ if (__begin != __end_input && *__begin >= _CharT('0') &&
+ *__begin <= _CharT('9')) {
+
+ /*
+ * There are more than 9 digits, do additional validations:
+ * - Does the 10th digit exceed the maximum allowed value?
+ * - Are there more than 10 digits?
+ * (More than 10 digits always overflows the maximum.)
+ */
+ uint64_t __v = uint64_t(__value) * 10 + *__begin++ - _CharT('0');
+ if (__v > __number_max ||
+ (__begin != __end_input && *__begin >= _CharT('0') &&
+ *__begin <= _CharT('9')))
+ __throw_format_error("The numeric value of the format-spec is too large");
+
+ __value = __v;
+ }
+
+ return {__begin, __value};
+}
+
+/**
+ * Multiplexer for all parse functions.
+ *
+ * The parser will return a pointer beyond the last consumed character. This
+ * should be the closing '}' of the arg-id.
+ */
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr __parse_number_result<_CharT>
+__parse_arg_id(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {
+ switch (*__begin) {
+ case _CharT('0'):
+ return __detail::__parse_zero(__begin, __end, __parse_ctx);
+
+ case _CharT(':'):
+ // This case is conditionally valid. It's allowed in an arg-id in the
+ // replacement-field, but not in the std-format-spec. The caller can
+ // provide a better diagnostic, so accept it here unconditionally.
+ case _CharT('}'):
+ return __detail::__parse_automatic(__begin, __end, __parse_ctx);
+ }
+ if (*__begin < _CharT('0') || *__begin > _CharT('9'))
+ __throw_format_error(
+ "The arg-id of the format-spec starts with an invalid character");
+
+ return __detail::__parse_manual(__begin, __end, __parse_ctx);
+}
+
+} // namespace __format
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMAT_STRING_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_to_n_result.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_to_n_result.h
new file mode 100644
index 0000000000..b973dc5c1d
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/format_to_n_result.h
@@ -0,0 +1,41 @@
+// -*- 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_TO_N_RESULT_H
+#define _LIBCPP___FORMAT_FORMAT_TO_N_RESULT_H
+
+#include <__config>
+#include <__iterator/incrementable_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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)
+
+template <class _OutIt>
+struct _LIBCPP_TEMPLATE_VIS format_to_n_result {
+ _OutIt out;
+ iter_difference_t<_OutIt> size;
+};
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMAT_TO_N_RESULT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter.h
new file mode 100644
index 0000000000..f9e0b6c84b
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter.h
@@ -0,0 +1,287 @@
+// -*- 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_FORMATTER_H
+#define _LIBCPP___FORMAT_FORMATTER_H
+
+#include <__algorithm/copy.h>
+#include <__algorithm/fill_n.h>
+#include <__algorithm/transform.h>
+#include <__assert>
+#include <__availability>
+#include <__config>
+#include <__format/format_error.h>
+#include <__format/format_fwd.h>
+#include <__format/format_string.h>
+#include <__format/parser_std_format_spec.h>
+#include <__utility/unreachable.h>
+#include <string_view>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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)
+
+/// The default formatter template.
+///
+/// [format.formatter.spec]/5
+/// If F is a disabled specialization of formatter, these values are false:
+/// - is_default_constructible_v<F>,
+/// - is_copy_constructible_v<F>,
+/// - is_move_constructible_v<F>,
+/// - is_copy_assignable<F>, and
+/// - is_move_assignable<F>.
+template <class _Tp, class _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter {
+ formatter() = delete;
+ formatter(const formatter&) = delete;
+ formatter& operator=(const formatter&) = delete;
+};
+
+namespace __format_spec {
+
+_LIBCPP_HIDE_FROM_ABI inline char* __insert_sign(char* __buf, bool __negative,
+ _Flags::_Sign __sign) {
+ if (__negative)
+ *__buf++ = '-';
+ else
+ switch (__sign) {
+ case _Flags::_Sign::__default:
+ case _Flags::_Sign::__minus:
+ // No sign added.
+ break;
+ case _Flags::_Sign::__plus:
+ *__buf++ = '+';
+ break;
+ case _Flags::_Sign::__space:
+ *__buf++ = ' ';
+ break;
+ }
+
+ return __buf;
+}
+
+_LIBCPP_HIDE_FROM_ABI constexpr char __hex_to_upper(char c) {
+ switch (c) {
+ case 'a':
+ return 'A';
+ case 'b':
+ return 'B';
+ case 'c':
+ return 'C';
+ case 'd':
+ return 'D';
+ case 'e':
+ return 'E';
+ case 'f':
+ return 'F';
+ }
+ return c;
+}
+
+} // namespace __format_spec
+
+namespace __formatter {
+
+/** The character types that formatters are specialized for. */
+template <class _CharT>
+concept __char_type = same_as<_CharT, char> || same_as<_CharT, wchar_t>;
+
+struct _LIBCPP_TEMPLATE_VIS __padding_size_result {
+ size_t __before;
+ size_t __after;
+};
+
+_LIBCPP_HIDE_FROM_ABI constexpr __padding_size_result
+__padding_size(size_t __size, size_t __width,
+ __format_spec::_Flags::_Alignment __align) {
+ _LIBCPP_ASSERT(__width > __size,
+ "Don't call this function when no padding is required");
+ _LIBCPP_ASSERT(
+ __align != __format_spec::_Flags::_Alignment::__default,
+ "Caller should adjust the default to the value required by the type");
+
+ size_t __fill = __width - __size;
+ switch (__align) {
+ case __format_spec::_Flags::_Alignment::__default:
+ __libcpp_unreachable();
+
+ case __format_spec::_Flags::_Alignment::__left:
+ return {0, __fill};
+
+ case __format_spec::_Flags::_Alignment::__center: {
+ // The extra padding is divided per [format.string.std]/3
+ // __before = floor(__fill, 2);
+ // __after = ceil(__fill, 2);
+ size_t __before = __fill / 2;
+ size_t __after = __fill - __before;
+ return {__before, __after};
+ }
+ case __format_spec::_Flags::_Alignment::__right:
+ return {__fill, 0};
+ }
+ __libcpp_unreachable();
+}
+
+/**
+ * Writes the input to the output with the required padding.
+ *
+ * Since the output column width is specified the function can be used for
+ * ASCII and Unicode input.
+ *
+ * @pre [@a __first, @a __last) is a valid range.
+ * @pre @a __size <= @a __width. Using this function when this pre-condition
+ * doesn't hold incurs an unwanted overhead.
+ *
+ * @param __out_it The output iterator to write to.
+ * @param __first Pointer to the first element to write.
+ * @param __last Pointer beyond the last element to write.
+ * @param __size The (estimated) output column width. When the elements
+ * to be written are ASCII the following condition holds
+ * @a __size == @a __last - @a __first.
+ * @param __width The number of output columns to write.
+ * @param __fill The character used for the alignment of the output.
+ * TODO FMT Will probably change to support Unicode grapheme
+ * cluster.
+ * @param __alignment The requested alignment.
+ *
+ * @returns An iterator pointing beyond the last element written.
+ *
+ * @note The type of the elements in range [@a __first, @a __last) can differ
+ * from the type of @a __fill. Integer output uses @c std::to_chars for its
+ * conversion, which means the [@a __first, @a __last) always contains elements
+ * of the type @c char.
+ */
+template <class _CharT, class _Fill>
+_LIBCPP_HIDE_FROM_ABI auto
+__write(output_iterator<const _CharT&> auto __out_it, const _CharT* __first,
+ const _CharT* __last, size_t __size, size_t __width, _Fill __fill,
+ __format_spec::_Flags::_Alignment __alignment) -> decltype(__out_it) {
+
+ _LIBCPP_ASSERT(__first <= __last, "Not a valid range");
+ _LIBCPP_ASSERT(__size < __width, "Precondition failure");
+
+ __padding_size_result __padding =
+ __padding_size(__size, __width, __alignment);
+ __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before, __fill);
+ __out_it = _VSTD::copy(__first, __last, _VSTD::move(__out_it));
+ return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after, __fill);
+}
+
+/**
+ * @overload
+ *
+ * Writes additional zero's for the precision before the exponent.
+ * This is used when the precision requested in the format string is larger
+ * than the maximum precision of the floating-point type. These precision
+ * digits are always 0.
+ *
+ * @param __exponent The location of the exponent character.
+ * @param __num_trailing_zeros The number of 0's to write before the exponent
+ * character.
+ */
+template <class _CharT, class _Fill>
+_LIBCPP_HIDE_FROM_ABI auto __write(output_iterator<const _CharT&> auto __out_it, const _CharT* __first,
+ const _CharT* __last, size_t __size, size_t __width, _Fill __fill,
+ __format_spec::_Flags::_Alignment __alignment, const _CharT* __exponent,
+ size_t __num_trailing_zeros) -> decltype(__out_it) {
+ _LIBCPP_ASSERT(__first <= __last, "Not a valid range");
+ _LIBCPP_ASSERT(__num_trailing_zeros > 0, "The overload not writing trailing zeros should have been used");
+
+ __padding_size_result __padding = __padding_size(__size + __num_trailing_zeros, __width, __alignment);
+ __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before, __fill);
+ __out_it = _VSTD::copy(__first, __exponent, _VSTD::move(__out_it));
+ __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __num_trailing_zeros, _CharT('0'));
+ __out_it = _VSTD::copy(__exponent, __last, _VSTD::move(__out_it));
+ return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after, __fill);
+}
+
+/**
+ * @overload
+ *
+ * Uses a transformation operation before writing an element.
+ *
+ * TODO FMT Fill will probably change to support Unicode grapheme cluster.
+ */
+template <class _CharT, class _UnaryOperation, class _Fill>
+_LIBCPP_HIDE_FROM_ABI auto
+__write(output_iterator<const _CharT&> auto __out_it, const _CharT* __first,
+ const _CharT* __last, size_t __size, _UnaryOperation __op,
+ size_t __width, _Fill __fill,
+ __format_spec::_Flags::_Alignment __alignment) -> decltype(__out_it) {
+
+ _LIBCPP_ASSERT(__first <= __last, "Not a valid range");
+ _LIBCPP_ASSERT(__size < __width, "Precondition failure");
+
+ __padding_size_result __padding =
+ __padding_size(__size, __width, __alignment);
+ __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before, __fill);
+ __out_it = _VSTD::transform(__first, __last, _VSTD::move(__out_it), __op);
+ return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after, __fill);
+}
+
+/**
+ * Writes Unicode input to the output with the required padding.
+ *
+ * This function does almost the same as the @ref __write function, but handles
+ * the width estimation of the Unicode input.
+ *
+ * @param __str The range [@a __first, @a __last).
+ * @param __precision The width to truncate the input string to, use @c -1 for
+ * no limit.
+ */
+template <class _CharT, class _Fill>
+_LIBCPP_HIDE_FROM_ABI auto
+__write_unicode(output_iterator<const _CharT&> auto __out_it,
+ basic_string_view<_CharT> __str, ptrdiff_t __width,
+ ptrdiff_t __precision, _Fill __fill,
+ __format_spec::_Flags::_Alignment __alignment)
+ -> decltype(__out_it) {
+
+ // This value changes when there Unicode column width limits the output
+ // size.
+ auto __last = __str.end();
+ if (__width != 0 || __precision != -1) {
+ __format_spec::__string_alignment<_CharT> __format_traits =
+ __format_spec::__get_string_alignment(__str.begin(), __str.end(),
+ __width, __precision);
+
+ if (__format_traits.__align)
+ return __write(_VSTD::move(__out_it), __str.begin(),
+ __format_traits.__last, __format_traits.__size, __width,
+ __fill, __alignment);
+
+ // No alignment required update the output based on the precision.
+ // This might be the same as __str.end().
+ __last = __format_traits.__last;
+ }
+
+ // Copy the input to the output. The output size might be limited by the
+ // precision.
+ return _VSTD::copy(__str.begin(), __last, _VSTD::move(__out_it));
+}
+
+} // namespace __formatter
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMATTER_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter_bool.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter_bool.h
new file mode 100644
index 0000000000..f428683657
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter_bool.h
@@ -0,0 +1,143 @@
+// -*- 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_FORMATTER_BOOL_H
+#define _LIBCPP___FORMAT_FORMATTER_BOOL_H
+
+#include <__availability>
+#include <__config>
+#include <__format/format_error.h>
+#include <__format/format_fwd.h>
+#include <__format/formatter.h>
+#include <__format/formatter_integral.h>
+#include <__format/parser_std_format_spec.h>
+#include <string_view>
+
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+#include <locale>
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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)
+
+namespace __format_spec {
+
+template <class _CharT>
+class _LIBCPP_TEMPLATE_VIS __parser_bool : public __parser_integral<_CharT> {
+public:
+ _LIBCPP_HIDE_FROM_ABI constexpr auto parse(auto& __parse_ctx)
+ -> decltype(__parse_ctx.begin()) {
+ auto __it = __parser_integral<_CharT>::__parse(__parse_ctx);
+
+ switch (this->__type) {
+ case _Flags::_Type::__default:
+ this->__type = _Flags::_Type::__string;
+ [[fallthrough]];
+ case _Flags::_Type::__string:
+ this->__handle_bool();
+ break;
+
+ case _Flags::_Type::__binary_lower_case:
+ case _Flags::_Type::__binary_upper_case:
+ case _Flags::_Type::__octal:
+ case _Flags::_Type::__decimal:
+ case _Flags::_Type::__hexadecimal_lower_case:
+ case _Flags::_Type::__hexadecimal_upper_case:
+ this->__handle_integer();
+ break;
+
+ default:
+ __throw_format_error(
+ "The format-spec type has a type not supported for a bool argument");
+ }
+
+ return __it;
+ }
+};
+
+template <class _CharT>
+struct _LIBCPP_TEMPLATE_VIS __bool_strings;
+
+template <>
+struct _LIBCPP_TEMPLATE_VIS __bool_strings<char> {
+ static constexpr string_view __true{"true"};
+ static constexpr string_view __false{"false"};
+};
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+struct _LIBCPP_TEMPLATE_VIS __bool_strings<wchar_t> {
+ static constexpr wstring_view __true{L"true"};
+ static constexpr wstring_view __false{L"false"};
+};
+#endif
+
+template <class _CharT>
+using __formatter_bool = __formatter_integral<__parser_bool<_CharT>>;
+
+} //namespace __format_spec
+
+// [format.formatter.spec]/2.3
+// For each charT, for each cv-unqualified arithmetic type ArithmeticT other
+// than char, wchar_t, char8_t, char16_t, or char32_t, a specialization
+
+template <__formatter::__char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<bool, _CharT>
+ : public __format_spec::__formatter_bool<_CharT> {
+ using _Base = __format_spec::__formatter_bool<_CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI auto format(bool __value, auto& __ctx)
+ -> decltype(__ctx.out()) {
+ if (this->__type != __format_spec::_Flags::_Type::__string)
+ return _Base::format(static_cast<unsigned char>(__value), __ctx);
+
+ if (this->__width_needs_substitution())
+ this->__substitute_width_arg_id(__ctx.arg(this->__width));
+
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+ if (this->__locale_specific_form) {
+ const auto& __np = use_facet<numpunct<_CharT>>(__ctx.locale());
+ basic_string<_CharT> __str = __value ? __np.truename() : __np.falsename();
+ return __formatter::__write_unicode(
+ __ctx.out(), basic_string_view<_CharT>{__str}, this->__width, -1,
+ this->__fill, this->__alignment);
+ }
+#endif
+ basic_string_view<_CharT> __str =
+ __value ? __format_spec::__bool_strings<_CharT>::__true
+ : __format_spec::__bool_strings<_CharT>::__false;
+
+ // The output only uses ASCII so every character is one column.
+ unsigned __size = __str.size();
+ if (__size >= this->__width)
+ return _VSTD::copy(__str.begin(), __str.end(), __ctx.out());
+
+ return __formatter::__write(__ctx.out(), __str.begin(), __str.end(), __size,
+ this->__width, this->__fill, this->__alignment);
+ }
+};
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMATTER_BOOL_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter_char.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter_char.h
new file mode 100644
index 0000000000..f565135821
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter_char.h
@@ -0,0 +1,104 @@
+// -*- 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_FORMATTER_CHAR_H
+#define _LIBCPP___FORMAT_FORMATTER_CHAR_H
+
+#include <__availability>
+#include <__config>
+#include <__format/format_error.h>
+#include <__format/format_fwd.h>
+#include <__format/formatter.h>
+#include <__format/formatter_integral.h>
+#include <__format/parser_std_format_spec.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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)
+
+namespace __format_spec {
+
+template <class _CharT>
+class _LIBCPP_TEMPLATE_VIS __parser_char : public __parser_integral<_CharT> {
+public:
+ _LIBCPP_HIDE_FROM_ABI constexpr auto parse(auto& __parse_ctx)
+ -> decltype(__parse_ctx.begin()) {
+ auto __it = __parser_integral<_CharT>::__parse(__parse_ctx);
+
+ switch (this->__type) {
+ case _Flags::_Type::__default:
+ this->__type = _Flags::_Type::__char;
+ [[fallthrough]];
+ case _Flags::_Type::__char:
+ this->__handle_char();
+ break;
+
+ case _Flags::_Type::__binary_lower_case:
+ case _Flags::_Type::__binary_upper_case:
+ case _Flags::_Type::__octal:
+ case _Flags::_Type::__decimal:
+ case _Flags::_Type::__hexadecimal_lower_case:
+ case _Flags::_Type::__hexadecimal_upper_case:
+ this->__handle_integer();
+ break;
+
+ default:
+ __throw_format_error(
+ "The format-spec type has a type not supported for a char argument");
+ }
+
+ return __it;
+ }
+};
+
+template <class _CharT>
+using __formatter_char = __formatter_integral<__parser_char<_CharT>>;
+
+} // namespace __format_spec
+
+// [format.formatter.spec]/2.1 The specializations
+
+template <>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<char, char>
+ : public __format_spec::__formatter_char<char> {};
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<char, wchar_t>
+ : public __format_spec::__formatter_char<wchar_t> {
+ using _Base = __format_spec::__formatter_char<wchar_t>;
+
+ _LIBCPP_HIDE_FROM_ABI auto format(char __value, auto& __ctx)
+ -> decltype(__ctx.out()) {
+ return _Base::format(static_cast<wchar_t>(__value), __ctx);
+ }
+};
+
+template <>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
+ formatter<wchar_t, wchar_t>
+ : public __format_spec::__formatter_char<wchar_t> {};
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMATTER_CHAR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter_floating_point.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter_floating_point.h
new file mode 100644
index 0000000000..aa32815af2
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter_floating_point.h
@@ -0,0 +1,718 @@
+// -*- 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_FORMATTER_FLOATING_POINT_H
+#define _LIBCPP___FORMAT_FORMATTER_FLOATING_POINT_H
+
+#include <__algorithm/copy.h>
+#include <__algorithm/copy_n.h>
+#include <__algorithm/fill_n.h>
+#include <__algorithm/find.h>
+#include <__algorithm/min.h>
+#include <__algorithm/rotate.h>
+#include <__algorithm/transform.h>
+#include <__assert>
+#include <__concepts/arithmetic.h>
+#include <__config>
+#include <__format/format_error.h>
+#include <__format/format_fwd.h>
+#include <__format/format_string.h>
+#include <__format/formatter.h>
+#include <__format/formatter_integral.h>
+#include <__format/parser_std_format_spec.h>
+#include <__utility/move.h>
+#include <__utility/unreachable.h>
+#include <charconv>
+#include <cmath>
+
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+# include <locale>
+#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
+
+// 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)
+
+namespace __format_spec {
+
+template <floating_point _Tp>
+_LIBCPP_HIDE_FROM_ABI char* __to_buffer(char* __first, char* __last, _Tp __value) {
+ to_chars_result __r = _VSTD::to_chars(__first, __last, __value);
+ _LIBCPP_ASSERT(__r.ec == errc(0), "Internal buffer too small");
+ return __r.ptr;
+}
+
+template <floating_point _Tp>
+_LIBCPP_HIDE_FROM_ABI char* __to_buffer(char* __first, char* __last, _Tp __value, chars_format __fmt) {
+ to_chars_result __r = _VSTD::to_chars(__first, __last, __value, __fmt);
+ _LIBCPP_ASSERT(__r.ec == errc(0), "Internal buffer too small");
+ return __r.ptr;
+}
+
+template <floating_point _Tp>
+_LIBCPP_HIDE_FROM_ABI char* __to_buffer(char* __first, char* __last, _Tp __value, chars_format __fmt, int __precision) {
+ to_chars_result __r = _VSTD::to_chars(__first, __last, __value, __fmt, __precision);
+ _LIBCPP_ASSERT(__r.ec == errc(0), "Internal buffer too small");
+ return __r.ptr;
+}
+
+// https://en.cppreference.com/w/cpp/language/types#cite_note-1
+// float min subnormal: +/-0x1p-149 max: +/- 3.402,823,4 10^38
+// double min subnormal: +/-0x1p-1074 max +/- 1.797,693,134,862,315,7 10^308
+// long double (x86) min subnormal: +/-0x1p-16446 max: +/- 1.189,731,495,357,231,765,021 10^4932
+//
+// The maximum number of digits required for the integral part is based on the
+// maximum's value power of 10. Every power of 10 requires one additional
+// decimal digit.
+// The maximum number of digits required for the fractional part is based on
+// the minimal subnormal hexadecimal output's power of 10. Every division of a
+// fraction's binary 1 by 2, requires one additional decimal digit.
+//
+// The maximum size of a formatted value depends on the selected output format.
+// Ignoring the fact the format string can request a precision larger than the
+// values maximum required, these values are:
+//
+// sign 1 code unit
+// __max_integral
+// radix point 1 code unit
+// __max_fractional
+// exponent character 1 code unit
+// sign 1 code unit
+// __max_fractional_value
+// -----------------------------------
+// total 4 code units extra required.
+//
+// TODO FMT Optimize the storage to avoid storing digits that are known to be zero.
+// https://www.exploringbinary.com/maximum-number-of-decimal-digits-in-binary-floating-point-numbers/
+
+// TODO FMT Add long double specialization when to_chars has proper long double support.
+template <class _Tp>
+struct __traits;
+
+template <floating_point _Fp>
+static constexpr size_t __float_buffer_size(int __precision) {
+ using _Traits = __traits<_Fp>;
+ return 4 + _Traits::__max_integral + __precision + _Traits::__max_fractional_value;
+}
+
+template <>
+struct __traits<float> {
+ static constexpr int __max_integral = 38;
+ static constexpr int __max_fractional = 149;
+ static constexpr int __max_fractional_value = 3;
+ static constexpr size_t __stack_buffer_size = 256;
+
+ static constexpr int __hex_precision_digits = 3;
+};
+
+template <>
+struct __traits<double> {
+ static constexpr int __max_integral = 308;
+ static constexpr int __max_fractional = 1074;
+ static constexpr int __max_fractional_value = 4;
+ static constexpr size_t __stack_buffer_size = 1024;
+
+ static constexpr int __hex_precision_digits = 4;
+};
+
+/// Helper class to store the conversion buffer.
+///
+/// Depending on the maxium size required for a value, the buffer is allocated
+/// on the stack or the heap.
+template <floating_point _Fp>
+class _LIBCPP_TEMPLATE_VIS __float_buffer {
+ using _Traits = __traits<_Fp>;
+
+public:
+ // TODO FMT Improve this constructor to do a better estimate.
+ // When using a scientific formatting with a precision of 6 a stack buffer
+ // will always suffice. At the moment that isn't important since floats and
+ // doubles use a stack buffer, unless the precision used in the format string
+ // is large.
+ // When supporting long doubles the __max_integral part becomes 4932 which
+ // may be too much for some platforms. For these cases a better estimate is
+ // required.
+ explicit _LIBCPP_HIDE_FROM_ABI __float_buffer(int __precision)
+ : __precision_(__precision != -1 ? __precision : _Traits::__max_fractional) {
+
+ // When the precision is larger than _Traits::__max_fractional the digits in
+ // the range (_Traits::__max_fractional, precision] will contain the value
+ // zero. There's no need to request to_chars to write these zeros:
+ // - When the value is large a temporary heap buffer needs to be allocated.
+ // - When to_chars writes the values they need to be "copied" to the output:
+ // - char: std::fill on the output iterator is faster than std::copy.
+ // - wchar_t: same argument as char, but additional std::copy won't work.
+ // The input is always a char buffer, so every char in the buffer needs
+ // to be converted from a char to a wchar_t.
+ if (__precision_ > _Traits::__max_fractional) {
+ __num_trailing_zeros_ = __precision_ - _Traits::__max_fractional;
+ __precision_ = _Traits::__max_fractional;
+ }
+
+ __size_ = __format_spec::__float_buffer_size<_Fp>(__precision_);
+ if (__size_ > _Traits::__stack_buffer_size)
+ // The allocated buffer's contents don't need initialization.
+ __begin_ = allocator<char>{}.allocate(__size_);
+ else
+ __begin_ = __buffer_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI ~__float_buffer() {
+ if (__size_ > _Traits::__stack_buffer_size)
+ allocator<char>{}.deallocate(__begin_, __size_);
+ }
+ _LIBCPP_HIDE_FROM_ABI __float_buffer(const __float_buffer&) = delete;
+ _LIBCPP_HIDE_FROM_ABI __float_buffer& operator=(const __float_buffer&) = delete;
+
+ _LIBCPP_HIDE_FROM_ABI char* begin() const { return __begin_; }
+ _LIBCPP_HIDE_FROM_ABI char* end() const { return __begin_ + __size_; }
+
+ _LIBCPP_HIDE_FROM_ABI int __precision() const { return __precision_; }
+ _LIBCPP_HIDE_FROM_ABI int __num_trailing_zeros() const { return __num_trailing_zeros_; }
+ _LIBCPP_HIDE_FROM_ABI void __remove_trailing_zeros() { __num_trailing_zeros_ = 0; }
+
+private:
+ int __precision_;
+ int __num_trailing_zeros_{0};
+ size_t __size_;
+ char* __begin_;
+ char __buffer_[_Traits::__stack_buffer_size];
+};
+
+struct __float_result {
+ /// Points at the beginning of the integral part in the buffer.
+ ///
+ /// When there's no sign character this points at the start of the buffer.
+ char* __integral;
+
+ /// Points at the radix point, when not present it's the same as \ref __last.
+ char* __radix_point;
+
+ /// Points at the exponent character, when not present it's the same as \ref __last.
+ char* __exponent;
+
+ /// Points beyond the last written element in the buffer.
+ char* __last;
+};
+
+/// Finds the position of the exponent character 'e' at the end of the buffer.
+///
+/// Assuming there is an exponent the input will terminate with
+/// eSdd and eSdddd (S = sign, d = digit)
+///
+/// \returns a pointer to the exponent or __last when not found.
+constexpr inline _LIBCPP_HIDE_FROM_ABI char* __find_exponent(char* __first, char* __last) {
+ ptrdiff_t __size = __last - __first;
+ if (__size > 4) {
+ __first = __last - _VSTD::min(__size, ptrdiff_t(6));
+ for (; __first != __last - 3; ++__first) {
+ if (*__first == 'e')
+ return __first;
+ }
+ }
+ return __last;
+}
+
+template <class _Fp, class _Tp>
+_LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_default(const __float_buffer<_Fp>& __buffer, _Tp __value,
+ char* __integral) {
+ __float_result __result;
+ __result.__integral = __integral;
+ __result.__last = __format_spec::__to_buffer(__integral, __buffer.end(), __value);
+
+ __result.__exponent = __format_spec::__find_exponent(__result.__integral, __result.__last);
+
+ // Constrains:
+ // - There's at least one decimal digit before the radix point.
+ // - The radix point, when present, is placed before the exponent.
+ __result.__radix_point = _VSTD::find(__result.__integral + 1, __result.__exponent, '.');
+
+ // When the radix point isn't found its position is the exponent instead of
+ // __result.__last.
+ if (__result.__radix_point == __result.__exponent)
+ __result.__radix_point = __result.__last;
+
+ // clang-format off
+ _LIBCPP_ASSERT((__result.__integral != __result.__last) &&
+ (__result.__radix_point == __result.__last || *__result.__radix_point == '.') &&
+ (__result.__exponent == __result.__last || *__result.__exponent == 'e'),
+ "Post-condition failure.");
+ // clang-format on
+
+ return __result;
+}
+
+template <class _Fp, class _Tp>
+_LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_hexadecimal_lower_case(const __float_buffer<_Fp>& __buffer,
+ _Tp __value, int __precision,
+ char* __integral) {
+ __float_result __result;
+ __result.__integral = __integral;
+ if (__precision == -1)
+ __result.__last = __format_spec::__to_buffer(__integral, __buffer.end(), __value, chars_format::hex);
+ else
+ __result.__last = __format_spec::__to_buffer(__integral, __buffer.end(), __value, chars_format::hex, __precision);
+
+ // H = one or more hex-digits
+ // S = sign
+ // D = one or more decimal-digits
+ // When the fractional part is zero and no precision the output is 0p+0
+ // else the output is 0.HpSD
+ // So testing the second position can differentiate between these two cases.
+ char* __first = __integral + 1;
+ if (*__first == '.') {
+ __result.__radix_point = __first;
+ // One digit is the minimum
+ // 0.hpSd
+ // ^-- last
+ // ^---- integral = end of search
+ // ^-------- start of search
+ // 0123456
+ //
+ // Four digits is the maximum
+ // 0.hpSdddd
+ // ^-- last
+ // ^---- integral = end of search
+ // ^-------- start of search
+ // 0123456789
+ static_assert(__traits<_Fp>::__hex_precision_digits <= 4, "Guard against possible underflow.");
+
+ char* __last = __result.__last - 2;
+ __first = __last - __traits<_Fp>::__hex_precision_digits;
+ __result.__exponent = _VSTD::find(__first, __last, 'p');
+ } else {
+ __result.__radix_point = __result.__last;
+ __result.__exponent = __first;
+ }
+
+ // clang-format off
+ _LIBCPP_ASSERT((__result.__integral != __result.__last) &&
+ (__result.__radix_point == __result.__last || *__result.__radix_point == '.') &&
+ (__result.__exponent != __result.__last && *__result.__exponent == 'p'),
+ "Post-condition failure.");
+ // clang-format on
+
+ return __result;
+}
+
+template <class _Fp, class _Tp>
+_LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_hexadecimal_upper_case(const __float_buffer<_Fp>& __buffer,
+ _Tp __value, int __precision,
+ char* __integral) {
+ __float_result __result =
+ __format_spec::__format_buffer_hexadecimal_lower_case(__buffer, __value, __precision, __integral);
+ _VSTD::transform(__result.__integral, __result.__exponent, __result.__integral, __hex_to_upper);
+ *__result.__exponent = 'P';
+ return __result;
+}
+
+template <class _Fp, class _Tp>
+_LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_scientific_lower_case(const __float_buffer<_Fp>& __buffer,
+ _Tp __value, int __precision,
+ char* __integral) {
+ __float_result __result;
+ __result.__integral = __integral;
+ __result.__last =
+ __format_spec::__to_buffer(__integral, __buffer.end(), __value, chars_format::scientific, __precision);
+
+ char* __first = __integral + 1;
+ _LIBCPP_ASSERT(__first != __result.__last, "No exponent present");
+ if (*__first == '.') {
+ __result.__radix_point = __first;
+ __result.__exponent = __format_spec::__find_exponent(__first + 1, __result.__last);
+ } else {
+ __result.__radix_point = __result.__last;
+ __result.__exponent = __first;
+ }
+
+ // clang-format off
+ _LIBCPP_ASSERT((__result.__integral != __result.__last) &&
+ (__result.__radix_point == __result.__last || *__result.__radix_point == '.') &&
+ (__result.__exponent != __result.__last && *__result.__exponent == 'e'),
+ "Post-condition failure.");
+ // clang-format on
+ return __result;
+}
+
+template <class _Fp, class _Tp>
+_LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_scientific_upper_case(const __float_buffer<_Fp>& __buffer,
+ _Tp __value, int __precision,
+ char* __integral) {
+ __float_result __result =
+ __format_spec::__format_buffer_scientific_lower_case(__buffer, __value, __precision, __integral);
+ *__result.__exponent = 'E';
+ return __result;
+}
+
+template <class _Fp, class _Tp>
+_LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_fixed(const __float_buffer<_Fp>& __buffer, _Tp __value,
+ int __precision, char* __integral) {
+ __float_result __result;
+ __result.__integral = __integral;
+ __result.__last = __format_spec::__to_buffer(__integral, __buffer.end(), __value, chars_format::fixed, __precision);
+
+ // When there's no precision there's no radix point.
+ // Else the radix point is placed at __precision + 1 from the end.
+ // By converting __precision to a bool the subtraction can be done
+ // unconditionally.
+ __result.__radix_point = __result.__last - (__precision + bool(__precision));
+ __result.__exponent = __result.__last;
+
+ // clang-format off
+ _LIBCPP_ASSERT((__result.__integral != __result.__last) &&
+ (__result.__radix_point == __result.__last || *__result.__radix_point == '.') &&
+ (__result.__exponent == __result.__last),
+ "Post-condition failure.");
+ // clang-format on
+ return __result;
+}
+
+template <class _Fp, class _Tp>
+_LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_general_lower_case(__float_buffer<_Fp>& __buffer, _Tp __value,
+ int __precision, char* __integral) {
+
+ __buffer.__remove_trailing_zeros();
+
+ __float_result __result;
+ __result.__integral = __integral;
+ __result.__last = __format_spec::__to_buffer(__integral, __buffer.end(), __value, chars_format::general, __precision);
+
+ char* __first = __integral + 1;
+ if (__first == __result.__last) {
+ __result.__radix_point = __result.__last;
+ __result.__exponent = __result.__last;
+ } else {
+ __result.__exponent = __format_spec::__find_exponent(__first, __result.__last);
+ if (__result.__exponent != __result.__last)
+ // In scientific mode if there's a radix point it will always be after
+ // the first digit. (This is the position __first points at).
+ __result.__radix_point = *__first == '.' ? __first : __result.__last;
+ else {
+ // In fixed mode the algorithm truncates trailing spaces and possibly the
+ // radix point. There's no good guess for the position of the radix point
+ // therefore scan the output after the first digit.
+ __result.__radix_point = _VSTD::find(__first, __result.__last, '.');
+ }
+ }
+
+ // clang-format off
+ _LIBCPP_ASSERT((__result.__integral != __result.__last) &&
+ (__result.__radix_point == __result.__last || *__result.__radix_point == '.') &&
+ (__result.__exponent == __result.__last || *__result.__exponent == 'e'),
+ "Post-condition failure.");
+ // clang-format on
+
+ return __result;
+}
+
+template <class _Fp, class _Tp>
+_LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_general_upper_case(__float_buffer<_Fp>& __buffer, _Tp __value,
+ int __precision, char* __integral) {
+ __float_result __result =
+ __format_spec::__format_buffer_general_lower_case(__buffer, __value, __precision, __integral);
+ if (__result.__exponent != __result.__last)
+ *__result.__exponent = 'E';
+ return __result;
+}
+
+# ifndef _LIBCPP_HAS_NO_LOCALIZATION
+template <class _OutIt, class _Fp, class _CharT>
+_LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(_OutIt __out_it, const __float_buffer<_Fp>& __buffer,
+ const __float_result& __result, _VSTD::locale __loc,
+ size_t __width, _Flags::_Alignment __alignment,
+ _CharT __fill) {
+ const auto& __np = use_facet<numpunct<_CharT>>(__loc);
+ string __grouping = __np.grouping();
+ char* __first = __result.__integral;
+ // When no radix point or exponent are present __last will be __result.__last.
+ char* __last = _VSTD::min(__result.__radix_point, __result.__exponent);
+
+ ptrdiff_t __digits = __last - __first;
+ if (!__grouping.empty()) {
+ if (__digits <= __grouping[0])
+ __grouping.clear();
+ else
+ __grouping = __determine_grouping(__digits, __grouping);
+ }
+
+ size_t __size = __result.__last - __buffer.begin() + // Formatted string
+ __buffer.__num_trailing_zeros() + // Not yet rendered zeros
+ __grouping.size() - // Grouping contains one
+ !__grouping.empty(); // additional character
+
+ __formatter::__padding_size_result __padding = {0, 0};
+ bool __zero_padding = __alignment == _Flags::_Alignment::__default;
+ if (__size < __width) {
+ if (__zero_padding) {
+ __alignment = _Flags::_Alignment::__right;
+ __fill = _CharT('0');
+ }
+
+ __padding = __formatter::__padding_size(__size, __width, __alignment);
+ }
+
+ // sign and (zero padding or alignment)
+ if (__zero_padding && __first != __buffer.begin())
+ *__out_it++ = *__buffer.begin();
+ __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before, __fill);
+ if (!__zero_padding && __first != __buffer.begin())
+ *__out_it++ = *__buffer.begin();
+
+ // integral part
+ if (__grouping.empty()) {
+ __out_it = _VSTD::copy_n(__first, __digits, _VSTD::move(__out_it));
+ } else {
+ auto __r = __grouping.rbegin();
+ auto __e = __grouping.rend() - 1;
+ _CharT __sep = __np.thousands_sep();
+ // The output is divided in small groups of numbers to write:
+ // - A group before the first separator.
+ // - A separator and a group, repeated for the number of separators.
+ // - A group after the last separator.
+ // This loop achieves that process by testing the termination condition
+ // midway in the loop.
+ while (true) {
+ __out_it = _VSTD::copy_n(__first, *__r, _VSTD::move(__out_it));
+ __first += *__r;
+
+ if (__r == __e)
+ break;
+
+ ++__r;
+ *__out_it++ = __sep;
+ }
+ }
+
+ // fractional part
+ if (__result.__radix_point != __result.__last) {
+ *__out_it++ = __np.decimal_point();
+ __out_it = _VSTD::copy(__result.__radix_point + 1, __result.__exponent, _VSTD::move(__out_it));
+ __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __buffer.__num_trailing_zeros(), _CharT('0'));
+ }
+
+ // exponent
+ if (__result.__exponent != __result.__last)
+ __out_it = _VSTD::copy(__result.__exponent, __result.__last, _VSTD::move(__out_it));
+
+ // alignment
+ return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after, __fill);
+}
+
+# endif // _LIBCPP_HAS_NO_LOCALIZATION
+
+template <__formatter::__char_type _CharT>
+class _LIBCPP_TEMPLATE_VIS __formatter_floating_point : public __parser_floating_point<_CharT> {
+public:
+ template <floating_point _Tp>
+ _LIBCPP_HIDE_FROM_ABI auto format(_Tp __value, auto& __ctx) -> decltype(__ctx.out()) {
+ if (this->__width_needs_substitution())
+ this->__substitute_width_arg_id(__ctx.arg(this->__width));
+
+ bool __negative = _VSTD::signbit(__value);
+
+ if (!_VSTD::isfinite(__value)) [[unlikely]]
+ return __format_non_finite(__ctx.out(), __negative, _VSTD::isnan(__value));
+
+ bool __has_precision = this->__has_precision_field();
+ if (this->__precision_needs_substitution())
+ this->__substitute_precision_arg_id(__ctx.arg(this->__precision));
+
+ // Depending on the std-format-spec string the sign and the value
+ // might not be outputted together:
+ // - zero-padding may insert additional '0' characters.
+ // Therefore the value is processed as a non negative value.
+ // The function @ref __insert_sign will insert a '-' when the value was
+ // negative.
+
+ if (__negative)
+ __value = _VSTD::copysign(__value, +1.0);
+
+ // TODO FMT _Fp should just be _Tp when to_chars has proper long double support.
+ using _Fp = conditional_t<same_as<_Tp, long double>, double, _Tp>;
+ // Force the type of the precision to avoid -1 to become an unsigned value.
+ __float_buffer<_Fp> __buffer(__has_precision ? int(this->__precision) : -1);
+ __float_result __result = __format_buffer(__buffer, __value, __negative, __has_precision);
+
+ if (this->__alternate_form && __result.__radix_point == __result.__last) {
+ *__result.__last++ = '.';
+
+ // When there is an exponent the point needs to be moved before the
+ // exponent. When there's no exponent the rotate does nothing. Since
+ // rotate tests whether the operation is a nop, call it unconditionally.
+ _VSTD::rotate(__result.__exponent, __result.__last - 1, __result.__last);
+ __result.__radix_point = __result.__exponent;
+
+ // The radix point is always placed before the exponent.
+ // - No exponent needs to point to the new last.
+ // - An exponent needs to move one position to the right.
+ // So it's safe to increment the value unconditionally.
+ ++__result.__exponent;
+ }
+
+# ifndef _LIBCPP_HAS_NO_LOCALIZATION
+ if (this->__locale_specific_form)
+ return __format_spec::__format_locale_specific_form(__ctx.out(), __buffer, __result, __ctx.locale(),
+ this->__width, this->__alignment, this->__fill);
+# endif
+
+ ptrdiff_t __size = __result.__last - __buffer.begin();
+ int __num_trailing_zeros = __buffer.__num_trailing_zeros();
+ if (__size + __num_trailing_zeros >= this->__width) {
+ if (__num_trailing_zeros && __result.__exponent != __result.__last)
+ // Insert trailing zeros before exponent character.
+ return _VSTD::copy(__result.__exponent, __result.__last,
+ _VSTD::fill_n(_VSTD::copy(__buffer.begin(), __result.__exponent, __ctx.out()),
+ __num_trailing_zeros, _CharT('0')));
+
+ return _VSTD::fill_n(_VSTD::copy(__buffer.begin(), __result.__last, __ctx.out()), __num_trailing_zeros,
+ _CharT('0'));
+ }
+
+ auto __out_it = __ctx.out();
+ char* __first = __buffer.begin();
+ if (this->__alignment == _Flags::_Alignment::__default) {
+ // When there is a sign output it before the padding. Note the __size
+ // doesn't need any adjustment, regardless whether the sign is written
+ // here or in __formatter::__write.
+ if (__first != __result.__integral)
+ *__out_it++ = *__first++;
+ // After the sign is written, zero padding is the same a right alignment
+ // with '0'.
+ this->__alignment = _Flags::_Alignment::__right;
+ this->__fill = _CharT('0');
+ }
+
+ if (__num_trailing_zeros)
+ return __formatter::__write(_VSTD::move(__out_it), __first, __result.__last, __size, this->__width, this->__fill,
+ this->__alignment, __result.__exponent, __num_trailing_zeros);
+
+ return __formatter::__write(_VSTD::move(__out_it), __first, __result.__last, __size, this->__width, this->__fill,
+ this->__alignment);
+ }
+
+private:
+ template <class _OutIt>
+ _LIBCPP_HIDE_FROM_ABI _OutIt __format_non_finite(_OutIt __out_it, bool __negative, bool __isnan) {
+ char __buffer[4];
+ char* __last = __insert_sign(__buffer, __negative, this->__sign);
+
+ // to_char can return inf, infinity, nan, and nan(n-char-sequence).
+ // The format library requires inf and nan.
+ // All in one expression to avoid dangling references.
+ __last = _VSTD::copy_n(&("infnanINFNAN"[6 * (this->__type == _Flags::_Type::__float_hexadecimal_upper_case ||
+ this->__type == _Flags::_Type::__scientific_upper_case ||
+ this->__type == _Flags::_Type::__fixed_upper_case ||
+ this->__type == _Flags::_Type::__general_upper_case) +
+ 3 * __isnan]),
+ 3, __last);
+
+ // [format.string.std]/13
+ // A zero (0) character preceding the width field pads the field with
+ // leading zeros (following any indication of sign or base) to the field
+ // width, except when applied to an infinity or NaN.
+ if (this->__alignment == _Flags::_Alignment::__default)
+ this->__alignment = _Flags::_Alignment::__right;
+
+ ptrdiff_t __size = __last - __buffer;
+ if (__size >= this->__width)
+ return _VSTD::copy_n(__buffer, __size, _VSTD::move(__out_it));
+
+ return __formatter::__write(_VSTD::move(__out_it), __buffer, __last, __size, this->__width, this->__fill,
+ this->__alignment);
+ }
+
+ /// Fills the buffer with the data based on the requested formatting.
+ ///
+ /// This function, when needed, turns the characters to upper case and
+ /// determines the "interesting" locations which are returned to the caller.
+ ///
+ /// This means the caller never has to convert the contents of the buffer to
+ /// upper case or search for radix points and the location of the exponent.
+ /// This gives a bit of overhead. The original code didn't do that, but due
+ /// to the number of possible additional work needed to turn this number to
+ /// the proper output the code was littered with tests for upper cases and
+ /// searches for radix points and exponents.
+ /// - When a precision larger than the type's precision is selected
+ /// additional zero characters need to be written before the exponent.
+ /// - alternate form needs to add a radix point when not present.
+ /// - localization needs to do grouping in the integral part.
+ template <class _Fp, class _Tp>
+ // TODO FMT _Fp should just be _Tp when to_chars has proper long double support.
+ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer(__float_buffer<_Fp>& __buffer, _Tp __value, bool __negative,
+ bool __has_precision) {
+ char* __first = __insert_sign(__buffer.begin(), __negative, this->__sign);
+ switch (this->__type) {
+ case _Flags::_Type::__default:
+ return __format_spec::__format_buffer_default(__buffer, __value, __first);
+
+ case _Flags::_Type::__float_hexadecimal_lower_case:
+ return __format_spec::__format_buffer_hexadecimal_lower_case(
+ __buffer, __value, __has_precision ? __buffer.__precision() : -1, __first);
+
+ case _Flags::_Type::__float_hexadecimal_upper_case:
+ return __format_spec::__format_buffer_hexadecimal_upper_case(
+ __buffer, __value, __has_precision ? __buffer.__precision() : -1, __first);
+
+ case _Flags::_Type::__scientific_lower_case:
+ return __format_spec::__format_buffer_scientific_lower_case(__buffer, __value, __buffer.__precision(), __first);
+
+ case _Flags::_Type::__scientific_upper_case:
+ return __format_spec::__format_buffer_scientific_upper_case(__buffer, __value, __buffer.__precision(), __first);
+
+ case _Flags::_Type::__fixed_lower_case:
+ case _Flags::_Type::__fixed_upper_case:
+ return __format_spec::__format_buffer_fixed(__buffer, __value, __buffer.__precision(), __first);
+
+ case _Flags::_Type::__general_lower_case:
+ return __format_spec::__format_buffer_general_lower_case(__buffer, __value, __buffer.__precision(), __first);
+
+ case _Flags::_Type::__general_upper_case:
+ return __format_spec::__format_buffer_general_upper_case(__buffer, __value, __buffer.__precision(), __first);
+
+ default:
+ _LIBCPP_ASSERT(false, "The parser should have validated the type");
+ __libcpp_unreachable();
+ }
+ }
+};
+
+} //namespace __format_spec
+
+template <__formatter::__char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<float, _CharT>
+ : public __format_spec::__formatter_floating_point<_CharT> {};
+template <__formatter::__char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<double, _CharT>
+ : public __format_spec::__formatter_floating_point<_CharT> {};
+template <__formatter::__char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long double, _CharT>
+ : public __format_spec::__formatter_floating_point<_CharT> {};
+
+# endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___FORMAT_FORMATTER_FLOATING_POINT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter_integer.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter_integer.h
new file mode 100644
index 0000000000..e6143a4745
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter_integer.h
@@ -0,0 +1,170 @@
+// -*- 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_FORMATTER_INTEGER_H
+#define _LIBCPP___FORMAT_FORMATTER_INTEGER_H
+
+#include <__availability>
+#include <__config>
+#include <__format/format_error.h>
+#include <__format/format_fwd.h>
+#include <__format/formatter.h>
+#include <__format/formatter_integral.h>
+#include <__format/parser_std_format_spec.h>
+#include <limits>
+
+#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)
+
+namespace __format_spec {
+
+template <class _CharT>
+class _LIBCPP_TEMPLATE_VIS __parser_integer : public __parser_integral<_CharT> {
+public:
+ _LIBCPP_HIDE_FROM_ABI constexpr auto parse(auto& __parse_ctx)
+ -> decltype(__parse_ctx.begin()) {
+ auto __it = __parser_integral<_CharT>::__parse(__parse_ctx);
+
+ switch (this->__type) {
+ case _Flags::_Type::__default:
+ this->__type = _Flags::_Type::__decimal;
+ [[fallthrough]];
+
+ case _Flags::_Type::__binary_lower_case:
+ case _Flags::_Type::__binary_upper_case:
+ case _Flags::_Type::__octal:
+ case _Flags::_Type::__decimal:
+ case _Flags::_Type::__hexadecimal_lower_case:
+ case _Flags::_Type::__hexadecimal_upper_case:
+ this->__handle_integer();
+ break;
+
+ case _Flags::_Type::__char:
+ this->__handle_char();
+ break;
+
+ default:
+ __throw_format_error("The format-spec type has a type not supported for "
+ "an integer argument");
+ }
+ return __it;
+ }
+};
+
+template <class _CharT>
+using __formatter_integer = __formatter_integral<__parser_integer<_CharT>>;
+
+} // namespace __format_spec
+
+// [format.formatter.spec]/2.3
+// For each charT, for each cv-unqualified arithmetic type ArithmeticT other
+// than char, wchar_t, char8_t, char16_t, or char32_t, a specialization
+
+// Signed integral types.
+template <__formatter::__char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
+ formatter<signed char, _CharT>
+ : public __format_spec::__formatter_integer<_CharT> {};
+template <__formatter::__char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<short, _CharT>
+ : public __format_spec::__formatter_integer<_CharT> {};
+template <__formatter::__char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<int, _CharT>
+ : public __format_spec::__formatter_integer<_CharT> {};
+template <__formatter::__char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long, _CharT>
+ : public __format_spec::__formatter_integer<_CharT> {};
+template <__formatter::__char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
+ formatter<long long, _CharT>
+ : public __format_spec::__formatter_integer<_CharT> {};
+#ifndef _LIBCPP_HAS_NO_INT128
+template <__formatter::__char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
+ formatter<__int128_t, _CharT>
+ : public __format_spec::__formatter_integer<_CharT> {
+ using _Base = __format_spec::__formatter_integer<_CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI auto format(__int128_t __value, auto& __ctx)
+ -> decltype(__ctx.out()) {
+ // TODO FMT Implement full 128 bit support.
+ using _To = long long;
+ if (__value < numeric_limits<_To>::min() ||
+ __value > numeric_limits<_To>::max())
+ __throw_format_error("128-bit value is outside of implemented range");
+
+ return _Base::format(static_cast<_To>(__value), __ctx);
+ }
+};
+#endif
+
+// Unsigned integral types.
+template <__formatter::__char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
+ formatter<unsigned char, _CharT>
+ : public __format_spec::__formatter_integer<_CharT> {};
+template <__formatter::__char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
+ formatter<unsigned short, _CharT>
+ : public __format_spec::__formatter_integer<_CharT> {};
+template <__formatter::__char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
+ formatter<unsigned, _CharT>
+ : public __format_spec::__formatter_integer<_CharT> {};
+template <__formatter::__char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
+ formatter<unsigned long, _CharT>
+ : public __format_spec::__formatter_integer<_CharT> {};
+template <__formatter::__char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
+ formatter<unsigned long long, _CharT>
+ : public __format_spec::__formatter_integer<_CharT> {};
+#ifndef _LIBCPP_HAS_NO_INT128
+template <__formatter::__char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
+ formatter<__uint128_t, _CharT>
+ : public __format_spec::__formatter_integer<_CharT> {
+ using _Base = __format_spec::__formatter_integer<_CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI auto format(__uint128_t __value, auto& __ctx)
+ -> decltype(__ctx.out()) {
+ // TODO FMT Implement full 128 bit support.
+ using _To = unsigned long long;
+ if (__value < numeric_limits<_To>::min() ||
+ __value > numeric_limits<_To>::max())
+ __throw_format_error("128-bit value is outside of implemented range");
+
+ return _Base::format(static_cast<_To>(__value), __ctx);
+ }
+};
+#endif
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___FORMAT_FORMATTER_INTEGER_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter_integral.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter_integral.h
new file mode 100644
index 0000000000..836082671c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter_integral.h
@@ -0,0 +1,465 @@
+// -*- 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_FORMATTER_INTEGRAL_H
+#define _LIBCPP___FORMAT_FORMATTER_INTEGRAL_H
+
+#include <__algorithm/copy.h>
+#include <__algorithm/copy_n.h>
+#include <__algorithm/fill_n.h>
+#include <__algorithm/transform.h>
+#include <__assert>
+#include <__config>
+#include <__format/format_error.h>
+#include <__format/format_fwd.h>
+#include <__format/formatter.h>
+#include <__format/parser_std_format_spec.h>
+#include <__utility/unreachable.h>
+#include <array>
+#include <charconv>
+#include <concepts>
+#include <limits>
+#include <string>
+
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+#include <locale>
+#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
+
+// 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)
+
+/**
+ * Integral formatting classes.
+ *
+ * There are two types used here:
+ * * C++-type, the type as used in C++.
+ * * format-type, the output type specified in the std-format-spec.
+ *
+ * Design of the integral formatters consists of several layers.
+ * * @ref __parser_integral The basic std-format-spec parser for all integral
+ * classes. This parser does the basic sanity checks. It also contains some
+ * helper functions that are nice to have available for all parsers.
+ * * A C++-type specific parser. These parsers must derive from
+ * @ref __parser_integral. Their task is to validate whether the parsed
+ * std-format-spec is valid for the C++-type and selected format-type. After
+ * validation they need to make sure all members are properly set. For
+ * example, when the alignment hasn't changed it needs to set the proper
+ * default alignment for the format-type. The following parsers are available:
+ * - @ref __parser_integer
+ * - @ref __parser_char
+ * - @ref __parser_bool
+ * * A general formatter for all integral types @ref __formatter_integral. This
+ * formatter can handle all formatting of integers and characters. The class
+ * derives from the proper formatter.
+ * Note the boolean string format-type isn't supported in this class.
+ * * A typedef C++-type group combining the @ref __formatter_integral with a
+ * parser:
+ * * @ref __formatter_integer
+ * * @ref __formatter_char
+ * * @ref __formatter_bool
+ * * Then every C++-type has its own formatter specializations. They inherit
+ * from the C++-type group typedef. Most specializations need nothing else.
+ * Others need some additional specializations in this class.
+ */
+namespace __format_spec {
+
+/** Wrapper around @ref to_chars, returning the output pointer. */
+template <integral _Tp>
+_LIBCPP_HIDE_FROM_ABI char* __to_buffer(char* __first, char* __last,
+ _Tp __value, int __base) {
+ // TODO FMT Evaluate code overhead due to not calling the internal function
+ // directly. (Should be zero overhead.)
+ to_chars_result __r = _VSTD::to_chars(__first, __last, __value, __base);
+ _LIBCPP_ASSERT(__r.ec == errc(0), "Internal buffer too small");
+ return __r.ptr;
+}
+
+/**
+ * Helper to determine the buffer size to output a integer in Base @em x.
+ *
+ * There are several overloads for the supported bases. The function uses the
+ * base as template argument so it can be used in a constant expression.
+ */
+template <unsigned_integral _Tp, size_t _Base>
+_LIBCPP_HIDE_FROM_ABI constexpr size_t __buffer_size() noexcept
+ requires(_Base == 2) {
+ return numeric_limits<_Tp>::digits // The number of binary digits.
+ + 2 // Reserve space for the '0[Bb]' prefix.
+ + 1; // Reserve space for the sign.
+}
+
+template <unsigned_integral _Tp, size_t _Base>
+_LIBCPP_HIDE_FROM_ABI constexpr size_t __buffer_size() noexcept
+ requires(_Base == 8) {
+ return numeric_limits<_Tp>::digits // The number of binary digits.
+ / 3 // Adjust to octal.
+ + 1 // Turn floor to ceil.
+ + 1 // Reserve space for the '0' prefix.
+ + 1; // Reserve space for the sign.
+}
+
+template <unsigned_integral _Tp, size_t _Base>
+_LIBCPP_HIDE_FROM_ABI constexpr size_t __buffer_size() noexcept
+ requires(_Base == 10) {
+ return numeric_limits<_Tp>::digits10 // The floored value.
+ + 1 // Turn floor to ceil.
+ + 1; // Reserve space for the sign.
+}
+
+template <unsigned_integral _Tp, size_t _Base>
+_LIBCPP_HIDE_FROM_ABI constexpr size_t __buffer_size() noexcept
+ requires(_Base == 16) {
+ return numeric_limits<_Tp>::digits // The number of binary digits.
+ / 4 // Adjust to hexadecimal.
+ + 2 // Reserve space for the '0[Xx]' prefix.
+ + 1; // Reserve space for the sign.
+}
+
+/**
+ * Determines the required grouping based on the size of the input.
+ *
+ * The grouping's last element will be repeated. For simplicity this repeating
+ * is unwrapped based on the length of the input. (When the input is short some
+ * groups are not processed.)
+ *
+ * @returns The size of the groups to write. This means the number of
+ * separator characters written is size() - 1.
+ *
+ * @note Since zero-sized groups cause issues they are silently ignored.
+ *
+ * @note The grouping field of the locale is always a @c std::string,
+ * regardless whether the @c std::numpunct's type is @c char or @c wchar_t.
+ */
+_LIBCPP_HIDE_FROM_ABI inline string
+__determine_grouping(ptrdiff_t __size, const string& __grouping) {
+ _LIBCPP_ASSERT(!__grouping.empty() && __size > __grouping[0],
+ "The slow grouping formatting is used while there will be no "
+ "separators written");
+ string __r;
+ auto __end = __grouping.end() - 1;
+ auto __ptr = __grouping.begin();
+
+ while (true) {
+ __size -= *__ptr;
+ if (__size > 0)
+ __r.push_back(*__ptr);
+ else {
+ // __size <= 0 so the value pushed will be <= *__ptr.
+ __r.push_back(*__ptr + __size);
+ return __r;
+ }
+
+ // Proceed to the next group.
+ if (__ptr != __end) {
+ do {
+ ++__ptr;
+ // Skip grouping with a width of 0.
+ } while (*__ptr == 0 && __ptr != __end);
+ }
+ }
+
+ __libcpp_unreachable();
+}
+
+template <class _Parser>
+requires __formatter::__char_type<typename _Parser::char_type>
+class _LIBCPP_TEMPLATE_VIS __formatter_integral : public _Parser {
+public:
+ using _CharT = typename _Parser::char_type;
+
+ template <integral _Tp>
+ _LIBCPP_HIDE_FROM_ABI auto format(_Tp __value, auto& __ctx)
+ -> decltype(__ctx.out()) {
+ if (this->__width_needs_substitution())
+ this->__substitute_width_arg_id(__ctx.arg(this->__width));
+
+ if (this->__type == _Flags::_Type::__char)
+ return __format_as_char(__value, __ctx);
+
+ if constexpr (unsigned_integral<_Tp>)
+ return __format_unsigned_integral(__value, false, __ctx);
+ else {
+ // Depending on the std-format-spec string the sign and the value
+ // might not be outputted together:
+ // - alternate form may insert a prefix string.
+ // - zero-padding may insert additional '0' characters.
+ // Therefore the value is processed as a positive unsigned value.
+ // The function @ref __insert_sign will a '-' when the value was negative.
+ auto __r = __to_unsigned_like(__value);
+ bool __negative = __value < 0;
+ if (__negative)
+ __r = __complement(__r);
+
+ return __format_unsigned_integral(__r, __negative, __ctx);
+ }
+ }
+
+private:
+ /** Generic formatting for format-type c. */
+ _LIBCPP_HIDE_FROM_ABI auto __format_as_char(integral auto __value,
+ auto& __ctx)
+ -> decltype(__ctx.out()) {
+ if (this->__alignment == _Flags::_Alignment::__default)
+ this->__alignment = _Flags::_Alignment::__right;
+
+ using _Tp = decltype(__value);
+ if constexpr (!same_as<_CharT, _Tp>) {
+ // cmp_less and cmp_greater can't be used for character types.
+ if constexpr (signed_integral<_CharT> == signed_integral<_Tp>) {
+ if (__value < numeric_limits<_CharT>::min() ||
+ __value > numeric_limits<_CharT>::max())
+ __throw_format_error(
+ "Integral value outside the range of the char type");
+ } else if constexpr (signed_integral<_CharT>) {
+ // _CharT is signed _Tp is unsigned
+ if (__value >
+ static_cast<make_unsigned_t<_CharT>>(numeric_limits<_CharT>::max()))
+ __throw_format_error(
+ "Integral value outside the range of the char type");
+ } else {
+ // _CharT is unsigned _Tp is signed
+ if (__value < 0 || static_cast<make_unsigned_t<_Tp>>(__value) >
+ numeric_limits<_CharT>::max())
+ __throw_format_error(
+ "Integral value outside the range of the char type");
+ }
+ }
+
+ const auto __c = static_cast<_CharT>(__value);
+ return __write(_VSTD::addressof(__c), _VSTD::addressof(__c) + 1,
+ __ctx.out());
+ }
+
+ /**
+ * Generic formatting for format-type bBdoxX.
+ *
+ * This small wrapper allocates a buffer with the required size. Then calls
+ * the real formatter with the buffer and the prefix for the base.
+ */
+ _LIBCPP_HIDE_FROM_ABI auto
+ __format_unsigned_integral(unsigned_integral auto __value, bool __negative,
+ auto& __ctx) -> decltype(__ctx.out()) {
+ switch (this->__type) {
+ case _Flags::_Type::__binary_lower_case: {
+ array<char, __buffer_size<decltype(__value), 2>()> __array;
+ return __format_unsigned_integral(__array.begin(), __array.end(), __value,
+ __negative, 2, __ctx, "0b");
+ }
+ case _Flags::_Type::__binary_upper_case: {
+ array<char, __buffer_size<decltype(__value), 2>()> __array;
+ return __format_unsigned_integral(__array.begin(), __array.end(), __value,
+ __negative, 2, __ctx, "0B");
+ }
+ case _Flags::_Type::__octal: {
+ // Octal is special; if __value == 0 there's no prefix.
+ array<char, __buffer_size<decltype(__value), 8>()> __array;
+ return __format_unsigned_integral(__array.begin(), __array.end(), __value,
+ __negative, 8, __ctx,
+ __value != 0 ? "0" : nullptr);
+ }
+ case _Flags::_Type::__decimal: {
+ array<char, __buffer_size<decltype(__value), 10>()> __array;
+ return __format_unsigned_integral(__array.begin(), __array.end(), __value,
+ __negative, 10, __ctx, nullptr);
+ }
+ case _Flags::_Type::__hexadecimal_lower_case: {
+ array<char, __buffer_size<decltype(__value), 16>()> __array;
+ return __format_unsigned_integral(__array.begin(), __array.end(), __value,
+ __negative, 16, __ctx, "0x");
+ }
+ case _Flags::_Type::__hexadecimal_upper_case: {
+ array<char, __buffer_size<decltype(__value), 16>()> __array;
+ return __format_unsigned_integral(__array.begin(), __array.end(), __value,
+ __negative, 16, __ctx, "0X");
+ }
+ default:
+ _LIBCPP_ASSERT(false, "The parser should have validated the type");
+ __libcpp_unreachable();
+ }
+ }
+
+ template <class _Tp>
+ requires(same_as<char, _Tp> || same_as<wchar_t, _Tp>) _LIBCPP_HIDE_FROM_ABI
+ auto __write(const _Tp* __first, const _Tp* __last, auto __out_it)
+ -> decltype(__out_it) {
+
+ unsigned __size = __last - __first;
+ if (this->__type != _Flags::_Type::__hexadecimal_upper_case) [[likely]] {
+ if (__size >= this->__width)
+ return _VSTD::copy(__first, __last, _VSTD::move(__out_it));
+
+ return __formatter::__write(_VSTD::move(__out_it), __first, __last,
+ __size, this->__width, this->__fill,
+ this->__alignment);
+ }
+
+ // this->__type == _Flags::_Type::__hexadecimal_upper_case
+ // This means all characters in the range [a-f] need to be changed to their
+ // uppercase representation. The transformation is done as transformation
+ // in the output routine instead of before. This avoids another pass over
+ // the data.
+ // TODO FMT See whether it's possible to do this transformation during the
+ // conversion. (This probably requires changing std::to_chars' alphabet.)
+ if (__size >= this->__width)
+ return _VSTD::transform(__first, __last, _VSTD::move(__out_it),
+ __hex_to_upper);
+
+ return __formatter::__write(_VSTD::move(__out_it), __first, __last, __size,
+ __hex_to_upper, this->__width, this->__fill,
+ this->__alignment);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI auto
+ __format_unsigned_integral(char* __begin, char* __end,
+ unsigned_integral auto __value, bool __negative,
+ int __base, auto& __ctx, const char* __prefix)
+ -> decltype(__ctx.out()) {
+ char* __first = __insert_sign(__begin, __negative, this->__sign);
+ if (this->__alternate_form && __prefix)
+ while (*__prefix)
+ *__first++ = *__prefix++;
+
+ char* __last = __to_buffer(__first, __end, __value, __base);
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+ if (this->__locale_specific_form) {
+ const auto& __np = use_facet<numpunct<_CharT>>(__ctx.locale());
+ string __grouping = __np.grouping();
+ ptrdiff_t __size = __last - __first;
+ // Writing the grouped form has more overhead than the normal output
+ // routines. If there will be no separators written the locale-specific
+ // form is identical to the normal routine. Test whether to grouped form
+ // is required.
+ if (!__grouping.empty() && __size > __grouping[0])
+ return __format_grouping(__ctx.out(), __begin, __first, __last,
+ __determine_grouping(__size, __grouping),
+ __np.thousands_sep());
+ }
+#endif
+ auto __out_it = __ctx.out();
+ if (this->__alignment != _Flags::_Alignment::__default)
+ __first = __begin;
+ else {
+ // __buf contains [sign][prefix]data
+ // ^ location of __first
+ // The zero padding is done like:
+ // - Write [sign][prefix]
+ // - Write data right aligned with '0' as fill character.
+ __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it));
+ this->__alignment = _Flags::_Alignment::__right;
+ this->__fill = _CharT('0');
+ uint32_t __size = __first - __begin;
+ this->__width -= _VSTD::min(__size, this->__width);
+ }
+
+ return __write(__first, __last, _VSTD::move(__out_it));
+ }
+
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+ /** Format's the locale-specific form's groupings. */
+ template <class _OutIt, class _CharT>
+ _LIBCPP_HIDE_FROM_ABI _OutIt
+ __format_grouping(_OutIt __out_it, const char* __begin, const char* __first,
+ const char* __last, string&& __grouping, _CharT __sep) {
+
+ // TODO FMT This function duplicates some functionality of the normal
+ // output routines. Evaluate whether these parts can be efficiently
+ // combined with the existing routines.
+
+ unsigned __size = (__first - __begin) + // [sign][prefix]
+ (__last - __first) + // data
+ (__grouping.size() - 1); // number of separator characters
+
+ __formatter::__padding_size_result __padding = {0, 0};
+ if (this->__alignment == _Flags::_Alignment::__default) {
+ // Write [sign][prefix].
+ __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it));
+
+ if (this->__width > __size) {
+ // Write zero padding.
+ __padding.__before = this->__width - __size;
+ __out_it = _VSTD::fill_n(_VSTD::move(__out_it), this->__width - __size,
+ _CharT('0'));
+ }
+ } else {
+ if (this->__width > __size) {
+ // Determine padding and write padding.
+ __padding = __formatter::__padding_size(__size, this->__width,
+ this->__alignment);
+
+ __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before,
+ this->__fill);
+ }
+ // Write [sign][prefix].
+ __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it));
+ }
+
+ auto __r = __grouping.rbegin();
+ auto __e = __grouping.rend() - 1;
+ _LIBCPP_ASSERT(__r != __e, "The slow grouping formatting is used while "
+ "there will be no separators written.");
+ // The output is divided in small groups of numbers to write:
+ // - A group before the first separator.
+ // - A separator and a group, repeated for the number of separators.
+ // - A group after the last separator.
+ // This loop achieves that process by testing the termination condition
+ // midway in the loop.
+ //
+ // TODO FMT This loop evaluates the loop invariant `this->__type !=
+ // _Flags::_Type::__hexadecimal_upper_case` for every iteration. (This test
+ // happens in the __write call.) Benchmark whether making two loops and
+ // hoisting the invariant is worth the effort.
+ while (true) {
+ if (this->__type == _Flags::_Type::__hexadecimal_upper_case) {
+ __last = __first + *__r;
+ __out_it = _VSTD::transform(__first, __last, _VSTD::move(__out_it),
+ __hex_to_upper);
+ __first = __last;
+ } else {
+ __out_it = _VSTD::copy_n(__first, *__r, _VSTD::move(__out_it));
+ __first += *__r;
+ }
+
+ if (__r == __e)
+ break;
+
+ ++__r;
+ *__out_it++ = __sep;
+ }
+
+ return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after,
+ this->__fill);
+ }
+#endif // _LIBCPP_HAS_NO_LOCALIZATION
+};
+
+} // namespace __format_spec
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___FORMAT_FORMATTER_INTEGRAL_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter_pointer.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter_pointer.h
new file mode 100644
index 0000000000..83d21e1c50
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter_pointer.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___FORMAT_FORMATTER_POINTER_H
+#define _LIBCPP___FORMAT_FORMATTER_POINTER_H
+
+#include <__algorithm/copy.h>
+#include <__assert>
+#include <__availability>
+#include <__config>
+#include <__format/format_error.h>
+#include <__format/format_fwd.h>
+#include <__format/formatter.h>
+#include <__format/formatter_integral.h>
+#include <__format/parser_std_format_spec.h>
+#include <__iterator/access.h>
+#include <cstdint>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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)
+
+namespace __format_spec {
+
+template <__formatter::__char_type _CharT>
+class _LIBCPP_TEMPLATE_VIS __formatter_pointer : public __parser_pointer<_CharT> {
+public:
+ _LIBCPP_HIDE_FROM_ABI auto format(const void* __ptr, auto& __ctx) -> decltype(__ctx.out()) {
+ _LIBCPP_ASSERT(this->__alignment != _Flags::_Alignment::__default,
+ "The call to parse should have updated the alignment");
+ if (this->__width_needs_substitution())
+ this->__substitute_width_arg_id(__ctx.arg(this->__width));
+
+ // This code looks a lot like the code to format a hexadecimal integral,
+ // but that code isn't public. Making that code public requires some
+ // refactoring.
+ // TODO FMT Remove code duplication.
+ char __buffer[2 + 2 * sizeof(uintptr_t)];
+ __buffer[0] = '0';
+ __buffer[1] = 'x';
+ char* __last = __to_buffer(__buffer + 2, _VSTD::end(__buffer), reinterpret_cast<uintptr_t>(__ptr), 16);
+
+ unsigned __size = __last - __buffer;
+ if (__size >= this->__width)
+ return _VSTD::copy(__buffer, __last, __ctx.out());
+
+ return __formatter::__write(__ctx.out(), __buffer, __last, __size, this->__width, this->__fill, this->__alignment);
+ }
+};
+
+} // namespace __format_spec
+
+// [format.formatter.spec]/2.4
+// For each charT, the pointer type specializations template<>
+// - struct formatter<nullptr_t, charT>;
+// - template<> struct formatter<void*, charT>;
+// - template<> struct formatter<const void*, charT>;
+template <__formatter::__char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<nullptr_t, _CharT>
+ : public __format_spec::__formatter_pointer<_CharT> {};
+template <__formatter::__char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<void*, _CharT>
+ : public __format_spec::__formatter_pointer<_CharT> {};
+template <__formatter::__char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const void*, _CharT>
+ : public __format_spec::__formatter_pointer<_CharT> {};
+
+# endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMATTER_POINTER_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter_string.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter_string.h
new file mode 100644
index 0000000000..54aa1215d9
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/formatter_string.h
@@ -0,0 +1,158 @@
+// -*- 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_FORMATTER_STRING_H
+#define _LIBCPP___FORMAT_FORMATTER_STRING_H
+
+#include <__assert>
+#include <__config>
+#include <__format/format_error.h>
+#include <__format/format_fwd.h>
+#include <__format/format_string.h>
+#include <__format/formatter.h>
+#include <__format/parser_std_format_spec.h>
+#include <string_view>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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)
+
+namespace __format_spec {
+
+template <__formatter::__char_type _CharT>
+class _LIBCPP_TEMPLATE_VIS __formatter_string : public __parser_string<_CharT> {
+public:
+ _LIBCPP_HIDE_FROM_ABI auto format(basic_string_view<_CharT> __str,
+ auto& __ctx) -> decltype(__ctx.out()) {
+
+ _LIBCPP_ASSERT(this->__alignment != _Flags::_Alignment::__default,
+ "The parser should not use these defaults");
+
+ if (this->__width_needs_substitution())
+ this->__substitute_width_arg_id(__ctx.arg(this->__width));
+
+ if (this->__precision_needs_substitution())
+ this->__substitute_precision_arg_id(__ctx.arg(this->__precision));
+
+ return __formatter::__write_unicode(
+ __ctx.out(), __str, this->__width,
+ this->__has_precision_field() ? this->__precision : -1, this->__fill,
+ this->__alignment);
+ }
+};
+
+} //namespace __format_spec
+
+// [format.formatter.spec]/2.2 For each charT, the string type specializations
+
+// Formatter const char*.
+template <__formatter::__char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
+ formatter<const _CharT*, _CharT>
+ : public __format_spec::__formatter_string<_CharT> {
+ using _Base = __format_spec::__formatter_string<_CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI auto format(const _CharT* __str, auto& __ctx)
+ -> decltype(__ctx.out()) {
+ _LIBCPP_ASSERT(__str, "The basic_format_arg constructor should have "
+ "prevented an invalid pointer.");
+
+ // When using a center or right alignment and the width option the length
+ // of __str must be known to add the padding upfront. This case is handled
+ // by the base class by converting the argument to a basic_string_view.
+ //
+ // When using left alignment and the width option the padding is added
+ // after outputting __str so the length can be determined while outputting
+ // __str. The same holds true for the precision, during outputting __str it
+ // can be validated whether the precision threshold has been reached. For
+ // now these optimizations aren't implemented. Instead the base class
+ // handles these options.
+ // TODO FMT Implement these improvements.
+ if (this->__has_width_field() || this->__has_precision_field())
+ return _Base::format(__str, __ctx);
+
+ // No formatting required, copy the string to the output.
+ auto __out_it = __ctx.out();
+ while (*__str)
+ *__out_it++ = *__str++;
+ return __out_it;
+ }
+};
+
+// Formatter char*.
+template <__formatter::__char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
+ formatter<_CharT*, _CharT> : public formatter<const _CharT*, _CharT> {
+ using _Base = formatter<const _CharT*, _CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI auto format(_CharT* __str, auto& __ctx)
+ -> decltype(__ctx.out()) {
+ return _Base::format(__str, __ctx);
+ }
+};
+
+// Formatter const char[].
+template <__formatter::__char_type _CharT, size_t _Size>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
+ formatter<const _CharT[_Size], _CharT>
+ : public __format_spec::__formatter_string<_CharT> {
+ using _Base = __format_spec::__formatter_string<_CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI auto format(const _CharT __str[_Size], auto& __ctx)
+ -> decltype(__ctx.out()) {
+ return _Base::format(basic_string_view<_CharT>(__str, _Size), __ctx);
+ }
+};
+
+// Formatter std::string.
+template <__formatter::__char_type _CharT, class _Traits, class _Allocator>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
+ formatter<basic_string<_CharT, _Traits, _Allocator>, _CharT>
+ : public __format_spec::__formatter_string<_CharT> {
+ using _Base = __format_spec::__formatter_string<_CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI auto
+ format(const basic_string<_CharT, _Traits, _Allocator>& __str, auto& __ctx)
+ -> decltype(__ctx.out()) {
+ // drop _Traits and _Allocator
+ return _Base::format(basic_string_view<_CharT>(__str.data(), __str.size()), __ctx);
+ }
+};
+
+// Formatter std::string_view.
+template <__formatter::__char_type _CharT, class _Traits>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<basic_string_view<_CharT, _Traits>, _CharT>
+ : public __format_spec::__formatter_string<_CharT> {
+ using _Base = __format_spec::__formatter_string<_CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI auto
+ format(basic_string_view<_CharT, _Traits> __str, auto& __ctx)
+ -> decltype(__ctx.out()) {
+ // drop _Traits
+ return _Base::format(basic_string_view<_CharT>(__str.data(), __str.size()), __ctx);
+ }
+};
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMATTER_STRING_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__format/parser_std_format_spec.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/parser_std_format_spec.h
new file mode 100644
index 0000000000..57f4e46e56
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__format/parser_std_format_spec.h
@@ -0,0 +1,1398 @@
+// -*- 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_PARSER_STD_FORMAT_SPEC_H
+#define _LIBCPP___FORMAT_PARSER_STD_FORMAT_SPEC_H
+
+#include <__algorithm/find_if.h>
+#include <__algorithm/min.h>
+#include <__assert>
+#include <__config>
+#include <__format/format_arg.h>
+#include <__format/format_error.h>
+#include <__format/format_string.h>
+#include <__variant/monostate.h>
+#include <bit>
+#include <concepts>
+#include <cstdint>
+#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
+
+// 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)
+
+namespace __format_spec {
+
+/**
+ * Contains the flags for the std-format-spec.
+ *
+ * Some format-options can only be used for specific C++ types and may depend on
+ * the selected format-type.
+ * * The C++type filtering can be done using the proper policies for
+ * @ref __parser_std.
+ * * The format-type filtering needs to be done post parsing in the parser
+ * derived from @ref __parser_std.
+ */
+class _LIBCPP_TYPE_VIS _Flags {
+public:
+ enum class _LIBCPP_ENUM_VIS _Alignment : uint8_t {
+ /**
+ * No alignment is set in the format string.
+ *
+ * Zero-padding is ignored when an alignment is selected.
+ * The default alignment depends on the selected format-type.
+ */
+ __default,
+ __left,
+ __center,
+ __right
+ };
+ enum class _LIBCPP_ENUM_VIS _Sign : uint8_t {
+ /**
+ * No sign is set in the format string.
+ *
+ * The sign isn't allowed for certain format-types. By using this value
+ * it's possible to detect whether or not the user explicitly set the sign
+ * flag. For formatting purposes it behaves the same as @ref __minus.
+ */
+ __default,
+ __minus,
+ __plus,
+ __space
+ };
+
+ _Alignment __alignment : 2 {_Alignment::__default};
+ _Sign __sign : 2 {_Sign::__default};
+ uint8_t __alternate_form : 1 {false};
+ uint8_t __zero_padding : 1 {false};
+ uint8_t __locale_specific_form : 1 {false};
+
+ enum class _LIBCPP_ENUM_VIS _Type : uint8_t {
+ __default,
+ __string,
+ __binary_lower_case,
+ __binary_upper_case,
+ __octal,
+ __decimal,
+ __hexadecimal_lower_case,
+ __hexadecimal_upper_case,
+ __pointer,
+ __char,
+ __float_hexadecimal_lower_case,
+ __float_hexadecimal_upper_case,
+ __scientific_lower_case,
+ __scientific_upper_case,
+ __fixed_lower_case,
+ __fixed_upper_case,
+ __general_lower_case,
+ __general_upper_case
+ };
+
+ _Type __type{_Type::__default};
+};
+
+namespace __detail {
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr bool
+__parse_alignment(_CharT __c, _Flags& __flags) noexcept {
+ switch (__c) {
+ case _CharT('<'):
+ __flags.__alignment = _Flags::_Alignment::__left;
+ return true;
+
+ case _CharT('^'):
+ __flags.__alignment = _Flags::_Alignment::__center;
+ return true;
+
+ case _CharT('>'):
+ __flags.__alignment = _Flags::_Alignment::__right;
+ return true;
+ }
+ return false;
+}
+} // namespace __detail
+
+template <class _CharT>
+class _LIBCPP_TEMPLATE_VIS __parser_fill_align {
+public:
+ // TODO FMT The standard doesn't specify this character is a Unicode
+ // character. Validate what fmt and MSVC have implemented.
+ _CharT __fill{_CharT(' ')};
+
+protected:
+ _LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
+ __parse(const _CharT* __begin, const _CharT* __end, _Flags& __flags) {
+ _LIBCPP_ASSERT(__begin != __end,
+ "When called with an empty input the function will cause "
+ "undefined behavior by evaluating data not in the input");
+ if (__begin + 1 != __end) {
+ if (__detail::__parse_alignment(*(__begin + 1), __flags)) {
+ if (*__begin == _CharT('{') || *__begin == _CharT('}'))
+ __throw_format_error(
+ "The format-spec fill field contains an invalid character");
+ __fill = *__begin;
+ return __begin + 2;
+ }
+ }
+
+ if (__detail::__parse_alignment(*__begin, __flags))
+ return __begin + 1;
+
+ return __begin;
+ }
+};
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
+__parse_sign(const _CharT* __begin, _Flags& __flags) noexcept {
+ switch (*__begin) {
+ case _CharT('-'):
+ __flags.__sign = _Flags::_Sign::__minus;
+ break;
+ case _CharT('+'):
+ __flags.__sign = _Flags::_Sign::__plus;
+ break;
+ case _CharT(' '):
+ __flags.__sign = _Flags::_Sign::__space;
+ break;
+ default:
+ return __begin;
+ }
+ return __begin + 1;
+}
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
+__parse_alternate_form(const _CharT* __begin, _Flags& __flags) noexcept {
+ if (*__begin == _CharT('#')) {
+ __flags.__alternate_form = true;
+ ++__begin;
+ }
+
+ return __begin;
+}
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
+__parse_zero_padding(const _CharT* __begin, _Flags& __flags) noexcept {
+ if (*__begin == _CharT('0')) {
+ __flags.__zero_padding = true;
+ ++__begin;
+ }
+
+ return __begin;
+}
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr __format::__parse_number_result< _CharT>
+__parse_arg_id(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {
+ // This function is a wrapper to call the real parser. But it does the
+ // validation for the pre-conditions and post-conditions.
+ if (__begin == __end)
+ __throw_format_error("End of input while parsing format-spec arg-id");
+
+ __format::__parse_number_result __r =
+ __format::__parse_arg_id(__begin, __end, __parse_ctx);
+
+ if (__r.__ptr == __end || *__r.__ptr != _CharT('}'))
+ __throw_format_error("Invalid arg-id");
+
+ ++__r.__ptr;
+ return __r;
+}
+
+template <class _Context>
+_LIBCPP_HIDE_FROM_ABI constexpr uint32_t
+__substitute_arg_id(basic_format_arg<_Context> __arg) {
+ return visit_format_arg(
+ [](auto __arg) -> uint32_t {
+ using _Type = decltype(__arg);
+ if constexpr (integral<_Type>) {
+ if constexpr (signed_integral<_Type>) {
+ if (__arg < 0)
+ __throw_format_error("A format-spec arg-id replacement shouldn't "
+ "have a negative value");
+ }
+
+ using _CT = common_type_t<_Type, decltype(__format::__number_max)>;
+ if (static_cast<_CT>(__arg) >
+ static_cast<_CT>(__format::__number_max))
+ __throw_format_error("A format-spec arg-id replacement exceeds "
+ "the maximum supported value");
+
+ return __arg;
+ } else if constexpr (same_as<_Type, monostate>)
+ __throw_format_error("Argument index out of bounds");
+ else
+ __throw_format_error("A format-spec arg-id replacement argument "
+ "isn't an integral type");
+ },
+ __arg);
+}
+
+class _LIBCPP_TYPE_VIS __parser_width {
+public:
+ /** Contains a width or an arg-id. */
+ uint32_t __width : 31 {0};
+ /** Determines whether the value stored is a width or an arg-id. */
+ uint32_t __width_as_arg : 1 {0};
+
+protected:
+ /**
+ * Does the supplied std-format-spec contain a width field?
+ *
+ * When the field isn't present there's no padding required. This can be used
+ * to optimize the formatting.
+ */
+ constexpr bool __has_width_field() const noexcept {
+ return __width_as_arg || __width;
+ }
+
+ /**
+ * Does the supplied width field contain an arg-id?
+ *
+ * If @c true the formatter needs to call @ref __substitute_width_arg_id.
+ */
+ constexpr bool __width_needs_substitution() const noexcept {
+ return __width_as_arg;
+ }
+
+ template <class _CharT>
+ _LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
+ __parse(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {
+ if (*__begin == _CharT('0'))
+ __throw_format_error(
+ "A format-spec width field shouldn't have a leading zero");
+
+ if (*__begin == _CharT('{')) {
+ __format::__parse_number_result __r =
+ __parse_arg_id(++__begin, __end, __parse_ctx);
+ __width = __r.__value;
+ __width_as_arg = 1;
+ return __r.__ptr;
+ }
+
+ if (*__begin < _CharT('0') || *__begin > _CharT('9'))
+ return __begin;
+
+ __format::__parse_number_result __r =
+ __format::__parse_number(__begin, __end);
+ __width = __r.__value;
+ _LIBCPP_ASSERT(__width != 0,
+ "A zero value isn't allowed and should be impossible, "
+ "due to validations in this function");
+ return __r.__ptr;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr void __substitute_width_arg_id(auto __arg) {
+ _LIBCPP_ASSERT(__width_as_arg == 1,
+ "Substitute width called when no substitution is required");
+
+ // The clearing of the flag isn't required but looks better when debugging
+ // the code.
+ __width_as_arg = 0;
+ __width = __substitute_arg_id(__arg);
+ if (__width == 0)
+ __throw_format_error(
+ "A format-spec width field replacement should have a positive value");
+ }
+};
+
+class _LIBCPP_TYPE_VIS __parser_precision {
+public:
+ /** Contains a precision or an arg-id. */
+ uint32_t __precision : 31 {__format::__number_max};
+ /**
+ * Determines whether the value stored is a precision or an arg-id.
+ *
+ * @note Since @ref __precision == @ref __format::__number_max is a valid
+ * value, the default value contains an arg-id of INT32_MAX. (This number of
+ * arguments isn't supported by compilers.) This is used to detect whether
+ * the std-format-spec contains a precision field.
+ */
+ uint32_t __precision_as_arg : 1 {1};
+
+protected:
+ /**
+ * Does the supplied std-format-spec contain a precision field?
+ *
+ * When the field isn't present there's no truncating required. This can be
+ * used to optimize the formatting.
+ */
+ constexpr bool __has_precision_field() const noexcept {
+
+ return __precision_as_arg == 0 || // Contains a value?
+ __precision != __format::__number_max; // The arg-id is valid?
+ }
+
+ /**
+ * Does the supplied precision field contain an arg-id?
+ *
+ * If @c true the formatter needs to call @ref __substitute_precision_arg_id.
+ */
+ constexpr bool __precision_needs_substitution() const noexcept {
+ return __precision_as_arg && __precision != __format::__number_max;
+ }
+
+ template <class _CharT>
+ _LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
+ __parse(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {
+ if (*__begin != _CharT('.'))
+ return __begin;
+
+ ++__begin;
+ if (__begin == __end)
+ __throw_format_error("End of input while parsing format-spec precision");
+
+ if (*__begin == _CharT('{')) {
+ __format::__parse_number_result __arg_id =
+ __parse_arg_id(++__begin, __end, __parse_ctx);
+ _LIBCPP_ASSERT(__arg_id.__value != __format::__number_max,
+ "Unsupported number of arguments, since this number of "
+ "arguments is used a special value");
+ __precision = __arg_id.__value;
+ return __arg_id.__ptr;
+ }
+
+ if (*__begin < _CharT('0') || *__begin > _CharT('9'))
+ __throw_format_error(
+ "The format-spec precision field doesn't contain a value or arg-id");
+
+ __format::__parse_number_result __r =
+ __format::__parse_number(__begin, __end);
+ __precision = __r.__value;
+ __precision_as_arg = 0;
+ return __r.__ptr;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr void __substitute_precision_arg_id(
+ auto __arg) {
+ _LIBCPP_ASSERT(
+ __precision_as_arg == 1 && __precision != __format::__number_max,
+ "Substitute precision called when no substitution is required");
+
+ // The clearing of the flag isn't required but looks better when debugging
+ // the code.
+ __precision_as_arg = 0;
+ __precision = __substitute_arg_id(__arg);
+ }
+};
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
+__parse_locale_specific_form(const _CharT* __begin, _Flags& __flags) noexcept {
+ if (*__begin == _CharT('L')) {
+ __flags.__locale_specific_form = true;
+ ++__begin;
+ }
+
+ return __begin;
+}
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
+__parse_type(const _CharT* __begin, _Flags& __flags) {
+
+ // Determines the type. It does not validate whether the selected type is
+ // valid. Most formatters have optional fields that are only allowed for
+ // certain types. These parsers need to do validation after the type has
+ // been parsed. So its easier to implement the validation for all types in
+ // the specific parse function.
+ switch (*__begin) {
+ case 'A':
+ __flags.__type = _Flags::_Type::__float_hexadecimal_upper_case;
+ break;
+ case 'B':
+ __flags.__type = _Flags::_Type::__binary_upper_case;
+ break;
+ case 'E':
+ __flags.__type = _Flags::_Type::__scientific_upper_case;
+ break;
+ case 'F':
+ __flags.__type = _Flags::_Type::__fixed_upper_case;
+ break;
+ case 'G':
+ __flags.__type = _Flags::_Type::__general_upper_case;
+ break;
+ case 'X':
+ __flags.__type = _Flags::_Type::__hexadecimal_upper_case;
+ break;
+ case 'a':
+ __flags.__type = _Flags::_Type::__float_hexadecimal_lower_case;
+ break;
+ case 'b':
+ __flags.__type = _Flags::_Type::__binary_lower_case;
+ break;
+ case 'c':
+ __flags.__type = _Flags::_Type::__char;
+ break;
+ case 'd':
+ __flags.__type = _Flags::_Type::__decimal;
+ break;
+ case 'e':
+ __flags.__type = _Flags::_Type::__scientific_lower_case;
+ break;
+ case 'f':
+ __flags.__type = _Flags::_Type::__fixed_lower_case;
+ break;
+ case 'g':
+ __flags.__type = _Flags::_Type::__general_lower_case;
+ break;
+ case 'o':
+ __flags.__type = _Flags::_Type::__octal;
+ break;
+ case 'p':
+ __flags.__type = _Flags::_Type::__pointer;
+ break;
+ case 's':
+ __flags.__type = _Flags::_Type::__string;
+ break;
+ case 'x':
+ __flags.__type = _Flags::_Type::__hexadecimal_lower_case;
+ break;
+ default:
+ return __begin;
+ }
+ return ++__begin;
+}
+
+/**
+ * Process the parsed alignment and zero-padding state of arithmetic types.
+ *
+ * [format.string.std]/13
+ * If the 0 character and an align option both appear, the 0 character is
+ * ignored.
+ *
+ * For the formatter a @ref __default alignment means zero-padding.
+ */
+_LIBCPP_HIDE_FROM_ABI constexpr void __process_arithmetic_alignment(_Flags& __flags) {
+ __flags.__zero_padding &= __flags.__alignment == _Flags::_Alignment::__default;
+ if (!__flags.__zero_padding && __flags.__alignment == _Flags::_Alignment::__default)
+ __flags.__alignment = _Flags::_Alignment::__right;
+}
+
+/**
+ * The parser for the std-format-spec.
+ *
+ * [format.string.std]/1 specifies the std-format-spec:
+ * fill-and-align sign # 0 width precision L type
+ *
+ * All these fields are optional. Whether these fields can be used depend on:
+ * - The type supplied to the format string.
+ * E.g. A string never uses the sign field so the field may not be set.
+ * This constrain is validated by the parsers in this file.
+ * - The supplied value for the optional type field.
+ * E.g. A int formatted as decimal uses the sign field.
+ * When formatted as a char the sign field may no longer be set.
+ * This constrain isn't validated by the parsers in this file.
+ *
+ * The base classes are ordered to minimize the amount of padding.
+ *
+ * This implements the parser for the string types.
+ */
+template <class _CharT>
+class _LIBCPP_TEMPLATE_VIS __parser_string
+ : public __parser_width, // provides __width(|as_arg)
+ public __parser_precision, // provides __precision(|as_arg)
+ public __parser_fill_align<_CharT>, // provides __fill and uses __flags
+ public _Flags // provides __flags
+{
+public:
+ using char_type = _CharT;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __parser_string() {
+ this->__alignment = _Flags::_Alignment::__left;
+ }
+
+ /**
+ * The low-level std-format-spec parse function.
+ *
+ * @pre __begin points at the beginning of the std-format-spec. This means
+ * directly after the ':'.
+ * @pre The std-format-spec parses the entire input, or the first unmatched
+ * character is a '}'.
+ *
+ * @returns The iterator pointing at the last parsed character.
+ */
+ _LIBCPP_HIDE_FROM_ABI constexpr auto parse(auto& __parse_ctx)
+ -> decltype(__parse_ctx.begin()) {
+ auto __it = __parse(__parse_ctx);
+ __process_display_type();
+ return __it;
+ }
+
+private:
+ /**
+ * Parses the std-format-spec.
+ *
+ * @throws __throw_format_error When @a __parse_ctx contains an ill-formed
+ * std-format-spec.
+ *
+ * @returns An iterator to the end of input or point at the closing '}'.
+ */
+ _LIBCPP_HIDE_FROM_ABI constexpr auto __parse(auto& __parse_ctx)
+ -> decltype(__parse_ctx.begin()) {
+
+ auto __begin = __parse_ctx.begin();
+ auto __end = __parse_ctx.end();
+ if (__begin == __end)
+ return __begin;
+
+ __begin = __parser_fill_align<_CharT>::__parse(__begin, __end,
+ static_cast<_Flags&>(*this));
+ if (__begin == __end)
+ return __begin;
+
+ __begin = __parser_width::__parse(__begin, __end, __parse_ctx);
+ if (__begin == __end)
+ return __begin;
+
+ __begin = __parser_precision::__parse(__begin, __end, __parse_ctx);
+ if (__begin == __end)
+ return __begin;
+
+ __begin = __parse_type(__begin, static_cast<_Flags&>(*this));
+
+ if (__begin != __end && *__begin != _CharT('}'))
+ __throw_format_error(
+ "The format-spec should consume the input or end with a '}'");
+
+ return __begin;
+ }
+
+ /** Processes the parsed std-format-spec based on the parsed display type. */
+ _LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type() {
+ switch (this->__type) {
+ case _Flags::_Type::__default:
+ case _Flags::_Type::__string:
+ break;
+
+ default:
+ __throw_format_error("The format-spec type has a type not supported for "
+ "a string argument");
+ }
+ }
+};
+
+/**
+ * The parser for the std-format-spec.
+ *
+ * This implements the parser for the integral types. This includes the
+ * character type and boolean type.
+ *
+ * See @ref __parser_string.
+ */
+template <class _CharT>
+class _LIBCPP_TEMPLATE_VIS __parser_integral
+ : public __parser_width, // provides __width(|as_arg)
+ public __parser_fill_align<_CharT>, // provides __fill and uses __flags
+ public _Flags // provides __flags
+{
+public:
+ using char_type = _CharT;
+
+protected:
+ /**
+ * The low-level std-format-spec parse function.
+ *
+ * @pre __begin points at the beginning of the std-format-spec. This means
+ * directly after the ':'.
+ * @pre The std-format-spec parses the entire input, or the first unmatched
+ * character is a '}'.
+ *
+ * @returns The iterator pointing at the last parsed character.
+ */
+ _LIBCPP_HIDE_FROM_ABI constexpr auto __parse(auto& __parse_ctx)
+ -> decltype(__parse_ctx.begin()) {
+ auto __begin = __parse_ctx.begin();
+ auto __end = __parse_ctx.end();
+ if (__begin == __end)
+ return __begin;
+
+ __begin = __parser_fill_align<_CharT>::__parse(__begin, __end,
+ static_cast<_Flags&>(*this));
+ if (__begin == __end)
+ return __begin;
+
+ __begin = __parse_sign(__begin, static_cast<_Flags&>(*this));
+ if (__begin == __end)
+ return __begin;
+
+ __begin = __parse_alternate_form(__begin, static_cast<_Flags&>(*this));
+ if (__begin == __end)
+ return __begin;
+
+ __begin = __parse_zero_padding(__begin, static_cast<_Flags&>(*this));
+ if (__begin == __end)
+ return __begin;
+
+ __begin = __parser_width::__parse(__begin, __end, __parse_ctx);
+ if (__begin == __end)
+ return __begin;
+
+ __begin =
+ __parse_locale_specific_form(__begin, static_cast<_Flags&>(*this));
+ if (__begin == __end)
+ return __begin;
+
+ __begin = __parse_type(__begin, static_cast<_Flags&>(*this));
+
+ if (__begin != __end && *__begin != _CharT('}'))
+ __throw_format_error(
+ "The format-spec should consume the input or end with a '}'");
+
+ return __begin;
+ }
+
+ /** Handles the post-parsing updates for the integer types. */
+ _LIBCPP_HIDE_FROM_ABI constexpr void __handle_integer() noexcept {
+ __process_arithmetic_alignment(static_cast<_Flags&>(*this));
+ }
+
+ /**
+ * Handles the post-parsing updates for the character types.
+ *
+ * Sets the alignment and validates the format flags set for a character type.
+ *
+ * At the moment the validation for a character and a Boolean behave the
+ * same, but this may change in the future.
+ * Specifically at the moment the locale-specific form is allowed for the
+ * char output type, but it has no effect on the output.
+ */
+ _LIBCPP_HIDE_FROM_ABI constexpr void __handle_char() { __handle_bool(); }
+
+ /**
+ * Handles the post-parsing updates for the Boolean types.
+ *
+ * Sets the alignment and validates the format flags set for a Boolean type.
+ */
+ _LIBCPP_HIDE_FROM_ABI constexpr void __handle_bool() {
+ if (this->__sign != _Flags::_Sign::__default)
+ __throw_format_error("A sign field isn't allowed in this format-spec");
+
+ if (this->__alternate_form)
+ __throw_format_error(
+ "An alternate form field isn't allowed in this format-spec");
+
+ if (this->__zero_padding)
+ __throw_format_error(
+ "A zero-padding field isn't allowed in this format-spec");
+
+ if (this->__alignment == _Flags::_Alignment::__default)
+ this->__alignment = _Flags::_Alignment::__left;
+ }
+};
+
+/**
+ * The parser for the std-format-spec.
+ *
+ * This implements the parser for the floating-point types.
+ *
+ * See @ref __parser_string.
+ */
+template <class _CharT>
+class _LIBCPP_TEMPLATE_VIS __parser_floating_point
+ : public __parser_width, // provides __width(|as_arg)
+ public __parser_precision, // provides __precision(|as_arg)
+ public __parser_fill_align<_CharT>, // provides __fill and uses __flags
+ public _Flags // provides __flags
+{
+public:
+ using char_type = _CharT;
+
+ /**
+ * The low-level std-format-spec parse function.
+ *
+ * @pre __begin points at the beginning of the std-format-spec. This means
+ * directly after the ':'.
+ * @pre The std-format-spec parses the entire input, or the first unmatched
+ * character is a '}'.
+ *
+ * @returns The iterator pointing at the last parsed character.
+ */
+ _LIBCPP_HIDE_FROM_ABI constexpr auto parse(auto& __parse_ctx)
+ -> decltype(__parse_ctx.begin()) {
+ auto __it = __parse(__parse_ctx);
+ __process_arithmetic_alignment(static_cast<_Flags&>(*this));
+ __process_display_type();
+ return __it;
+ }
+protected:
+ /**
+ * The low-level std-format-spec parse function.
+ *
+ * @pre __begin points at the beginning of the std-format-spec. This means
+ * directly after the ':'.
+ * @pre The std-format-spec parses the entire input, or the first unmatched
+ * character is a '}'.
+ *
+ * @returns The iterator pointing at the last parsed character.
+ */
+ _LIBCPP_HIDE_FROM_ABI constexpr auto __parse(auto& __parse_ctx)
+ -> decltype(__parse_ctx.begin()) {
+ auto __begin = __parse_ctx.begin();
+ auto __end = __parse_ctx.end();
+ if (__begin == __end)
+ return __begin;
+
+ __begin = __parser_fill_align<_CharT>::__parse(__begin, __end,
+ static_cast<_Flags&>(*this));
+ if (__begin == __end)
+ return __begin;
+
+ __begin = __parse_sign(__begin, static_cast<_Flags&>(*this));
+ if (__begin == __end)
+ return __begin;
+
+ __begin = __parse_alternate_form(__begin, static_cast<_Flags&>(*this));
+ if (__begin == __end)
+ return __begin;
+
+ __begin = __parse_zero_padding(__begin, static_cast<_Flags&>(*this));
+ if (__begin == __end)
+ return __begin;
+
+ __begin = __parser_width::__parse(__begin, __end, __parse_ctx);
+ if (__begin == __end)
+ return __begin;
+
+ __begin = __parser_precision::__parse(__begin, __end, __parse_ctx);
+ if (__begin == __end)
+ return __begin;
+
+ __begin =
+ __parse_locale_specific_form(__begin, static_cast<_Flags&>(*this));
+ if (__begin == __end)
+ return __begin;
+
+ __begin = __parse_type(__begin, static_cast<_Flags&>(*this));
+
+ if (__begin != __end && *__begin != _CharT('}'))
+ __throw_format_error(
+ "The format-spec should consume the input or end with a '}'");
+
+ return __begin;
+ }
+
+ /** Processes the parsed std-format-spec based on the parsed display type. */
+ _LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type() {
+ switch (this->__type) {
+ case _Flags::_Type::__default:
+ // When no precision specified then it keeps default since that
+ // formatting differs from the other types.
+ if (this->__has_precision_field())
+ this->__type = _Flags::_Type::__general_lower_case;
+ break;
+ case _Flags::_Type::__float_hexadecimal_lower_case:
+ case _Flags::_Type::__float_hexadecimal_upper_case:
+ // Precision specific behavior will be handled later.
+ break;
+ case _Flags::_Type::__scientific_lower_case:
+ case _Flags::_Type::__scientific_upper_case:
+ case _Flags::_Type::__fixed_lower_case:
+ case _Flags::_Type::__fixed_upper_case:
+ case _Flags::_Type::__general_lower_case:
+ case _Flags::_Type::__general_upper_case:
+ if (!this->__has_precision_field()) {
+ // Set the default precision for the call to to_chars.
+ this->__precision = 6;
+ this->__precision_as_arg = false;
+ }
+ break;
+
+ default:
+ __throw_format_error("The format-spec type has a type not supported for "
+ "a floating-point argument");
+ }
+ }
+};
+
+/**
+ * The parser for the std-format-spec.
+ *
+ * This implements the parser for the pointer types.
+ *
+ * See @ref __parser_string.
+ */
+template <class _CharT>
+class _LIBCPP_TEMPLATE_VIS __parser_pointer : public __parser_width, // provides __width(|as_arg)
+ public __parser_fill_align<_CharT>, // provides __fill and uses __flags
+ public _Flags // provides __flags
+{
+public:
+ using char_type = _CharT;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __parser_pointer() {
+ // Implements LWG3612 Inconsistent pointer alignment in std::format.
+ // The issue's current status is "Tentatively Ready" and libc++ status is
+ // still experimental.
+ //
+ // TODO FMT Validate this with the final resolution of LWG3612.
+ this->__alignment = _Flags::_Alignment::__right;
+ }
+
+ /**
+ * The low-level std-format-spec parse function.
+ *
+ * @pre __begin points at the beginning of the std-format-spec. This means
+ * directly after the ':'.
+ * @pre The std-format-spec parses the entire input, or the first unmatched
+ * character is a '}'.
+ *
+ * @returns The iterator pointing at the last parsed character.
+ */
+ _LIBCPP_HIDE_FROM_ABI constexpr auto parse(auto& __parse_ctx) -> decltype(__parse_ctx.begin()) {
+ auto __it = __parse(__parse_ctx);
+ __process_display_type();
+ return __it;
+ }
+
+protected:
+ /**
+ * The low-level std-format-spec parse function.
+ *
+ * @pre __begin points at the beginning of the std-format-spec. This means
+ * directly after the ':'.
+ * @pre The std-format-spec parses the entire input, or the first unmatched
+ * character is a '}'.
+ *
+ * @returns The iterator pointing at the last parsed character.
+ */
+ _LIBCPP_HIDE_FROM_ABI constexpr auto __parse(auto& __parse_ctx) -> decltype(__parse_ctx.begin()) {
+ auto __begin = __parse_ctx.begin();
+ auto __end = __parse_ctx.end();
+ if (__begin == __end)
+ return __begin;
+
+ __begin = __parser_fill_align<_CharT>::__parse(__begin, __end, static_cast<_Flags&>(*this));
+ if (__begin == __end)
+ return __begin;
+
+ // An integer presentation type isn't defined in the Standard.
+ // Since a pointer is formatted as an integer it can be argued it's an
+ // integer presentation type. However there are two LWG-issues asserting it
+ // isn't an integer presentation type:
+ // - LWG3612 Inconsistent pointer alignment in std::format
+ // - LWG3644 std::format does not define "integer presentation type"
+ //
+ // There's a paper to make additional clarifications on the status of
+ // formatting pointers and proposes additional fields to be valid. That
+ // paper hasn't been reviewed by the Committee yet.
+ // - P2510 Formatting pointers
+ //
+ // The current implementation assumes formatting pointers isn't covered by
+ // "integer presentation type".
+ // TODO FMT Apply the LWG-issues/papers after approval/rejection by the Committee.
+
+ __begin = __parser_width::__parse(__begin, __end, __parse_ctx);
+ if (__begin == __end)
+ return __begin;
+
+ __begin = __parse_type(__begin, static_cast<_Flags&>(*this));
+
+ if (__begin != __end && *__begin != _CharT('}'))
+ __throw_format_error("The format-spec should consume the input or end with a '}'");
+
+ return __begin;
+ }
+
+ /** Processes the parsed std-format-spec based on the parsed display type. */
+ _LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type() {
+ switch (this->__type) {
+ case _Flags::_Type::__default:
+ this->__type = _Flags::_Type::__pointer;
+ break;
+ case _Flags::_Type::__pointer:
+ break;
+ default:
+ __throw_format_error("The format-spec type has a type not supported for a pointer argument");
+ }
+ }
+};
+
+/** Helper struct returned from @ref __get_string_alignment. */
+template <class _CharT>
+struct _LIBCPP_TEMPLATE_VIS __string_alignment {
+ /** Points beyond the last character to write to the output. */
+ const _CharT* __last;
+ /**
+ * The estimated number of columns in the output or 0.
+ *
+ * Only when the output needs to be aligned it's required to know the exact
+ * number of columns in the output. So if the formatted output has only a
+ * minimum width the exact size isn't important. It's only important to know
+ * the minimum has been reached. The minimum width is the width specified in
+ * the format-spec.
+ *
+ * For example in this code @code std::format("{:10}", MyString); @endcode
+ * the width estimation can stop once the algorithm has determined the output
+ * width is 10 columns.
+ *
+ * So if:
+ * * @ref __align == @c true the @ref __size is the estimated number of
+ * columns required.
+ * * @ref __align == @c false the @ref __size is the estimated number of
+ * columns required or 0 when the estimation algorithm stopped prematurely.
+ */
+ ptrdiff_t __size;
+ /**
+ * Does the output need to be aligned.
+ *
+ * When alignment is needed the output algorithm needs to add the proper
+ * padding. Else the output algorithm just needs to copy the input up to
+ * @ref __last.
+ */
+ bool __align;
+};
+
+#ifndef _LIBCPP_HAS_NO_UNICODE
+namespace __detail {
+
+/**
+ * Unicode column width estimates.
+ *
+ * Unicode can be stored in several formats: UTF-8, UTF-16, and UTF-32.
+ * Depending on format the relation between the number of code units stored and
+ * the number of output columns differs. The first relation is the number of
+ * code units forming a code point. (The text assumes the code units are
+ * unsigned.)
+ * - UTF-8 The number of code units is between one and four. The first 127
+ * Unicode code points match the ASCII character set. When the highest bit is
+ * set it means the code point has more than one code unit.
+ * - UTF-16: The number of code units is between 1 and 2. When the first
+ * code unit is in the range [0xd800,0xdfff) it means the code point uses two
+ * code units.
+ * - UTF-32: The number of code units is always one.
+ *
+ * The code point to the number of columns isn't well defined. The code uses the
+ * estimations defined in [format.string.std]/11. This list might change in the
+ * future.
+ *
+ * The algorithm of @ref __get_string_alignment uses two different scanners:
+ * - The simple scanner @ref __estimate_column_width_fast. This scanner assumes
+ * 1 code unit is 1 column. This scanner stops when it can't be sure the
+ * assumption is valid:
+ * - UTF-8 when the code point is encoded in more than 1 code unit.
+ * - UTF-16 and UTF-32 when the first multi-column code point is encountered.
+ * (The code unit's value is lower than 0xd800 so the 2 code unit encoding
+ * is irrelevant for this scanner.)
+ * Due to these assumptions the scanner is faster than the full scanner. It
+ * can process all text only containing ASCII. For UTF-16/32 it can process
+ * most (all?) European languages. (Note the set it can process might be
+ * reduced in the future, due to updates in the scanning rules.)
+ * - The full scanner @ref __estimate_column_width. This scanner, if needed,
+ * converts multiple code units into one code point then converts the code
+ * point to a column width.
+ *
+ * See also:
+ * - [format.string.general]/11
+ * - https://en.wikipedia.org/wiki/UTF-8#Encoding
+ * - https://en.wikipedia.org/wiki/UTF-16#U+D800_to_U+DFFF
+ */
+
+/**
+ * The first 2 column code point.
+ *
+ * This is the point where the fast UTF-16/32 scanner needs to stop processing.
+ */
+inline constexpr uint32_t __two_column_code_point = 0x1100;
+
+/** Helper concept for an UTF-8 character type. */
+template <class _CharT>
+concept __utf8_character = same_as<_CharT, char> || same_as<_CharT, char8_t>;
+
+/** Helper concept for an UTF-16 character type. */
+template <class _CharT>
+concept __utf16_character = (same_as<_CharT, wchar_t> && sizeof(wchar_t) == 2) || same_as<_CharT, char16_t>;
+
+/** Helper concept for an UTF-32 character type. */
+template <class _CharT>
+concept __utf32_character = (same_as<_CharT, wchar_t> && sizeof(wchar_t) == 4) || same_as<_CharT, char32_t>;
+
+/** Helper concept for an UTF-16 or UTF-32 character type. */
+template <class _CharT>
+concept __utf16_or_32_character = __utf16_character<_CharT> || __utf32_character<_CharT>;
+
+/**
+ * Converts a code point to the column width.
+ *
+ * The estimations are conforming to [format.string.general]/11
+ *
+ * This version expects a value less than 0x1'0000, which is a 3-byte UTF-8
+ * character.
+ */
+_LIBCPP_HIDE_FROM_ABI inline constexpr int __column_width_3(uint32_t __c) noexcept {
+ _LIBCPP_ASSERT(__c < 0x1'0000,
+ "Use __column_width_4 or __column_width for larger values");
+
+ // clang-format off
+ return 1 + (__c >= 0x1100 && (__c <= 0x115f ||
+ (__c >= 0x2329 && (__c <= 0x232a ||
+ (__c >= 0x2e80 && (__c <= 0x303e ||
+ (__c >= 0x3040 && (__c <= 0xa4cf ||
+ (__c >= 0xac00 && (__c <= 0xd7a3 ||
+ (__c >= 0xf900 && (__c <= 0xfaff ||
+ (__c >= 0xfe10 && (__c <= 0xfe19 ||
+ (__c >= 0xfe30 && (__c <= 0xfe6f ||
+ (__c >= 0xff00 && (__c <= 0xff60 ||
+ (__c >= 0xffe0 && (__c <= 0xffe6
+ ))))))))))))))))))));
+ // clang-format on
+}
+
+/**
+ * @overload
+ *
+ * This version expects a value greater than or equal to 0x1'0000, which is a
+ * 4-byte UTF-8 character.
+ */
+_LIBCPP_HIDE_FROM_ABI inline constexpr int __column_width_4(uint32_t __c) noexcept {
+ _LIBCPP_ASSERT(__c >= 0x1'0000,
+ "Use __column_width_3 or __column_width for smaller values");
+
+ // clang-format off
+ return 1 + (__c >= 0x1'f300 && (__c <= 0x1'f64f ||
+ (__c >= 0x1'f900 && (__c <= 0x1'f9ff ||
+ (__c >= 0x2'0000 && (__c <= 0x2'fffd ||
+ (__c >= 0x3'0000 && (__c <= 0x3'fffd
+ ))))))));
+ // clang-format on
+}
+
+/**
+ * @overload
+ *
+ * The general case, accepting all values.
+ */
+_LIBCPP_HIDE_FROM_ABI inline constexpr int __column_width(uint32_t __c) noexcept {
+ if (__c < 0x1'0000)
+ return __column_width_3(__c);
+
+ return __column_width_4(__c);
+}
+
+/**
+ * Estimate the column width for the UTF-8 sequence using the fast algorithm.
+ */
+template <__utf8_character _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
+__estimate_column_width_fast(const _CharT* __first,
+ const _CharT* __last) noexcept {
+ return _VSTD::find_if(__first, __last,
+ [](unsigned char __c) { return __c & 0x80; });
+}
+
+/**
+ * @overload
+ *
+ * The implementation for UTF-16/32.
+ */
+template <__utf16_or_32_character _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
+__estimate_column_width_fast(const _CharT* __first,
+ const _CharT* __last) noexcept {
+ return _VSTD::find_if(__first, __last,
+ [](uint32_t __c) { return __c >= 0x1100; });
+}
+
+template <class _CharT>
+struct _LIBCPP_TEMPLATE_VIS __column_width_result {
+ /** The number of output columns. */
+ size_t __width;
+ /**
+ * The last parsed element.
+ *
+ * This limits the original output to fit in the wanted number of columns.
+ */
+ const _CharT* __ptr;
+};
+
+/**
+ * Small helper to determine the width of malformed Unicode.
+ *
+ * @note This function's only needed for UTF-8. During scanning UTF-8 there
+ * are multiple place where it can be detected that the Unicode is malformed.
+ * UTF-16 only requires 1 test and UTF-32 requires no testing.
+ */
+template <__utf8_character _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT>
+__estimate_column_width_malformed(const _CharT* __first, const _CharT* __last,
+ size_t __maximum, size_t __result) noexcept {
+ size_t __size = __last - __first;
+ size_t __n = _VSTD::min(__size, __maximum);
+ return {__result + __n, __first + __n};
+}
+
+/**
+ * Determines the number of output columns needed to render the input.
+ *
+ * @note When the scanner encounters malformed Unicode it acts as-if every code
+ * unit at the end of the input is one output column. It's expected the output
+ * terminal will replace these malformed code units with a one column
+ * replacement characters.
+ *
+ * @param __first Points to the first element of the input range.
+ * @param __last Points beyond the last element of the input range.
+ * @param __maximum The maximum number of output columns. The returned number
+ * of estimated output columns will not exceed this value.
+ */
+template <__utf8_character _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT>
+__estimate_column_width(const _CharT* __first, const _CharT* __last,
+ size_t __maximum) noexcept {
+ size_t __result = 0;
+
+ while (__first != __last) {
+ // Based on the number of leading 1 bits the number of code units in the
+ // code point can be determined. See
+ // https://en.wikipedia.org/wiki/UTF-8#Encoding
+ switch (_VSTD::countl_one(static_cast<unsigned char>(*__first))) {
+ case 0: // 1-code unit encoding: all 1 column
+ ++__result;
+ ++__first;
+ break;
+
+ case 2: // 2-code unit encoding: all 1 column
+ // Malformed Unicode.
+ if (__last - __first < 2) [[unlikely]]
+ return __estimate_column_width_malformed(__first, __last, __maximum,
+ __result);
+ __first += 2;
+ ++__result;
+ break;
+
+ case 3: // 3-code unit encoding: either 1 or 2 columns
+ // Malformed Unicode.
+ if (__last - __first < 3) [[unlikely]]
+ return __estimate_column_width_malformed(__first, __last, __maximum,
+ __result);
+ {
+ uint32_t __c = static_cast<unsigned char>(*__first++) & 0x0f;
+ __c <<= 6;
+ __c |= static_cast<unsigned char>(*__first++) & 0x3f;
+ __c <<= 6;
+ __c |= static_cast<unsigned char>(*__first++) & 0x3f;
+ __result += __column_width_3(__c);
+ if (__result > __maximum)
+ return {__result - 2, __first - 3};
+ }
+ break;
+ case 4: // 4-code unit encoding: either 1 or 2 columns
+ // Malformed Unicode.
+ if (__last - __first < 4) [[unlikely]]
+ return __estimate_column_width_malformed(__first, __last, __maximum,
+ __result);
+ {
+ uint32_t __c = static_cast<unsigned char>(*__first++) & 0x07;
+ __c <<= 6;
+ __c |= static_cast<unsigned char>(*__first++) & 0x3f;
+ __c <<= 6;
+ __c |= static_cast<unsigned char>(*__first++) & 0x3f;
+ __c <<= 6;
+ __c |= static_cast<unsigned char>(*__first++) & 0x3f;
+ __result += __column_width_4(__c);
+ if (__result > __maximum)
+ return {__result - 2, __first - 4};
+ }
+ break;
+ default:
+ // Malformed Unicode.
+ return __estimate_column_width_malformed(__first, __last, __maximum,
+ __result);
+ }
+
+ if (__result >= __maximum)
+ return {__result, __first};
+ }
+ return {__result, __first};
+}
+
+template <__utf16_character _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT>
+__estimate_column_width(const _CharT* __first, const _CharT* __last,
+ size_t __maximum) noexcept {
+ size_t __result = 0;
+
+ while (__first != __last) {
+ uint32_t __c = *__first;
+ // Is the code unit part of a surrogate pair? See
+ // https://en.wikipedia.org/wiki/UTF-16#U+D800_to_U+DFFF
+ if (__c >= 0xd800 && __c <= 0xDfff) {
+ // Malformed Unicode.
+ if (__last - __first < 2) [[unlikely]]
+ return {__result + 1, __first + 1};
+
+ __c -= 0xd800;
+ __c <<= 10;
+ __c += (*(__first + 1) - 0xdc00);
+ __c += 0x10'000;
+
+ __result += __column_width_4(__c);
+ if (__result > __maximum)
+ return {__result - 2, __first};
+ __first += 2;
+ } else {
+ __result += __column_width_3(__c);
+ if (__result > __maximum)
+ return {__result - 2, __first};
+ ++__first;
+ }
+
+ if (__result >= __maximum)
+ return {__result, __first};
+ }
+
+ return {__result, __first};
+}
+
+template <__utf32_character _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT>
+__estimate_column_width(const _CharT* __first, const _CharT* __last,
+ size_t __maximum) noexcept {
+ size_t __result = 0;
+
+ while (__first != __last) {
+ wchar_t __c = *__first;
+ __result += __column_width(__c);
+
+ if (__result > __maximum)
+ return {__result - 2, __first};
+
+ ++__first;
+ if (__result >= __maximum)
+ return {__result, __first};
+ }
+
+ return {__result, __first};
+}
+
+} // namespace __detail
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr __string_alignment<_CharT>
+__get_string_alignment(const _CharT* __first, const _CharT* __last,
+ ptrdiff_t __width, ptrdiff_t __precision) noexcept {
+ _LIBCPP_ASSERT(__width != 0 || __precision != -1,
+ "The function has no effect and shouldn't be used");
+
+ // TODO FMT There might be more optimizations possible:
+ // If __precision == __format::__number_max and the encoding is:
+ // * UTF-8 : 4 * (__last - __first) >= __width
+ // * UTF-16 : 2 * (__last - __first) >= __width
+ // * UTF-32 : (__last - __first) >= __width
+ // In these cases it's certain the output is at least the requested width.
+ // It's unknown how often this happens in practice. For now the improvement
+ // isn't implemented.
+
+ /*
+ * First assume there are no special Unicode code units in the input.
+ * - Apply the precision (this may reduce the size of the input). When
+ * __precison == -1 this step is omitted.
+ * - Scan for special code units in the input.
+ * If our assumption was correct the __pos will be at the end of the input.
+ */
+ const ptrdiff_t __length = __last - __first;
+ const _CharT* __limit =
+ __first +
+ (__precision == -1 ? __length : _VSTD::min(__length, __precision));
+ ptrdiff_t __size = __limit - __first;
+ const _CharT* __pos =
+ __detail::__estimate_column_width_fast(__first, __limit);
+
+ if (__pos == __limit)
+ return {__limit, __size, __size < __width};
+
+ /*
+ * Our assumption was wrong, there are special Unicode code units.
+ * The range [__first, __pos) contains a set of code units with the
+ * following property:
+ * Every _CharT in the range will be rendered in 1 column.
+ *
+ * If there's no maximum width and the parsed size already exceeds the
+ * minimum required width. The real size isn't important. So bail out.
+ */
+ if (__precision == -1 && (__pos - __first) >= __width)
+ return {__last, 0, false};
+
+ /* If there's a __precision, truncate the output to that width. */
+ ptrdiff_t __prefix = __pos - __first;
+ if (__precision != -1) {
+ _LIBCPP_ASSERT(__precision > __prefix, "Logic error.");
+ auto __lengh_info = __detail::__estimate_column_width(
+ __pos, __last, __precision - __prefix);
+ __size = __lengh_info.__width + __prefix;
+ return {__lengh_info.__ptr, __size, __size < __width};
+ }
+
+ /* Else use __width to determine the number of required padding characters. */
+ _LIBCPP_ASSERT(__width > __prefix, "Logic error.");
+ /*
+ * The column width is always one or two columns. For the precision the wanted
+ * column width is the maximum, for the width it's the minimum. Using the
+ * width estimation with its truncating behavior will result in the wrong
+ * result in the following case:
+ * - The last code unit processed requires two columns and exceeds the
+ * maximum column width.
+ * By increasing the __maximum by one avoids this issue. (It means it may
+ * pass one code point more than required to determine the proper result;
+ * that however isn't a problem for the algorithm.)
+ */
+ size_t __maximum = 1 + __width - __prefix;
+ auto __lengh_info =
+ __detail::__estimate_column_width(__pos, __last, __maximum);
+ if (__lengh_info.__ptr != __last) {
+ // Consumed the width number of code units. The exact size of the string
+ // is unknown. We only know we don't need to align the output.
+ _LIBCPP_ASSERT(static_cast<ptrdiff_t>(__lengh_info.__width + __prefix) >=
+ __width,
+ "Logic error");
+ return {__last, 0, false};
+ }
+
+ __size = __lengh_info.__width + __prefix;
+ return {__last, __size, __size < __width};
+}
+#else // _LIBCPP_HAS_NO_UNICODE
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr __string_alignment<_CharT>
+__get_string_alignment(const _CharT* __first, const _CharT* __last,
+ ptrdiff_t __width, ptrdiff_t __precision) noexcept {
+ const ptrdiff_t __length = __last - __first;
+ const _CharT* __limit =
+ __first +
+ (__precision == -1 ? __length : _VSTD::min(__length, __precision));
+ ptrdiff_t __size = __limit - __first;
+ return {__limit, __size, __size < __width};
+}
+#endif // _LIBCPP_HAS_NO_UNICODE
+
+} // namespace __format_spec
+
+# endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___FORMAT_PARSER_STD_FORMAT_SPEC_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/binary_function.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/binary_function.h
new file mode 100644
index 0000000000..51135ef51e
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/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/libs/cxxsupp/libcxxmsvc/include/__functional/binary_negate.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/binary_negate.h
new file mode 100644
index 0000000000..17c5c20668
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/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/libs/cxxsupp/libcxxmsvc/include/__functional/bind.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/bind.h
new file mode 100644
index 0000000000..a5b0c0e191
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/bind.h
@@ -0,0 +1,418 @@
+// -*- 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/invoke.h>
+#include <__functional/weak_result_type.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 : _If<
+ _IsSame<_Tp, __uncvref_t<_Tp> >::value,
+ false_type,
+ is_bind_expression<__uncvref_t<_Tp> >
+> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr size_t is_bind_expression_v = is_bind_expression<_Tp>::value;
+#endif
+
+template<class _Tp>
+struct is_placeholder : _If<
+ _IsSame<_Tp, __uncvref_t<_Tp> >::value,
+ integral_constant<int, 0>,
+ is_placeholder<__uncvref_t<_Tp> >
+> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline 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
+/* inline */ constexpr __ph<1> _1{};
+/* inline */ constexpr __ph<2> _2{};
+/* inline */ constexpr __ph<3> _3{};
+/* inline */ constexpr __ph<4> _4{};
+/* inline */ constexpr __ph<5> _5{};
+/* inline */ constexpr __ph<6> _6{};
+/* inline */ constexpr __ph<7> _7{};
+/* inline */ constexpr __ph<8> _8{};
+/* inline */ constexpr __ph<9> _9{};
+/* inline */ constexpr __ph<10> _10{};
+#endif // defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY)
+
+} // namespace 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 __enable_if_t
+<
+ 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;
+};
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( push )
+#pragma warning ( disable : 4296 )
+#endif
+
+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>
+{
+};
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( pop )
+#endif
+
+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)...);
+}
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( push )
+#pragma warning ( disable : 4296 )
+#endif
+
+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)...));
+ }
+};
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( pop )
+#endif
+
+#if defined(__CUDACC__) && defined(_MSC_VER)
+# define Y_CUDAFE_MSVC_BUG
+#endif
+
+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;
+#if !defined(Y_CUDAFE_MSVC_BUG)
+ typedef typename base::_Td _Td;
+#else
+ typedef typename tuple<typename decay<_BoundArgs>::type...> _Td;
+#endif
+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/libs/cxxsupp/libcxxmsvc/include/__functional/bind_back.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/bind_back.h
new file mode 100644
index 0000000000..d64981aa9e
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/bind_back.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___FUNCTIONAL_BIND_BACK_H
+#define _LIBCPP___FUNCTIONAL_BIND_BACK_H
+
+#include <__config>
+#include <__functional/invoke.h>
+#include <__functional/perfect_forward.h>
+#include <__utility/forward.h>
+#include <__utility/integer_sequence.h>
+#include <tuple>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+template <size_t _NBound, class = make_index_sequence<_NBound>>
+struct __bind_back_op;
+
+template <size_t _NBound, size_t ..._Ip>
+struct __bind_back_op<_NBound, index_sequence<_Ip...>> {
+ template <class _Fn, class _Bound, class ..._Args>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Fn&& __f, _Bound&& __bound, _Args&& ...__args) const
+ noexcept(noexcept(_VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_Bound>(__bound))...)))
+ -> decltype( _VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_Bound>(__bound))...))
+ { return _VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_Bound>(__bound))...); }
+};
+
+template <class _Fn, class _BoundArgs>
+struct __bind_back_t : __perfect_forward<__bind_back_op<tuple_size_v<_BoundArgs>>, _Fn, _BoundArgs> {
+ using __perfect_forward<__bind_back_op<tuple_size_v<_BoundArgs>>, _Fn, _BoundArgs>::__perfect_forward;
+};
+
+template <class _Fn, class ..._Args, class = enable_if_t<
+ _And<
+ 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
+>>
+_LIBCPP_HIDE_FROM_ABI
+constexpr auto __bind_back(_Fn&& __f, _Args&&... __args)
+ noexcept(noexcept(__bind_back_t<decay_t<_Fn>, tuple<decay_t<_Args>...>>(_VSTD::forward<_Fn>(__f), _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...))))
+ -> decltype( __bind_back_t<decay_t<_Fn>, tuple<decay_t<_Args>...>>(_VSTD::forward<_Fn>(__f), _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)))
+ { return __bind_back_t<decay_t<_Fn>, tuple<decay_t<_Args>...>>(_VSTD::forward<_Fn>(__f), _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)); }
+
+#endif // _LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_BIND_BACK_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/bind_front.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/bind_front.h
new file mode 100644
index 0000000000..22fb3a69dc
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/bind_front.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___FUNCTIONAL_BIND_FRONT_H
+#define _LIBCPP___FUNCTIONAL_BIND_FRONT_H
+
+#include <__config>
+#include <__functional/invoke.h>
+#include <__functional/perfect_forward.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
+
+#if _LIBCPP_STD_VER > 17
+
+struct __bind_front_op {
+ template <class ..._Args>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Args&& ...__args) const
+ 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 ..._BoundArgs>
+struct __bind_front_t : __perfect_forward<__bind_front_op, _Fn, _BoundArgs...> {
+ using __perfect_forward<__bind_front_op, _Fn, _BoundArgs...>::__perfect_forward;
+};
+
+template <class _Fn, class... _Args, class = enable_if_t<
+ _And<
+ 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
+>>
+_LIBCPP_HIDE_FROM_ABI
+constexpr auto bind_front(_Fn&& __f, _Args&&... __args) {
+ return __bind_front_t<decay_t<_Fn>, decay_t<_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/libs/cxxsupp/libcxxmsvc/include/__functional/binder1st.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/binder1st.h
new file mode 100644
index 0000000000..13b2459dff
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/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/libs/cxxsupp/libcxxmsvc/include/__functional/binder2nd.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/binder2nd.h
new file mode 100644
index 0000000000..ff0f5f0816
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/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/libs/cxxsupp/libcxxmsvc/include/__functional/compose.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/compose.h
new file mode 100644
index 0000000000..25213f28b1
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/compose.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_COMPOSE_H
+#define _LIBCPP___FUNCTIONAL_COMPOSE_H
+
+#include <__config>
+#include <__functional/invoke.h>
+#include <__functional/perfect_forward.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
+
+#if _LIBCPP_STD_VER > 17
+
+struct __compose_op {
+ template<class _Fn1, class _Fn2, class ..._Args>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Fn1&& __f1, _Fn2&& __f2, _Args&&... __args) const
+ noexcept(noexcept(_VSTD::invoke(_VSTD::forward<_Fn1>(__f1), _VSTD::invoke(_VSTD::forward<_Fn2>(__f2), _VSTD::forward<_Args>(__args)...))))
+ -> decltype( _VSTD::invoke(_VSTD::forward<_Fn1>(__f1), _VSTD::invoke(_VSTD::forward<_Fn2>(__f2), _VSTD::forward<_Args>(__args)...)))
+ { return _VSTD::invoke(_VSTD::forward<_Fn1>(__f1), _VSTD::invoke(_VSTD::forward<_Fn2>(__f2), _VSTD::forward<_Args>(__args)...)); }
+};
+
+template <class _Fn1, class _Fn2>
+struct __compose_t : __perfect_forward<__compose_op, _Fn1, _Fn2> {
+ using __perfect_forward<__compose_op, _Fn1, _Fn2>::__perfect_forward;
+};
+
+template <class _Fn1, class _Fn2>
+_LIBCPP_HIDE_FROM_ABI
+constexpr auto __compose(_Fn1&& __f1, _Fn2&& __f2)
+ noexcept(noexcept(__compose_t<decay_t<_Fn1>, decay_t<_Fn2>>(_VSTD::forward<_Fn1>(__f1), _VSTD::forward<_Fn2>(__f2))))
+ -> decltype( __compose_t<decay_t<_Fn1>, decay_t<_Fn2>>(_VSTD::forward<_Fn1>(__f1), _VSTD::forward<_Fn2>(__f2)))
+ { return __compose_t<decay_t<_Fn1>, decay_t<_Fn2>>(_VSTD::forward<_Fn1>(__f1), _VSTD::forward<_Fn2>(__f2)); }
+
+#endif // _LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_COMPOSE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/default_searcher.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/default_searcher.h
new file mode 100644
index 0000000000..05fb23d7c3
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/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/pair.h>
+
+#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/libs/cxxsupp/libcxxmsvc/include/__functional/function.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/function.h
new file mode 100644
index 0000000000..b1faed9549
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/function.h
@@ -0,0 +1,2818 @@
+// -*- 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_FUNCTION_H
+#define _LIBCPP___FUNCTIONAL_FUNCTION_H
+
+#include <__assert>
+#include <__config>
+#include <__functional/binary_function.h>
+#include <__functional/invoke.h>
+#include <__functional/unary_function.h>
+#include <__iterator/iterator_traits.h>
+#include <__memory/addressof.h>
+#include <__memory/allocator_traits.h>
+#include <__memory/compressed_pair.h>
+#include <__memory/shared_ptr.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include <exception>
+#include <memory> // TODO: replace with <__memory/__builtin_new_allocator.h>
+#include <type_traits>
+
+#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
+{
+public:
+// Note that when a key function is not used, every translation unit that uses
+// bad_function_call will end up containing a weak definition of the vtable and
+// typeinfo.
+#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
+ virtual ~bad_function_call() _NOEXCEPT;
+#else
+ virtual ~bad_function_call() _NOEXCEPT {}
+#endif
+
+#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
+ 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 _Fp _Target;
+ typedef _LIBCPP_NODEBUG _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 _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 _VSTD::addressof(__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
+
+} // namespace __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_;
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( push )
+#pragma warning ( disable : 4348 )
+#endif
+ template <class _Fp, bool = _And<
+ _IsNotSame<__uncvref_t<_Fp>, function>,
+ __invokable<_Fp, _ArgTypes...>
+ >::value>
+ struct __callable;
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( pop )
+#endif
+ 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
+};
+
+#if _LIBCPP_STD_VER >= 17
+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_STD_VER >= 17
+
+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;
+
+template<class _Rp>
+class __base<_Rp()>
+{
+ __base(const __base&);
+ __base& operator=(const __base&);
+public:
+ __base() {}
+ virtual ~__base() {}
+ virtual __base* __clone() const = 0;
+ virtual void __clone(__base*) const = 0;
+ virtual void destroy() = 0;
+ virtual void destroy_deallocate() = 0;
+ virtual _Rp operator()() = 0;
+#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
+};
+
+template<class _Rp, class _A0>
+class __base<_Rp(_A0)>
+{
+ __base(const __base&);
+ __base& operator=(const __base&);
+public:
+ __base() {}
+ virtual ~__base() {}
+ virtual __base* __clone() const = 0;
+ virtual void __clone(__base*) const = 0;
+ virtual void destroy() = 0;
+ virtual void destroy_deallocate() = 0;
+ virtual _Rp operator()(_A0) = 0;
+#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
+};
+
+template<class _Rp, class _A0, class _A1>
+class __base<_Rp(_A0, _A1)>
+{
+ __base(const __base&);
+ __base& operator=(const __base&);
+public:
+ __base() {}
+ virtual ~__base() {}
+ virtual __base* __clone() const = 0;
+ virtual void __clone(__base*) const = 0;
+ virtual void destroy() = 0;
+ virtual void destroy_deallocate() = 0;
+ virtual _Rp operator()(_A0, _A1) = 0;
+#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
+};
+
+template<class _Rp, class _A0, class _A1, class _A2>
+class __base<_Rp(_A0, _A1, _A2)>
+{
+ __base(const __base&);
+ __base& operator=(const __base&);
+public:
+ __base() {}
+ virtual ~__base() {}
+ virtual __base* __clone() const = 0;
+ virtual void __clone(__base*) const = 0;
+ virtual void destroy() = 0;
+ virtual void destroy_deallocate() = 0;
+ virtual _Rp operator()(_A0, _A1, _A2) = 0;
+#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
+};
+
+template<class _FD, class _Alloc, class _FB> class __func;
+
+template<class _Fp, class _Alloc, class _Rp>
+class __func<_Fp, _Alloc, _Rp()>
+ : public __base<_Rp()>
+{
+ __compressed_pair<_Fp, _Alloc> __f_;
+public:
+ explicit __func(_Fp __f) : __f_(_VSTD::move(__f), __default_init_tag()) {}
+ explicit __func(_Fp __f, _Alloc __a) : __f_(_VSTD::move(__f), _VSTD::move(__a)) {}
+ virtual __base<_Rp()>* __clone() const;
+ virtual void __clone(__base<_Rp()>*) const;
+ virtual void destroy();
+ virtual void destroy_deallocate();
+ virtual _Rp operator()();
+#ifndef _LIBCPP_NO_RTTI
+ virtual const void* target(const type_info&) const;
+ virtual const std::type_info& target_type() const;
+#endif // _LIBCPP_NO_RTTI
+};
+
+template<class _Fp, class _Alloc, class _Rp>
+__base<_Rp()>*
+__func<_Fp, _Alloc, _Rp()>::__clone() const
+{
+ typedef allocator_traits<_Alloc> __alloc_traits;
+ typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
+ _Ap __a(__f_.second());
+ typedef __allocator_destructor<_Ap> _Dp;
+ unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+ ::new ((void*)__hold.get()) __func(__f_.first(), _Alloc(__a));
+ return __hold.release();
+}
+
+template<class _Fp, class _Alloc, class _Rp>
+void
+__func<_Fp, _Alloc, _Rp()>::__clone(__base<_Rp()>* __p) const
+{
+ ::new ((void*)__p) __func(__f_.first(), __f_.second());
+}
+
+template<class _Fp, class _Alloc, class _Rp>
+void
+__func<_Fp, _Alloc, _Rp()>::destroy()
+{
+ __f_.~__compressed_pair<_Fp, _Alloc>();
+}
+
+template<class _Fp, class _Alloc, class _Rp>
+void
+__func<_Fp, _Alloc, _Rp()>::destroy_deallocate()
+{
+ typedef allocator_traits<_Alloc> __alloc_traits;
+ typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
+ _Ap __a(__f_.second());
+ __f_.~__compressed_pair<_Fp, _Alloc>();
+ __a.deallocate(this, 1);
+}
+
+template<class _Fp, class _Alloc, class _Rp>
+_Rp
+__func<_Fp, _Alloc, _Rp()>::operator()()
+{
+ typedef __invoke_void_return_wrapper<_Rp> _Invoker;
+ return _Invoker::__call(__f_.first());
+}
+
+#ifndef _LIBCPP_NO_RTTI
+
+template<class _Fp, class _Alloc, class _Rp>
+const void*
+__func<_Fp, _Alloc, _Rp()>::target(const type_info& __ti) const
+{
+ if (__ti == typeid(_Fp))
+ return _VSTD::addressof(__f_.first());
+ return (const void*)0;
+}
+
+template<class _Fp, class _Alloc, class _Rp>
+const std::type_info&
+__func<_Fp, _Alloc, _Rp()>::target_type() const
+{
+ return typeid(_Fp);
+}
+
+#endif // _LIBCPP_NO_RTTI
+
+template<class _Fp, class _Alloc, class _Rp, class _A0>
+class __func<_Fp, _Alloc, _Rp(_A0)>
+ : public __base<_Rp(_A0)>
+{
+ __compressed_pair<_Fp, _Alloc> __f_;
+public:
+ _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f), __default_init_tag()) {}
+ _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f, _Alloc __a)
+ : __f_(_VSTD::move(__f), _VSTD::move(__a)) {}
+ virtual __base<_Rp(_A0)>* __clone() const;
+ virtual void __clone(__base<_Rp(_A0)>*) const;
+ virtual void destroy();
+ virtual void destroy_deallocate();
+ virtual _Rp operator()(_A0);
+#ifndef _LIBCPP_NO_RTTI
+ virtual const void* target(const type_info&) const;
+ virtual const std::type_info& target_type() const;
+#endif // _LIBCPP_NO_RTTI
+};
+
+template<class _Fp, class _Alloc, class _Rp, class _A0>
+__base<_Rp(_A0)>*
+__func<_Fp, _Alloc, _Rp(_A0)>::__clone() const
+{
+ typedef allocator_traits<_Alloc> __alloc_traits;
+ typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
+ _Ap __a(__f_.second());
+ typedef __allocator_destructor<_Ap> _Dp;
+ unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+ ::new ((void*)__hold.get()) __func(__f_.first(), _Alloc(__a));
+ return __hold.release();
+}
+
+template<class _Fp, class _Alloc, class _Rp, class _A0>
+void
+__func<_Fp, _Alloc, _Rp(_A0)>::__clone(__base<_Rp(_A0)>* __p) const
+{
+ ::new ((void*)__p) __func(__f_.first(), __f_.second());
+}
+
+template<class _Fp, class _Alloc, class _Rp, class _A0>
+void
+__func<_Fp, _Alloc, _Rp(_A0)>::destroy()
+{
+ __f_.~__compressed_pair<_Fp, _Alloc>();
+}
+
+template<class _Fp, class _Alloc, class _Rp, class _A0>
+void
+__func<_Fp, _Alloc, _Rp(_A0)>::destroy_deallocate()
+{
+ typedef allocator_traits<_Alloc> __alloc_traits;
+ typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
+ _Ap __a(__f_.second());
+ __f_.~__compressed_pair<_Fp, _Alloc>();
+ __a.deallocate(this, 1);
+}
+
+template<class _Fp, class _Alloc, class _Rp, class _A0>
+_Rp
+__func<_Fp, _Alloc, _Rp(_A0)>::operator()(_A0 __a0)
+{
+ typedef __invoke_void_return_wrapper<_Rp> _Invoker;
+ return _Invoker::__call(__f_.first(), __a0);
+}
+
+#ifndef _LIBCPP_NO_RTTI
+
+template<class _Fp, class _Alloc, class _Rp, class _A0>
+const void*
+__func<_Fp, _Alloc, _Rp(_A0)>::target(const type_info& __ti) const
+{
+ if (__ti == typeid(_Fp))
+ return &__f_.first();
+ return (const void*)0;
+}
+
+template<class _Fp, class _Alloc, class _Rp, class _A0>
+const std::type_info&
+__func<_Fp, _Alloc, _Rp(_A0)>::target_type() const
+{
+ return typeid(_Fp);
+}
+
+#endif // _LIBCPP_NO_RTTI
+
+template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
+class __func<_Fp, _Alloc, _Rp(_A0, _A1)>
+ : public __base<_Rp(_A0, _A1)>
+{
+ __compressed_pair<_Fp, _Alloc> __f_;
+public:
+ _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f), __default_init_tag()) {}
+ _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f, _Alloc __a)
+ : __f_(_VSTD::move(__f), _VSTD::move(__a)) {}
+ virtual __base<_Rp(_A0, _A1)>* __clone() const;
+ virtual void __clone(__base<_Rp(_A0, _A1)>*) const;
+ virtual void destroy();
+ virtual void destroy_deallocate();
+ virtual _Rp operator()(_A0, _A1);
+#ifndef _LIBCPP_NO_RTTI
+ virtual const void* target(const type_info&) const;
+ virtual const std::type_info& target_type() const;
+#endif // _LIBCPP_NO_RTTI
+};
+
+template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
+__base<_Rp(_A0, _A1)>*
+__func<_Fp, _Alloc, _Rp(_A0, _A1)>::__clone() const
+{
+ typedef allocator_traits<_Alloc> __alloc_traits;
+ typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
+ _Ap __a(__f_.second());
+ typedef __allocator_destructor<_Ap> _Dp;
+ unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+ ::new ((void*)__hold.get()) __func(__f_.first(), _Alloc(__a));
+ return __hold.release();
+}
+
+template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
+void
+__func<_Fp, _Alloc, _Rp(_A0, _A1)>::__clone(__base<_Rp(_A0, _A1)>* __p) const
+{
+ ::new ((void*)__p) __func(__f_.first(), __f_.second());
+}
+
+template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
+void
+__func<_Fp, _Alloc, _Rp(_A0, _A1)>::destroy()
+{
+ __f_.~__compressed_pair<_Fp, _Alloc>();
+}
+
+template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
+void
+__func<_Fp, _Alloc, _Rp(_A0, _A1)>::destroy_deallocate()
+{
+ typedef allocator_traits<_Alloc> __alloc_traits;
+ typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
+ _Ap __a(__f_.second());
+ __f_.~__compressed_pair<_Fp, _Alloc>();
+ __a.deallocate(this, 1);
+}
+
+template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
+_Rp
+__func<_Fp, _Alloc, _Rp(_A0, _A1)>::operator()(_A0 __a0, _A1 __a1)
+{
+ typedef __invoke_void_return_wrapper<_Rp> _Invoker;
+ return _Invoker::__call(__f_.first(), __a0, __a1);
+}
+
+#ifndef _LIBCPP_NO_RTTI
+
+template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
+const void*
+__func<_Fp, _Alloc, _Rp(_A0, _A1)>::target(const type_info& __ti) const
+{
+ if (__ti == typeid(_Fp))
+ return &__f_.first();
+ return (const void*)0;
+}
+
+template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
+const std::type_info&
+__func<_Fp, _Alloc, _Rp(_A0, _A1)>::target_type() const
+{
+ return typeid(_Fp);
+}
+
+#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)>
+ : public __base<_Rp(_A0, _A1, _A2)>
+{
+ __compressed_pair<_Fp, _Alloc> __f_;
+public:
+ _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f), __default_init_tag()) {}
+ _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f, _Alloc __a)
+ : __f_(_VSTD::move(__f), _VSTD::move(__a)) {}
+ virtual __base<_Rp(_A0, _A1, _A2)>* __clone() const;
+ virtual void __clone(__base<_Rp(_A0, _A1, _A2)>*) const;
+ virtual void destroy();
+ virtual void destroy_deallocate();
+ virtual _Rp operator()(_A0, _A1, _A2);
+#ifndef _LIBCPP_NO_RTTI
+ virtual const void* target(const type_info&) const;
+ virtual const std::type_info& target_type() const;
+#endif // _LIBCPP_NO_RTTI
+};
+
+template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
+__base<_Rp(_A0, _A1, _A2)>*
+__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::__clone() const
+{
+ typedef allocator_traits<_Alloc> __alloc_traits;
+ typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
+ _Ap __a(__f_.second());
+ typedef __allocator_destructor<_Ap> _Dp;
+ unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+ ::new ((void*)__hold.get()) __func(__f_.first(), _Alloc(__a));
+ return __hold.release();
+}
+
+template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
+void
+__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::__clone(__base<_Rp(_A0, _A1, _A2)>* __p) const
+{
+ ::new ((void*)__p) __func(__f_.first(), __f_.second());
+}
+
+template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
+void
+__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::destroy()
+{
+ __f_.~__compressed_pair<_Fp, _Alloc>();
+}
+
+template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
+void
+__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::destroy_deallocate()
+{
+ typedef allocator_traits<_Alloc> __alloc_traits;
+ typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
+ _Ap __a(__f_.second());
+ __f_.~__compressed_pair<_Fp, _Alloc>();
+ __a.deallocate(this, 1);
+}
+
+template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
+_Rp
+__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::operator()(_A0 __a0, _A1 __a1, _A2 __a2)
+{
+ typedef __invoke_void_return_wrapper<_Rp> _Invoker;
+ return _Invoker::__call(__f_.first(), __a0, __a1, __a2);
+}
+
+#ifndef _LIBCPP_NO_RTTI
+
+template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
+const void*
+__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::target(const type_info& __ti) const
+{
+ if (__ti == typeid(_Fp))
+ return &__f_.first();
+ return (const void*)0;
+}
+
+template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
+const std::type_info&
+__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::target_type() const
+{
+ return typeid(_Fp);
+}
+
+#endif // _LIBCPP_NO_RTTI
+
+} // namespace __function
+
+template<class _Rp>
+class _LIBCPP_TEMPLATE_VIS function<_Rp()>
+{
+ typedef __function::__base<_Rp()> __base;
+ aligned_storage<3*sizeof(void*)>::type __buf_;
+ __base* __f_;
+
+public:
+ typedef _Rp result_type;
+
+ // 20.7.16.2.1, construct/copy/destroy:
+ _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {}
+ _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {}
+ function(const function&);
+ template<class _Fp>
+ function(_Fp,
+ typename enable_if<!is_integral<_Fp>::value>::type* = 0);
+
+ template<class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY
+ function(allocator_arg_t, const _Alloc&) : __f_(0) {}
+ template<class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY
+ function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {}
+ template<class _Alloc>
+ function(allocator_arg_t, const _Alloc&, const function&);
+ template<class _Fp, class _Alloc>
+ function(allocator_arg_t, const _Alloc& __a, _Fp __f,
+ typename enable_if<!is_integral<_Fp>::value>::type* = 0);
+
+ function& operator=(const function&);
+ function& operator=(nullptr_t);
+ template<class _Fp>
+ typename enable_if
+ <
+ !is_integral<_Fp>::value,
+ function&
+ >::type
+ operator=(_Fp);
+
+ ~function();
+
+ // 20.7.16.2.2, function modifiers:
+ void swap(function&);
+ template<class _Fp, class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY
+ void assign(_Fp __f, const _Alloc& __a)
+ {function(allocator_arg, __a, __f).swap(*this);}
+
+ // 20.7.16.2.3, function capacity:
+ _LIBCPP_INLINE_VISIBILITY explicit operator bool() const {return __f_;}
+
+ template<class _R2>
+ bool operator==(const function<_R2()>&) const = delete;
+ template<class _R2>
+ bool operator!=(const function<_R2()>&) const = delete;
+
+ // 20.7.16.2.4, function invocation:
+ _Rp operator()() const;
+
+#ifndef _LIBCPP_NO_RTTI
+ // 20.7.16.2.5, function target access:
+ const std::type_info& target_type() const;
+ template <typename _Tp> _Tp* target();
+ template <typename _Tp> const _Tp* target() const;
+#endif // _LIBCPP_NO_RTTI
+};
+
+template<class _Rp>
+function<_Rp()>::function(const function& __f)
+{
+ if (__f.__f_ == 0)
+ __f_ = 0;
+ else if (__f.__f_ == (const __base*)&__f.__buf_)
+ {
+ __f_ = (__base*)&__buf_;
+ __f.__f_->__clone(__f_);
+ }
+ else
+ __f_ = __f.__f_->__clone();
+}
+
+template<class _Rp>
+template<class _Alloc>
+function<_Rp()>::function(allocator_arg_t, const _Alloc&, const function& __f)
+{
+ if (__f.__f_ == 0)
+ __f_ = 0;
+ else if (__f.__f_ == (const __base*)&__f.__buf_)
+ {
+ __f_ = (__base*)&__buf_;
+ __f.__f_->__clone(__f_);
+ }
+ else
+ __f_ = __f.__f_->__clone();
+}
+
+template<class _Rp>
+template <class _Fp>
+function<_Rp()>::function(_Fp __f,
+ typename enable_if<!is_integral<_Fp>::value>::type*)
+ : __f_(0)
+{
+ if (__function::__not_null(__f))
+ {
+ typedef __function::__func<_Fp, allocator<_Fp>, _Rp()> _FF;
+ if (sizeof(_FF) <= sizeof(__buf_))
+ {
+ __f_ = (__base*)&__buf_;
+ ::new ((void*)__f_) _FF(__f);
+ }
+ else
+ {
+ typedef allocator<_FF> _Ap;
+ _Ap __a;
+ typedef __allocator_destructor<_Ap> _Dp;
+ unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+ ::new ((void*)__hold.get()) _FF(__f, allocator<_Fp>(__a));
+ __f_ = __hold.release();
+ }
+ }
+}
+
+template<class _Rp>
+template <class _Fp, class _Alloc>
+function<_Rp()>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
+ typename enable_if<!is_integral<_Fp>::value>::type*)
+ : __f_(0)
+{
+ typedef allocator_traits<_Alloc> __alloc_traits;
+ if (__function::__not_null(__f))
+ {
+ typedef __function::__func<_Fp, _Alloc, _Rp()> _FF;
+ if (sizeof(_FF) <= sizeof(__buf_))
+ {
+ __f_ = (__base*)&__buf_;
+ ::new ((void*)__f_) _FF(__f, __a0);
+ }
+ else
+ {
+ typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
+ _Ap __a(__a0);
+ typedef __allocator_destructor<_Ap> _Dp;
+ unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+ ::new ((void*)__hold.get()) _FF(__f, _Alloc(__a));
+ __f_ = __hold.release();
+ }
+ }
+}
+
+template<class _Rp>
+function<_Rp()>&
+function<_Rp()>::operator=(const function& __f)
+{
+ if (__f)
+ function(__f).swap(*this);
+ else
+ *this = nullptr;
+ return *this;
+}
+
+template<class _Rp>
+function<_Rp()>&
+function<_Rp()>::operator=(nullptr_t)
+{
+ __base* __t = __f_;
+ __f_ = 0;
+ if (__t == (__base*)&__buf_)
+ __t->destroy();
+ else if (__t)
+ __t->destroy_deallocate();
+ return *this;
+}
+
+template<class _Rp>
+template <class _Fp>
+typename enable_if
+<
+ !is_integral<_Fp>::value,
+ function<_Rp()>&
+>::type
+function<_Rp()>::operator=(_Fp __f)
+{
+ function(_VSTD::move(__f)).swap(*this);
+ return *this;
+}
+
+template<class _Rp>
+function<_Rp()>::~function()
+{
+ if (__f_ == (__base*)&__buf_)
+ __f_->destroy();
+ else if (__f_)
+ __f_->destroy_deallocate();
+}
+
+template<class _Rp>
+void
+function<_Rp()>::swap(function& __f)
+{
+ if (_VSTD::addressof(__f) == this)
+ return;
+ if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
+ {
+ typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
+ __base* __t = (__base*)&__tempbuf;
+ __f_->__clone(__t);
+ __f_->destroy();
+ __f_ = 0;
+ __f.__f_->__clone((__base*)&__buf_);
+ __f.__f_->destroy();
+ __f.__f_ = 0;
+ __f_ = (__base*)&__buf_;
+ __t->__clone((__base*)&__f.__buf_);
+ __t->destroy();
+ __f.__f_ = (__base*)&__f.__buf_;
+ }
+ else if (__f_ == (__base*)&__buf_)
+ {
+ __f_->__clone((__base*)&__f.__buf_);
+ __f_->destroy();
+ __f_ = __f.__f_;
+ __f.__f_ = (__base*)&__f.__buf_;
+ }
+ else if (__f.__f_ == (__base*)&__f.__buf_)
+ {
+ __f.__f_->__clone((__base*)&__buf_);
+ __f.__f_->destroy();
+ __f.__f_ = __f_;
+ __f_ = (__base*)&__buf_;
+ }
+ else
+ _VSTD::swap(__f_, __f.__f_);
+}
+
+template<class _Rp>
+_Rp
+function<_Rp()>::operator()() const
+{
+ if (__f_ == 0)
+ __throw_bad_function_call();
+ return (*__f_)();
+}
+
+#ifndef _LIBCPP_NO_RTTI
+
+template<class _Rp>
+const std::type_info&
+function<_Rp()>::target_type() const
+{
+ if (__f_ == 0)
+ return typeid(void);
+ return __f_->target_type();
+}
+
+template<class _Rp>
+template <typename _Tp>
+_Tp*
+function<_Rp()>::target()
+{
+ if (__f_ == 0)
+ return (_Tp*)0;
+ return (_Tp*) const_cast<void *>(__f_->target(typeid(_Tp)));
+}
+
+template<class _Rp>
+template <typename _Tp>
+const _Tp*
+function<_Rp()>::target() const
+{
+ if (__f_ == 0)
+ return (const _Tp*)0;
+ return (const _Tp*)__f_->target(typeid(_Tp));
+}
+
+#endif // _LIBCPP_NO_RTTI
+
+template<class _Rp, class _A0>
+class _LIBCPP_TEMPLATE_VIS function<_Rp(_A0)>
+ : public unary_function<_A0, _Rp>
+{
+ typedef __function::__base<_Rp(_A0)> __base;
+ aligned_storage<3*sizeof(void*)>::type __buf_;
+ __base* __f_;
+
+public:
+ typedef _Rp result_type;
+
+ // 20.7.16.2.1, construct/copy/destroy:
+ _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {}
+ _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {}
+ function(const function&);
+ template<class _Fp>
+ function(_Fp,
+ typename enable_if<!is_integral<_Fp>::value>::type* = 0);
+
+ template<class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY
+ function(allocator_arg_t, const _Alloc&) : __f_(0) {}
+ template<class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY
+ function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {}
+ template<class _Alloc>
+ function(allocator_arg_t, const _Alloc&, const function&);
+ template<class _Fp, class _Alloc>
+ function(allocator_arg_t, const _Alloc& __a, _Fp __f,
+ typename enable_if<!is_integral<_Fp>::value>::type* = 0);
+
+ function& operator=(const function&);
+ function& operator=(nullptr_t);
+ template<class _Fp>
+ typename enable_if
+ <
+ !is_integral<_Fp>::value,
+ function&
+ >::type
+ operator=(_Fp);
+
+ ~function();
+
+ // 20.7.16.2.2, function modifiers:
+ void swap(function&);
+ template<class _Fp, class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY
+ void assign(_Fp __f, const _Alloc& __a)
+ {function(allocator_arg, __a, __f).swap(*this);}
+
+ // 20.7.16.2.3, function capacity:
+ _LIBCPP_INLINE_VISIBILITY explicit operator bool() const {return __f_;}
+
+ template<class _R2, class _B0>
+ bool operator==(const function<_R2(_B0)>&) const = delete;
+ template<class _R2, class _B0>
+ bool operator!=(const function<_R2(_B0)>&) const = delete;
+
+ // 20.7.16.2.4, function invocation:
+ _Rp operator()(_A0) const;
+
+#ifndef _LIBCPP_NO_RTTI
+ // 20.7.16.2.5, function target access:
+ const std::type_info& target_type() const;
+ template <typename _Tp> _Tp* target();
+ template <typename _Tp> const _Tp* target() const;
+#endif // _LIBCPP_NO_RTTI
+};
+
+template<class _Rp, class _A0>
+function<_Rp(_A0)>::function(const function& __f)
+{
+ if (__f.__f_ == 0)
+ __f_ = 0;
+ else if (__f.__f_ == (const __base*)&__f.__buf_)
+ {
+ __f_ = (__base*)&__buf_;
+ __f.__f_->__clone(__f_);
+ }
+ else
+ __f_ = __f.__f_->__clone();
+}
+
+template<class _Rp, class _A0>
+template<class _Alloc>
+function<_Rp(_A0)>::function(allocator_arg_t, const _Alloc&, const function& __f)
+{
+ if (__f.__f_ == 0)
+ __f_ = 0;
+ else if (__f.__f_ == (const __base*)&__f.__buf_)
+ {
+ __f_ = (__base*)&__buf_;
+ __f.__f_->__clone(__f_);
+ }
+ else
+ __f_ = __f.__f_->__clone();
+}
+
+template<class _Rp, class _A0>
+template <class _Fp>
+function<_Rp(_A0)>::function(_Fp __f,
+ typename enable_if<!is_integral<_Fp>::value>::type*)
+ : __f_(0)
+{
+ if (__function::__not_null(__f))
+ {
+ typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0)> _FF;
+ if (sizeof(_FF) <= sizeof(__buf_))
+ {
+ __f_ = (__base*)&__buf_;
+ ::new ((void*)__f_) _FF(__f);
+ }
+ else
+ {
+ typedef allocator<_FF> _Ap;
+ _Ap __a;
+ typedef __allocator_destructor<_Ap> _Dp;
+ unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+ ::new ((void*)__hold.get()) _FF(__f, allocator<_Fp>(__a));
+ __f_ = __hold.release();
+ }
+ }
+}
+
+template<class _Rp, class _A0>
+template <class _Fp, class _Alloc>
+function<_Rp(_A0)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
+ typename enable_if<!is_integral<_Fp>::value>::type*)
+ : __f_(0)
+{
+ typedef allocator_traits<_Alloc> __alloc_traits;
+ if (__function::__not_null(__f))
+ {
+ typedef __function::__func<_Fp, _Alloc, _Rp(_A0)> _FF;
+ if (sizeof(_FF) <= sizeof(__buf_))
+ {
+ __f_ = (__base*)&__buf_;
+ ::new ((void*)__f_) _FF(__f, __a0);
+ }
+ else
+ {
+ typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
+ _Ap __a(__a0);
+ typedef __allocator_destructor<_Ap> _Dp;
+ unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+ ::new ((void*)__hold.get()) _FF(__f, _Alloc(__a));
+ __f_ = __hold.release();
+ }
+ }
+}
+
+template<class _Rp, class _A0>
+function<_Rp(_A0)>&
+function<_Rp(_A0)>::operator=(const function& __f)
+{
+ if (__f)
+ function(__f).swap(*this);
+ else
+ *this = nullptr;
+ return *this;
+}
+
+template<class _Rp, class _A0>
+function<_Rp(_A0)>&
+function<_Rp(_A0)>::operator=(nullptr_t)
+{
+ __base* __t = __f_;
+ __f_ = 0;
+ if (__t == (__base*)&__buf_)
+ __t->destroy();
+ else if (__t)
+ __t->destroy_deallocate();
+ return *this;
+}
+
+template<class _Rp, class _A0>
+template <class _Fp>
+typename enable_if
+<
+ !is_integral<_Fp>::value,
+ function<_Rp(_A0)>&
+>::type
+function<_Rp(_A0)>::operator=(_Fp __f)
+{
+ function(_VSTD::move(__f)).swap(*this);
+ return *this;
+}
+
+template<class _Rp, class _A0>
+function<_Rp(_A0)>::~function()
+{
+ if (__f_ == (__base*)&__buf_)
+ __f_->destroy();
+ else if (__f_)
+ __f_->destroy_deallocate();
+}
+
+template<class _Rp, class _A0>
+void
+function<_Rp(_A0)>::swap(function& __f)
+{
+ if (_VSTD::addressof(__f) == this)
+ return;
+ if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
+ {
+ typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
+ __base* __t = (__base*)&__tempbuf;
+ __f_->__clone(__t);
+ __f_->destroy();
+ __f_ = 0;
+ __f.__f_->__clone((__base*)&__buf_);
+ __f.__f_->destroy();
+ __f.__f_ = 0;
+ __f_ = (__base*)&__buf_;
+ __t->__clone((__base*)&__f.__buf_);
+ __t->destroy();
+ __f.__f_ = (__base*)&__f.__buf_;
+ }
+ else if (__f_ == (__base*)&__buf_)
+ {
+ __f_->__clone((__base*)&__f.__buf_);
+ __f_->destroy();
+ __f_ = __f.__f_;
+ __f.__f_ = (__base*)&__f.__buf_;
+ }
+ else if (__f.__f_ == (__base*)&__f.__buf_)
+ {
+ __f.__f_->__clone((__base*)&__buf_);
+ __f.__f_->destroy();
+ __f.__f_ = __f_;
+ __f_ = (__base*)&__buf_;
+ }
+ else
+ _VSTD::swap(__f_, __f.__f_);
+}
+
+template<class _Rp, class _A0>
+_Rp
+function<_Rp(_A0)>::operator()(_A0 __a0) const
+{
+ if (__f_ == 0)
+ __throw_bad_function_call();
+ return (*__f_)(__a0);
+}
+
+#ifndef _LIBCPP_NO_RTTI
+
+template<class _Rp, class _A0>
+const std::type_info&
+function<_Rp(_A0)>::target_type() const
+{
+ if (__f_ == 0)
+ return typeid(void);
+ return __f_->target_type();
+}
+
+template<class _Rp, class _A0>
+template <typename _Tp>
+_Tp*
+function<_Rp(_A0)>::target()
+{
+ if (__f_ == 0)
+ return (_Tp*)0;
+ return (_Tp*) const_cast<void *>(__f_->target(typeid(_Tp)));
+}
+
+template<class _Rp, class _A0>
+template <typename _Tp>
+const _Tp*
+function<_Rp(_A0)>::target() const
+{
+ if (__f_ == 0)
+ return (const _Tp*)0;
+ return (const _Tp*)__f_->target(typeid(_Tp));
+}
+
+#endif // _LIBCPP_NO_RTTI
+
+template<class _Rp, class _A0, class _A1>
+class _LIBCPP_TEMPLATE_VIS function<_Rp(_A0, _A1)>
+ : public binary_function<_A0, _A1, _Rp>
+{
+ typedef __function::__base<_Rp(_A0, _A1)> __base;
+ aligned_storage<3*sizeof(void*)>::type __buf_;
+ __base* __f_;
+
+public:
+ typedef _Rp result_type;
+
+ // 20.7.16.2.1, construct/copy/destroy:
+ _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {}
+ _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {}
+ function(const function&);
+ template<class _Fp>
+ function(_Fp,
+ typename enable_if<!is_integral<_Fp>::value>::type* = 0);
+
+ template<class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY
+ function(allocator_arg_t, const _Alloc&) : __f_(0) {}
+ template<class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY
+ function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {}
+ template<class _Alloc>
+ function(allocator_arg_t, const _Alloc&, const function&);
+ template<class _Fp, class _Alloc>
+ function(allocator_arg_t, const _Alloc& __a, _Fp __f,
+ typename enable_if<!is_integral<_Fp>::value>::type* = 0);
+
+ function& operator=(const function&);
+ function& operator=(nullptr_t);
+ template<class _Fp>
+ typename enable_if
+ <
+ !is_integral<_Fp>::value,
+ function&
+ >::type
+ operator=(_Fp);
+
+ ~function();
+
+ // 20.7.16.2.2, function modifiers:
+ void swap(function&);
+ template<class _Fp, class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY
+ void assign(_Fp __f, const _Alloc& __a)
+ {function(allocator_arg, __a, __f).swap(*this);}
+
+ // 20.7.16.2.3, function capacity:
+ _LIBCPP_INLINE_VISIBILITY explicit operator bool() const {return __f_;}
+
+ template<class _R2, class _B0, class _B1>
+ bool operator==(const function<_R2(_B0, _B1)>&) const = delete;
+ template<class _R2, class _B0, class _B1>
+ bool operator!=(const function<_R2(_B0, _B1)>&) const = delete;
+
+ // 20.7.16.2.4, function invocation:
+ _Rp operator()(_A0, _A1) const;
+
+#ifndef _LIBCPP_NO_RTTI
+ // 20.7.16.2.5, function target access:
+ const std::type_info& target_type() const;
+ template <typename _Tp> _Tp* target();
+ template <typename _Tp> const _Tp* target() const;
+#endif // _LIBCPP_NO_RTTI
+};
+
+template<class _Rp, class _A0, class _A1>
+function<_Rp(_A0, _A1)>::function(const function& __f)
+{
+ if (__f.__f_ == 0)
+ __f_ = 0;
+ else if (__f.__f_ == (const __base*)&__f.__buf_)
+ {
+ __f_ = (__base*)&__buf_;
+ __f.__f_->__clone(__f_);
+ }
+ else
+ __f_ = __f.__f_->__clone();
+}
+
+template<class _Rp, class _A0, class _A1>
+template<class _Alloc>
+function<_Rp(_A0, _A1)>::function(allocator_arg_t, const _Alloc&, const function& __f)
+{
+ if (__f.__f_ == 0)
+ __f_ = 0;
+ else if (__f.__f_ == (const __base*)&__f.__buf_)
+ {
+ __f_ = (__base*)&__buf_;
+ __f.__f_->__clone(__f_);
+ }
+ else
+ __f_ = __f.__f_->__clone();
+}
+
+template<class _Rp, class _A0, class _A1>
+template <class _Fp>
+function<_Rp(_A0, _A1)>::function(_Fp __f,
+ typename enable_if<!is_integral<_Fp>::value>::type*)
+ : __f_(0)
+{
+ if (__function::__not_null(__f))
+ {
+ typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0, _A1)> _FF;
+ if (sizeof(_FF) <= sizeof(__buf_))
+ {
+ __f_ = (__base*)&__buf_;
+ ::new ((void*)__f_) _FF(__f);
+ }
+ else
+ {
+ typedef allocator<_FF> _Ap;
+ _Ap __a;
+ typedef __allocator_destructor<_Ap> _Dp;
+ unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+ ::new ((void*)__hold.get()) _FF(__f, allocator<_Fp>(__a));
+ __f_ = __hold.release();
+ }
+ }
+}
+
+template<class _Rp, class _A0, class _A1>
+template <class _Fp, class _Alloc>
+function<_Rp(_A0, _A1)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
+ typename enable_if<!is_integral<_Fp>::value>::type*)
+ : __f_(0)
+{
+ typedef allocator_traits<_Alloc> __alloc_traits;
+ if (__function::__not_null(__f))
+ {
+ typedef __function::__func<_Fp, _Alloc, _Rp(_A0, _A1)> _FF;
+ if (sizeof(_FF) <= sizeof(__buf_))
+ {
+ __f_ = (__base*)&__buf_;
+ ::new ((void*)__f_) _FF(__f, __a0);
+ }
+ else
+ {
+ typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
+ _Ap __a(__a0);
+ typedef __allocator_destructor<_Ap> _Dp;
+ unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+ ::new ((void*)__hold.get()) _FF(__f, _Alloc(__a));
+ __f_ = __hold.release();
+ }
+ }
+}
+
+template<class _Rp, class _A0, class _A1>
+function<_Rp(_A0, _A1)>&
+function<_Rp(_A0, _A1)>::operator=(const function& __f)
+{
+ if (__f)
+ function(__f).swap(*this);
+ else
+ *this = nullptr;
+ return *this;
+}
+
+template<class _Rp, class _A0, class _A1>
+function<_Rp(_A0, _A1)>&
+function<_Rp(_A0, _A1)>::operator=(nullptr_t)
+{
+ __base* __t = __f_;
+ __f_ = 0;
+ if (__t == (__base*)&__buf_)
+ __t->destroy();
+ else if (__t)
+ __t->destroy_deallocate();
+ return *this;
+}
+
+template<class _Rp, class _A0, class _A1>
+template <class _Fp>
+typename enable_if
+<
+ !is_integral<_Fp>::value,
+ function<_Rp(_A0, _A1)>&
+>::type
+function<_Rp(_A0, _A1)>::operator=(_Fp __f)
+{
+ function(_VSTD::move(__f)).swap(*this);
+ return *this;
+}
+
+template<class _Rp, class _A0, class _A1>
+function<_Rp(_A0, _A1)>::~function()
+{
+ if (__f_ == (__base*)&__buf_)
+ __f_->destroy();
+ else if (__f_)
+ __f_->destroy_deallocate();
+}
+
+template<class _Rp, class _A0, class _A1>
+void
+function<_Rp(_A0, _A1)>::swap(function& __f)
+{
+ if (_VSTD::addressof(__f) == this)
+ return;
+ if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
+ {
+ typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
+ __base* __t = (__base*)&__tempbuf;
+ __f_->__clone(__t);
+ __f_->destroy();
+ __f_ = 0;
+ __f.__f_->__clone((__base*)&__buf_);
+ __f.__f_->destroy();
+ __f.__f_ = 0;
+ __f_ = (__base*)&__buf_;
+ __t->__clone((__base*)&__f.__buf_);
+ __t->destroy();
+ __f.__f_ = (__base*)&__f.__buf_;
+ }
+ else if (__f_ == (__base*)&__buf_)
+ {
+ __f_->__clone((__base*)&__f.__buf_);
+ __f_->destroy();
+ __f_ = __f.__f_;
+ __f.__f_ = (__base*)&__f.__buf_;
+ }
+ else if (__f.__f_ == (__base*)&__f.__buf_)
+ {
+ __f.__f_->__clone((__base*)&__buf_);
+ __f.__f_->destroy();
+ __f.__f_ = __f_;
+ __f_ = (__base*)&__buf_;
+ }
+ else
+ _VSTD::swap(__f_, __f.__f_);
+}
+
+template<class _Rp, class _A0, class _A1>
+_Rp
+function<_Rp(_A0, _A1)>::operator()(_A0 __a0, _A1 __a1) const
+{
+ if (__f_ == 0)
+ __throw_bad_function_call();
+ return (*__f_)(__a0, __a1);
+}
+
+#ifndef _LIBCPP_NO_RTTI
+
+template<class _Rp, class _A0, class _A1>
+const std::type_info&
+function<_Rp(_A0, _A1)>::target_type() const
+{
+ if (__f_ == 0)
+ return typeid(void);
+ return __f_->target_type();
+}
+
+template<class _Rp, class _A0, class _A1>
+template <typename _Tp>
+_Tp*
+function<_Rp(_A0, _A1)>::target()
+{
+ if (__f_ == 0)
+ return (_Tp*)0;
+ return (_Tp*) const_cast<void *>(__f_->target(typeid(_Tp)));
+}
+
+template<class _Rp, class _A0, class _A1>
+template <typename _Tp>
+const _Tp*
+function<_Rp(_A0, _A1)>::target() const
+{
+ if (__f_ == 0)
+ return (const _Tp*)0;
+ return (const _Tp*)__f_->target(typeid(_Tp));
+}
+
+#endif // _LIBCPP_NO_RTTI
+
+template<class _Rp, class _A0, class _A1, class _A2>
+class _LIBCPP_TEMPLATE_VIS function<_Rp(_A0, _A1, _A2)>
+{
+ typedef __function::__base<_Rp(_A0, _A1, _A2)> __base;
+ aligned_storage<3*sizeof(void*)>::type __buf_;
+ __base* __f_;
+
+public:
+ typedef _Rp result_type;
+
+ // 20.7.16.2.1, construct/copy/destroy:
+ _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {}
+ _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {}
+ function(const function&);
+ template<class _Fp>
+ function(_Fp,
+ typename enable_if<!is_integral<_Fp>::value>::type* = 0);
+
+ template<class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY
+ function(allocator_arg_t, const _Alloc&) : __f_(0) {}
+ template<class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY
+ function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {}
+ template<class _Alloc>
+ function(allocator_arg_t, const _Alloc&, const function&);
+ template<class _Fp, class _Alloc>
+ function(allocator_arg_t, const _Alloc& __a, _Fp __f,
+ typename enable_if<!is_integral<_Fp>::value>::type* = 0);
+
+ function& operator=(const function&);
+ function& operator=(nullptr_t);
+ template<class _Fp>
+ typename enable_if
+ <
+ !is_integral<_Fp>::value,
+ function&
+ >::type
+ operator=(_Fp);
+
+ ~function();
+
+ // 20.7.16.2.2, function modifiers:
+ void swap(function&);
+ template<class _Fp, class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY
+ void assign(_Fp __f, const _Alloc& __a)
+ {function(allocator_arg, __a, __f).swap(*this);}
+
+ // 20.7.16.2.3, function capacity:
+ _LIBCPP_INLINE_VISIBILITY explicit operator bool() const {return __f_;}
+
+ template<class _R2, class _B0, class _B1, class _B2>
+ bool operator==(const function<_R2(_B0, _B1, _B2)>&) const = delete;
+ template<class _R2, class _B0, class _B1, class _B2>
+ bool operator!=(const function<_R2(_B0, _B1, _B2)>&) const = delete;
+
+ // 20.7.16.2.4, function invocation:
+ _Rp operator()(_A0, _A1, _A2) const;
+
+#ifndef _LIBCPP_NO_RTTI
+ // 20.7.16.2.5, function target access:
+ const std::type_info& target_type() const;
+ template <typename _Tp> _Tp* target();
+ template <typename _Tp> const _Tp* target() const;
+#endif // _LIBCPP_NO_RTTI
+};
+
+template<class _Rp, class _A0, class _A1, class _A2>
+function<_Rp(_A0, _A1, _A2)>::function(const function& __f)
+{
+ if (__f.__f_ == 0)
+ __f_ = 0;
+ else if (__f.__f_ == (const __base*)&__f.__buf_)
+ {
+ __f_ = (__base*)&__buf_;
+ __f.__f_->__clone(__f_);
+ }
+ else
+ __f_ = __f.__f_->__clone();
+}
+
+template<class _Rp, class _A0, class _A1, class _A2>
+template<class _Alloc>
+function<_Rp(_A0, _A1, _A2)>::function(allocator_arg_t, const _Alloc&,
+ const function& __f)
+{
+ if (__f.__f_ == 0)
+ __f_ = 0;
+ else if (__f.__f_ == (const __base*)&__f.__buf_)
+ {
+ __f_ = (__base*)&__buf_;
+ __f.__f_->__clone(__f_);
+ }
+ else
+ __f_ = __f.__f_->__clone();
+}
+
+template<class _Rp, class _A0, class _A1, class _A2>
+template <class _Fp>
+function<_Rp(_A0, _A1, _A2)>::function(_Fp __f,
+ typename enable_if<!is_integral<_Fp>::value>::type*)
+ : __f_(0)
+{
+ if (__function::__not_null(__f))
+ {
+ typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0, _A1, _A2)> _FF;
+ if (sizeof(_FF) <= sizeof(__buf_))
+ {
+ __f_ = (__base*)&__buf_;
+ ::new ((void*)__f_) _FF(__f);
+ }
+ else
+ {
+ typedef allocator<_FF> _Ap;
+ _Ap __a;
+ typedef __allocator_destructor<_Ap> _Dp;
+ unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+ ::new ((void*)__hold.get()) _FF(__f, allocator<_Fp>(__a));
+ __f_ = __hold.release();
+ }
+ }
+}
+
+template<class _Rp, class _A0, class _A1, class _A2>
+template <class _Fp, class _Alloc>
+function<_Rp(_A0, _A1, _A2)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
+ typename enable_if<!is_integral<_Fp>::value>::type*)
+ : __f_(0)
+{
+ typedef allocator_traits<_Alloc> __alloc_traits;
+ if (__function::__not_null(__f))
+ {
+ typedef __function::__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)> _FF;
+ if (sizeof(_FF) <= sizeof(__buf_))
+ {
+ __f_ = (__base*)&__buf_;
+ ::new ((void*)__f_) _FF(__f, __a0);
+ }
+ else
+ {
+ typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
+ _Ap __a(__a0);
+ typedef __allocator_destructor<_Ap> _Dp;
+ unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+ ::new ((void*)__hold.get()) _FF(__f, _Alloc(__a));
+ __f_ = __hold.release();
+ }
+ }
+}
+
+template<class _Rp, class _A0, class _A1, class _A2>
+function<_Rp(_A0, _A1, _A2)>&
+function<_Rp(_A0, _A1, _A2)>::operator=(const function& __f)
+{
+ if (__f)
+ function(__f).swap(*this);
+ else
+ *this = nullptr;
+ return *this;
+}
+
+template<class _Rp, class _A0, class _A1, class _A2>
+function<_Rp(_A0, _A1, _A2)>&
+function<_Rp(_A0, _A1, _A2)>::operator=(nullptr_t)
+{
+ __base* __t = __f_;
+ __f_ = 0;
+ if (__t == (__base*)&__buf_)
+ __t->destroy();
+ else if (__t)
+ __t->destroy_deallocate();
+ return *this;
+}
+
+template<class _Rp, class _A0, class _A1, class _A2>
+template <class _Fp>
+typename enable_if
+<
+ !is_integral<_Fp>::value,
+ function<_Rp(_A0, _A1, _A2)>&
+>::type
+function<_Rp(_A0, _A1, _A2)>::operator=(_Fp __f)
+{
+ function(_VSTD::move(__f)).swap(*this);
+ return *this;
+}
+
+template<class _Rp, class _A0, class _A1, class _A2>
+function<_Rp(_A0, _A1, _A2)>::~function()
+{
+ if (__f_ == (__base*)&__buf_)
+ __f_->destroy();
+ else if (__f_)
+ __f_->destroy_deallocate();
+}
+
+template<class _Rp, class _A0, class _A1, class _A2>
+void
+function<_Rp(_A0, _A1, _A2)>::swap(function& __f)
+{
+ if (_VSTD::addressof(__f) == this)
+ return;
+ if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
+ {
+ typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
+ __base* __t = (__base*)&__tempbuf;
+ __f_->__clone(__t);
+ __f_->destroy();
+ __f_ = 0;
+ __f.__f_->__clone((__base*)&__buf_);
+ __f.__f_->destroy();
+ __f.__f_ = 0;
+ __f_ = (__base*)&__buf_;
+ __t->__clone((__base*)&__f.__buf_);
+ __t->destroy();
+ __f.__f_ = (__base*)&__f.__buf_;
+ }
+ else if (__f_ == (__base*)&__buf_)
+ {
+ __f_->__clone((__base*)&__f.__buf_);
+ __f_->destroy();
+ __f_ = __f.__f_;
+ __f.__f_ = (__base*)&__f.__buf_;
+ }
+ else if (__f.__f_ == (__base*)&__f.__buf_)
+ {
+ __f.__f_->__clone((__base*)&__buf_);
+ __f.__f_->destroy();
+ __f.__f_ = __f_;
+ __f_ = (__base*)&__buf_;
+ }
+ else
+ _VSTD::swap(__f_, __f.__f_);
+}
+
+template<class _Rp, class _A0, class _A1, class _A2>
+_Rp
+function<_Rp(_A0, _A1, _A2)>::operator()(_A0 __a0, _A1 __a1, _A2 __a2) const
+{
+ if (__f_ == 0)
+ __throw_bad_function_call();
+ return (*__f_)(__a0, __a1, __a2);
+}
+
+#ifndef _LIBCPP_NO_RTTI
+
+template<class _Rp, class _A0, class _A1, class _A2>
+const std::type_info&
+function<_Rp(_A0, _A1, _A2)>::target_type() const
+{
+ if (__f_ == 0)
+ return typeid(void);
+ return __f_->target_type();
+}
+
+template<class _Rp, class _A0, class _A1, class _A2>
+template <typename _Tp>
+_Tp*
+function<_Rp(_A0, _A1, _A2)>::target()
+{
+ if (__f_ == 0)
+ return (_Tp*)0;
+ return (_Tp*) const_cast<void *>(__f_->target(typeid(_Tp)));
+}
+
+template<class _Rp, class _A0, class _A1, class _A2>
+template <typename _Tp>
+const _Tp*
+function<_Rp(_A0, _A1, _A2)>::target() const
+{
+ if (__f_ == 0)
+ return (const _Tp*)0;
+ return (const _Tp*)__f_->target(typeid(_Tp));
+}
+
+#endif // _LIBCPP_NO_RTTI
+
+template <class _Fp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const function<_Fp>& __f, nullptr_t) {return !__f;}
+
+template <class _Fp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(nullptr_t, const function<_Fp>& __f) {return !__f;}
+
+template <class _Fp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const function<_Fp>& __f, nullptr_t) {return (bool)__f;}
+
+template <class _Fp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(nullptr_t, const function<_Fp>& __f) {return (bool)__f;}
+
+template <class _Fp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(function<_Fp>& __x, function<_Fp>& __y)
+{return __x.swap(__y);}
+
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_FUNCTION_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/hash.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/hash.h
new file mode 100644
index 0000000000..89cb02a368
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/hash.h
@@ -0,0 +1,875 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <cstddef>
+#include <cstdint>
+#include <cstring>
+#include <limits>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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;
+};
+
+// Disable double inline warning.
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( push )
+#pragma warning ( disable : 4141 )
+#endif
+_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);
+}
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( pop )
+#endif
+
+_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
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+_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);}
+};
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+_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
+ }
+};
+
+_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>
+{
+};
+
+#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 = 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 = 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;
+
+template <class _Type, class ..._Keys>
+using __enable_hash_helper _LIBCPP_NODEBUG = __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;
+#endif
+
+#endif // !_LIBCPP_CXX03_LANG
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_HASH_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/identity.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/identity.h
new file mode 100644
index 0000000000..646325aca4
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/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/forward.h>
+
+#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/libs/cxxsupp/libcxxmsvc/include/__functional/invoke.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/invoke.h
new file mode 100644
index 0000000000..b4c3e76562
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/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/libs/cxxsupp/libcxxmsvc/include/__functional/is_transparent.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/is_transparent.h
new file mode 100644
index 0000000000..74326c76c1
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/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/libs/cxxsupp/libcxxmsvc/include/__functional/mem_fn.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/mem_fn.h
new file mode 100644
index 0000000000..10967a8a14
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/mem_fn.h
@@ -0,0 +1,162 @@
+// -*- 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/binary_function.h>
+#include <__functional/invoke.h>
+#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 _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/libs/cxxsupp/libcxxmsvc/include/__functional/mem_fun_ref.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/mem_fun_ref.h
new file mode 100644
index 0000000000..81f48e66e7
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/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/binary_function.h>
+#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 _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/libs/cxxsupp/libcxxmsvc/include/__functional/not_fn.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/not_fn.h
new file mode 100644
index 0000000000..b5c415c25c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/not_fn.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_NOT_FN_H
+#define _LIBCPP___FUNCTIONAL_NOT_FN_H
+
+#include <__config>
+#include <__functional/invoke.h>
+#include <__functional/perfect_forward.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
+
+#if _LIBCPP_STD_VER > 14
+
+struct __not_fn_op {
+ template <class... _Args>
+ _LIBCPP_HIDE_FROM_ABI
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 auto operator()(_Args&&... __args) const
+ 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>
+struct __not_fn_t : __perfect_forward<__not_fn_op, _Fn> {
+ using __perfect_forward<__not_fn_op, _Fn>::__perfect_forward;
+};
+
+template <class _Fn, class = enable_if_t<
+ is_constructible_v<decay_t<_Fn>, _Fn> &&
+ is_move_constructible_v<decay_t<_Fn>>
+>>
+_LIBCPP_HIDE_FROM_ABI
+_LIBCPP_CONSTEXPR_AFTER_CXX17 auto not_fn(_Fn&& __f) {
+ return __not_fn_t<decay_t<_Fn>>(_VSTD::forward<_Fn>(__f));
+}
+
+#endif // _LIBCPP_STD_VER > 14
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_NOT_FN_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/operations.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/operations.h
new file mode 100644
index 0000000000..9df6d773fe
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/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/libs/cxxsupp/libcxxmsvc/include/__functional/perfect_forward.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/perfect_forward.h
new file mode 100644
index 0000000000..9ffea1a8c7
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/perfect_forward.h
@@ -0,0 +1,94 @@
+// -*- 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 <__utility/declval.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include <tuple>
+#include <type_traits>
+
+#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 _Indices, class... _BoundArgs>
+struct __perfect_forward_impl;
+
+template <class _Op, size_t... _Idx, class... _BoundArgs>
+struct __perfect_forward_impl<_Op, index_sequence<_Idx...>, _BoundArgs...> {
+private:
+ tuple<_BoundArgs...> __bound_args_;
+
+public:
+ template <class... _Args, class = enable_if_t<
+ is_constructible_v<tuple<_BoundArgs...>, _Args&&...>
+ >>
+ explicit constexpr __perfect_forward_impl(_Args&&... __bound_args)
+ : __bound_args_(_VSTD::forward<_Args>(__bound_args)...) {}
+
+ __perfect_forward_impl(__perfect_forward_impl const&) = default;
+ __perfect_forward_impl(__perfect_forward_impl&&) = default;
+
+ __perfect_forward_impl& operator=(__perfect_forward_impl const&) = default;
+ __perfect_forward_impl& operator=(__perfect_forward_impl&&) = default;
+
+ template <class... _Args, class = enable_if_t<is_invocable_v<_Op, _BoundArgs&..., _Args...>>>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) &
+ noexcept(noexcept(_Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...)))
+ -> decltype( _Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...))
+ { return _Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...); }
+
+ template <class... _Args, class = enable_if_t<!is_invocable_v<_Op, _BoundArgs&..., _Args...>>>
+ auto operator()(_Args&&...) & = delete;
+
+ template <class... _Args, class = enable_if_t<is_invocable_v<_Op, _BoundArgs const&..., _Args...>>>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const&
+ noexcept(noexcept(_Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...)))
+ -> decltype( _Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...))
+ { return _Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...); }
+
+ template <class... _Args, class = enable_if_t<!is_invocable_v<_Op, _BoundArgs const&..., _Args...>>>
+ auto operator()(_Args&&...) const& = delete;
+
+ template <class... _Args, class = enable_if_t<is_invocable_v<_Op, _BoundArgs..., _Args...>>>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) &&
+ noexcept(noexcept(_Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...)))
+ -> decltype( _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...))
+ { return _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...); }
+
+ template <class... _Args, class = enable_if_t<!is_invocable_v<_Op, _BoundArgs..., _Args...>>>
+ auto operator()(_Args&&...) && = delete;
+
+ template <class... _Args, class = enable_if_t<is_invocable_v<_Op, _BoundArgs const..., _Args...>>>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const&&
+ noexcept(noexcept(_Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...)))
+ -> decltype( _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...))
+ { return _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...); }
+
+ template <class... _Args, class = enable_if_t<!is_invocable_v<_Op, _BoundArgs const..., _Args...>>>
+ auto operator()(_Args&&...) const&& = delete;
+};
+
+// __perfect_forward implements a perfect-forwarding call wrapper as explained in [func.require].
+template <class _Op, class ..._Args>
+using __perfect_forward = __perfect_forward_impl<_Op, index_sequence_for<_Args...>, _Args...>;
+
+#endif // _LIBCPP_STD_VER > 14
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_PERFECT_FORWARD_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/pointer_to_binary_function.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/pointer_to_binary_function.h
new file mode 100644
index 0000000000..187e3098c4
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/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/libs/cxxsupp/libcxxmsvc/include/__functional/pointer_to_unary_function.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/pointer_to_unary_function.h
new file mode 100644
index 0000000000..a0f98c1a55
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/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/libs/cxxsupp/libcxxmsvc/include/__functional/ranges_operations.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/ranges_operations.h
new file mode 100644
index 0000000000..e8cf51981a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/ranges_operations.h
@@ -0,0 +1,98 @@
+// -*- 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 <__utility/forward.h>
+#include <concepts>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_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_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/reference_wrapper.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/reference_wrapper.h
new file mode 100644
index 0000000000..b7d2f87302
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/reference_wrapper.h
@@ -0,0 +1,212 @@
+// -*- 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_;
+
+ static void __fun(_Tp&) _NOEXCEPT;
+ static void __fun(_Tp&&) = delete;
+
+public:
+ template <class _Up, class = __enable_if_t<!__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);
+ }
+
+ // 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
+};
+
+#if _LIBCPP_STD_VER > 14
+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 __t;
+}
+
+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 __t;
+}
+
+template <class _Tp> void ref(const _Tp&&) = delete;
+template <class _Tp> void cref(const _Tp&&) = delete;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/unary_function.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/unary_function.h
new file mode 100644
index 0000000000..af2a0b967c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/unary_function.h
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_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
+
+#endif // _LIBCPP___FUNCTIONAL_UNARY_FUNCTION_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/unary_negate.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/unary_negate.h
new file mode 100644
index 0000000000..7ff1f6e879
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/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/libs/cxxsupp/libcxxmsvc/include/__functional/unwrap_ref.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/unwrap_ref.h
new file mode 100644
index 0000000000..f7207934e1
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/unwrap_ref.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___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_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+struct __unwrap_reference { typedef _LIBCPP_NODEBUG _Tp type; };
+
+template <class _Tp>
+class reference_wrapper;
+
+template <class _Tp>
+struct __unwrap_reference<reference_wrapper<_Tp> > { typedef _LIBCPP_NODEBUG _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
+
+#endif // _LIBCPP___FUNCTIONAL_UNWRAP_REF_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/weak_result_type.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/weak_result_type.h
new file mode 100644
index 0000000000..1ab9008e7f
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__functional/weak_result_type.h
@@ -0,0 +1,482 @@
+// -*- 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(...);
+ // Fix for MSVC which allows to reference private types. Wrap into declval to prevent that.
+ template <class _Up> static char __test(decltype(std::declval<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 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 _Rp result_type;
+};
+
+template <class _Rp>
+struct __weak_result_type<_Rp (&)()>
+{
+ typedef _LIBCPP_NODEBUG _Rp result_type;
+};
+
+template <class _Rp>
+struct __weak_result_type<_Rp (*)()>
+{
+ typedef _LIBCPP_NODEBUG _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/libs/cxxsupp/libcxxmsvc/include/__hash_table b/contrib/libs/cxxsupp/libcxxmsvc/include/__hash_table
new file mode 100644
index 0000000000..e802dd2137
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__hash_table
@@ -0,0 +1,2809 @@
+// -*- 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__HASH_TABLE
+#define _LIBCPP__HASH_TABLE
+
+#include <__algorithm/max.h>
+#include <__algorithm/min.h>
+#include <__assert>
+#include <__bits> // __libcpp_clz
+#include <__config>
+#include <__debug>
+#include <__functional/hash.h>
+#include <cmath>
+#include <initializer_list>
+#include <iterator>
+#include <memory>
+#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 _Key, class _Tp>
+struct __hash_value_type;
+
+template <class _Tp>
+struct __is_hash_value_type_imp : false_type {};
+
+template <class _Key, class _Value>
+struct __is_hash_value_type_imp<__hash_value_type<_Key, _Value> > : true_type {};
+
+template <class ..._Args>
+struct __is_hash_value_type : false_type {};
+
+template <class _One>
+struct __is_hash_value_type<_One> : __is_hash_value_type_imp<__uncvref_t<_One> > {};
+
+_LIBCPP_FUNC_VIS
+size_t __next_prime(size_t __n);
+
+template <class _NodePtr>
+struct __hash_node_base
+{
+ typedef typename pointer_traits<_NodePtr>::element_type __node_type;
+ typedef __hash_node_base __first_node;
+ typedef typename __rebind_pointer<_NodePtr, __first_node>::type __node_base_pointer;
+ typedef _NodePtr __node_pointer;
+
+#if defined(_LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB)
+ typedef __node_base_pointer __next_pointer;
+#else
+ typedef typename conditional<
+ is_pointer<__node_pointer>::value,
+ __node_base_pointer,
+ __node_pointer>::type __next_pointer;
+#endif
+
+ __next_pointer __next_;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __next_pointer __ptr() _NOEXCEPT {
+ return static_cast<__next_pointer>(
+ pointer_traits<__node_base_pointer>::pointer_to(*this));
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __node_pointer __upcast() _NOEXCEPT {
+ return static_cast<__node_pointer>(
+ pointer_traits<__node_base_pointer>::pointer_to(*this));
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_t __hash() const _NOEXCEPT {
+ return static_cast<__node_type const&>(*this).__hash_;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY __hash_node_base() _NOEXCEPT : __next_(nullptr) {}
+};
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning( push )
+#pragma warning( disable: 4624 )
+#endif // _LIBCPP_COMPILER_MSVC
+template <class _Tp, class _VoidPtr>
+struct _LIBCPP_STANDALONE_DEBUG __hash_node
+ : public __hash_node_base
+ <
+ typename __rebind_pointer<_VoidPtr, __hash_node<_Tp, _VoidPtr> >::type
+ >
+{
+ typedef _Tp __node_value_type;
+
+ size_t __hash_;
+ __node_value_type __value_;
+};
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning( pop )
+#endif // _LIBCPP_COMPILER_MSVC
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__is_hash_power2(size_t __bc)
+{
+ return __bc > 2 && !(__bc & (__bc - 1));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+size_t
+__constrain_hash(size_t __h, size_t __bc)
+{
+ return !(__bc & (__bc - 1)) ? __h & (__bc - 1) :
+ (__h < __bc ? __h : __h % __bc);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+size_t
+__next_hash_pow2(size_t __n)
+{
+ return __n < 2 ? __n : (size_t(1) << (numeric_limits<size_t>::digits - __libcpp_clz(__n-1)));
+}
+
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc> class __hash_table;
+
+template <class _NodePtr> class _LIBCPP_TEMPLATE_VIS __hash_iterator;
+template <class _ConstNodePtr> class _LIBCPP_TEMPLATE_VIS __hash_const_iterator;
+template <class _NodePtr> class _LIBCPP_TEMPLATE_VIS __hash_local_iterator;
+template <class _ConstNodePtr> class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;
+template <class _HashIterator> class _LIBCPP_TEMPLATE_VIS __hash_map_iterator;
+template <class _HashIterator> class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator;
+
+template <class _Tp>
+struct __hash_key_value_types {
+ static_assert(!is_reference<_Tp>::value && !is_const<_Tp>::value, "");
+ typedef _Tp key_type;
+ typedef _Tp __node_value_type;
+ typedef _Tp __container_value_type;
+ static const bool __is_map = false;
+
+ _LIBCPP_INLINE_VISIBILITY
+ static key_type const& __get_key(_Tp const& __v) {
+ return __v;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ static __container_value_type const& __get_value(__node_value_type const& __v) {
+ return __v;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ static __container_value_type* __get_ptr(__node_value_type& __n) {
+ return _VSTD::addressof(__n);
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ static __container_value_type&& __move(__node_value_type& __v) {
+ return _VSTD::move(__v);
+ }
+};
+
+template <class _Key, class _Tp>
+struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > {
+ typedef _Key key_type;
+ typedef _Tp mapped_type;
+ typedef __hash_value_type<_Key, _Tp> __node_value_type;
+ typedef pair<const _Key, _Tp> __container_value_type;
+ typedef __container_value_type __map_value_type;
+ static const bool __is_map = true;
+
+ _LIBCPP_INLINE_VISIBILITY
+ static key_type const& __get_key(__container_value_type const& __v) {
+ return __v.first;
+ }
+
+ template <class _Up>
+ _LIBCPP_INLINE_VISIBILITY
+ static typename enable_if<__is_same_uncvref<_Up, __node_value_type>::value,
+ __container_value_type const&>::type
+ __get_value(_Up& __t) {
+ return __t.__get_value();
+ }
+
+ template <class _Up>
+ _LIBCPP_INLINE_VISIBILITY
+ static typename enable_if<__is_same_uncvref<_Up, __container_value_type>::value,
+ __container_value_type const&>::type
+ __get_value(_Up& __t) {
+ return __t;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ static __container_value_type* __get_ptr(__node_value_type& __n) {
+ return _VSTD::addressof(__n.__get_value());
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ static pair<key_type&&, mapped_type&&> __move(__node_value_type& __v) {
+ return __v.__move();
+ }
+};
+
+template <class _Tp, class _AllocPtr, class _KVTypes = __hash_key_value_types<_Tp>,
+ bool = _KVTypes::__is_map>
+struct __hash_map_pointer_types {};
+
+template <class _Tp, class _AllocPtr, class _KVTypes>
+struct __hash_map_pointer_types<_Tp, _AllocPtr, _KVTypes, true> {
+ typedef typename _KVTypes::__map_value_type _Mv;
+ typedef typename __rebind_pointer<_AllocPtr, _Mv>::type
+ __map_value_type_pointer;
+ typedef typename __rebind_pointer<_AllocPtr, const _Mv>::type
+ __const_map_value_type_pointer;
+};
+
+template <class _NodePtr, class _NodeT = typename pointer_traits<_NodePtr>::element_type>
+struct __hash_node_types;
+
+template <class _NodePtr, class _Tp, class _VoidPtr>
+struct __hash_node_types<_NodePtr, __hash_node<_Tp, _VoidPtr> >
+ : public __hash_key_value_types<_Tp>, __hash_map_pointer_types<_Tp, _VoidPtr>
+
+{
+ typedef __hash_key_value_types<_Tp> __base;
+
+public:
+ typedef ptrdiff_t difference_type;
+ typedef size_t size_type;
+
+ typedef typename __rebind_pointer<_NodePtr, void>::type __void_pointer;
+
+ typedef typename pointer_traits<_NodePtr>::element_type __node_type;
+ typedef _NodePtr __node_pointer;
+
+ typedef __hash_node_base<__node_pointer> __node_base_type;
+ typedef typename __rebind_pointer<_NodePtr, __node_base_type>::type
+ __node_base_pointer;
+
+ typedef typename __node_base_type::__next_pointer __next_pointer;
+
+ typedef _Tp __node_value_type;
+ typedef typename __rebind_pointer<_VoidPtr, __node_value_type>::type
+ __node_value_type_pointer;
+ typedef typename __rebind_pointer<_VoidPtr, const __node_value_type>::type
+ __const_node_value_type_pointer;
+
+private:
+ static_assert(!is_const<__node_type>::value,
+ "_NodePtr should never be a pointer to const");
+ static_assert((is_same<typename pointer_traits<_VoidPtr>::element_type, void>::value),
+ "_VoidPtr does not point to unqualified void type");
+ static_assert((is_same<typename __rebind_pointer<_VoidPtr, __node_type>::type,
+ _NodePtr>::value), "_VoidPtr does not rebind to _NodePtr.");
+};
+
+template <class _HashIterator>
+struct __hash_node_types_from_iterator;
+template <class _NodePtr>
+struct __hash_node_types_from_iterator<__hash_iterator<_NodePtr> > : __hash_node_types<_NodePtr> {};
+template <class _NodePtr>
+struct __hash_node_types_from_iterator<__hash_const_iterator<_NodePtr> > : __hash_node_types<_NodePtr> {};
+template <class _NodePtr>
+struct __hash_node_types_from_iterator<__hash_local_iterator<_NodePtr> > : __hash_node_types<_NodePtr> {};
+template <class _NodePtr>
+struct __hash_node_types_from_iterator<__hash_const_local_iterator<_NodePtr> > : __hash_node_types<_NodePtr> {};
+
+
+template <class _NodeValueTp, class _VoidPtr>
+struct __make_hash_node_types {
+ typedef __hash_node<_NodeValueTp, _VoidPtr> _NodeTp;
+ typedef typename __rebind_pointer<_VoidPtr, _NodeTp>::type _NodePtr;
+ typedef __hash_node_types<_NodePtr> type;
+};
+
+template <class _NodePtr>
+class _LIBCPP_TEMPLATE_VIS __hash_iterator
+{
+ typedef __hash_node_types<_NodePtr> _NodeTypes;
+ typedef _NodePtr __node_pointer;
+ typedef typename _NodeTypes::__next_pointer __next_pointer;
+
+ __next_pointer __node_;
+
+public:
+ typedef forward_iterator_tag iterator_category;
+ typedef typename _NodeTypes::__node_value_type value_type;
+ typedef typename _NodeTypes::difference_type difference_type;
+ typedef value_type& reference;
+ typedef typename _NodeTypes::__node_value_type_pointer pointer;
+
+ _LIBCPP_INLINE_VISIBILITY __hash_iterator() _NOEXCEPT : __node_(nullptr) {
+ _VSTD::__debug_db_insert_i(this);
+ }
+
+#if _LIBCPP_DEBUG_LEVEL == 2
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_iterator(const __hash_iterator& __i)
+ : __node_(__i.__node_)
+ {
+ __get_db()->__iterator_copy(this, _VSTD::addressof(__i));
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ ~__hash_iterator()
+ {
+ __get_db()->__erase_i(this);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_iterator& operator=(const __hash_iterator& __i)
+ {
+ if (this != _VSTD::addressof(__i))
+ {
+ __get_db()->__iterator_copy(this, _VSTD::addressof(__i));
+ __node_ = __i.__node_;
+ }
+ return *this;
+ }
+#endif // _LIBCPP_DEBUG_LEVEL == 2
+
+ _LIBCPP_INLINE_VISIBILITY
+ reference operator*() const {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
+ "Attempted to dereference a non-dereferenceable unordered container iterator");
+ return __node_->__upcast()->__value_;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ pointer operator->() const {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
+ "Attempted to dereference a non-dereferenceable unordered container iterator");
+ return pointer_traits<pointer>::pointer_to(__node_->__upcast()->__value_);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_iterator& operator++() {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
+ "Attempted to increment a non-incrementable unordered container iterator");
+ __node_ = __node_->__next_;
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_iterator operator++(int)
+ {
+ __hash_iterator __t(*this);
+ ++(*this);
+ return __t;
+ }
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const __hash_iterator& __x, const __hash_iterator& __y)
+ {
+ return __x.__node_ == __y.__node_;
+ }
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const __hash_iterator& __x, const __hash_iterator& __y)
+ {return !(__x == __y);}
+
+private:
+#if _LIBCPP_DEBUG_LEVEL == 2
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_iterator(__next_pointer __node, const void* __c) _NOEXCEPT
+ : __node_(__node)
+ {
+ __get_db()->__insert_ic(this, __c);
+ }
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_iterator(__next_pointer __node) _NOEXCEPT
+ : __node_(__node)
+ {}
+#endif
+ template <class, class, class, class> friend class __hash_table;
+ template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator;
+ template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_iterator;
+ template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_map;
+ template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;
+};
+
+template <class _NodePtr>
+class _LIBCPP_TEMPLATE_VIS __hash_const_iterator
+{
+ static_assert(!is_const<typename pointer_traits<_NodePtr>::element_type>::value, "");
+ typedef __hash_node_types<_NodePtr> _NodeTypes;
+ typedef _NodePtr __node_pointer;
+ typedef typename _NodeTypes::__next_pointer __next_pointer;
+
+ __next_pointer __node_;
+
+public:
+ typedef __hash_iterator<_NodePtr> __non_const_iterator;
+
+ typedef forward_iterator_tag iterator_category;
+ typedef typename _NodeTypes::__node_value_type value_type;
+ typedef typename _NodeTypes::difference_type difference_type;
+ typedef const value_type& reference;
+ typedef typename _NodeTypes::__const_node_value_type_pointer pointer;
+
+
+ _LIBCPP_INLINE_VISIBILITY __hash_const_iterator() _NOEXCEPT : __node_(nullptr) {
+ _VSTD::__debug_db_insert_i(this);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_const_iterator(const __non_const_iterator& __x) _NOEXCEPT
+ : __node_(__x.__node_)
+ {
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __get_db()->__iterator_copy(this, _VSTD::addressof(__x));
+#endif
+ }
+
+#if _LIBCPP_DEBUG_LEVEL == 2
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_const_iterator(const __hash_const_iterator& __i)
+ : __node_(__i.__node_)
+ {
+ __get_db()->__iterator_copy(this, _VSTD::addressof(__i));
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ ~__hash_const_iterator()
+ {
+ __get_db()->__erase_i(this);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_const_iterator& operator=(const __hash_const_iterator& __i)
+ {
+ if (this != _VSTD::addressof(__i))
+ {
+ __get_db()->__iterator_copy(this, _VSTD::addressof(__i));
+ __node_ = __i.__node_;
+ }
+ return *this;
+ }
+#endif // _LIBCPP_DEBUG_LEVEL == 2
+
+ _LIBCPP_INLINE_VISIBILITY
+ reference operator*() const {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
+ "Attempted to dereference a non-dereferenceable unordered container const_iterator");
+ return __node_->__upcast()->__value_;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ pointer operator->() const {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
+ "Attempted to dereference a non-dereferenceable unordered container const_iterator");
+ return pointer_traits<pointer>::pointer_to(__node_->__upcast()->__value_);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_const_iterator& operator++() {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
+ "Attempted to increment a non-incrementable unordered container const_iterator");
+ __node_ = __node_->__next_;
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_const_iterator operator++(int)
+ {
+ __hash_const_iterator __t(*this);
+ ++(*this);
+ return __t;
+ }
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const __hash_const_iterator& __x, const __hash_const_iterator& __y)
+ {
+ return __x.__node_ == __y.__node_;
+ }
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const __hash_const_iterator& __x, const __hash_const_iterator& __y)
+ {return !(__x == __y);}
+
+private:
+#if _LIBCPP_DEBUG_LEVEL == 2
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_const_iterator(__next_pointer __node, const void* __c) _NOEXCEPT
+ : __node_(__node)
+ {
+ __get_db()->__insert_ic(this, __c);
+ }
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_const_iterator(__next_pointer __node) _NOEXCEPT
+ : __node_(__node)
+ {}
+#endif
+ template <class, class, class, class> friend class __hash_table;
+ template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator;
+ template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_map;
+ template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;
+};
+
+template <class _NodePtr>
+class _LIBCPP_TEMPLATE_VIS __hash_local_iterator
+{
+ typedef __hash_node_types<_NodePtr> _NodeTypes;
+ typedef _NodePtr __node_pointer;
+ typedef typename _NodeTypes::__next_pointer __next_pointer;
+
+ __next_pointer __node_;
+ size_t __bucket_;
+ size_t __bucket_count_;
+
+public:
+ typedef forward_iterator_tag iterator_category;
+ typedef typename _NodeTypes::__node_value_type value_type;
+ typedef typename _NodeTypes::difference_type difference_type;
+ typedef value_type& reference;
+ typedef typename _NodeTypes::__node_value_type_pointer pointer;
+
+ _LIBCPP_INLINE_VISIBILITY __hash_local_iterator() _NOEXCEPT : __node_(nullptr) {
+ _VSTD::__debug_db_insert_i(this);
+ }
+
+#if _LIBCPP_DEBUG_LEVEL == 2
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_local_iterator(const __hash_local_iterator& __i)
+ : __node_(__i.__node_),
+ __bucket_(__i.__bucket_),
+ __bucket_count_(__i.__bucket_count_)
+ {
+ __get_db()->__iterator_copy(this, _VSTD::addressof(__i));
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ ~__hash_local_iterator()
+ {
+ __get_db()->__erase_i(this);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_local_iterator& operator=(const __hash_local_iterator& __i)
+ {
+ if (this != _VSTD::addressof(__i))
+ {
+ __get_db()->__iterator_copy(this, _VSTD::addressof(__i));
+ __node_ = __i.__node_;
+ __bucket_ = __i.__bucket_;
+ __bucket_count_ = __i.__bucket_count_;
+ }
+ return *this;
+ }
+#endif // _LIBCPP_DEBUG_LEVEL == 2
+
+ _LIBCPP_INLINE_VISIBILITY
+ reference operator*() const {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
+ "Attempted to dereference a non-dereferenceable unordered container local_iterator");
+ return __node_->__upcast()->__value_;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ pointer operator->() const {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
+ "Attempted to dereference a non-dereferenceable unordered container local_iterator");
+ return pointer_traits<pointer>::pointer_to(__node_->__upcast()->__value_);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_local_iterator& operator++() {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
+ "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;
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_local_iterator operator++(int)
+ {
+ __hash_local_iterator __t(*this);
+ ++(*this);
+ return __t;
+ }
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const __hash_local_iterator& __x, const __hash_local_iterator& __y)
+ {
+ return __x.__node_ == __y.__node_;
+ }
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const __hash_local_iterator& __x, const __hash_local_iterator& __y)
+ {return !(__x == __y);}
+
+private:
+#if _LIBCPP_DEBUG_LEVEL == 2
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_local_iterator(__next_pointer __node, size_t __bucket,
+ size_t __bucket_count, const void* __c) _NOEXCEPT
+ : __node_(__node),
+ __bucket_(__bucket),
+ __bucket_count_(__bucket_count)
+ {
+ __get_db()->__insert_ic(this, __c);
+ if (__node_ != nullptr)
+ __node_ = __node_->__next_;
+ }
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_local_iterator(__next_pointer __node, size_t __bucket,
+ size_t __bucket_count) _NOEXCEPT
+ : __node_(__node),
+ __bucket_(__bucket),
+ __bucket_count_(__bucket_count)
+ {
+ if (__node_ != nullptr)
+ __node_ = __node_->__next_;
+ }
+#endif
+ template <class, class, class, class> friend class __hash_table;
+ template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;
+ template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_iterator;
+};
+
+template <class _ConstNodePtr>
+class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator
+{
+ typedef __hash_node_types<_ConstNodePtr> _NodeTypes;
+ typedef _ConstNodePtr __node_pointer;
+ typedef typename _NodeTypes::__next_pointer __next_pointer;
+
+ __next_pointer __node_;
+ size_t __bucket_;
+ size_t __bucket_count_;
+
+ typedef pointer_traits<__node_pointer> __pointer_traits;
+ typedef typename __pointer_traits::element_type __node;
+ typedef typename remove_const<__node>::type __non_const_node;
+ typedef typename __rebind_pointer<__node_pointer, __non_const_node>::type
+ __non_const_node_pointer;
+public:
+ typedef __hash_local_iterator<__non_const_node_pointer>
+ __non_const_iterator;
+
+ typedef forward_iterator_tag iterator_category;
+ typedef typename _NodeTypes::__node_value_type value_type;
+ typedef typename _NodeTypes::difference_type difference_type;
+ typedef const value_type& reference;
+ typedef typename _NodeTypes::__const_node_value_type_pointer pointer;
+
+
+ _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator() _NOEXCEPT : __node_(nullptr) {
+ _VSTD::__debug_db_insert_i(this);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_const_local_iterator(const __non_const_iterator& __x) _NOEXCEPT
+ : __node_(__x.__node_),
+ __bucket_(__x.__bucket_),
+ __bucket_count_(__x.__bucket_count_)
+ {
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __get_db()->__iterator_copy(this, _VSTD::addressof(__x));
+#endif
+ }
+
+#if _LIBCPP_DEBUG_LEVEL == 2
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_const_local_iterator(const __hash_const_local_iterator& __i)
+ : __node_(__i.__node_),
+ __bucket_(__i.__bucket_),
+ __bucket_count_(__i.__bucket_count_)
+ {
+ __get_db()->__iterator_copy(this, _VSTD::addressof(__i));
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ ~__hash_const_local_iterator()
+ {
+ __get_db()->__erase_i(this);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_const_local_iterator& operator=(const __hash_const_local_iterator& __i)
+ {
+ if (this != _VSTD::addressof(__i))
+ {
+ __get_db()->__iterator_copy(this, _VSTD::addressof(__i));
+ __node_ = __i.__node_;
+ __bucket_ = __i.__bucket_;
+ __bucket_count_ = __i.__bucket_count_;
+ }
+ return *this;
+ }
+#endif // _LIBCPP_DEBUG_LEVEL == 2
+
+ _LIBCPP_INLINE_VISIBILITY
+ reference operator*() const {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
+ "Attempted to dereference a non-dereferenceable unordered container const_local_iterator");
+ return __node_->__upcast()->__value_;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ pointer operator->() const {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
+ "Attempted to dereference a non-dereferenceable unordered container const_local_iterator");
+ return pointer_traits<pointer>::pointer_to(__node_->__upcast()->__value_);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_const_local_iterator& operator++() {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
+ "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;
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_const_local_iterator operator++(int)
+ {
+ __hash_const_local_iterator __t(*this);
+ ++(*this);
+ return __t;
+ }
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const __hash_const_local_iterator& __x, const __hash_const_local_iterator& __y)
+ {
+ return __x.__node_ == __y.__node_;
+ }
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const __hash_const_local_iterator& __x, const __hash_const_local_iterator& __y)
+ {return !(__x == __y);}
+
+private:
+#if _LIBCPP_DEBUG_LEVEL == 2
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_const_local_iterator(__next_pointer __node_ptr, size_t __bucket,
+ size_t __bucket_count, const void* __c) _NOEXCEPT
+ : __node_(__node_ptr),
+ __bucket_(__bucket),
+ __bucket_count_(__bucket_count)
+ {
+ __get_db()->__insert_ic(this, __c);
+ if (__node_ != nullptr)
+ __node_ = __node_->__next_;
+ }
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_const_local_iterator(__next_pointer __node_ptr, size_t __bucket,
+ size_t __bucket_count) _NOEXCEPT
+ : __node_(__node_ptr),
+ __bucket_(__bucket),
+ __bucket_count_(__bucket_count)
+ {
+ if (__node_ != nullptr)
+ __node_ = __node_->__next_;
+ }
+#endif
+ template <class, class, class, class> friend class __hash_table;
+ template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator;
+};
+
+template <class _Alloc>
+class __bucket_list_deallocator
+{
+ typedef _Alloc allocator_type;
+ typedef allocator_traits<allocator_type> __alloc_traits;
+ typedef typename __alloc_traits::size_type size_type;
+
+ __compressed_pair<size_type, allocator_type> __data_;
+public:
+ typedef typename __alloc_traits::pointer pointer;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __bucket_list_deallocator()
+ _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
+ : __data_(0, __default_init_tag()) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __bucket_list_deallocator(const allocator_type& __a, size_type __size)
+ _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
+ : __data_(__size, __a) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __bucket_list_deallocator(__bucket_list_deallocator&& __x)
+ _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
+ : __data_(_VSTD::move(__x.__data_))
+ {
+ __x.size() = 0;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type& size() _NOEXCEPT {return __data_.first();}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type size() const _NOEXCEPT {return __data_.first();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ allocator_type& __alloc() _NOEXCEPT {return __data_.second();}
+ _LIBCPP_INLINE_VISIBILITY
+ const allocator_type& __alloc() const _NOEXCEPT {return __data_.second();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void operator()(pointer __p) _NOEXCEPT
+ {
+ __alloc_traits::deallocate(__alloc(), __p, size());
+ }
+};
+
+template <class _Alloc> class __hash_map_node_destructor;
+
+template <class _Alloc>
+class __hash_node_destructor
+{
+ typedef _Alloc allocator_type;
+ typedef allocator_traits<allocator_type> __alloc_traits;
+
+public:
+ typedef typename __alloc_traits::pointer pointer;
+private:
+ typedef __hash_node_types<pointer> _NodeTypes;
+
+ allocator_type& __na_;
+
+public:
+ bool __value_constructed;
+
+ __hash_node_destructor(__hash_node_destructor const&) = default;
+ __hash_node_destructor& operator=(const __hash_node_destructor&) = delete;
+
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __hash_node_destructor(allocator_type& __na,
+ bool __constructed = false) _NOEXCEPT
+ : __na_(__na),
+ __value_constructed(__constructed)
+ {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void operator()(pointer __p) _NOEXCEPT
+ {
+ if (__value_constructed)
+ __alloc_traits::destroy(__na_, _NodeTypes::__get_ptr(__p->__value_));
+ if (__p)
+ __alloc_traits::deallocate(__na_, __p, 1);
+ }
+
+ template <class> friend class __hash_map_node_destructor;
+};
+
+#if _LIBCPP_STD_VER > 14
+template <class _NodeType, class _Alloc>
+struct __generic_container_node_destructor;
+
+template <class _Tp, class _VoidPtr, class _Alloc>
+struct __generic_container_node_destructor<__hash_node<_Tp, _VoidPtr>, _Alloc>
+ : __hash_node_destructor<_Alloc>
+{
+ using __hash_node_destructor<_Alloc>::__hash_node_destructor;
+};
+#endif
+
+template <class _Key, class _Hash, class _Equal>
+struct __enforce_unordered_container_requirements {
+#ifndef _LIBCPP_CXX03_LANG
+ static_assert(__check_hash_requirements<_Key, _Hash>::value,
+ "the specified hash does not meet the Hash requirements");
+ static_assert(is_copy_constructible<_Equal>::value,
+ "the specified comparator is required to be copy constructible");
+#endif
+ typedef int type;
+};
+
+template <class _Key, class _Hash, class _Equal>
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_DIAGNOSE_WARNING(!__invokable<_Equal const&, _Key const&, _Key const&>::value,
+ "the specified comparator type does not provide a viable const call operator")
+ _LIBCPP_DIAGNOSE_WARNING(!__invokable<_Hash const&, _Key const&>::value,
+ "the specified hash functor does not provide a viable const call operator")
+#endif
+typename __enforce_unordered_container_requirements<_Key, _Hash, _Equal>::type
+__diagnose_unordered_container_requirements(int);
+
+// This dummy overload is used so that the compiler won't emit a spurious
+// "no matching function for call to __diagnose_unordered_xxx" diagnostic
+// when the overload above causes a hard error.
+template <class _Key, class _Hash, class _Equal>
+int __diagnose_unordered_container_requirements(void*);
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+class __hash_table
+{
+public:
+ typedef _Tp value_type;
+ typedef _Hash hasher;
+ typedef _Equal key_equal;
+ typedef _Alloc allocator_type;
+
+private:
+ typedef allocator_traits<allocator_type> __alloc_traits;
+ typedef typename
+ __make_hash_node_types<value_type, typename __alloc_traits::void_pointer>::type
+ _NodeTypes;
+public:
+
+ typedef typename _NodeTypes::__node_value_type __node_value_type;
+ typedef typename _NodeTypes::__container_value_type __container_value_type;
+ typedef typename _NodeTypes::key_type key_type;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef typename __alloc_traits::pointer pointer;
+ typedef typename __alloc_traits::const_pointer const_pointer;
+#ifndef _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
+ typedef typename __alloc_traits::size_type size_type;
+#else
+ typedef typename _NodeTypes::size_type size_type;
+#endif
+ typedef typename _NodeTypes::difference_type difference_type;
+public:
+ // Create __node
+
+ typedef typename _NodeTypes::__node_type __node;
+ typedef typename __rebind_alloc_helper<__alloc_traits, __node>::type __node_allocator;
+ typedef allocator_traits<__node_allocator> __node_traits;
+ typedef typename _NodeTypes::__void_pointer __void_pointer;
+ typedef typename _NodeTypes::__node_pointer __node_pointer;
+ typedef typename _NodeTypes::__node_pointer __node_const_pointer;
+ typedef typename _NodeTypes::__node_base_type __first_node;
+ typedef typename _NodeTypes::__node_base_pointer __node_base_pointer;
+ typedef typename _NodeTypes::__next_pointer __next_pointer;
+
+private:
+ // check for sane allocator pointer rebinding semantics. Rebinding the
+ // allocator for a new pointer type should be exactly the same as rebinding
+ // the pointer using 'pointer_traits'.
+ static_assert((is_same<__node_pointer, typename __node_traits::pointer>::value),
+ "Allocator does not rebind pointers in a sane manner.");
+ typedef typename __rebind_alloc_helper<__node_traits, __first_node>::type
+ __node_base_allocator;
+ typedef allocator_traits<__node_base_allocator> __node_base_traits;
+ static_assert((is_same<__node_base_pointer, typename __node_base_traits::pointer>::value),
+ "Allocator does not rebind pointers in a sane manner.");
+
+private:
+
+ typedef typename __rebind_alloc_helper<__node_traits, __next_pointer>::type __pointer_allocator;
+ typedef __bucket_list_deallocator<__pointer_allocator> __bucket_list_deleter;
+ typedef unique_ptr<__next_pointer[], __bucket_list_deleter> __bucket_list;
+ typedef allocator_traits<__pointer_allocator> __pointer_alloc_traits;
+ typedef typename __bucket_list_deleter::pointer __node_pointer_pointer;
+
+ // --- Member data begin ---
+ __bucket_list __bucket_list_;
+ __compressed_pair<__first_node, __node_allocator> __p1_;
+ __compressed_pair<size_type, hasher> __p2_;
+ __compressed_pair<float, key_equal> __p3_;
+ // --- Member data end ---
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type& size() _NOEXCEPT {return __p2_.first();}
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ size_type size() const _NOEXCEPT {return __p2_.first();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ hasher& hash_function() _NOEXCEPT {return __p2_.second();}
+ _LIBCPP_INLINE_VISIBILITY
+ const hasher& hash_function() const _NOEXCEPT {return __p2_.second();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ float& max_load_factor() _NOEXCEPT {return __p3_.first();}
+ _LIBCPP_INLINE_VISIBILITY
+ float max_load_factor() const _NOEXCEPT {return __p3_.first();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ key_equal& key_eq() _NOEXCEPT {return __p3_.second();}
+ _LIBCPP_INLINE_VISIBILITY
+ const key_equal& key_eq() const _NOEXCEPT {return __p3_.second();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __node_allocator& __node_alloc() _NOEXCEPT {return __p1_.second();}
+ _LIBCPP_INLINE_VISIBILITY
+ const __node_allocator& __node_alloc() const _NOEXCEPT
+ {return __p1_.second();}
+
+public:
+ typedef __hash_iterator<__node_pointer> iterator;
+ typedef __hash_const_iterator<__node_pointer> const_iterator;
+ typedef __hash_local_iterator<__node_pointer> local_iterator;
+ typedef __hash_const_local_iterator<__node_pointer> const_local_iterator;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_table()
+ _NOEXCEPT_(
+ is_nothrow_default_constructible<__bucket_list>::value &&
+ is_nothrow_default_constructible<__first_node>::value &&
+ is_nothrow_default_constructible<__node_allocator>::value &&
+ is_nothrow_default_constructible<hasher>::value &&
+ is_nothrow_default_constructible<key_equal>::value);
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_table(const hasher& __hf, const key_equal& __eql);
+ __hash_table(const hasher& __hf, const key_equal& __eql,
+ const allocator_type& __a);
+ explicit __hash_table(const allocator_type& __a);
+ __hash_table(const __hash_table& __u);
+ __hash_table(const __hash_table& __u, const allocator_type& __a);
+ __hash_table(__hash_table&& __u)
+ _NOEXCEPT_(
+ is_nothrow_move_constructible<__bucket_list>::value &&
+ is_nothrow_move_constructible<__first_node>::value &&
+ is_nothrow_move_constructible<__node_allocator>::value &&
+ is_nothrow_move_constructible<hasher>::value &&
+ is_nothrow_move_constructible<key_equal>::value);
+ __hash_table(__hash_table&& __u, const allocator_type& __a);
+ ~__hash_table();
+
+ __hash_table& operator=(const __hash_table& __u);
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_table& operator=(__hash_table&& __u)
+ _NOEXCEPT_(
+ __node_traits::propagate_on_container_move_assignment::value &&
+ is_nothrow_move_assignable<__node_allocator>::value &&
+ is_nothrow_move_assignable<hasher>::value &&
+ is_nothrow_move_assignable<key_equal>::value);
+ template <class _InputIterator>
+ void __assign_unique(_InputIterator __first, _InputIterator __last);
+ template <class _InputIterator>
+ void __assign_multi(_InputIterator __first, _InputIterator __last);
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type max_size() const _NOEXCEPT
+ {
+ return _VSTD::min<size_type>(
+ __node_traits::max_size(__node_alloc()),
+ numeric_limits<difference_type >::max()
+ );
+ }
+
+private:
+ _LIBCPP_INLINE_VISIBILITY
+ __next_pointer __node_insert_multi_prepare(size_t __cp_hash,
+ value_type& __cp_val);
+ _LIBCPP_INLINE_VISIBILITY
+ void __node_insert_multi_perform(__node_pointer __cp,
+ __next_pointer __pn) _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __next_pointer __node_insert_unique_prepare(size_t __nd_hash,
+ value_type& __nd_val);
+ _LIBCPP_INLINE_VISIBILITY
+ void __node_insert_unique_perform(__node_pointer __ptr) _NOEXCEPT;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool> __node_insert_unique(__node_pointer __nd);
+ _LIBCPP_INLINE_VISIBILITY
+ iterator __node_insert_multi(__node_pointer __nd);
+ _LIBCPP_INLINE_VISIBILITY
+ iterator __node_insert_multi(const_iterator __p,
+ __node_pointer __nd);
+
+ template <class _Key, class ..._Args>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool> __emplace_unique_key_args(_Key const& __k, _Args&&... __args);
+
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool> __emplace_unique_impl(_Args&&... __args);
+
+ template <class _Pp>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool> __emplace_unique(_Pp&& __x) {
+ return __emplace_unique_extract_key(_VSTD::forward<_Pp>(__x),
+ __can_extract_key<_Pp, key_type>());
+ }
+
+ template <class _First, class _Second>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if<
+ __can_extract_map_key<_First, key_type, __container_value_type>::value,
+ pair<iterator, bool>
+ >::type __emplace_unique(_First&& __f, _Second&& __s) {
+ return __emplace_unique_key_args(__f, _VSTD::forward<_First>(__f),
+ _VSTD::forward<_Second>(__s));
+ }
+
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool> __emplace_unique(_Args&&... __args) {
+ return __emplace_unique_impl(_VSTD::forward<_Args>(__args)...);
+ }
+
+ template <class _Pp>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool>
+ __emplace_unique_extract_key(_Pp&& __x, __extract_key_fail_tag) {
+ return __emplace_unique_impl(_VSTD::forward<_Pp>(__x));
+ }
+ template <class _Pp>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool>
+ __emplace_unique_extract_key(_Pp&& __x, __extract_key_self_tag) {
+ return __emplace_unique_key_args(__x, _VSTD::forward<_Pp>(__x));
+ }
+ template <class _Pp>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool>
+ __emplace_unique_extract_key(_Pp&& __x, __extract_key_first_tag) {
+ return __emplace_unique_key_args(__x.first, _VSTD::forward<_Pp>(__x));
+ }
+
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator __emplace_multi(_Args&&... __args);
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator __emplace_hint_multi(const_iterator __p, _Args&&... __args);
+
+
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool>
+ __insert_unique(__container_value_type&& __x) {
+ return __emplace_unique_key_args(_NodeTypes::__get_key(__x), _VSTD::move(__x));
+ }
+
+ template <class _Pp, class = typename enable_if<
+ !__is_same_uncvref<_Pp, __container_value_type>::value
+ >::type>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool> __insert_unique(_Pp&& __x) {
+ return __emplace_unique(_VSTD::forward<_Pp>(__x));
+ }
+
+ template <class _Pp>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator __insert_multi(_Pp&& __x) {
+ return __emplace_multi(_VSTD::forward<_Pp>(__x));
+ }
+
+ template <class _Pp>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator __insert_multi(const_iterator __p, _Pp&& __x) {
+ return __emplace_hint_multi(__p, _VSTD::forward<_Pp>(__x));
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool> __insert_unique(const __container_value_type& __x) {
+ return __emplace_unique_key_args(_NodeTypes::__get_key(__x), __x);
+ }
+
+#if _LIBCPP_STD_VER > 14
+ template <class _NodeHandle, class _InsertReturnType>
+ _LIBCPP_INLINE_VISIBILITY
+ _InsertReturnType __node_handle_insert_unique(_NodeHandle&& __nh);
+ template <class _NodeHandle>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator __node_handle_insert_unique(const_iterator __hint,
+ _NodeHandle&& __nh);
+ template <class _Table>
+ _LIBCPP_INLINE_VISIBILITY
+ void __node_handle_merge_unique(_Table& __source);
+
+ template <class _NodeHandle>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator __node_handle_insert_multi(_NodeHandle&& __nh);
+ template <class _NodeHandle>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator __node_handle_insert_multi(const_iterator __hint, _NodeHandle&& __nh);
+ template <class _Table>
+ _LIBCPP_INLINE_VISIBILITY
+ void __node_handle_merge_multi(_Table& __source);
+
+ template <class _NodeHandle>
+ _LIBCPP_INLINE_VISIBILITY
+ _NodeHandle __node_handle_extract(key_type const& __key);
+ template <class _NodeHandle>
+ _LIBCPP_INLINE_VISIBILITY
+ _NodeHandle __node_handle_extract(const_iterator __it);
+#endif
+
+ void clear() _NOEXCEPT;
+ void rehash(size_type __n);
+ _LIBCPP_INLINE_VISIBILITY void reserve(size_type __n)
+ {rehash(static_cast<size_type>(ceil(__n / max_load_factor())));}
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type bucket_count() const _NOEXCEPT
+ {
+ return __bucket_list_.get_deleter().size();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator begin() _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ iterator end() _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator begin() const _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator end() const _NOEXCEPT;
+
+ template <class _Key>
+ _LIBCPP_INLINE_VISIBILITY
+ size_type bucket(const _Key& __k) const
+ {
+ _LIBCPP_ASSERT(bucket_count() > 0,
+ "unordered container::bucket(key) called when bucket_count() == 0");
+ return __constrain_hash(hash_function()(__k), bucket_count());
+ }
+
+ template <class _Key>
+ iterator find(const _Key& __x);
+ template <class _Key>
+ const_iterator find(const _Key& __x) const;
+
+ typedef __hash_node_destructor<__node_allocator> _Dp;
+ typedef unique_ptr<__node, _Dp> __node_holder;
+
+ iterator erase(const_iterator __p);
+ iterator erase(const_iterator __first, const_iterator __last);
+ template <class _Key>
+ size_type __erase_unique(const _Key& __k);
+ template <class _Key>
+ size_type __erase_multi(const _Key& __k);
+ __node_holder remove(const_iterator __p) _NOEXCEPT;
+
+ template <class _Key>
+ _LIBCPP_INLINE_VISIBILITY
+ size_type __count_unique(const _Key& __k) const;
+ template <class _Key>
+ size_type __count_multi(const _Key& __k) const;
+
+ template <class _Key>
+ pair<iterator, iterator>
+ __equal_range_unique(const _Key& __k);
+ template <class _Key>
+ pair<const_iterator, const_iterator>
+ __equal_range_unique(const _Key& __k) const;
+
+ template <class _Key>
+ pair<iterator, iterator>
+ __equal_range_multi(const _Key& __k);
+ template <class _Key>
+ pair<const_iterator, const_iterator>
+ __equal_range_multi(const _Key& __k) const;
+
+ void swap(__hash_table& __u)
+#if _LIBCPP_STD_VER <= 11
+ _NOEXCEPT_(
+ __is_nothrow_swappable<hasher>::value && __is_nothrow_swappable<key_equal>::value
+ && (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value
+ || __is_nothrow_swappable<__pointer_allocator>::value)
+ && (!__node_traits::propagate_on_container_swap::value
+ || __is_nothrow_swappable<__node_allocator>::value)
+ );
+#else
+ _NOEXCEPT_(__is_nothrow_swappable<hasher>::value && __is_nothrow_swappable<key_equal>::value);
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type max_bucket_count() const _NOEXCEPT
+ {return max_size(); }
+ size_type bucket_size(size_type __n) const;
+ _LIBCPP_INLINE_VISIBILITY float load_factor() const _NOEXCEPT
+ {
+ size_type __bc = bucket_count();
+ return __bc != 0 ? (float)size() / __bc : 0.f;
+ }
+ _LIBCPP_INLINE_VISIBILITY void max_load_factor(float __mlf) _NOEXCEPT
+ {
+ _LIBCPP_ASSERT(__mlf > 0,
+ "unordered container::max_load_factor(lf) called with lf <= 0");
+ max_load_factor() = _VSTD::max(__mlf, load_factor());
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ local_iterator
+ begin(size_type __n)
+ {
+ _LIBCPP_ASSERT(__n < bucket_count(),
+ "unordered container::begin(n) called with n >= bucket_count()");
+#if _LIBCPP_DEBUG_LEVEL == 2
+ return local_iterator(__bucket_list_[__n], __n, bucket_count(), this);
+#else
+ return local_iterator(__bucket_list_[__n], __n, bucket_count());
+#endif
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ local_iterator
+ end(size_type __n)
+ {
+ _LIBCPP_ASSERT(__n < bucket_count(),
+ "unordered container::end(n) called with n >= bucket_count()");
+#if _LIBCPP_DEBUG_LEVEL == 2
+ return local_iterator(nullptr, __n, bucket_count(), this);
+#else
+ return local_iterator(nullptr, __n, bucket_count());
+#endif
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ const_local_iterator
+ cbegin(size_type __n) const
+ {
+ _LIBCPP_ASSERT(__n < bucket_count(),
+ "unordered container::cbegin(n) called with n >= bucket_count()");
+#if _LIBCPP_DEBUG_LEVEL == 2
+ return const_local_iterator(__bucket_list_[__n], __n, bucket_count(), this);
+#else
+ return const_local_iterator(__bucket_list_[__n], __n, bucket_count());
+#endif
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ const_local_iterator
+ cend(size_type __n) const
+ {
+ _LIBCPP_ASSERT(__n < bucket_count(),
+ "unordered container::cend(n) called with n >= bucket_count()");
+#if _LIBCPP_DEBUG_LEVEL == 2
+ return const_local_iterator(nullptr, __n, bucket_count(), this);
+#else
+ return const_local_iterator(nullptr, __n, bucket_count());
+#endif
+ }
+
+#if _LIBCPP_DEBUG_LEVEL == 2
+
+ bool __dereferenceable(const const_iterator* __i) const;
+ bool __decrementable(const const_iterator* __i) const;
+ 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
+
+private:
+ void __rehash(size_type __n);
+
+ template <class ..._Args>
+ __node_holder __construct_node(_Args&& ...__args);
+
+ template <class _First, class ..._Rest>
+ __node_holder __construct_node_hash(size_t __hash, _First&& __f, _Rest&&... __rest);
+
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __copy_assign_alloc(const __hash_table& __u)
+ {__copy_assign_alloc(__u, integral_constant<bool,
+ __node_traits::propagate_on_container_copy_assignment::value>());}
+ void __copy_assign_alloc(const __hash_table& __u, true_type);
+ _LIBCPP_INLINE_VISIBILITY
+ void __copy_assign_alloc(const __hash_table&, false_type) {}
+
+ void __move_assign(__hash_table& __u, false_type);
+ void __move_assign(__hash_table& __u, true_type)
+ _NOEXCEPT_(
+ is_nothrow_move_assignable<__node_allocator>::value &&
+ is_nothrow_move_assignable<hasher>::value &&
+ is_nothrow_move_assignable<key_equal>::value);
+ _LIBCPP_INLINE_VISIBILITY
+ void __move_assign_alloc(__hash_table& __u)
+ _NOEXCEPT_(
+ !__node_traits::propagate_on_container_move_assignment::value ||
+ (is_nothrow_move_assignable<__pointer_allocator>::value &&
+ is_nothrow_move_assignable<__node_allocator>::value))
+ {__move_assign_alloc(__u, integral_constant<bool,
+ __node_traits::propagate_on_container_move_assignment::value>());}
+ _LIBCPP_INLINE_VISIBILITY
+ void __move_assign_alloc(__hash_table& __u, true_type)
+ _NOEXCEPT_(
+ is_nothrow_move_assignable<__pointer_allocator>::value &&
+ is_nothrow_move_assignable<__node_allocator>::value)
+ {
+ __bucket_list_.get_deleter().__alloc() =
+ _VSTD::move(__u.__bucket_list_.get_deleter().__alloc());
+ __node_alloc() = _VSTD::move(__u.__node_alloc());
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ void __move_assign_alloc(__hash_table&, false_type) _NOEXCEPT {}
+
+ void __deallocate_node(__next_pointer __np) _NOEXCEPT;
+ __next_pointer __detach() _NOEXCEPT;
+
+ template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_map;
+ template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;
+};
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+inline
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table()
+ _NOEXCEPT_(
+ is_nothrow_default_constructible<__bucket_list>::value &&
+ is_nothrow_default_constructible<__first_node>::value &&
+ is_nothrow_default_constructible<__node_allocator>::value &&
+ is_nothrow_default_constructible<hasher>::value &&
+ is_nothrow_default_constructible<key_equal>::value)
+ : __p2_(0, __default_init_tag()),
+ __p3_(1.0f, __default_init_tag())
+{
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+inline
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const hasher& __hf,
+ const key_equal& __eql)
+ : __bucket_list_(nullptr, __bucket_list_deleter()),
+ __p1_(),
+ __p2_(0, __hf),
+ __p3_(1.0f, __eql)
+{
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const hasher& __hf,
+ const key_equal& __eql,
+ const allocator_type& __a)
+ : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)),
+ __p1_(__default_init_tag(), __node_allocator(__a)),
+ __p2_(0, __hf),
+ __p3_(1.0f, __eql)
+{
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const allocator_type& __a)
+ : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)),
+ __p1_(__default_init_tag(), __node_allocator(__a)),
+ __p2_(0, __default_init_tag()),
+ __p3_(1.0f, __default_init_tag())
+{
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u)
+ : __bucket_list_(nullptr,
+ __bucket_list_deleter(allocator_traits<__pointer_allocator>::
+ select_on_container_copy_construction(
+ __u.__bucket_list_.get_deleter().__alloc()), 0)),
+ __p1_(__default_init_tag(), allocator_traits<__node_allocator>::
+ select_on_container_copy_construction(__u.__node_alloc())),
+ __p2_(0, __u.hash_function()),
+ __p3_(__u.__p3_)
+{
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u,
+ const allocator_type& __a)
+ : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)),
+ __p1_(__default_init_tag(), __node_allocator(__a)),
+ __p2_(0, __u.hash_function()),
+ __p3_(__u.__p3_)
+{
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u)
+ _NOEXCEPT_(
+ is_nothrow_move_constructible<__bucket_list>::value &&
+ is_nothrow_move_constructible<__first_node>::value &&
+ is_nothrow_move_constructible<__node_allocator>::value &&
+ is_nothrow_move_constructible<hasher>::value &&
+ is_nothrow_move_constructible<key_equal>::value)
+ : __bucket_list_(_VSTD::move(__u.__bucket_list_)),
+ __p1_(_VSTD::move(__u.__p1_)),
+ __p2_(_VSTD::move(__u.__p2_)),
+ __p3_(_VSTD::move(__u.__p3_))
+{
+ if (size() > 0)
+ {
+ __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] =
+ __p1_.first().__ptr();
+ __u.__p1_.first().__next_ = nullptr;
+ __u.size() = 0;
+ }
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u,
+ const allocator_type& __a)
+ : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)),
+ __p1_(__default_init_tag(), __node_allocator(__a)),
+ __p2_(0, _VSTD::move(__u.hash_function())),
+ __p3_(_VSTD::move(__u.__p3_))
+{
+ if (__a == allocator_type(__u.__node_alloc()))
+ {
+ __bucket_list_.reset(__u.__bucket_list_.release());
+ __bucket_list_.get_deleter().size() = __u.__bucket_list_.get_deleter().size();
+ __u.__bucket_list_.get_deleter().size() = 0;
+ if (__u.size() > 0)
+ {
+ __p1_.first().__next_ = __u.__p1_.first().__next_;
+ __u.__p1_.first().__next_ = nullptr;
+ __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] =
+ __p1_.first().__ptr();
+ size() = __u.size();
+ __u.size() = 0;
+ }
+ }
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table()
+{
+#if defined(_LIBCPP_CXX03_LANG)
+ static_assert((is_copy_constructible<key_equal>::value),
+ "Predicate must be copy-constructible.");
+ static_assert((is_copy_constructible<hasher>::value),
+ "Hasher must be copy-constructible.");
+#endif
+
+ __deallocate_node(__p1_.first().__next_);
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __get_db()->__erase_c(this);
+#endif
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+void
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__copy_assign_alloc(
+ const __hash_table& __u, true_type)
+{
+ if (__node_alloc() != __u.__node_alloc())
+ {
+ clear();
+ __bucket_list_.reset();
+ __bucket_list_.get_deleter().size() = 0;
+ }
+ __bucket_list_.get_deleter().__alloc() = __u.__bucket_list_.get_deleter().__alloc();
+ __node_alloc() = __u.__node_alloc();
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+__hash_table<_Tp, _Hash, _Equal, _Alloc>&
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(const __hash_table& __u)
+{
+ if (this != _VSTD::addressof(__u))
+ {
+ __copy_assign_alloc(__u);
+ hash_function() = __u.hash_function();
+ key_eq() = __u.key_eq();
+ max_load_factor() = __u.max_load_factor();
+ __assign_multi(__u.begin(), __u.end());
+ }
+ return *this;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+void
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate_node(__next_pointer __np)
+ _NOEXCEPT
+{
+ __node_allocator& __na = __node_alloc();
+ while (__np != nullptr)
+ {
+ __next_pointer __next = __np->__next_;
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __c_node* __c = __get_db()->__find_c_and_lock(this);
+ for (__i_node** __p = __c->end_; __p != __c->beg_; )
+ {
+ --__p;
+ iterator* __i = static_cast<iterator*>((*__p)->__i_);
+ if (__i->__node_ == __np)
+ {
+ (*__p)->__c_ = nullptr;
+ if (--__c->end_ != __p)
+ _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
+ }
+ }
+ __get_db()->unlock();
+#endif
+ __node_pointer __real_np = __np->__upcast();
+ __node_traits::destroy(__na, _NodeTypes::__get_ptr(__real_np->__value_));
+ __node_traits::deallocate(__na, __real_np, 1);
+ __np = __next;
+ }
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__next_pointer
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__detach() _NOEXCEPT
+{
+ size_type __bc = bucket_count();
+ for (size_type __i = 0; __i < __bc; ++__i)
+ __bucket_list_[__i] = nullptr;
+ size() = 0;
+ __next_pointer __cache = __p1_.first().__next_;
+ __p1_.first().__next_ = nullptr;
+ return __cache;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+void
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(
+ __hash_table& __u, true_type)
+ _NOEXCEPT_(
+ is_nothrow_move_assignable<__node_allocator>::value &&
+ is_nothrow_move_assignable<hasher>::value &&
+ is_nothrow_move_assignable<key_equal>::value)
+{
+ clear();
+ __bucket_list_.reset(__u.__bucket_list_.release());
+ __bucket_list_.get_deleter().size() = __u.__bucket_list_.get_deleter().size();
+ __u.__bucket_list_.get_deleter().size() = 0;
+ __move_assign_alloc(__u);
+ size() = __u.size();
+ hash_function() = _VSTD::move(__u.hash_function());
+ max_load_factor() = __u.max_load_factor();
+ key_eq() = _VSTD::move(__u.key_eq());
+ __p1_.first().__next_ = __u.__p1_.first().__next_;
+ if (size() > 0)
+ {
+ __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] =
+ __p1_.first().__ptr();
+ __u.__p1_.first().__next_ = nullptr;
+ __u.size() = 0;
+ }
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __get_db()->swap(this, _VSTD::addressof(__u));
+#endif
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+void
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(
+ __hash_table& __u, false_type)
+{
+ if (__node_alloc() == __u.__node_alloc())
+ __move_assign(__u, true_type());
+ else
+ {
+ hash_function() = _VSTD::move(__u.hash_function());
+ key_eq() = _VSTD::move(__u.key_eq());
+ max_load_factor() = __u.max_load_factor();
+ if (bucket_count() != 0)
+ {
+ __next_pointer __cache = __detach();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ const_iterator __i = __u.begin();
+ while (__cache != nullptr && __u.size() != 0)
+ {
+ __cache->__upcast()->__value_ =
+ _VSTD::move(__u.remove(__i++)->__value_);
+ __next_pointer __next = __cache->__next_;
+ __node_insert_multi(__cache->__upcast());
+ __cache = __next;
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __deallocate_node(__cache);
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ __deallocate_node(__cache);
+ }
+ const_iterator __i = __u.begin();
+ while (__u.size() != 0)
+ {
+ __node_holder __h = __construct_node(_NodeTypes::__move(__u.remove(__i++)->__value_));
+ __node_insert_multi(__h.get());
+ __h.release();
+ }
+ }
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+inline
+__hash_table<_Tp, _Hash, _Equal, _Alloc>&
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(__hash_table&& __u)
+ _NOEXCEPT_(
+ __node_traits::propagate_on_container_move_assignment::value &&
+ is_nothrow_move_assignable<__node_allocator>::value &&
+ is_nothrow_move_assignable<hasher>::value &&
+ is_nothrow_move_assignable<key_equal>::value)
+{
+ __move_assign(__u, integral_constant<bool,
+ __node_traits::propagate_on_container_move_assignment::value>());
+ return *this;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _InputIterator>
+void
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_unique(_InputIterator __first,
+ _InputIterator __last)
+{
+ typedef iterator_traits<_InputIterator> _ITraits;
+ typedef typename _ITraits::value_type _ItValueType;
+ static_assert((is_same<_ItValueType, __container_value_type>::value),
+ "__assign_unique may only be called with the containers value type");
+
+ if (bucket_count() != 0)
+ {
+ __next_pointer __cache = __detach();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ for (; __cache != nullptr && __first != __last; ++__first)
+ {
+ __cache->__upcast()->__value_ = *__first;
+ __next_pointer __next = __cache->__next_;
+ __node_insert_unique(__cache->__upcast());
+ __cache = __next;
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __deallocate_node(__cache);
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ __deallocate_node(__cache);
+ }
+ for (; __first != __last; ++__first)
+ __insert_unique(*__first);
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _InputIterator>
+void
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __first,
+ _InputIterator __last)
+{
+ typedef iterator_traits<_InputIterator> _ITraits;
+ typedef typename _ITraits::value_type _ItValueType;
+ static_assert((is_same<_ItValueType, __container_value_type>::value ||
+ is_same<_ItValueType, __node_value_type>::value),
+ "__assign_multi may only be called with the containers value type"
+ " or the nodes value type");
+ if (bucket_count() != 0)
+ {
+ __next_pointer __cache = __detach();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ for (; __cache != nullptr && __first != __last; ++__first)
+ {
+ __cache->__upcast()->__value_ = *__first;
+ __next_pointer __next = __cache->__next_;
+ __node_insert_multi(__cache->__upcast());
+ __cache = __next;
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __deallocate_node(__cache);
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ __deallocate_node(__cache);
+ }
+ for (; __first != __last; ++__first)
+ __insert_multi(_NodeTypes::__get_value(*__first));
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+inline
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() _NOEXCEPT
+{
+#if _LIBCPP_DEBUG_LEVEL == 2
+ return iterator(__p1_.first().__next_, this);
+#else
+ return iterator(__p1_.first().__next_);
+#endif
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+inline
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::end() _NOEXCEPT
+{
+#if _LIBCPP_DEBUG_LEVEL == 2
+ return iterator(nullptr, this);
+#else
+ return iterator(nullptr);
+#endif
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+inline
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() const _NOEXCEPT
+{
+#if _LIBCPP_DEBUG_LEVEL == 2
+ return const_iterator(__p1_.first().__next_, this);
+#else
+ return const_iterator(__p1_.first().__next_);
+#endif
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+inline
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::end() const _NOEXCEPT
+{
+#if _LIBCPP_DEBUG_LEVEL == 2
+ return const_iterator(nullptr, this);
+#else
+ return const_iterator(nullptr);
+#endif
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+void
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::clear() _NOEXCEPT
+{
+ if (size() > 0)
+ {
+ __deallocate_node(__p1_.first().__next_);
+ __p1_.first().__next_ = nullptr;
+ size_type __bc = bucket_count();
+ for (size_type __i = 0; __i < __bc; ++__i)
+ __bucket_list_[__i] = nullptr;
+ size() = 0;
+ }
+}
+
+
+// Prepare the container for an insertion of the value __value with the hash
+// __hash. This does a lookup into the container to see if __value is already
+// present, and performs a rehash if necessary. Returns a pointer to the
+// existing element if it exists, otherwise nullptr.
+//
+// Note that this function does forward exceptions if key_eq() throws, and never
+// mutates __value or actually inserts into the map.
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+_LIBCPP_INLINE_VISIBILITY
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__next_pointer
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_prepare(
+ size_t __hash, value_type& __value)
+{
+ size_type __bc = bucket_count();
+
+ if (__bc != 0)
+ {
+ size_t __chash = __constrain_hash(__hash, __bc);
+ __next_pointer __ndptr = __bucket_list_[__chash];
+ if (__ndptr != nullptr)
+ {
+ for (__ndptr = __ndptr->__next_; __ndptr != nullptr &&
+ __constrain_hash(__ndptr->__hash(), __bc) == __chash;
+ __ndptr = __ndptr->__next_)
+ {
+ if (key_eq()(__ndptr->__upcast()->__value_, __value))
+ return __ndptr;
+ }
+ }
+ }
+ if (size()+1 > __bc * max_load_factor() || __bc == 0)
+ {
+ rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
+ size_type(ceil(float(size() + 1) / max_load_factor()))));
+ }
+ return nullptr;
+}
+
+// Insert the node __nd into the container by pushing it into the right bucket,
+// and updating size(). Assumes that __nd->__hash is up-to-date, and that
+// rehashing has already occurred and that no element with the same key exists
+// in the map.
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+_LIBCPP_INLINE_VISIBILITY
+void
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_perform(
+ __node_pointer __nd) _NOEXCEPT
+{
+ size_type __bc = bucket_count();
+ size_t __chash = __constrain_hash(__nd->__hash(), __bc);
+ // insert_after __bucket_list_[__chash], or __first_node if bucket is null
+ __next_pointer __pn = __bucket_list_[__chash];
+ if (__pn == nullptr)
+ {
+ __pn =__p1_.first().__ptr();
+ __nd->__next_ = __pn->__next_;
+ __pn->__next_ = __nd->__ptr();
+ // fix up __bucket_list_
+ __bucket_list_[__chash] = __pn;
+ if (__nd->__next_ != nullptr)
+ __bucket_list_[__constrain_hash(__nd->__next_->__hash(), __bc)] = __nd->__ptr();
+ }
+ else
+ {
+ __nd->__next_ = __pn->__next_;
+ __pn->__next_ = __nd->__ptr();
+ }
+ ++size();
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique(__node_pointer __nd)
+{
+ __nd->__hash_ = hash_function()(__nd->__value_);
+ __next_pointer __existing_node =
+ __node_insert_unique_prepare(__nd->__hash(), __nd->__value_);
+
+ // Insert the node, unless it already exists in the container.
+ bool __inserted = false;
+ if (__existing_node == nullptr)
+ {
+ __node_insert_unique_perform(__nd);
+ __existing_node = __nd->__ptr();
+ __inserted = true;
+ }
+#if _LIBCPP_DEBUG_LEVEL == 2
+ return pair<iterator, bool>(iterator(__existing_node, this), __inserted);
+#else
+ return pair<iterator, bool>(iterator(__existing_node), __inserted);
+#endif
+}
+
+// Prepare the container for an insertion of the value __cp_val with the hash
+// __cp_hash. This does a lookup into the container to see if __cp_value is
+// already present, and performs a rehash if necessary. Returns a pointer to the
+// last occurrence of __cp_val in the map.
+//
+// Note that this function does forward exceptions if key_eq() throws, and never
+// mutates __value or actually inserts into the map.
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__next_pointer
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_prepare(
+ size_t __cp_hash, value_type& __cp_val)
+{
+ size_type __bc = bucket_count();
+ if (size()+1 > __bc * max_load_factor() || __bc == 0)
+ {
+ rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
+ size_type(ceil(float(size() + 1) / max_load_factor()))));
+ __bc = bucket_count();
+ }
+ size_t __chash = __constrain_hash(__cp_hash, __bc);
+ __next_pointer __pn = __bucket_list_[__chash];
+ if (__pn != nullptr)
+ {
+ for (bool __found = false; __pn->__next_ != nullptr &&
+ __constrain_hash(__pn->__next_->__hash(), __bc) == __chash;
+ __pn = __pn->__next_)
+ {
+ // __found key_eq() action
+ // false false loop
+ // true true loop
+ // false true set __found to true
+ // true false break
+ if (__found != (__pn->__next_->__hash() == __cp_hash &&
+ key_eq()(__pn->__next_->__upcast()->__value_, __cp_val)))
+ {
+ if (!__found)
+ __found = true;
+ else
+ break;
+ }
+ }
+ }
+ return __pn;
+}
+
+// Insert the node __cp into the container after __pn (which is the last node in
+// the bucket that compares equal to __cp). Rehashing, and checking for
+// uniqueness has already been performed (in __node_insert_multi_prepare), so
+// all we need to do is update the bucket and size(). Assumes that __cp->__hash
+// is up-to-date.
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+void
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_perform(
+ __node_pointer __cp, __next_pointer __pn) _NOEXCEPT
+{
+ size_type __bc = bucket_count();
+ size_t __chash = __constrain_hash(__cp->__hash_, __bc);
+ if (__pn == nullptr)
+ {
+ __pn =__p1_.first().__ptr();
+ __cp->__next_ = __pn->__next_;
+ __pn->__next_ = __cp->__ptr();
+ // fix up __bucket_list_
+ __bucket_list_[__chash] = __pn;
+ if (__cp->__next_ != nullptr)
+ __bucket_list_[__constrain_hash(__cp->__next_->__hash(), __bc)]
+ = __cp->__ptr();
+ }
+ else
+ {
+ __cp->__next_ = __pn->__next_;
+ __pn->__next_ = __cp->__ptr();
+ if (__cp->__next_ != nullptr)
+ {
+ size_t __nhash = __constrain_hash(__cp->__next_->__hash(), __bc);
+ if (__nhash != __chash)
+ __bucket_list_[__nhash] = __cp->__ptr();
+ }
+ }
+ ++size();
+}
+
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(__node_pointer __cp)
+{
+ __cp->__hash_ = hash_function()(__cp->__value_);
+ __next_pointer __pn = __node_insert_multi_prepare(__cp->__hash(), __cp->__value_);
+ __node_insert_multi_perform(__cp, __pn);
+
+#if _LIBCPP_DEBUG_LEVEL == 2
+ return iterator(__cp->__ptr(), this);
+#else
+ return iterator(__cp->__ptr());
+#endif
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(
+ const_iterator __p, __node_pointer __cp)
+{
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
+ "unordered container::emplace_hint(const_iterator, args...) called with an iterator not"
+ " referring to this unordered container");
+ if (__p != end() && key_eq()(*__p, __cp->__value_))
+ {
+ __next_pointer __np = __p.__node_;
+ __cp->__hash_ = __np->__hash();
+ size_type __bc = bucket_count();
+ if (size()+1 > __bc * max_load_factor() || __bc == 0)
+ {
+ rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
+ size_type(ceil(float(size() + 1) / max_load_factor()))));
+ __bc = bucket_count();
+ }
+ size_t __chash = __constrain_hash(__cp->__hash_, __bc);
+ __next_pointer __pp = __bucket_list_[__chash];
+ while (__pp->__next_ != __np)
+ __pp = __pp->__next_;
+ __cp->__next_ = __np;
+ __pp->__next_ = static_cast<__next_pointer>(__cp);
+ ++size();
+#if _LIBCPP_DEBUG_LEVEL == 2
+ return iterator(static_cast<__next_pointer>(__cp), this);
+#else
+ return iterator(static_cast<__next_pointer>(__cp));
+#endif
+ }
+ return __node_insert_multi(__cp);
+}
+
+
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _Key, class ..._Args>
+pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const& __k, _Args&&... __args)
+{
+
+ size_t __hash = hash_function()(__k);
+ size_type __bc = bucket_count();
+ bool __inserted = false;
+ __next_pointer __nd;
+ size_t __chash;
+ if (__bc != 0)
+ {
+ __chash = __constrain_hash(__hash, __bc);
+ __nd = __bucket_list_[__chash];
+ if (__nd != nullptr)
+ {
+ for (__nd = __nd->__next_; __nd != nullptr &&
+ (__nd->__hash() == __hash || __constrain_hash(__nd->__hash(), __bc) == __chash);
+ __nd = __nd->__next_)
+ {
+ if (key_eq()(__nd->__upcast()->__value_, __k))
+ goto __done;
+ }
+ }
+ }
+ {
+ __node_holder __h = __construct_node_hash(__hash, _VSTD::forward<_Args>(__args)...);
+ if (size()+1 > __bc * max_load_factor() || __bc == 0)
+ {
+ rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
+ size_type(ceil(float(size() + 1) / max_load_factor()))));
+ __bc = bucket_count();
+ __chash = __constrain_hash(__hash, __bc);
+ }
+ // insert_after __bucket_list_[__chash], or __first_node if bucket is null
+ __next_pointer __pn = __bucket_list_[__chash];
+ if (__pn == nullptr)
+ {
+ __pn = __p1_.first().__ptr();
+ __h->__next_ = __pn->__next_;
+ __pn->__next_ = __h.get()->__ptr();
+ // fix up __bucket_list_
+ __bucket_list_[__chash] = __pn;
+ if (__h->__next_ != nullptr)
+ __bucket_list_[__constrain_hash(__h->__next_->__hash(), __bc)]
+ = __h.get()->__ptr();
+ }
+ else
+ {
+ __h->__next_ = __pn->__next_;
+ __pn->__next_ = static_cast<__next_pointer>(__h.get());
+ }
+ __nd = static_cast<__next_pointer>(__h.release());
+ // increment size
+ ++size();
+ __inserted = true;
+ }
+__done:
+#if _LIBCPP_DEBUG_LEVEL == 2
+ return pair<iterator, bool>(iterator(__nd, this), __inserted);
+#else
+ return pair<iterator, bool>(iterator(__nd), __inserted);
+#endif
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class... _Args>
+pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_impl(_Args&&... __args)
+{
+ __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
+ pair<iterator, bool> __r = __node_insert_unique(__h.get());
+ if (__r.second)
+ __h.release();
+ return __r;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class... _Args>
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_multi(_Args&&... __args)
+{
+ __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
+ iterator __r = __node_insert_multi(__h.get());
+ __h.release();
+ return __r;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class... _Args>
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_hint_multi(
+ const_iterator __p, _Args&&... __args)
+{
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
+ "unordered container::emplace_hint(const_iterator, args...) called with an iterator not"
+ " referring to this unordered container");
+ __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
+ iterator __r = __node_insert_multi(__p, __h.get());
+ __h.release();
+ return __r;
+}
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _NodeHandle, class _InsertReturnType>
+_LIBCPP_INLINE_VISIBILITY
+_InsertReturnType
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_unique(
+ _NodeHandle&& __nh)
+{
+ if (__nh.empty())
+ return _InsertReturnType{end(), false, _NodeHandle()};
+ pair<iterator, bool> __result = __node_insert_unique(__nh.__ptr_);
+ if (__result.second)
+ __nh.__release_ptr();
+ return _InsertReturnType{__result.first, __result.second, _VSTD::move(__nh)};
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _NodeHandle>
+_LIBCPP_INLINE_VISIBILITY
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_unique(
+ const_iterator, _NodeHandle&& __nh)
+{
+ if (__nh.empty())
+ return end();
+ pair<iterator, bool> __result = __node_insert_unique(__nh.__ptr_);
+ if (__result.second)
+ __nh.__release_ptr();
+ return __result.first;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _NodeHandle>
+_LIBCPP_INLINE_VISIBILITY
+_NodeHandle
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_extract(
+ key_type const& __key)
+{
+ iterator __i = find(__key);
+ if (__i == end())
+ return _NodeHandle();
+ return __node_handle_extract<_NodeHandle>(__i);
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _NodeHandle>
+_LIBCPP_INLINE_VISIBILITY
+_NodeHandle
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_extract(
+ const_iterator __p)
+{
+ allocator_type __alloc(__node_alloc());
+ return _NodeHandle(remove(__p).release(), __alloc);
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _Table>
+_LIBCPP_INLINE_VISIBILITY
+void
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_merge_unique(
+ _Table& __source)
+{
+ static_assert(is_same<__node, typename _Table::__node>::value, "");
+
+ for (typename _Table::iterator __it = __source.begin();
+ __it != __source.end();)
+ {
+ __node_pointer __src_ptr = __it.__node_->__upcast();
+ size_t __hash = hash_function()(__src_ptr->__value_);
+ __next_pointer __existing_node =
+ __node_insert_unique_prepare(__hash, __src_ptr->__value_);
+ auto __prev_iter = __it++;
+ if (__existing_node == nullptr)
+ {
+ (void)__source.remove(__prev_iter).release();
+ __src_ptr->__hash_ = __hash;
+ __node_insert_unique_perform(__src_ptr);
+ }
+ }
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _NodeHandle>
+_LIBCPP_INLINE_VISIBILITY
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_multi(
+ _NodeHandle&& __nh)
+{
+ if (__nh.empty())
+ return end();
+ iterator __result = __node_insert_multi(__nh.__ptr_);
+ __nh.__release_ptr();
+ return __result;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _NodeHandle>
+_LIBCPP_INLINE_VISIBILITY
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_multi(
+ const_iterator __hint, _NodeHandle&& __nh)
+{
+ if (__nh.empty())
+ return end();
+ iterator __result = __node_insert_multi(__hint, __nh.__ptr_);
+ __nh.__release_ptr();
+ return __result;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _Table>
+_LIBCPP_INLINE_VISIBILITY
+void
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_merge_multi(
+ _Table& __source)
+{
+ static_assert(is_same<typename _Table::__node, __node>::value, "");
+
+ for (typename _Table::iterator __it = __source.begin();
+ __it != __source.end();)
+ {
+ __node_pointer __src_ptr = __it.__node_->__upcast();
+ size_t __src_hash = hash_function()(__src_ptr->__value_);
+ __next_pointer __pn =
+ __node_insert_multi_prepare(__src_hash, __src_ptr->__value_);
+ (void)__source.remove(__it++).release();
+ __src_ptr->__hash_ = __src_hash;
+ __node_insert_multi_perform(__src_ptr, __pn);
+ }
+}
+#endif // _LIBCPP_STD_VER > 14
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+void
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::rehash(size_type __n)
+_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
+{
+ if (__n == 1)
+ __n = 2;
+ else if (__n & (__n - 1))
+ __n = __next_prime(__n);
+ size_type __bc = bucket_count();
+ if (__n > __bc)
+ __rehash(__n);
+ else if (__n < __bc)
+ {
+ __n = _VSTD::max<size_type>
+ (
+ __n,
+ __is_hash_power2(__bc) ? __next_hash_pow2(size_t(ceil(float(size()) / max_load_factor()))) :
+ __next_prime(size_t(ceil(float(size()) / max_load_factor())))
+ );
+ if (__n < __bc)
+ __rehash(__n);
+ }
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+void
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __nbc)
+{
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __get_db()->__invalidate_all(this);
+#endif
+ __pointer_allocator& __npa = __bucket_list_.get_deleter().__alloc();
+ __bucket_list_.reset(__nbc > 0 ?
+ __pointer_alloc_traits::allocate(__npa, __nbc) : nullptr);
+ __bucket_list_.get_deleter().size() = __nbc;
+ if (__nbc > 0)
+ {
+ for (size_type __i = 0; __i < __nbc; ++__i)
+ __bucket_list_[__i] = nullptr;
+ __next_pointer __pp = __p1_.first().__ptr();
+ __next_pointer __cp = __pp->__next_;
+ if (__cp != nullptr)
+ {
+ size_type __chash = __constrain_hash(__cp->__hash(), __nbc);
+ __bucket_list_[__chash] = __pp;
+ size_type __phash = __chash;
+ for (__pp = __cp, void(), __cp = __cp->__next_; __cp != nullptr;
+ __cp = __pp->__next_)
+ {
+ __chash = __constrain_hash(__cp->__hash(), __nbc);
+ if (__chash == __phash)
+ __pp = __cp;
+ else
+ {
+ if (__bucket_list_[__chash] == nullptr)
+ {
+ __bucket_list_[__chash] = __pp;
+ __pp = __cp;
+ __phash = __chash;
+ }
+ else
+ {
+ __next_pointer __np = __cp;
+ for (; __np->__next_ != nullptr &&
+ key_eq()(__cp->__upcast()->__value_,
+ __np->__next_->__upcast()->__value_);
+ __np = __np->__next_)
+ ;
+ __pp->__next_ = __np->__next_;
+ __np->__next_ = __bucket_list_[__chash]->__next_;
+ __bucket_list_[__chash]->__next_ = __cp;
+
+ }
+ }
+ }
+ }
+ }
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _Key>
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k)
+{
+ size_t __hash = hash_function()(__k);
+ size_type __bc = bucket_count();
+ if (__bc != 0)
+ {
+ size_t __chash = __constrain_hash(__hash, __bc);
+ __next_pointer __nd = __bucket_list_[__chash];
+ if (__nd != nullptr)
+ {
+ for (__nd = __nd->__next_; __nd != nullptr &&
+ (__nd->__hash() == __hash
+ || __constrain_hash(__nd->__hash(), __bc) == __chash);
+ __nd = __nd->__next_)
+ {
+ if ((__nd->__hash() == __hash)
+ && key_eq()(__nd->__upcast()->__value_, __k))
+#if _LIBCPP_DEBUG_LEVEL == 2
+ return iterator(__nd, this);
+#else
+ return iterator(__nd);
+#endif
+ }
+ }
+ }
+ return end();
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _Key>
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const
+{
+ size_t __hash = hash_function()(__k);
+ size_type __bc = bucket_count();
+ if (__bc != 0)
+ {
+ size_t __chash = __constrain_hash(__hash, __bc);
+ __next_pointer __nd = __bucket_list_[__chash];
+ if (__nd != nullptr)
+ {
+ for (__nd = __nd->__next_; __nd != nullptr &&
+ (__hash == __nd->__hash()
+ || __constrain_hash(__nd->__hash(), __bc) == __chash);
+ __nd = __nd->__next_)
+ {
+ if ((__nd->__hash() == __hash)
+ && key_eq()(__nd->__upcast()->__value_, __k))
+#if _LIBCPP_DEBUG_LEVEL == 2
+ return const_iterator(__nd, this);
+#else
+ return const_iterator(__nd);
+#endif
+ }
+ }
+
+ }
+ return end();
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class ..._Args>
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(_Args&& ...__args)
+{
+ static_assert(!__is_hash_value_type<_Args...>::value,
+ "Construct cannot be called with a hash value type");
+ __node_allocator& __na = __node_alloc();
+ __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
+ __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), _VSTD::forward<_Args>(__args)...);
+ __h.get_deleter().__value_constructed = true;
+ __h->__hash_ = hash_function()(__h->__value_);
+ __h->__next_ = nullptr;
+ return __h;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _First, class ..._Rest>
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node_hash(
+ size_t __hash, _First&& __f, _Rest&& ...__rest)
+{
+ static_assert(!__is_hash_value_type<_First, _Rest...>::value,
+ "Construct cannot be called with a hash value type");
+ __node_allocator& __na = __node_alloc();
+ __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
+ __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_),
+ _VSTD::forward<_First>(__f),
+ _VSTD::forward<_Rest>(__rest)...);
+ __h.get_deleter().__value_constructed = true;
+ __h->__hash_ = __hash;
+ __h->__next_ = nullptr;
+ return __h;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __p)
+{
+ __next_pointer __np = __p.__node_;
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
+ "unordered container erase(iterator) called with an iterator not"
+ " referring to this container");
+ _LIBCPP_DEBUG_ASSERT(__p != end(),
+ "unordered container erase(iterator) called with a non-dereferenceable iterator");
+#if _LIBCPP_DEBUG_LEVEL == 2
+ iterator __r(__np, this);
+#else
+ iterator __r(__np);
+#endif
+ ++__r;
+ remove(__p);
+ return __r;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __first,
+ const_iterator __last)
+{
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__first)) == this,
+ "unordered container::erase(iterator, iterator) called with an iterator not"
+ " referring to this container");
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__last)) == this,
+ "unordered container::erase(iterator, iterator) called with an iterator not"
+ " referring to this container");
+ for (const_iterator __p = __first; __first != __last; __p = __first)
+ {
+ ++__first;
+ erase(__p);
+ }
+ __next_pointer __np = __last.__node_;
+#if _LIBCPP_DEBUG_LEVEL == 2
+ return iterator (__np, this);
+#else
+ return iterator (__np);
+#endif
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _Key>
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__erase_unique(const _Key& __k)
+{
+ iterator __i = find(__k);
+ if (__i == end())
+ return 0;
+ erase(__i);
+ return 1;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _Key>
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__erase_multi(const _Key& __k)
+{
+ size_type __r = 0;
+ iterator __i = find(__k);
+ if (__i != end())
+ {
+ iterator __e = end();
+ do
+ {
+ erase(__i++);
+ ++__r;
+ } while (__i != __e && key_eq()(*__i, __k));
+ }
+ return __r;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT
+{
+ // current node
+ __next_pointer __cn = __p.__node_;
+ size_type __bc = bucket_count();
+ size_t __chash = __constrain_hash(__cn->__hash(), __bc);
+ // find previous node
+ __next_pointer __pn = __bucket_list_[__chash];
+ for (; __pn->__next_ != __cn; __pn = __pn->__next_)
+ ;
+ // Fix up __bucket_list_
+ // if __pn is not in same bucket (before begin is not in same bucket) &&
+ // if __cn->__next_ is not in same bucket (nullptr is not in same bucket)
+ if (__pn == __p1_.first().__ptr()
+ || __constrain_hash(__pn->__hash(), __bc) != __chash)
+ {
+ if (__cn->__next_ == nullptr
+ || __constrain_hash(__cn->__next_->__hash(), __bc) != __chash)
+ __bucket_list_[__chash] = nullptr;
+ }
+ // if __cn->__next_ is not in same bucket (nullptr is in same bucket)
+ if (__cn->__next_ != nullptr)
+ {
+ size_t __nhash = __constrain_hash(__cn->__next_->__hash(), __bc);
+ if (__nhash != __chash)
+ __bucket_list_[__nhash] = __pn;
+ }
+ // remove __cn
+ __pn->__next_ = __cn->__next_;
+ __cn->__next_ = nullptr;
+ --size();
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __c_node* __c = __get_db()->__find_c_and_lock(this);
+ for (__i_node** __dp = __c->end_; __dp != __c->beg_; )
+ {
+ --__dp;
+ iterator* __i = static_cast<iterator*>((*__dp)->__i_);
+ if (__i->__node_ == __cn)
+ {
+ (*__dp)->__c_ = nullptr;
+ if (--__c->end_ != __dp)
+ _VSTD::memmove(__dp, __dp+1, (__c->end_ - __dp)*sizeof(__i_node*));
+ }
+ }
+ __get_db()->unlock();
+#endif
+ return __node_holder(__cn->__upcast(), _Dp(__node_alloc(), true));
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _Key>
+inline
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__count_unique(const _Key& __k) const
+{
+ return static_cast<size_type>(find(__k) != end());
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _Key>
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__count_multi(const _Key& __k) const
+{
+ size_type __r = 0;
+ const_iterator __i = find(__k);
+ if (__i != end())
+ {
+ const_iterator __e = end();
+ do
+ {
+ ++__i;
+ ++__r;
+ } while (__i != __e && key_eq()(*__i, __k));
+ }
+ return __r;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _Key>
+pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator,
+ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator>
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_unique(
+ const _Key& __k)
+{
+ iterator __i = find(__k);
+ iterator __j = __i;
+ if (__i != end())
+ ++__j;
+ return pair<iterator, iterator>(__i, __j);
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _Key>
+pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator,
+ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator>
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_unique(
+ const _Key& __k) const
+{
+ const_iterator __i = find(__k);
+ const_iterator __j = __i;
+ if (__i != end())
+ ++__j;
+ return pair<const_iterator, const_iterator>(__i, __j);
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _Key>
+pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator,
+ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator>
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_multi(
+ const _Key& __k)
+{
+ iterator __i = find(__k);
+ iterator __j = __i;
+ if (__i != end())
+ {
+ iterator __e = end();
+ do
+ {
+ ++__j;
+ } while (__j != __e && key_eq()(*__j, __k));
+ }
+ return pair<iterator, iterator>(__i, __j);
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _Key>
+pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator,
+ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator>
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_multi(
+ const _Key& __k) const
+{
+ const_iterator __i = find(__k);
+ const_iterator __j = __i;
+ if (__i != end())
+ {
+ const_iterator __e = end();
+ do
+ {
+ ++__j;
+ } while (__j != __e && key_eq()(*__j, __k));
+ }
+ return pair<const_iterator, const_iterator>(__i, __j);
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+void
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)
+#if _LIBCPP_STD_VER <= 11
+ _NOEXCEPT_(
+ __is_nothrow_swappable<hasher>::value && __is_nothrow_swappable<key_equal>::value
+ && (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value
+ || __is_nothrow_swappable<__pointer_allocator>::value)
+ && (!__node_traits::propagate_on_container_swap::value
+ || __is_nothrow_swappable<__node_allocator>::value)
+ )
+#else
+ _NOEXCEPT_(__is_nothrow_swappable<hasher>::value && __is_nothrow_swappable<key_equal>::value)
+#endif
+{
+ _LIBCPP_ASSERT(__node_traits::propagate_on_container_swap::value ||
+ this->__node_alloc() == __u.__node_alloc(),
+ "list::swap: Either propagate_on_container_swap must be true"
+ " or the allocators must compare equal");
+ {
+ __node_pointer_pointer __npp = __bucket_list_.release();
+ __bucket_list_.reset(__u.__bucket_list_.release());
+ __u.__bucket_list_.reset(__npp);
+ }
+ _VSTD::swap(__bucket_list_.get_deleter().size(), __u.__bucket_list_.get_deleter().size());
+ _VSTD::__swap_allocator(__bucket_list_.get_deleter().__alloc(),
+ __u.__bucket_list_.get_deleter().__alloc());
+ _VSTD::__swap_allocator(__node_alloc(), __u.__node_alloc());
+ _VSTD::swap(__p1_.first().__next_, __u.__p1_.first().__next_);
+ __p2_.swap(__u.__p2_);
+ __p3_.swap(__u.__p3_);
+ if (size() > 0)
+ __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] =
+ __p1_.first().__ptr();
+ if (__u.size() > 0)
+ __u.__bucket_list_[__constrain_hash(__u.__p1_.first().__next_->__hash(), __u.bucket_count())] =
+ __u.__p1_.first().__ptr();
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __get_db()->swap(this, _VSTD::addressof(__u));
+#endif
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::bucket_size(size_type __n) const
+{
+ _LIBCPP_ASSERT(__n < bucket_count(),
+ "unordered container::bucket_size(n) called with n >= bucket_count()");
+ __next_pointer __np = __bucket_list_[__n];
+ size_type __bc = bucket_count();
+ size_type __r = 0;
+ if (__np != nullptr)
+ {
+ for (__np = __np->__next_; __np != nullptr &&
+ __constrain_hash(__np->__hash(), __bc) == __n;
+ __np = __np->__next_, (void) ++__r)
+ ;
+ }
+ return __r;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(__hash_table<_Tp, _Hash, _Equal, _Alloc>& __x,
+ __hash_table<_Tp, _Hash, _Equal, _Alloc>& __y)
+ _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+ __x.swap(__y);
+}
+
+#if _LIBCPP_DEBUG_LEVEL == 2
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+bool
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__dereferenceable(const const_iterator* __i) const
+{
+ return __i->__node_ != nullptr;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+bool
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__decrementable(const const_iterator*) const
+{
+ return false;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+bool
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__addable(const const_iterator*, ptrdiff_t) const
+{
+ return false;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+bool
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__subscriptable(const const_iterator*, ptrdiff_t) const
+{
+ return false;
+}
+
+#endif // _LIBCPP_DEBUG_LEVEL == 2
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP__HASH_TABLE
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__ios/fpos.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__ios/fpos.h
new file mode 100644
index 0000000000..87f0135fc3
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__ios/fpos.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___IOS_FPOS_H
+#define _LIBCPP___IOS_FPOS_H
+
+#include <__config>
+#include <iosfwd>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _StateT>
+class _LIBCPP_TEMPLATE_VIS fpos {
+private:
+ _StateT __st_;
+ streamoff __off_;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI fpos(streamoff __off = streamoff()) : __st_(), __off_(__off) {}
+
+ _LIBCPP_HIDE_FROM_ABI operator streamoff() const { return __off_; }
+
+ _LIBCPP_HIDE_FROM_ABI _StateT state() const { return __st_; }
+ _LIBCPP_HIDE_FROM_ABI void state(_StateT __st) { __st_ = __st; }
+
+ _LIBCPP_HIDE_FROM_ABI fpos& operator+=(streamoff __off) {
+ __off_ += __off;
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI fpos operator+(streamoff __off) const {
+ fpos __t(*this);
+ __t += __off;
+ return __t;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI fpos& operator-=(streamoff __off) {
+ __off_ -= __off;
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI fpos operator-(streamoff __off) const {
+ fpos __t(*this);
+ __t -= __off;
+ return __t;
+ }
+};
+
+template <class _StateT>
+inline _LIBCPP_HIDE_FROM_ABI
+streamoff operator-(const fpos<_StateT>& __x, const fpos<_StateT>& __y) {
+ return streamoff(__x) - streamoff(__y);
+}
+
+template <class _StateT>
+inline _LIBCPP_HIDE_FROM_ABI
+bool operator==(const fpos<_StateT>& __x, const fpos<_StateT>& __y) {
+ return streamoff(__x) == streamoff(__y);
+}
+
+template <class _StateT>
+inline _LIBCPP_HIDE_FROM_ABI
+bool operator!=(const fpos<_StateT>& __x, const fpos<_StateT>& __y) {
+ return streamoff(__x) != streamoff(__y);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___IOS_FPOS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/access.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/access.h
new file mode 100644
index 0000000000..7abd4c5573
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/access.h
@@ -0,0 +1,129 @@
+// -*- 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_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
+
+#endif // _LIBCPP___ITERATOR_ACCESS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/advance.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/advance.h
new file mode 100644
index 0000000000..1e49676ce7
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/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 <__assert>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iterator_traits.h>
+#include <__utility/move.h>
+#include <__utility/unreachable.h>
+#include <concepts>
+#include <cstdlib>
+#include <limits>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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 = __enable_if_t<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_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+// [range.iter.op.advance]
+
+namespace ranges {
+namespace __advance {
+
+struct __fn {
+private:
+ 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:
+ // 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)`.
+ // __magnitude_geq(a, b) returns |a| >= |b|, assuming they have the same sign.
+ auto __magnitude_geq = [](auto __a, auto __b) {
+ return __a == 0 ? __b == 0 :
+ __a > 0 ? __a >= __b :
+ __a <= __b;
+ };
+ 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();
+ }
+};
+
+} // namespace __advance
+
+inline namespace __cpo {
+ inline constexpr auto advance = __advance::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ITERATOR_ADVANCE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/back_insert_iterator.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/back_insert_iterator.h
new file mode 100644
index 0000000000..9a4b05703b
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/back_insert_iterator.h
@@ -0,0 +1,70 @@
+// -*- 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_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_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit back_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {}
+ _LIBCPP_HIDE_FROM_ABI _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_HIDE_FROM_ABI _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_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator*() {return *this;}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator++() {return *this;}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator operator++(int) {return *this;}
+};
+
+template <class _Container>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+back_insert_iterator<_Container>
+back_inserter(_Container& __x)
+{
+ return back_insert_iterator<_Container>(__x);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ITERATOR_BACK_INSERT_ITERATOR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/common_iterator.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/common_iterator.h
new file mode 100644
index 0000000000..505e4f1f3f
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/common_iterator.h
@@ -0,0 +1,283 @@
+// -*- 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 <__assert>
+#include <__config>
+#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_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+template<class _Iter>
+concept __can_use_postfix_proxy =
+ constructible_from<iter_value_t<_Iter>, iter_reference_t<_Iter>> &&
+ move_constructible<iter_value_t<_Iter>>;
+
+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:
+ constexpr const iter_value_t<_Iter>* operator->() const noexcept {
+ 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 const iter_value_t<_Iter>& operator*() const noexcept {
+ 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(), "Attempted to construct from a valueless common_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(), "Attempted to assign from a valueless common_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;
+ }
+
+ constexpr decltype(auto) operator*()
+ {
+ _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), "Attempted to dereference a non-dereferenceable common_iterator");
+ return *_VSTD::__unchecked_get<_Iter>(__hold_);
+ }
+
+ constexpr decltype(auto) operator*() const
+ requires __dereferenceable<const _Iter>
+ {
+ _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), "Attempted to dereference a non-dereferenceable common_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_), "Attempted to dereference a non-dereferenceable common_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_), "Attempted to increment a non-dereferenceable common_iterator");
+ ++_VSTD::__unchecked_get<_Iter>(__hold_); return *this;
+ }
+
+ decltype(auto) operator++(int) {
+ _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), "Attempted to increment a non-dereferenceable common_iterator");
+ if constexpr (forward_iterator<_Iter>) {
+ auto __tmp = *this;
+ ++*this;
+ return __tmp;
+ } else if constexpr (requires (_Iter& __i) { { *__i++ } -> __can_reference; } ||
+ !__can_use_postfix_proxy<_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 constexpr bool operator==(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) {
+ _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator");
+ _LIBCPP_ASSERT(!__y.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator");
+
+ 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 constexpr bool operator==(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) {
+ _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator");
+ _LIBCPP_ASSERT(!__y.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator");
+
+ 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 constexpr iter_difference_t<_I2> operator-(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) {
+ _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception(), "Attempted to subtract from a valueless common_iterator");
+ _LIBCPP_ASSERT(!__y.__hold_.valueless_by_exception(), "Attempted to subtract a valueless common_iterator");
+
+ 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 constexpr 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_), "Attempted to iter_move a non-dereferenceable common_iterator");
+ return ranges::iter_move( _VSTD::__unchecked_get<_Iter>(__i.__hold_));
+ }
+
+ template<indirectly_swappable<_Iter> _I2, class _S2>
+ friend constexpr 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_), "Attempted to iter_swap a non-dereferenceable common_iterator");
+ _LIBCPP_ASSERT(holds_alternative<_I2>(__y.__hold_), "Attempted to iter_swap a non-dereferenceable common_iterator");
+ return ranges::iter_swap(_VSTD::__unchecked_get<_Iter>(__x.__hold_), _VSTD::__unchecked_get<_I2>(__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<input_iterator _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_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ITERATOR_COMMON_ITERATOR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/concepts.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/concepts.h
new file mode 100644
index 0000000000..92ef781457
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/concepts.h
@@ -0,0 +1,280 @@
+// -*- 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_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [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 =
+ // TODO: remove this once the clang bug is fixed (bugs.llvm.org/PR48173).
+ !same_as<_Ip, bool> && // Currently, clang does not handle bool correctly.
+ 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 } -> __can_reference;
+ } &&
+ 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>>> &&
+ 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>>;
+
+template<class _In, class _Out>
+concept indirectly_copyable =
+ indirectly_readable<_In> &&
+ indirectly_writable<_Out, iter_reference_t<_In>>;
+
+template<class _In, class _Out>
+concept indirectly_copyable_storable =
+ indirectly_copyable<_In, _Out> &&
+ indirectly_writable<_Out, iter_value_t<_In>&> &&
+ indirectly_writable<_Out, const iter_value_t<_In>&> &&
+ indirectly_writable<_Out, iter_value_t<_In>&&> &&
+ indirectly_writable<_Out, const iter_value_t<_In>&&> &&
+ copyable<iter_value_t<_In>> &&
+ constructible_from<iter_value_t<_In>, iter_reference_t<_In>> &&
+ assignable_from<iter_value_t<_In>&, iter_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).
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ITERATOR_CONCEPTS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/counted_iterator.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/counted_iterator.h
new file mode 100644
index 0000000000..826d5de51f
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/counted_iterator.h
@@ -0,0 +1,303 @@
+// -*- 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 <__assert>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/default_sentinel.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 <__memory/pointer_traits.h>
+#include <__utility/move.h>
+#include <compare>
+#include <concepts>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+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:
+ _LIBCPP_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& noexcept { 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_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ITERATOR_COUNTED_ITERATOR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/data.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/data.h
new file mode 100644
index 0000000000..88eb752b64
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/data.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___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_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
+
+#endif // _LIBCPP___ITERATOR_DATA_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/default_sentinel.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/default_sentinel.h
new file mode 100644
index 0000000000..669032aa97
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/default_sentinel.h
@@ -0,0 +1,30 @@
+// -*- 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_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+struct default_sentinel_t { };
+inline constexpr default_sentinel_t default_sentinel{};
+
+#endif // _LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ITERATOR_DEFAULT_SENTINEL_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/distance.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/distance.h
new file mode 100644
index 0000000000..78b8177fae
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/distance.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_DISTANCE_H
+#define _LIBCPP___ITERATOR_DISTANCE_H
+
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iterator_traits.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/size.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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());
+}
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+// [range.iter.op.distance]
+
+namespace ranges {
+namespace __distance {
+
+struct __fn {
+ template<class _Ip, sentinel_for<_Ip> _Sp>
+ requires (!sized_sentinel_for<_Sp, _Ip>)
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr iter_difference_t<_Ip> operator()(_Ip __first, _Sp __last) const {
+ iter_difference_t<_Ip> __n = 0;
+ while (__first != __last) {
+ ++__first;
+ ++__n;
+ }
+ return __n;
+ }
+
+ template<class _Ip, sized_sentinel_for<decay_t<_Ip>> _Sp>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr iter_difference_t<_Ip> operator()(_Ip&& __first, _Sp __last) const {
+ if constexpr (sized_sentinel_for<_Sp, __uncvref_t<_Ip>>) {
+ return __last - __first;
+ } else {
+ return __last - decay_t<_Ip>(__first);
+ }
+ }
+
+ template<range _Rp>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr range_difference_t<_Rp> operator()(_Rp&& __r) const {
+ if constexpr (sized_range<_Rp>) {
+ return static_cast<range_difference_t<_Rp>>(ranges::size(__r));
+ } else {
+ return operator()(ranges::begin(__r), ranges::end(__r));
+ }
+ }
+};
+
+} // namespace __distance
+
+inline namespace __cpo {
+ inline constexpr auto distance = __distance::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ITERATOR_DISTANCE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/empty.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/empty.h
new file mode 100644
index 0000000000..748ca9ecbd
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/empty.h
@@ -0,0 +1,44 @@
+// -*- 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_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
+
+#endif // _LIBCPP___ITERATOR_EMPTY_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/erase_if_container.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/erase_if_container.h
new file mode 100644
index 0000000000..d7c71a947a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/erase_if_container.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_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_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
+
+#endif // _LIBCPP___ITERATOR_ERASE_IF_CONTAINER_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/front_insert_iterator.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/front_insert_iterator.h
new file mode 100644
index 0000000000..69b2d32d07
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/front_insert_iterator.h
@@ -0,0 +1,70 @@
+// -*- 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_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
+
+#endif // _LIBCPP___ITERATOR_FRONT_INSERT_ITERATOR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/incrementable_traits.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/incrementable_traits.h
new file mode 100644
index 0000000000..f36b417bf8
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/incrementable_traits.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___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_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [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_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ITERATOR_INCREMENTABLE_TRAITS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/indirectly_comparable.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/indirectly_comparable.h
new file mode 100644
index 0000000000..9002b21fd5
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/indirectly_comparable.h
@@ -0,0 +1,34 @@
+// -*- 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_INDIRECTLY_COMPARABLE_H
+#define _LIBCPP___ITERATOR_INDIRECTLY_COMPARABLE_H
+
+#include <__config>
+#include <__functional/identity.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+template <class _I1, class _I2, class _Rp, class _P1 = identity, class _P2 = identity>
+concept indirectly_comparable =
+ indirect_binary_predicate<_Rp, projected<_I1, _P1>, projected<_I2, _P2>>;
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ITERATOR_INDIRECTLY_COMPARABLE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/insert_iterator.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/insert_iterator.h
new file mode 100644
index 0000000000..aba197ec21
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/insert_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_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 <__ranges/access.h>
+#include <__utility/move.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+template <class _Container>
+using __insert_iterator_iter_t = ranges::iterator_t<_Container>;
+#else
+template <class _Container>
+using __insert_iterator_iter_t = typename _Container::iterator;
+#endif
+
+_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;
+ __insert_iterator_iter_t<_Container> iter;
+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, __insert_iterator_iter_t<_Container> __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, __insert_iterator_iter_t<_Container> __i)
+{
+ return insert_iterator<_Container>(__x, __i);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ITERATOR_INSERT_ITERATOR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/istream_iterator.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/istream_iterator.h
new file mode 100644
index 0000000000..9ee0a989b8
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/istream_iterator.h
@@ -0,0 +1,104 @@
+// -*- 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/default_sentinel.h>
+#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_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_() {}
+#if _LIBCPP_STD_VER > 17
+ _LIBCPP_HIDE_FROM_ABI constexpr istream_iterator(default_sentinel_t) : istream_iterator() {}
+#endif // _LIBCPP_STD_VER > 17
+ _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);
+
+#if _LIBCPP_STD_VER > 17
+ friend _LIBCPP_HIDE_FROM_ABI bool operator==(const istream_iterator& __i, default_sentinel_t) {
+ return __i.__in_stream_ == nullptr;
+ }
+#endif // _LIBCPP_STD_VER > 17
+};
+
+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_;
+}
+
+#if _LIBCPP_STD_VER <= 17
+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);
+}
+#endif // _LIBCPP_STD_VER <= 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ITERATOR_ISTREAM_ITERATOR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/istreambuf_iterator.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/istreambuf_iterator.h
new file mode 100644
index 0000000000..3b16f79476
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/istreambuf_iterator.h
@@ -0,0 +1,118 @@
+// -*- 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/default_sentinel.h>
+#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_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) {}
+#if _LIBCPP_STD_VER > 17
+ _LIBCPP_INLINE_VISIBILITY constexpr istreambuf_iterator(default_sentinel_t) noexcept
+ : istreambuf_iterator() {}
+#endif // _LIBCPP_STD_VER > 17
+ _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();}
+
+#if _LIBCPP_STD_VER > 17
+ friend _LIBCPP_HIDE_FROM_ABI bool operator==(const istreambuf_iterator& __i, default_sentinel_t) {
+ return __i.__test_for_eof();
+ }
+#endif // _LIBCPP_STD_VER > 17
+};
+
+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);}
+
+#if _LIBCPP_STD_VER <= 17
+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);}
+#endif // _LIBCPP_STD_VER <= 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ITERATOR_ISTREAMBUF_ITERATOR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/iter_move.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/iter_move.h
new file mode 100644
index 0000000000..4a89662927
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/iter_move.h
@@ -0,0 +1,93 @@
+// -*- 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 <__utility/move.h>
+#include <concepts> // __class_or_enum
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [iterator.cust.move]
+
+namespace ranges {
+namespace __iter_move {
+
+void iter_move();
+
+template <class _Tp>
+concept __unqualified_iter_move =
+ __class_or_enum<remove_cvref_t<_Tp>> &&
+ requires (_Tp&& __t) {
+ iter_move(_VSTD::forward<_Tp>(__t));
+ };
+
+// [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 __iter_move
+
+inline namespace __cpo {
+ inline constexpr auto iter_move = __iter_move::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+template<__dereferenceable _Tp>
+ requires requires(_Tp& __t) { { ranges::iter_move(__t) } -> __can_reference; }
+using iter_rvalue_reference_t = decltype(ranges::iter_move(declval<_Tp&>()));
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ITERATOR_ITER_MOVE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/iter_swap.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/iter_swap.h
new file mode 100644
index 0000000000..291558fadc
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/iter_swap.h
@@ -0,0 +1,106 @@
+// -*- 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 <__utility/forward.h>
+#include <__utility/move.h>
+#include <concepts>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [iter.cust.swap]
+
+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 =
+ (__class_or_enum<remove_cvref_t<_T1>> || __class_or_enum<remove_cvref_t<_T2>>) &&
+ 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);
+ }
+ };
+} // 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_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ITERATOR_ITER_SWAP_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/iterator.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/iterator.h
new file mode 100644
index 0000000000..b417eeab79
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/iterator.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_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_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
+
+#endif // _LIBCPP___ITERATOR_ITERATOR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/iterator_traits.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/iterator_traits.h
new file mode 100644
index 0000000000..6ffb2ab806
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/iterator_traits.h
@@ -0,0 +1,495 @@
+// -*- 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_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+template <class _Tp>
+using __with_reference = _Tp&;
+
+template <class _Tp>
+concept __can_reference = requires {
+ typename __with_reference<_Tp>;
+};
+
+template <class _Tp>
+concept __dereferenceable = requires(_Tp& __t) {
+ { *__t } -> __can_reference; // not required to be equality-preserving
+};
+
+// [iterator.traits]
+template<__dereferenceable _Tp>
+using iter_reference_t = decltype(*declval<_Tp&>());
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+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 = __enable_if_t<
+ __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_CONCEPTS)
+
+// 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 } -> __can_reference;
+ { ++__i } -> same_as<_Ip&>;
+ { *__i++ } -> __can_reference;
+ } &&
+ 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_CONCEPTS)
+
+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_CONCEPTS)
+
+template<class _Tp>
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+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> {};
+
+#if _LIBCPP_STD_VER >= 17
+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_STD_VER >= 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ITERATOR_ITERATOR_TRAITS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/mergeable.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/mergeable.h
new file mode 100644
index 0000000000..08022aab6d
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/mergeable.h
@@ -0,0 +1,41 @@
+// -*- 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_MERGEABLE_H
+#define _LIBCPP___ITERATOR_MERGEABLE_H
+
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+template <class _Input1, class _Input2, class _Output,
+ class _Comp = ranges::less, class _Proj1 = identity, class _Proj2 = identity>
+concept mergeable =
+ input_iterator<_Input1> &&
+ input_iterator<_Input2> &&
+ weakly_incrementable<_Output> &&
+ indirectly_copyable<_Input1, _Output> &&
+ indirectly_copyable<_Input2, _Output> &&
+ indirect_strict_weak_order<_Comp, projected<_Input1, _Proj1>, projected<_Input2, _Proj2>>;
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ITERATOR_MERGEABLE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/move_iterator.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/move_iterator.h
new file mode 100644
index 0000000000..e157b71a2f
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/move_iterator.h
@@ -0,0 +1,185 @@
+// -*- 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 <__utility/move.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Iter>
+class _LIBCPP_TEMPLATE_VIS move_iterator
+{
+public:
+#if _LIBCPP_STD_VER > 17
+ typedef input_iterator_tag iterator_concept;
+#endif
+
+ typedef _Iter iterator_type;
+ 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<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_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ move_iterator() : __current_() {}
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ explicit move_iterator(_Iter __i) : __current_(_VSTD::move(__i)) {}
+
+ template <class _Up, class = __enable_if_t<
+ !is_same<_Up, _Iter>::value && is_convertible<const _Up&, _Iter>::value
+ > >
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ move_iterator(const move_iterator<_Up>& __u) : __current_(__u.base()) {}
+
+ template <class _Up, class = __enable_if_t<
+ !is_same<_Up, _Iter>::value &&
+ is_convertible<const _Up&, _Iter>::value &&
+ is_assignable<_Iter&, const _Up&>::value
+ > >
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ move_iterator& operator=(const move_iterator<_Up>& __u) {
+ __current_ = __u.base();
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _Iter base() const { return __current_; }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ reference operator*() const { return static_cast<reference>(*__current_); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ pointer operator->() const { return __current_; }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ reference operator[](difference_type __n) const { return static_cast<reference>(__current_[__n]); }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ move_iterator& operator++() { ++__current_; return *this; }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ move_iterator operator++(int) { move_iterator __tmp(*this); ++__current_; return __tmp; }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ move_iterator& operator--() { --__current_; return *this; }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ move_iterator operator--(int) { move_iterator __tmp(*this); --__current_; return __tmp; }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ move_iterator operator+(difference_type __n) const { return move_iterator(__current_ + __n); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ move_iterator& operator+=(difference_type __n) { __current_ += __n; return *this; }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ move_iterator operator-(difference_type __n) const { return move_iterator(__current_ - __n); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ move_iterator& operator-=(difference_type __n) { __current_ -= __n; return *this; }
+
+private:
+ _Iter __current_;
+};
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_HIDE_FROM_ABI _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_HIDE_FROM_ABI _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_HIDE_FROM_ABI _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_HIDE_FROM_ABI _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_HIDE_FROM_ABI _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_HIDE_FROM_ABI _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_HIDE_FROM_ABI _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_HIDE_FROM_ABI
+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_HIDE_FROM_ABI _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_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+move_iterator<_Iter>
+make_move_iterator(_Iter __i)
+{
+ return move_iterator<_Iter>(_VSTD::move(__i));
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ITERATOR_MOVE_ITERATOR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/next.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/next.h
new file mode 100644
index 0000000000..2a37382cca
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/next.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___ITERATOR_NEXT_H
+#define _LIBCPP___ITERATOR_NEXT_H
+
+#include <__assert>
+#include <__config>
+#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_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_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+// [range.iter.op.next]
+
+namespace ranges {
+namespace __next {
+
+struct __fn {
+ 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;
+ }
+};
+
+} // namespace __next
+
+inline namespace __cpo {
+ inline constexpr auto next = __next::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ITERATOR_NEXT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/ostream_iterator.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/ostream_iterator.h
new file mode 100644
index 0000000000..f6601b23d6
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/ostream_iterator.h
@@ -0,0 +1,70 @@
+// -*- 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_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
+
+#endif // _LIBCPP___ITERATOR_OSTREAM_ITERATOR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/ostreambuf_iterator.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/ostreambuf_iterator.h
new file mode 100644
index 0000000000..16ddb6525a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/ostreambuf_iterator.h
@@ -0,0 +1,76 @@
+// -*- 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_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
+
+#endif // _LIBCPP___ITERATOR_OSTREAMBUF_ITERATOR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/permutable.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/permutable.h
new file mode 100644
index 0000000000..85834a23c8
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/permutable.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_PERMUTABLE_H
+#define _LIBCPP___ITERATOR_PERMUTABLE_H
+
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/iter_swap.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+template <class _Iterator>
+concept permutable =
+ forward_iterator<_Iterator> &&
+ indirectly_movable_storable<_Iterator, _Iterator> &&
+ indirectly_swappable<_Iterator, _Iterator>;
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ITERATOR_PERMUTABLE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/prev.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/prev.h
new file mode 100644
index 0000000000..36bf3d906a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/prev.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___ITERATOR_PREV_H
+#define _LIBCPP___ITERATOR_PREV_H
+
+#include <__assert>
+#include <__config>
+#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_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_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+// [range.iter.op.prev]
+
+namespace ranges {
+namespace __prev {
+
+struct __fn {
+ 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;
+ }
+};
+
+} // namespace __prev
+
+inline namespace __cpo {
+ inline constexpr auto prev = __prev::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ITERATOR_PREV_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/projected.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/projected.h
new file mode 100644
index 0000000000..2edbe0da61
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/projected.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_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_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+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_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ITERATOR_PROJECTED_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/readable_traits.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/readable_traits.h
new file mode 100644
index 0000000000..5bc59a89f3
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/readable_traits.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___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_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [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> {};
+
+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_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ITERATOR_READABLE_TRAITS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/reverse_access.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/reverse_access.h
new file mode 100644
index 0000000000..40c266378d
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/reverse_access.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___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_BEGIN_NAMESPACE_STD
+
+#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 // _LIBCPP_STD_VER > 11
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ITERATOR_REVERSE_ACCESS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/reverse_iterator.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/reverse_iterator.h
new file mode 100644
index 0000000000..90bc2d752e
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/reverse_iterator.h
@@ -0,0 +1,235 @@
+// -*- 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 <__compare/compare_three_way_result.h>
+#include <__compare/three_way_comparable.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_BEGIN_NAMESPACE_STD
+
+_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
+
+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 = __enable_if_t<
+ !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 = __enable_if_t<
+ !is_same<_Up, _Iter>::value &&
+ is_convertible<_Up const&, _Iter>::value &&
+ is_assignable<_Iter&, _Up const&>::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 = __enable_if_t<
+ !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 = __enable_if_t<
+ !is_same<_Up, _Iter>::value &&
+ is_convertible<_Up const&, _Iter>::value &&
+ is_assignable<_Iter&, _Up const&>::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();
+}
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+template <class _Iter1, three_way_comparable_with<_Iter1> _Iter2>
+_LIBCPP_HIDE_FROM_ABI constexpr
+compare_three_way_result_t<_Iter1, _Iter2>
+operator<=>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
+{
+ return __y.base() <=> __x.base();
+}
+#endif
+
+#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
+
+#endif // _LIBCPP___ITERATOR_REVERSE_ITERATOR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/size.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/size.h
new file mode 100644
index 0000000000..bf40207a86
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/size.h
@@ -0,0 +1,53 @@
+// -*- 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_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
+
+#endif // _LIBCPP___ITERATOR_SIZE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/sortable.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/sortable.h
new file mode 100644
index 0000000000..77a553d3ec
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/sortable.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___ITERATOR_SORTABLE_H
+#define _LIBCPP___ITERATOR_SORTABLE_H
+
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/permutable.h>
+#include <__iterator/projected.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+template <class _Iter, class _Comp = ranges::less, class _Proj = identity>
+concept sortable =
+ permutable<_Iter> &&
+ indirect_strict_weak_order<_Comp, projected<_Iter, _Proj>>;
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ITERATOR_SORTABLE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/unreachable_sentinel.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/unreachable_sentinel.h
new file mode 100644
index 0000000000..b94ca53f40
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/unreachable_sentinel.h
@@ -0,0 +1,38 @@
+// -*- 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_UNREACHABLE_SENTINEL_H
+#define _LIBCPP___ITERATOR_UNREACHABLE_SENTINEL_H
+
+#include <__config>
+#include <__iterator/concepts.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+struct unreachable_sentinel_t {
+ template<weakly_incrementable _Iter>
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator==(unreachable_sentinel_t, const _Iter&) noexcept {
+ return false;
+ }
+};
+
+inline constexpr unreachable_sentinel_t unreachable_sentinel{};
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ITERATOR_UNREACHABLE_SENTINEL_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/wrap_iter.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/wrap_iter.h
new file mode 100644
index 0000000000..d91a25ee6c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__iterator/wrap_iter.h
@@ -0,0 +1,285 @@
+// -*- 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/addressof.h>
+#include <__memory/pointer_traits.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter() _NOEXCEPT
+ : __i()
+ {
+ _VSTD::__debug_db_insert_i(this);
+ }
+ template <class _Up> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ __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
+ if (!__libcpp_is_constant_evaluated())
+ __get_db()->__iterator_copy(this, _VSTD::addressof(__u));
+#endif
+ }
+#if _LIBCPP_DEBUG_LEVEL == 2
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ __wrap_iter(const __wrap_iter& __x)
+ : __i(__x.base())
+ {
+ if (!__libcpp_is_constant_evaluated())
+ __get_db()->__iterator_copy(this, _VSTD::addressof(__x));
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ __wrap_iter& operator=(const __wrap_iter& __x)
+ {
+ if (this != _VSTD::addressof(__x))
+ {
+ if (!__libcpp_is_constant_evaluated())
+ __get_db()->__iterator_copy(this, _VSTD::addressof(__x));
+ __i = __x.__i;
+ }
+ return *this;
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ ~__wrap_iter()
+ {
+ if (!__libcpp_is_constant_evaluated())
+ __get_db()->__erase_i(this);
+ }
+#endif
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference operator*() const _NOEXCEPT
+ {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
+ "Attempted to dereference a non-dereferenceable iterator");
+ return *__i;
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 pointer operator->() const _NOEXCEPT
+ {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
+ "Attempted to dereference a non-dereferenceable iterator");
+ return _VSTD::__to_address(__i);
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter& operator++() _NOEXCEPT
+ {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
+ "Attempted to increment a non-incrementable iterator");
+ ++__i;
+ return *this;
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter operator++(int) _NOEXCEPT
+ {__wrap_iter __tmp(*this); ++(*this); return __tmp;}
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter& operator--() _NOEXCEPT
+ {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__decrementable(this),
+ "Attempted to decrement a non-decrementable iterator");
+ --__i;
+ return *this;
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter operator--(int) _NOEXCEPT
+ {__wrap_iter __tmp(*this); --(*this); return __tmp;}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter operator+ (difference_type __n) const _NOEXCEPT
+ {__wrap_iter __w(*this); __w += __n; return __w;}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter& operator+=(difference_type __n) _NOEXCEPT
+ {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__addable(this, __n),
+ "Attempted to add/subtract an iterator outside its valid range");
+ __i += __n;
+ return *this;
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter operator- (difference_type __n) const _NOEXCEPT
+ {return *this + (-__n);}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter& operator-=(difference_type __n) _NOEXCEPT
+ {*this += -__n; return *this;}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference operator[](difference_type __n) const _NOEXCEPT
+ {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__subscriptable(this, __n),
+ "Attempted to subscript an iterator outside its valid range");
+ return __i[__n];
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 iterator_type base() const _NOEXCEPT {return __i;}
+
+private:
+#if _LIBCPP_DEBUG_LEVEL == 2
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter(const void* __p, iterator_type __x) : __i(__x)
+ {
+ if (!__libcpp_is_constant_evaluated())
+ __get_db()->__insert_ic(this, __p);
+ }
+#else
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __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_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
+bool operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT
+{
+ return __x.base() == __y.base();
+}
+
+template <class _Iter1, class _Iter2>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
+bool operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
+{
+ return __x.base() == __y.base();
+}
+
+template <class _Iter1>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT
+{
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__less_than_comparable(_VSTD::addressof(__x), _VSTD::addressof(__y)),
+ "Attempted to compare incomparable iterators");
+ return __x.base() < __y.base();
+}
+
+template <class _Iter1, class _Iter2>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
+{
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y),
+ "Attempted to compare incomparable iterators");
+ return __x.base() < __y.base();
+}
+
+template <class _Iter1>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
+bool operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT
+{
+ return !(__x == __y);
+}
+
+template <class _Iter1, class _Iter2>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
+bool operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
+{
+ return !(__x == __y);
+}
+
+template <class _Iter1>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
+bool operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT
+{
+ return __y < __x;
+}
+
+template <class _Iter1, class _Iter2>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
+bool operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
+{
+ return __y < __x;
+}
+
+template <class _Iter1>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
+bool operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT
+{
+ return !(__x < __y);
+}
+
+template <class _Iter1, class _Iter2>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
+bool operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
+{
+ return !(__x < __y);
+}
+
+template <class _Iter1>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
+bool operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT
+{
+ return !(__y < __x);
+}
+
+template <class _Iter1, class _Iter2>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
+bool operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
+{
+ return !(__y < __x);
+}
+
+template <class _Iter1, class _Iter2>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+#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
+{
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__less_than_comparable(_VSTD::addressof(__x), _VSTD::addressof(__y)),
+ "Attempted to subtract incompatible iterators");
+ return __x.base() - __y.base();
+}
+
+template <class _Iter1>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+__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 _It>
+struct _LIBCPP_TEMPLATE_VIS pointer_traits<__wrap_iter<_It> >
+{
+ typedef __wrap_iter<_It> pointer;
+ typedef typename pointer_traits<_It>::element_type element_type;
+ typedef typename pointer_traits<_It>::difference_type difference_type;
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
+ static element_type *to_address(pointer __w) _NOEXCEPT {
+ return _VSTD::__to_address(__w.base());
+ }
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ITERATOR_WRAP_ITER_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__locale b/contrib/libs/cxxsupp/libcxxmsvc/include/__locale
new file mode 100644
index 0000000000..323ed3e212
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__locale
@@ -0,0 +1,1818 @@
+// -*- 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___LOCALE
+#define _LIBCPP___LOCALE
+
+#include <__availability>
+#include <__config>
+#include <atomic>
+#include <cctype>
+#include <cstdint>
+#include <locale.h>
+#include <memory>
+#include <mutex>
+#include <string>
+#include <utility>
+
+#if defined(_LIBCPP_MSVCRT_LIKE)
+# include <cstring>
+# include <__support/win32/locale_win32.h>
+#elif defined(_AIX) || defined(__MVS__)
+# include <__support/ibm/xlocale.h>
+#elif defined(__ANDROID__)
+# include <__support/android/locale_bionic.h>
+#elif defined(__sun__)
+# include <xlocale.h>
+# include <__support/solaris/xlocale.h>
+#elif defined(_NEWLIB_VERSION)
+# include <__support/newlib/xlocale.h>
+#elif defined(__OpenBSD__)
+# include <__support/openbsd/xlocale.h>
+#elif (defined(__APPLE__) || defined(__FreeBSD__) \
+ || defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
+# include <xlocale.h>
+#elif defined(__Fuchsia__)
+# include <__support/fuchsia/xlocale.h>
+#elif defined(__wasi__)
+// WASI libc uses musl's locales support.
+# include <__support/musl/xlocale.h>
+#elif defined(_LIBCPP_HAS_MUSL_LIBC)
+# include <__support/musl/xlocale.h>
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_LOCALE__L_EXTENSIONS)
+struct __libcpp_locale_guard {
+ _LIBCPP_INLINE_VISIBILITY
+ __libcpp_locale_guard(locale_t& __loc) : __old_loc_(uselocale(__loc)) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ ~__libcpp_locale_guard() {
+ if (__old_loc_)
+ uselocale(__old_loc_);
+ }
+
+ locale_t __old_loc_;
+private:
+ __libcpp_locale_guard(__libcpp_locale_guard const&);
+ __libcpp_locale_guard& operator=(__libcpp_locale_guard const&);
+};
+#elif defined(_LIBCPP_MSVCRT_LIKE)
+struct __libcpp_locale_guard {
+ __libcpp_locale_guard(locale_t __l) :
+ __status(_configthreadlocale(_ENABLE_PER_THREAD_LOCALE)) {
+ // Setting the locale can be expensive even when the locale given is
+ // already the current locale, so do an explicit check to see if the
+ // current locale is already the one we want.
+ const char* __lc = __setlocale(nullptr);
+ // If every category is the same, the locale string will simply be the
+ // locale name, otherwise it will be a semicolon-separated string listing
+ // each category. In the second case, we know at least one category won't
+ // be what we want, so we only have to check the first case.
+ if (_VSTD::strcmp(__l.__get_locale(), __lc) != 0) {
+ __locale_all = _strdup(__lc);
+ if (__locale_all == nullptr)
+ __throw_bad_alloc();
+ __setlocale(__l.__get_locale());
+ }
+ }
+ ~__libcpp_locale_guard() {
+ // The CRT documentation doesn't explicitly say, but setlocale() does the
+ // right thing when given a semicolon-separated list of locale settings
+ // for the different categories in the same format as returned by
+ // setlocale(LC_ALL, nullptr).
+ if (__locale_all != nullptr) {
+ __setlocale(__locale_all);
+ free(__locale_all);
+ }
+ _configthreadlocale(__status);
+ }
+ static const char* __setlocale(const char* __locale) {
+ const char* __new_locale = setlocale(LC_ALL, __locale);
+ if (__new_locale == nullptr)
+ __throw_bad_alloc();
+ return __new_locale;
+ }
+ int __status;
+ char* __locale_all = nullptr;
+};
+#endif
+
+class _LIBCPP_TYPE_VIS locale;
+
+template <class _Facet>
+_LIBCPP_INLINE_VISIBILITY
+bool
+has_facet(const locale&) _NOEXCEPT;
+
+template <class _Facet>
+_LIBCPP_INLINE_VISIBILITY
+const _Facet&
+use_facet(const locale&);
+
+class _LIBCPP_TYPE_VIS locale
+{
+public:
+ // types:
+ class _LIBCPP_TYPE_VIS facet;
+ class _LIBCPP_TYPE_VIS id;
+
+ typedef int category;
+ _LIBCPP_AVAILABILITY_LOCALE_CATEGORY
+ static const category // values assigned here are for exposition only
+ none = 0,
+ collate = LC_COLLATE_MASK,
+ ctype = LC_CTYPE_MASK,
+ monetary = LC_MONETARY_MASK,
+ numeric = LC_NUMERIC_MASK,
+ time = LC_TIME_MASK,
+ messages = LC_MESSAGES_MASK,
+ all = collate | ctype | monetary | numeric | time | messages;
+
+ // construct/copy/destroy:
+ locale() _NOEXCEPT;
+ locale(const locale&) _NOEXCEPT;
+ explicit locale(const char*);
+ explicit locale(const string&);
+ locale(const locale&, const char*, category);
+ locale(const locale&, const string&, category);
+ template <class _Facet>
+ _LIBCPP_INLINE_VISIBILITY locale(const locale&, _Facet*);
+ locale(const locale&, const locale&, category);
+
+ ~locale();
+
+ const locale& operator=(const locale&) _NOEXCEPT;
+
+ template <class _Facet>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ locale combine(const locale&) const;
+
+ // locale operations:
+ string name() const;
+ bool operator==(const locale&) const;
+ bool operator!=(const locale& __y) const {return !(*this == __y);}
+ template <class _CharT, class _Traits, class _Allocator>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ bool operator()(const basic_string<_CharT, _Traits, _Allocator>&,
+ const basic_string<_CharT, _Traits, _Allocator>&) const;
+
+ // global locale objects:
+ static locale global(const locale&);
+ static const locale& classic();
+
+private:
+ class __imp;
+ __imp* __locale_;
+
+ void __install_ctor(const locale&, facet*, long);
+ static locale& __global();
+ bool has_facet(id&) const;
+ const facet* use_facet(id&) const;
+
+ template <class _Facet> friend bool has_facet(const locale&) _NOEXCEPT;
+ template <class _Facet> friend const _Facet& use_facet(const locale&);
+};
+
+class _LIBCPP_TYPE_VIS locale::facet
+ : public __shared_count
+{
+protected:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit facet(size_t __refs = 0)
+ : __shared_count(static_cast<long>(__refs)-1) {}
+
+ virtual ~facet();
+
+// facet(const facet&) = delete; // effectively done in __shared_count
+// void operator=(const facet&) = delete;
+private:
+ virtual void __on_zero_shared() _NOEXCEPT;
+};
+
+class _LIBCPP_TYPE_VIS locale::id
+{
+ std::atomic<int32_t> __id_;
+
+ static int32_t __next_id;
+public:
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR id() :__id_(0) {}
+ void operator=(const id&) = delete;
+ id(const id&) = delete;
+
+public: // only needed for tests
+ long __get();
+
+ friend class locale;
+ friend class locale::__imp;
+};
+
+template <class _Facet>
+inline _LIBCPP_INLINE_VISIBILITY
+locale::locale(const locale& __other, _Facet* __f)
+{
+ __install_ctor(__other, __f, __f ? __f->id.__get() : 0);
+}
+
+template <class _Facet>
+locale
+locale::combine(const locale& __other) const
+{
+ if (!_VSTD::has_facet<_Facet>(__other))
+ __throw_runtime_error("locale::combine: locale missing facet");
+
+ return locale(*this, &const_cast<_Facet&>(_VSTD::use_facet<_Facet>(__other)));
+}
+
+template <class _Facet>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+has_facet(const locale& __l) _NOEXCEPT
+{
+ return __l.has_facet(_Facet::id);
+}
+
+template <class _Facet>
+inline _LIBCPP_INLINE_VISIBILITY
+const _Facet&
+use_facet(const locale& __l)
+{
+ return static_cast<const _Facet&>(*__l.use_facet(_Facet::id));
+}
+
+// template <class _CharT> class collate;
+
+template <class _CharT>
+class _LIBCPP_TEMPLATE_VIS collate
+ : public locale::facet
+{
+public:
+ typedef _CharT char_type;
+ typedef basic_string<char_type> string_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit collate(size_t __refs = 0)
+ : locale::facet(__refs) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ int compare(const char_type* __lo1, const char_type* __hi1,
+ const char_type* __lo2, const char_type* __hi2) const
+ {
+ return do_compare(__lo1, __hi1, __lo2, __hi2);
+ }
+
+// Disable double inline warning.
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( push )
+#pragma warning ( disable : 4141 )
+#endif
+ // FIXME(EricWF): The _LIBCPP_ALWAYS_INLINE is needed on Windows to work
+ // around a dllimport bug that expects an external instantiation.
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_ALWAYS_INLINE
+ string_type transform(const char_type* __lo, const char_type* __hi) const
+ {
+ return do_transform(__lo, __hi);
+ }
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( pop )
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ long hash(const char_type* __lo, const char_type* __hi) const
+ {
+ return do_hash(__lo, __hi);
+ }
+
+ static locale::id id;
+
+protected:
+ ~collate();
+ virtual int do_compare(const char_type* __lo1, const char_type* __hi1,
+ const char_type* __lo2, const char_type* __hi2) const;
+ virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const
+ {return string_type(__lo, __hi);}
+ virtual long do_hash(const char_type* __lo, const char_type* __hi) const;
+};
+
+template <class _CharT> locale::id collate<_CharT>::id;
+
+template <class _CharT>
+collate<_CharT>::~collate()
+{
+}
+
+template <class _CharT>
+int
+collate<_CharT>::do_compare(const char_type* __lo1, const char_type* __hi1,
+ const char_type* __lo2, const char_type* __hi2) const
+{
+ for (; __lo2 != __hi2; ++__lo1, ++__lo2)
+ {
+ if (__lo1 == __hi1 || *__lo1 < *__lo2)
+ return -1;
+ if (*__lo2 < *__lo1)
+ return 1;
+ }
+ return __lo1 != __hi1;
+}
+
+template <class _CharT>
+long
+collate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) const
+{
+ size_t __h = 0;
+ const size_t __sr = __CHAR_BIT__ * sizeof(size_t) - 8;
+ const size_t __mask = size_t(0xF) << (__sr + 4);
+ for(const char_type* __p = __lo; __p != __hi; ++__p)
+ {
+ __h = (__h << 4) + static_cast<size_t>(*__p);
+ size_t __g = __h & __mask;
+ __h ^= __g | (__g >> __sr);
+ }
+ return static_cast<long>(__h);
+}
+
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<char>)
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<wchar_t>)
+#endif
+
+// template <class CharT> class collate_byname;
+
+template <class _CharT> class _LIBCPP_TEMPLATE_VIS collate_byname;
+
+template <>
+class _LIBCPP_TYPE_VIS collate_byname<char>
+ : public collate<char>
+{
+ locale_t __l;
+public:
+ typedef char char_type;
+ typedef basic_string<char_type> string_type;
+
+ explicit collate_byname(const char* __n, size_t __refs = 0);
+ explicit collate_byname(const string& __n, size_t __refs = 0);
+
+protected:
+ ~collate_byname();
+ virtual int do_compare(const char_type* __lo1, const char_type* __hi1,
+ const char_type* __lo2, const char_type* __hi2) const;
+ virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const;
+};
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+class _LIBCPP_TYPE_VIS collate_byname<wchar_t>
+ : public collate<wchar_t>
+{
+ locale_t __l;
+public:
+ typedef wchar_t char_type;
+ typedef basic_string<char_type> string_type;
+
+ explicit collate_byname(const char* __n, size_t __refs = 0);
+ explicit collate_byname(const string& __n, size_t __refs = 0);
+
+protected:
+ ~collate_byname();
+
+ virtual int do_compare(const char_type* __lo1, const char_type* __hi1,
+ const char_type* __lo2, const char_type* __hi2) const;
+ virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const;
+};
+#endif
+
+template <class _CharT, class _Traits, class _Allocator>
+bool
+locale::operator()(const basic_string<_CharT, _Traits, _Allocator>& __x,
+ const basic_string<_CharT, _Traits, _Allocator>& __y) const
+{
+ return _VSTD::use_facet<_VSTD::collate<_CharT> >(*this).compare(
+ __x.data(), __x.data() + __x.size(),
+ __y.data(), __y.data() + __y.size()) < 0;
+}
+
+// template <class charT> class ctype
+
+class _LIBCPP_TYPE_VIS ctype_base
+{
+public:
+#if defined(_LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE)
+ typedef unsigned long mask;
+ static const mask space = 1<<0;
+ static const mask print = 1<<1;
+ static const mask cntrl = 1<<2;
+ static const mask upper = 1<<3;
+ static const mask lower = 1<<4;
+ static const mask alpha = 1<<5;
+ static const mask digit = 1<<6;
+ static const mask punct = 1<<7;
+ static const mask xdigit = 1<<8;
+ static const mask blank = 1<<9;
+#if defined(__BIONIC__)
+ // Historically this was a part of regex_traits rather than ctype_base. The
+ // historical value of the constant is preserved for ABI compatibility.
+ static const mask __regex_word = 0x8000;
+#else
+ static const mask __regex_word = 1<<10;
+#endif // defined(__BIONIC__)
+#elif defined(__GLIBC__)
+ typedef unsigned short mask;
+ static const mask space = _ISspace;
+ static const mask print = _ISprint;
+ static const mask cntrl = _IScntrl;
+ static const mask upper = _ISupper;
+ static const mask lower = _ISlower;
+ static const mask alpha = _ISalpha;
+ static const mask digit = _ISdigit;
+ static const mask punct = _ISpunct;
+ static const mask xdigit = _ISxdigit;
+ static const mask blank = _ISblank;
+#if defined(__mips__)
+ static const mask __regex_word = static_cast<mask>(_ISbit(15));
+#else
+ static const mask __regex_word = 0x80;
+#endif
+#elif defined(_LIBCPP_MSVCRT_LIKE)
+ typedef unsigned short mask;
+ static const mask space = _SPACE;
+ static const mask print = _BLANK|_PUNCT|_ALPHA|_DIGIT;
+ static const mask cntrl = _CONTROL;
+ static const mask upper = _UPPER;
+ static const mask lower = _LOWER;
+ static const mask alpha = _ALPHA;
+ static const mask digit = _DIGIT;
+ static const mask punct = _PUNCT;
+ static const mask xdigit = _HEX;
+ static const mask blank = _BLANK;
+ static const mask __regex_word = 0x4000; // 0x8000 and 0x0100 and 0x00ff are used
+# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
+#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
+# ifdef __APPLE__
+ typedef __uint32_t mask;
+# elif defined(__FreeBSD__)
+ typedef unsigned long mask;
+# elif defined(__EMSCRIPTEN__) || defined(__NetBSD__)
+ typedef unsigned short mask;
+# endif
+ static const mask space = _CTYPE_S;
+ static const mask print = _CTYPE_R;
+ static const mask cntrl = _CTYPE_C;
+ static const mask upper = _CTYPE_U;
+ static const mask lower = _CTYPE_L;
+ static const mask alpha = _CTYPE_A;
+ static const mask digit = _CTYPE_D;
+ static const mask punct = _CTYPE_P;
+ static const mask xdigit = _CTYPE_X;
+
+# if defined(__NetBSD__)
+ static const mask blank = _CTYPE_BL;
+ // NetBSD defines classes up to 0x2000
+ // see sys/ctype_bits.h, _CTYPE_Q
+ static const mask __regex_word = 0x8000;
+# else
+ static const mask blank = _CTYPE_B;
+ static const mask __regex_word = 0x80;
+# endif
+#elif defined(__sun__) || defined(_AIX)
+ typedef unsigned int mask;
+ static const mask space = _ISSPACE;
+ static const mask print = _ISPRINT;
+ static const mask cntrl = _ISCNTRL;
+ static const mask upper = _ISUPPER;
+ static const mask lower = _ISLOWER;
+ static const mask alpha = _ISALPHA;
+ static const mask digit = _ISDIGIT;
+ static const mask punct = _ISPUNCT;
+ static const mask xdigit = _ISXDIGIT;
+ static const mask blank = _ISBLANK;
+ static const mask __regex_word = 0x80;
+#elif defined(_NEWLIB_VERSION)
+ // Same type as Newlib's _ctype_ array in newlib/libc/include/ctype.h.
+ typedef char mask;
+ static const mask space = _S;
+ static const mask print = _P | _U | _L | _N | _B;
+ static const mask cntrl = _C;
+ static const mask upper = _U;
+ static const mask lower = _L;
+ static const mask alpha = _U | _L;
+ static const mask digit = _N;
+ static const mask punct = _P;
+ static const mask xdigit = _X | _N;
+ static const mask blank = _B;
+ static const mask __regex_word = 0x80;
+# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
+# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
+# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT
+#elif defined(__MVS__)
+# if defined(__NATIVE_ASCII_F)
+ typedef unsigned int mask;
+ static const mask space = _ISSPACE_A;
+ static const mask print = _ISPRINT_A;
+ static const mask cntrl = _ISCNTRL_A;
+ static const mask upper = _ISUPPER_A;
+ static const mask lower = _ISLOWER_A;
+ static const mask alpha = _ISALPHA_A;
+ static const mask digit = _ISDIGIT_A;
+ static const mask punct = _ISPUNCT_A;
+ static const mask xdigit = _ISXDIGIT_A;
+ static const mask blank = _ISBLANK_A;
+# else
+ typedef unsigned short mask;
+ static const mask space = __ISSPACE;
+ static const mask print = __ISPRINT;
+ static const mask cntrl = __ISCNTRL;
+ static const mask upper = __ISUPPER;
+ static const mask lower = __ISLOWER;
+ static const mask alpha = __ISALPHA;
+ static const mask digit = __ISDIGIT;
+ static const mask punct = __ISPUNCT;
+ static const mask xdigit = __ISXDIGIT;
+ static const mask blank = __ISBLANK;
+# endif
+ static const mask __regex_word = 0x8000;
+#else
+# error unknown rune table for this platform -- do you mean to define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE?
+#endif
+ static const mask alnum = alpha | digit;
+ static const mask graph = alnum | punct;
+
+ _LIBCPP_INLINE_VISIBILITY ctype_base() {}
+
+// TODO: Remove the ifndef when the assert no longer fails on AIX.
+#ifndef _AIX
+ static_assert((__regex_word & ~(space | print | cntrl | upper | lower | alpha | digit | punct | xdigit | blank)) == __regex_word,
+ "__regex_word can't overlap other bits");
+#endif
+};
+
+template <class _CharT> class _LIBCPP_TEMPLATE_VIS ctype;
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+class _LIBCPP_TYPE_VIS ctype<wchar_t>
+ : public locale::facet,
+ public ctype_base
+{
+public:
+ typedef wchar_t char_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit ctype(size_t __refs = 0)
+ : locale::facet(__refs) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool is(mask __m, char_type __c) const
+ {
+ return do_is(__m, __c);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const
+ {
+ return do_is(__low, __high, __vec);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ const char_type* scan_is(mask __m, const char_type* __low, const char_type* __high) const
+ {
+ return do_scan_is(__m, __low, __high);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const
+ {
+ return do_scan_not(__m, __low, __high);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ char_type toupper(char_type __c) const
+ {
+ return do_toupper(__c);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ const char_type* toupper(char_type* __low, const char_type* __high) const
+ {
+ return do_toupper(__low, __high);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ char_type tolower(char_type __c) const
+ {
+ return do_tolower(__c);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ const char_type* tolower(char_type* __low, const char_type* __high) const
+ {
+ return do_tolower(__low, __high);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ char_type widen(char __c) const
+ {
+ return do_widen(__c);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ const char* widen(const char* __low, const char* __high, char_type* __to) const
+ {
+ return do_widen(__low, __high, __to);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ char narrow(char_type __c, char __dfault) const
+ {
+ return do_narrow(__c, __dfault);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ const char_type* narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const
+ {
+ return do_narrow(__low, __high, __dfault, __to);
+ }
+
+ static locale::id id;
+
+protected:
+ ~ctype();
+ virtual bool do_is(mask __m, char_type __c) const;
+ virtual const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const;
+ virtual const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const;
+ virtual const char_type* do_scan_not(mask __m, const char_type* __low, const char_type* __high) const;
+ virtual char_type do_toupper(char_type) const;
+ virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;
+ virtual char_type do_tolower(char_type) const;
+ virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const;
+ virtual char_type do_widen(char) const;
+ virtual const char* do_widen(const char* __low, const char* __high, char_type* __dest) const;
+ virtual char do_narrow(char_type, char __dfault) const;
+ virtual const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const;
+};
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+template <>
+class _LIBCPP_TYPE_VIS ctype<char>
+ : public locale::facet, public ctype_base
+{
+ const mask* __tab_;
+ bool __del_;
+public:
+ typedef char char_type;
+
+ explicit ctype(const mask* __tab = nullptr, bool __del = false, size_t __refs = 0);
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool is(mask __m, char_type __c) const
+ {
+ return isascii(__c) ? (__tab_[static_cast<int>(__c)] & __m) !=0 : false;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const
+ {
+ for (; __low != __high; ++__low, ++__vec)
+ *__vec = isascii(*__low) ? __tab_[static_cast<int>(*__low)] : 0;
+ return __low;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ const char_type* scan_is (mask __m, const char_type* __low, const char_type* __high) const
+ {
+ for (; __low != __high; ++__low)
+ if (isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m))
+ break;
+ return __low;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const
+ {
+ for (; __low != __high; ++__low)
+ if (!(isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m)))
+ break;
+ return __low;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ char_type toupper(char_type __c) const
+ {
+ return do_toupper(__c);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ const char_type* toupper(char_type* __low, const char_type* __high) const
+ {
+ return do_toupper(__low, __high);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ char_type tolower(char_type __c) const
+ {
+ return do_tolower(__c);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ const char_type* tolower(char_type* __low, const char_type* __high) const
+ {
+ return do_tolower(__low, __high);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ char_type widen(char __c) const
+ {
+ return do_widen(__c);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ const char* widen(const char* __low, const char* __high, char_type* __to) const
+ {
+ return do_widen(__low, __high, __to);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ char narrow(char_type __c, char __dfault) const
+ {
+ return do_narrow(__c, __dfault);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ const char* narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const
+ {
+ return do_narrow(__low, __high, __dfault, __to);
+ }
+
+ static locale::id id;
+
+#ifdef _CACHED_RUNES
+ static const size_t table_size = _CACHED_RUNES;
+#else
+ static const size_t table_size = 256; // FIXME: Don't hardcode this.
+#endif
+ _LIBCPP_INLINE_VISIBILITY const mask* table() const _NOEXCEPT {return __tab_;}
+ static const mask* classic_table() _NOEXCEPT;
+#if defined(__GLIBC__) || defined(__EMSCRIPTEN__)
+ static const int* __classic_upper_table() _NOEXCEPT;
+ static const int* __classic_lower_table() _NOEXCEPT;
+#endif
+#if defined(__NetBSD__)
+ static const short* __classic_upper_table() _NOEXCEPT;
+ static const short* __classic_lower_table() _NOEXCEPT;
+#endif
+#if defined(__MVS__)
+ static const unsigned short* __classic_upper_table() _NOEXCEPT;
+ static const unsigned short* __classic_lower_table() _NOEXCEPT;
+#endif
+
+protected:
+ ~ctype();
+ virtual char_type do_toupper(char_type __c) const;
+ virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;
+ virtual char_type do_tolower(char_type __c) const;
+ virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const;
+ virtual char_type do_widen(char __c) const;
+ virtual const char* do_widen(const char* __low, const char* __high, char_type* __to) const;
+ virtual char do_narrow(char_type __c, char __dfault) const;
+ virtual const char* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const;
+};
+
+// template <class CharT> class ctype_byname;
+
+template <class _CharT> class _LIBCPP_TEMPLATE_VIS ctype_byname;
+
+template <>
+class _LIBCPP_TYPE_VIS ctype_byname<char>
+ : public ctype<char>
+{
+ locale_t __l;
+
+public:
+ explicit ctype_byname(const char*, size_t = 0);
+ explicit ctype_byname(const string&, size_t = 0);
+
+protected:
+ ~ctype_byname();
+ virtual char_type do_toupper(char_type) const;
+ virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;
+ virtual char_type do_tolower(char_type) const;
+ virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const;
+};
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+class _LIBCPP_TYPE_VIS ctype_byname<wchar_t>
+ : public ctype<wchar_t>
+{
+ locale_t __l;
+
+public:
+ explicit ctype_byname(const char*, size_t = 0);
+ explicit ctype_byname(const string&, size_t = 0);
+
+protected:
+ ~ctype_byname();
+ virtual bool do_is(mask __m, char_type __c) const;
+ virtual const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const;
+ virtual const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const;
+ virtual const char_type* do_scan_not(mask __m, const char_type* __low, const char_type* __high) const;
+ virtual char_type do_toupper(char_type) const;
+ virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;
+ virtual char_type do_tolower(char_type) const;
+ virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const;
+ virtual char_type do_widen(char) const;
+ virtual const char* do_widen(const char* __low, const char* __high, char_type* __dest) const;
+ virtual char do_narrow(char_type, char __dfault) const;
+ virtual const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const;
+};
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+isspace(_CharT __c, const locale& __loc)
+{
+ return use_facet<ctype<_CharT> >(__loc).is(ctype_base::space, __c);
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+isprint(_CharT __c, const locale& __loc)
+{
+ return use_facet<ctype<_CharT> >(__loc).is(ctype_base::print, __c);
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+iscntrl(_CharT __c, const locale& __loc)
+{
+ return use_facet<ctype<_CharT> >(__loc).is(ctype_base::cntrl, __c);
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+isupper(_CharT __c, const locale& __loc)
+{
+ return use_facet<ctype<_CharT> >(__loc).is(ctype_base::upper, __c);
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+islower(_CharT __c, const locale& __loc)
+{
+ return use_facet<ctype<_CharT> >(__loc).is(ctype_base::lower, __c);
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+isalpha(_CharT __c, const locale& __loc)
+{
+ return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alpha, __c);
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+isdigit(_CharT __c, const locale& __loc)
+{
+ return use_facet<ctype<_CharT> >(__loc).is(ctype_base::digit, __c);
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+ispunct(_CharT __c, const locale& __loc)
+{
+ return use_facet<ctype<_CharT> >(__loc).is(ctype_base::punct, __c);
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+isxdigit(_CharT __c, const locale& __loc)
+{
+ return use_facet<ctype<_CharT> >(__loc).is(ctype_base::xdigit, __c);
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+isalnum(_CharT __c, const locale& __loc)
+{
+ return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alnum, __c);
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+isgraph(_CharT __c, const locale& __loc)
+{
+ return use_facet<ctype<_CharT> >(__loc).is(ctype_base::graph, __c);
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+_CharT
+toupper(_CharT __c, const locale& __loc)
+{
+ return use_facet<ctype<_CharT> >(__loc).toupper(__c);
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+_CharT
+tolower(_CharT __c, const locale& __loc)
+{
+ return use_facet<ctype<_CharT> >(__loc).tolower(__c);
+}
+
+// codecvt_base
+
+class _LIBCPP_TYPE_VIS codecvt_base
+{
+public:
+ _LIBCPP_INLINE_VISIBILITY codecvt_base() {}
+ enum result {ok, partial, error, noconv};
+};
+
+// template <class internT, class externT, class stateT> class codecvt;
+
+template <class _InternT, class _ExternT, class _StateT> class _LIBCPP_TEMPLATE_VIS codecvt;
+
+// template <> class codecvt<char, char, mbstate_t>
+
+template <>
+class _LIBCPP_TYPE_VIS codecvt<char, char, mbstate_t>
+ : public locale::facet,
+ public codecvt_base
+{
+public:
+ typedef char intern_type;
+ typedef char extern_type;
+ typedef mbstate_t state_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit codecvt(size_t __refs = 0)
+ : locale::facet(__refs) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result out(state_type& __st,
+ const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
+ {
+ return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ result unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
+ {
+ return do_unshift(__st, __to, __to_end, __to_nxt);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ result in(state_type& __st,
+ const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+ intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
+ {
+ return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ int encoding() const _NOEXCEPT
+ {
+ return do_encoding();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool always_noconv() const _NOEXCEPT
+ {
+ return do_always_noconv();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
+ {
+ return do_length(__st, __frm, __end, __mx);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ int max_length() const _NOEXCEPT
+ {
+ return do_max_length();
+ }
+
+ static locale::id id;
+
+protected:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit codecvt(const char*, size_t __refs = 0)
+ : locale::facet(__refs) {}
+
+ ~codecvt();
+
+ virtual result do_out(state_type& __st,
+ const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual result do_in(state_type& __st,
+ const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+ intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+ virtual result do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual int do_encoding() const _NOEXCEPT;
+ virtual bool do_always_noconv() const _NOEXCEPT;
+ virtual int do_length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
+ virtual int do_max_length() const _NOEXCEPT;
+};
+
+// template <> class codecvt<wchar_t, char, mbstate_t>
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+class _LIBCPP_TYPE_VIS codecvt<wchar_t, char, mbstate_t>
+ : public locale::facet,
+ public codecvt_base
+{
+ locale_t __l;
+public:
+ typedef wchar_t intern_type;
+ typedef char extern_type;
+ typedef mbstate_t state_type;
+
+ explicit codecvt(size_t __refs = 0);
+
+ _LIBCPP_INLINE_VISIBILITY
+ result out(state_type& __st,
+ const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
+ {
+ return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ result unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
+ {
+ return do_unshift(__st, __to, __to_end, __to_nxt);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ result in(state_type& __st,
+ const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+ intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
+ {
+ return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ int encoding() const _NOEXCEPT
+ {
+ return do_encoding();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool always_noconv() const _NOEXCEPT
+ {
+ return do_always_noconv();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
+ {
+ return do_length(__st, __frm, __end, __mx);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ int max_length() const _NOEXCEPT
+ {
+ return do_max_length();
+ }
+
+ static locale::id id;
+
+protected:
+ explicit codecvt(const char*, size_t __refs = 0);
+
+ ~codecvt();
+
+ virtual result do_out(state_type& __st,
+ const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual result do_in(state_type& __st,
+ const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+ intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+ virtual result do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual int do_encoding() const _NOEXCEPT;
+ virtual bool do_always_noconv() const _NOEXCEPT;
+ virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
+ virtual int do_max_length() const _NOEXCEPT;
+};
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+// template <> class codecvt<char16_t, char, mbstate_t> // deprecated in C++20
+
+template <>
+class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_TYPE_VIS codecvt<char16_t, char, mbstate_t>
+ : public locale::facet,
+ public codecvt_base
+{
+public:
+ typedef char16_t intern_type;
+ typedef char extern_type;
+ typedef mbstate_t state_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit codecvt(size_t __refs = 0)
+ : locale::facet(__refs) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result out(state_type& __st,
+ const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
+ {
+ return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ result unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
+ {
+ return do_unshift(__st, __to, __to_end, __to_nxt);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ result in(state_type& __st,
+ const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+ intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
+ {
+ return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ int encoding() const _NOEXCEPT
+ {
+ return do_encoding();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool always_noconv() const _NOEXCEPT
+ {
+ return do_always_noconv();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
+ {
+ return do_length(__st, __frm, __end, __mx);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ int max_length() const _NOEXCEPT
+ {
+ return do_max_length();
+ }
+
+ static locale::id id;
+
+protected:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit codecvt(const char*, size_t __refs = 0)
+ : locale::facet(__refs) {}
+
+ ~codecvt();
+
+ virtual result do_out(state_type& __st,
+ const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual result do_in(state_type& __st,
+ const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+ intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+ virtual result do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual int do_encoding() const _NOEXCEPT;
+ virtual bool do_always_noconv() const _NOEXCEPT;
+ virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
+ virtual int do_max_length() const _NOEXCEPT;
+};
+
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
+
+// template <> class codecvt<char16_t, char8_t, mbstate_t> // C++20
+
+template <>
+class _LIBCPP_TYPE_VIS codecvt<char16_t, char8_t, mbstate_t>
+ : public locale::facet,
+ public codecvt_base
+{
+public:
+ typedef char16_t intern_type;
+ typedef char8_t extern_type;
+ typedef mbstate_t state_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit codecvt(size_t __refs = 0)
+ : locale::facet(__refs) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result out(state_type& __st,
+ const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
+ {
+ return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ result unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
+ {
+ return do_unshift(__st, __to, __to_end, __to_nxt);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ result in(state_type& __st,
+ const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+ intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
+ {
+ return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ int encoding() const _NOEXCEPT
+ {
+ return do_encoding();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool always_noconv() const _NOEXCEPT
+ {
+ return do_always_noconv();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
+ {
+ return do_length(__st, __frm, __end, __mx);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ int max_length() const _NOEXCEPT
+ {
+ return do_max_length();
+ }
+
+ static locale::id id;
+
+protected:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit codecvt(const char*, size_t __refs = 0)
+ : locale::facet(__refs) {}
+
+ ~codecvt();
+
+ virtual result do_out(state_type& __st,
+ const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual result do_in(state_type& __st,
+ const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+ intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+ virtual result do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual int do_encoding() const _NOEXCEPT;
+ virtual bool do_always_noconv() const _NOEXCEPT;
+ virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
+ virtual int do_max_length() const _NOEXCEPT;
+};
+
+#endif
+
+// template <> class codecvt<char32_t, char, mbstate_t> // deprecated in C++20
+
+template <>
+class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_TYPE_VIS codecvt<char32_t, char, mbstate_t>
+ : public locale::facet,
+ public codecvt_base
+{
+public:
+ typedef char32_t intern_type;
+ typedef char extern_type;
+ typedef mbstate_t state_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit codecvt(size_t __refs = 0)
+ : locale::facet(__refs) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result out(state_type& __st,
+ const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
+ {
+ return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ result unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
+ {
+ return do_unshift(__st, __to, __to_end, __to_nxt);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ result in(state_type& __st,
+ const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+ intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
+ {
+ return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ int encoding() const _NOEXCEPT
+ {
+ return do_encoding();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool always_noconv() const _NOEXCEPT
+ {
+ return do_always_noconv();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
+ {
+ return do_length(__st, __frm, __end, __mx);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ int max_length() const _NOEXCEPT
+ {
+ return do_max_length();
+ }
+
+ static locale::id id;
+
+protected:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit codecvt(const char*, size_t __refs = 0)
+ : locale::facet(__refs) {}
+
+ ~codecvt();
+
+ virtual result do_out(state_type& __st,
+ const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual result do_in(state_type& __st,
+ const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+ intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+ virtual result do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual int do_encoding() const _NOEXCEPT;
+ virtual bool do_always_noconv() const _NOEXCEPT;
+ virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
+ virtual int do_max_length() const _NOEXCEPT;
+};
+
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
+
+// template <> class codecvt<char32_t, char8_t, mbstate_t> // C++20
+
+template <>
+class _LIBCPP_TYPE_VIS codecvt<char32_t, char8_t, mbstate_t>
+ : public locale::facet,
+ public codecvt_base
+{
+public:
+ typedef char32_t intern_type;
+ typedef char8_t extern_type;
+ typedef mbstate_t state_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit codecvt(size_t __refs = 0)
+ : locale::facet(__refs) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result out(state_type& __st,
+ const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
+ {
+ return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ result unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
+ {
+ return do_unshift(__st, __to, __to_end, __to_nxt);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ result in(state_type& __st,
+ const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+ intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
+ {
+ return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ int encoding() const _NOEXCEPT
+ {
+ return do_encoding();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool always_noconv() const _NOEXCEPT
+ {
+ return do_always_noconv();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
+ {
+ return do_length(__st, __frm, __end, __mx);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ int max_length() const _NOEXCEPT
+ {
+ return do_max_length();
+ }
+
+ static locale::id id;
+
+protected:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit codecvt(const char*, size_t __refs = 0)
+ : locale::facet(__refs) {}
+
+ ~codecvt();
+
+ virtual result do_out(state_type& __st,
+ const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual result do_in(state_type& __st,
+ const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+ intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+ virtual result do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual int do_encoding() const _NOEXCEPT;
+ virtual bool do_always_noconv() const _NOEXCEPT;
+ virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
+ virtual int do_max_length() const _NOEXCEPT;
+};
+
+#endif
+
+// template <class _InternT, class _ExternT, class _StateT> class codecvt_byname
+
+template <class _InternT, class _ExternT, class _StateT>
+class _LIBCPP_TEMPLATE_VIS codecvt_byname
+ : public codecvt<_InternT, _ExternT, _StateT>
+{
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit codecvt_byname(const char* __nm, size_t __refs = 0)
+ : codecvt<_InternT, _ExternT, _StateT>(__nm, __refs) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit codecvt_byname(const string& __nm, size_t __refs = 0)
+ : codecvt<_InternT, _ExternT, _StateT>(__nm.c_str(), __refs) {}
+protected:
+ ~codecvt_byname();
+};
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <class _InternT, class _ExternT, class _StateT>
+codecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname()
+{
+}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char, char, mbstate_t>)
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>)
+#endif
+_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_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
+
+template <size_t _Np>
+struct __narrow_to_utf8
+{
+ template <class _OutputIterator, class _CharT>
+ _OutputIterator
+ operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const;
+};
+
+template <>
+struct __narrow_to_utf8<8>
+{
+ template <class _OutputIterator, class _CharT>
+ _LIBCPP_INLINE_VISIBILITY
+ _OutputIterator
+ operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const
+ {
+ for (; __wb < __we; ++__wb, ++__s)
+ *__s = *__wb;
+ return __s;
+ }
+};
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <>
+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
+
+ ~__narrow_to_utf8();
+
+ template <class _OutputIterator, class _CharT>
+ _LIBCPP_INLINE_VISIBILITY
+ _OutputIterator
+ operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const
+ {
+ result __r = ok;
+ mbstate_t __mb;
+ while (__wb < __we && __r != error)
+ {
+ const int __sz = 32;
+ char __buf[__sz];
+ char* __bn;
+ const char16_t* __wn = (const char16_t*)__wb;
+ __r = do_out(__mb, (const char16_t*)__wb, (const char16_t*)__we, __wn,
+ __buf, __buf+__sz, __bn);
+ if (__r == codecvt_base::error || __wn == (const char16_t*)__wb)
+ __throw_runtime_error("locale not supported");
+ for (const char* __p = __buf; __p < __bn; ++__p, ++__s)
+ *__s = *__p;
+ __wb = (const _CharT*)__wn;
+ }
+ return __s;
+ }
+};
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <>
+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
+
+ ~__narrow_to_utf8();
+
+ template <class _OutputIterator, class _CharT>
+ _LIBCPP_INLINE_VISIBILITY
+ _OutputIterator
+ operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const
+ {
+ result __r = ok;
+ mbstate_t __mb;
+ while (__wb < __we && __r != error)
+ {
+ const int __sz = 32;
+ char __buf[__sz];
+ char* __bn;
+ const char32_t* __wn = (const char32_t*)__wb;
+ __r = do_out(__mb, (const char32_t*)__wb, (const char32_t*)__we, __wn,
+ __buf, __buf+__sz, __bn);
+ if (__r == codecvt_base::error || __wn == (const char32_t*)__wb)
+ __throw_runtime_error("locale not supported");
+ for (const char* __p = __buf; __p < __bn; ++__p, ++__s)
+ *__s = *__p;
+ __wb = (const _CharT*)__wn;
+ }
+ return __s;
+ }
+};
+
+template <size_t _Np>
+struct __widen_from_utf8
+{
+ template <class _OutputIterator>
+ _OutputIterator
+ operator()(_OutputIterator __s, const char* __nb, const char* __ne) const;
+};
+
+template <>
+struct __widen_from_utf8<8>
+{
+ template <class _OutputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ _OutputIterator
+ operator()(_OutputIterator __s, const char* __nb, const char* __ne) const
+ {
+ for (; __nb < __ne; ++__nb, ++__s)
+ *__s = *__nb;
+ return __s;
+ }
+};
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <>
+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
+
+ ~__widen_from_utf8();
+
+ template <class _OutputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ _OutputIterator
+ operator()(_OutputIterator __s, const char* __nb, const char* __ne) const
+ {
+ result __r = ok;
+ mbstate_t __mb;
+ while (__nb < __ne && __r != error)
+ {
+ const int __sz = 32;
+ char16_t __buf[__sz];
+ char16_t* __bn;
+ const char* __nn = __nb;
+ __r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb+__sz : __ne, __nn,
+ __buf, __buf+__sz, __bn);
+ if (__r == codecvt_base::error || __nn == __nb)
+ __throw_runtime_error("locale not supported");
+ for (const char16_t* __p = __buf; __p < __bn; ++__p, ++__s)
+ *__s = *__p;
+ __nb = __nn;
+ }
+ return __s;
+ }
+};
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <>
+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
+
+ ~__widen_from_utf8();
+
+ template <class _OutputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ _OutputIterator
+ operator()(_OutputIterator __s, const char* __nb, const char* __ne) const
+ {
+ result __r = ok;
+ mbstate_t __mb;
+ while (__nb < __ne && __r != error)
+ {
+ const int __sz = 32;
+ char32_t __buf[__sz];
+ char32_t* __bn;
+ const char* __nn = __nb;
+ __r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb+__sz : __ne, __nn,
+ __buf, __buf+__sz, __bn);
+ if (__r == codecvt_base::error || __nn == __nb)
+ __throw_runtime_error("locale not supported");
+ for (const char32_t* __p = __buf; __p < __bn; ++__p, ++__s)
+ *__s = *__p;
+ __nb = __nn;
+ }
+ return __s;
+ }
+};
+
+// template <class charT> class numpunct
+
+template <class _CharT> class _LIBCPP_TEMPLATE_VIS numpunct;
+
+template <>
+class _LIBCPP_TYPE_VIS numpunct<char>
+ : public locale::facet
+{
+public:
+ typedef char char_type;
+ typedef basic_string<char_type> string_type;
+
+ explicit numpunct(size_t __refs = 0);
+
+ _LIBCPP_INLINE_VISIBILITY char_type decimal_point() const {return do_decimal_point();}
+ _LIBCPP_INLINE_VISIBILITY char_type thousands_sep() const {return do_thousands_sep();}
+ _LIBCPP_INLINE_VISIBILITY string grouping() const {return do_grouping();}
+ _LIBCPP_INLINE_VISIBILITY string_type truename() const {return do_truename();}
+ _LIBCPP_INLINE_VISIBILITY string_type falsename() const {return do_falsename();}
+
+ static locale::id id;
+
+protected:
+ ~numpunct();
+ virtual char_type do_decimal_point() const;
+ virtual char_type do_thousands_sep() const;
+ virtual string do_grouping() const;
+ virtual string_type do_truename() const;
+ virtual string_type do_falsename() const;
+
+ char_type __decimal_point_;
+ char_type __thousands_sep_;
+ string __grouping_;
+};
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+class _LIBCPP_TYPE_VIS numpunct<wchar_t>
+ : public locale::facet
+{
+public:
+ typedef wchar_t char_type;
+ typedef basic_string<char_type> string_type;
+
+ explicit numpunct(size_t __refs = 0);
+
+ _LIBCPP_INLINE_VISIBILITY char_type decimal_point() const {return do_decimal_point();}
+ _LIBCPP_INLINE_VISIBILITY char_type thousands_sep() const {return do_thousands_sep();}
+ _LIBCPP_INLINE_VISIBILITY string grouping() const {return do_grouping();}
+ _LIBCPP_INLINE_VISIBILITY string_type truename() const {return do_truename();}
+ _LIBCPP_INLINE_VISIBILITY string_type falsename() const {return do_falsename();}
+
+ static locale::id id;
+
+protected:
+ ~numpunct();
+ virtual char_type do_decimal_point() const;
+ virtual char_type do_thousands_sep() const;
+ virtual string do_grouping() const;
+ virtual string_type do_truename() const;
+ virtual string_type do_falsename() const;
+
+ char_type __decimal_point_;
+ char_type __thousands_sep_;
+ string __grouping_;
+};
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+// template <class charT> class numpunct_byname
+
+template <class _CharT> class _LIBCPP_TEMPLATE_VIS numpunct_byname;
+
+template <>
+class _LIBCPP_TYPE_VIS numpunct_byname<char>
+: public numpunct<char>
+{
+public:
+ typedef char char_type;
+ typedef basic_string<char_type> string_type;
+
+ explicit numpunct_byname(const char* __nm, size_t __refs = 0);
+ explicit numpunct_byname(const string& __nm, size_t __refs = 0);
+
+protected:
+ ~numpunct_byname();
+
+private:
+ void __init(const char*);
+};
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+class _LIBCPP_TYPE_VIS numpunct_byname<wchar_t>
+: public numpunct<wchar_t>
+{
+public:
+ typedef wchar_t char_type;
+ typedef basic_string<char_type> string_type;
+
+ explicit numpunct_byname(const char* __nm, size_t __refs = 0);
+ explicit numpunct_byname(const string& __nm, size_t __refs = 0);
+
+protected:
+ ~numpunct_byname();
+
+private:
+ void __init(const char*);
+};
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___LOCALE
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__mbstate_t.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__mbstate_t.h
new file mode 100644
index 0000000000..487a6d092c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__mbstate_t.h
@@ -0,0 +1,44 @@
+// -*- 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___MBSTATE_T_H
+#define _LIBCPP___MBSTATE_T_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+// TODO(ldionne):
+// The goal of this header is to provide mbstate_t without having to pull in
+// <wchar.h> or <uchar.h>. This is necessary because we need that type even
+// when we don't have (or try to provide) support for wchar_t, because several
+// types like std::fpos are defined in terms of mbstate_t.
+//
+// This is a gruesome hack, but I don't know how to make it cleaner for
+// the time being.
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# include <wchar.h> // for mbstate_t
+#elif __has_include(<bits/types/mbstate_t.h>)
+# include <bits/types/mbstate_t.h> // works on most Unixes
+#elif __has_include(<sys/_types/_mbstate_t.h>)
+# include <sys/_types/_mbstate_t.h> // works on Darwin
+#else
+# error "The library was configured without support for wide-characters, but we don't know how to get the definition of mbstate_t without <wchar.h> on your platform."
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+using ::mbstate_t _LIBCPP_USING_IF_EXISTS;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___MBSTATE_T_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/addressof.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/addressof.h
new file mode 100644
index 0000000000..75e3dd0647
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/addressof.h
@@ -0,0 +1,76 @@
+// -*- 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_ADDRESSOF_H
+#define _LIBCPP___MEMORY_ADDRESSOF_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+inline _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
+_Tp*
+addressof(_Tp& __x) _NOEXCEPT
+{
+ return __builtin_addressof(__x);
+}
+
+#if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
+// Objective-C++ Automatic Reference Counting uses qualified pointers
+// that require special addressof() signatures. When
+// _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler
+// itself is providing these definitions. Otherwise, we provide them.
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+__strong _Tp*
+addressof(__strong _Tp& __x) _NOEXCEPT
+{
+ return &__x;
+}
+
+#ifdef _LIBCPP_HAS_OBJC_ARC_WEAK
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+__weak _Tp*
+addressof(__weak _Tp& __x) _NOEXCEPT
+{
+ return &__x;
+}
+#endif
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+__autoreleasing _Tp*
+addressof(__autoreleasing _Tp& __x) _NOEXCEPT
+{
+ return &__x;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+__unsafe_unretained _Tp*
+addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
+{
+ return &__x;
+}
+#endif
+
+#if !defined(_LIBCPP_CXX03_LANG)
+template <class _Tp> _Tp* addressof(const _Tp&&) noexcept = delete;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___MEMORY_ADDRESSOF_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/allocation_guard.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/allocation_guard.h
new file mode 100644
index 0000000000..424598cc81
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/allocation_guard.h
@@ -0,0 +1,83 @@
+// -*- 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_ALLOCATION_GUARD_H
+#define _LIBCPP___MEMORY_ALLOCATION_GUARD_H
+
+#include <__config>
+#include <__memory/allocator_traits.h>
+#include <__utility/move.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// Helper class to allocate memory using an Allocator in an exception safe
+// manner.
+//
+// The intended usage of this class is as follows:
+//
+// 0
+// 1 __allocation_guard<SomeAllocator> guard(alloc, 10);
+// 2 do_some_initialization_that_may_throw(guard.__get());
+// 3 save_allocated_pointer_in_a_noexcept_operation(guard.__release_ptr());
+// 4
+//
+// If line (2) throws an exception during initialization of the memory, the
+// guard's destructor will be called, and the memory will be released using
+// Allocator deallocation. Otherwise, we release the memory from the guard on
+// line (3) in an operation that can't throw -- after that, the guard is not
+// responsible for the memory anymore.
+//
+// This is similar to a unique_ptr, except it's easier to use with a
+// custom allocator.
+template<class _Alloc>
+struct __allocation_guard {
+ using _Pointer = typename allocator_traits<_Alloc>::pointer;
+ using _Size = typename allocator_traits<_Alloc>::size_type;
+
+ template<class _AllocT> // we perform the allocator conversion inside the constructor
+ _LIBCPP_HIDE_FROM_ABI
+ explicit __allocation_guard(_AllocT __alloc, _Size __n)
+ : __alloc_(_VSTD::move(__alloc))
+ , __n_(__n)
+ , __ptr_(allocator_traits<_Alloc>::allocate(__alloc_, __n_)) // initialization order is important
+ { }
+
+ _LIBCPP_HIDE_FROM_ABI
+ ~__allocation_guard() _NOEXCEPT {
+ if (__ptr_ != nullptr) {
+ allocator_traits<_Alloc>::deallocate(__alloc_, __ptr_, __n_);
+ }
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ _Pointer __release_ptr() _NOEXCEPT { // not called __release() because it's a keyword in objective-c++
+ _Pointer __tmp = __ptr_;
+ __ptr_ = nullptr;
+ return __tmp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ _Pointer __get() const _NOEXCEPT {
+ return __ptr_;
+ }
+
+private:
+ _Alloc __alloc_;
+ _Size __n_;
+ _Pointer __ptr_;
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___MEMORY_ALLOCATION_GUARD_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/allocator.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/allocator.h
new file mode 100644
index 0000000000..cd02a22df7
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/allocator.h
@@ -0,0 +1,249 @@
+// -*- 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_BEGIN_NAMESPACE_STD
+
+template <class _Tp> class allocator;
+
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
+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> >
+{
+ static_assert(!is_volatile<_Tp>::value, "std::allocator does not support volatile types");
+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 = 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_bad_array_new_length();
+ 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((void*)__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> >
+{
+ static_assert(!is_volatile<_Tp>::value, "std::allocator does not support volatile types");
+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 = 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_bad_array_new_length();
+ 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
+
+#endif // _LIBCPP___MEMORY_ALLOCATOR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/allocator_arg_t.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/allocator_arg_t.h
new file mode 100644
index 0000000000..2d63b1f905
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/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
+/* inline */ 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 __uncvref_t<_Alloc> _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/libs/cxxsupp/libcxxmsvc/include/__memory/allocator_traits.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/allocator_traits.h
new file mode 100644
index 0000000000..5215556cdf
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/allocator_traits.h
@@ -0,0 +1,405 @@
+// -*- 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_TRAITS_H
+#define _LIBCPP___MEMORY_ALLOCATOR_TRAITS_H
+
+#include <__config>
+#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)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#define _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(NAME, PROPERTY) \
+ template <class _Tp, class = void> struct NAME : false_type { }; \
+ template <class _Tp> struct NAME<_Tp, typename __void_t<typename _Tp:: PROPERTY >::type> : true_type { }
+
+// __pointer
+_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_pointer, pointer);
+template <class _Tp, class _Alloc,
+ class _RawAlloc = typename remove_reference<_Alloc>::type,
+ bool = __has_pointer<_RawAlloc>::value>
+struct __pointer {
+ using type _LIBCPP_NODEBUG = typename _RawAlloc::pointer;
+};
+template <class _Tp, class _Alloc, class _RawAlloc>
+struct __pointer<_Tp, _Alloc, _RawAlloc, false> {
+ using type _LIBCPP_NODEBUG = _Tp*;
+};
+
+// __const_pointer
+_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_const_pointer, const_pointer);
+template <class _Tp, class _Ptr, class _Alloc,
+ bool = __has_const_pointer<_Alloc>::value>
+struct __const_pointer {
+ using type _LIBCPP_NODEBUG = typename _Alloc::const_pointer;
+};
+template <class _Tp, class _Ptr, class _Alloc>
+struct __const_pointer<_Tp, _Ptr, _Alloc, false> {
+#ifdef _LIBCPP_CXX03_LANG
+ using type = typename pointer_traits<_Ptr>::template rebind<const _Tp>::other;
+#else
+ using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<const _Tp>;
+#endif
+};
+
+// __void_pointer
+_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_void_pointer, void_pointer);
+template <class _Ptr, class _Alloc,
+ bool = __has_void_pointer<_Alloc>::value>
+struct __void_pointer {
+ using type _LIBCPP_NODEBUG = typename _Alloc::void_pointer;
+};
+template <class _Ptr, class _Alloc>
+struct __void_pointer<_Ptr, _Alloc, false> {
+#ifdef _LIBCPP_CXX03_LANG
+ using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<void>::other;
+#else
+ using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<void>;
+#endif
+};
+
+// __const_void_pointer
+_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_const_void_pointer, const_void_pointer);
+template <class _Ptr, class _Alloc,
+ bool = __has_const_void_pointer<_Alloc>::value>
+struct __const_void_pointer {
+ using type _LIBCPP_NODEBUG = typename _Alloc::const_void_pointer;
+};
+template <class _Ptr, class _Alloc>
+struct __const_void_pointer<_Ptr, _Alloc, false> {
+#ifdef _LIBCPP_CXX03_LANG
+ using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<const void>::other;
+#else
+ using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<const void>;
+#endif
+};
+
+// __size_type
+_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_size_type, size_type);
+template <class _Alloc, class _DiffType, bool = __has_size_type<_Alloc>::value>
+struct __size_type : make_unsigned<_DiffType> { };
+template <class _Alloc, class _DiffType>
+struct __size_type<_Alloc, _DiffType, true> {
+ using type _LIBCPP_NODEBUG = typename _Alloc::size_type;
+};
+
+// __alloc_traits_difference_type
+_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_alloc_traits_difference_type, difference_type);
+template <class _Alloc, class _Ptr, bool = __has_alloc_traits_difference_type<_Alloc>::value>
+struct __alloc_traits_difference_type {
+ using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::difference_type;
+};
+template <class _Alloc, class _Ptr>
+struct __alloc_traits_difference_type<_Alloc, _Ptr, true> {
+ using type _LIBCPP_NODEBUG = typename _Alloc::difference_type;
+};
+
+// __propagate_on_container_copy_assignment
+_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_propagate_on_container_copy_assignment, propagate_on_container_copy_assignment);
+template <class _Alloc, bool = __has_propagate_on_container_copy_assignment<_Alloc>::value>
+struct __propagate_on_container_copy_assignment : false_type { };
+template <class _Alloc>
+struct __propagate_on_container_copy_assignment<_Alloc, true> {
+ using type _LIBCPP_NODEBUG = typename _Alloc::propagate_on_container_copy_assignment;
+};
+
+// __propagate_on_container_move_assignment
+_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_propagate_on_container_move_assignment, propagate_on_container_move_assignment);
+template <class _Alloc, bool = __has_propagate_on_container_move_assignment<_Alloc>::value>
+struct __propagate_on_container_move_assignment : false_type { };
+template <class _Alloc>
+struct __propagate_on_container_move_assignment<_Alloc, true> {
+ using type _LIBCPP_NODEBUG = typename _Alloc::propagate_on_container_move_assignment;
+};
+
+// __propagate_on_container_swap
+_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_propagate_on_container_swap, propagate_on_container_swap);
+template <class _Alloc, bool = __has_propagate_on_container_swap<_Alloc>::value>
+struct __propagate_on_container_swap : false_type { };
+template <class _Alloc>
+struct __propagate_on_container_swap<_Alloc, true> {
+ using type _LIBCPP_NODEBUG = typename _Alloc::propagate_on_container_swap;
+};
+
+// __is_always_equal
+_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_is_always_equal, is_always_equal);
+template <class _Alloc, bool = __has_is_always_equal<_Alloc>::value>
+struct __is_always_equal : is_empty<_Alloc> { };
+template <class _Alloc>
+struct __is_always_equal<_Alloc, true> {
+ using type _LIBCPP_NODEBUG = typename _Alloc::is_always_equal;
+};
+
+// __allocator_traits_rebind
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <class _Tp, class _Up, class = void>
+struct __has_rebind_other : false_type { };
+template <class _Tp, class _Up>
+struct __has_rebind_other<_Tp, _Up, typename __void_t<
+ typename _Tp::template rebind<_Up>::other
+>::type> : true_type { };
+
+template <class _Tp, class _Up, bool = __has_rebind_other<_Tp, _Up>::value>
+struct __allocator_traits_rebind {
+ using type _LIBCPP_NODEBUG = typename _Tp::template rebind<_Up>::other;
+};
+template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up>
+struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, true> {
+ using type _LIBCPP_NODEBUG = typename _Alloc<_Tp, _Args...>::template rebind<_Up>::other;
+};
+template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up>
+struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, false> {
+ using type _LIBCPP_NODEBUG = _Alloc<_Up, _Args...>;
+};
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+
+template<class _Alloc, class _Tp>
+using __allocator_traits_rebind_t = typename __allocator_traits_rebind<_Alloc, _Tp>::type;
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+
+// __has_allocate_hint
+template <class _Alloc, class _SizeType, class _ConstVoidPtr, class = void>
+struct __has_allocate_hint : false_type { };
+
+template <class _Alloc, class _SizeType, class _ConstVoidPtr>
+struct __has_allocate_hint<_Alloc, _SizeType, _ConstVoidPtr, decltype(
+ (void)declval<_Alloc>().allocate(declval<_SizeType>(), declval<_ConstVoidPtr>())
+)> : true_type { };
+
+// __has_construct
+template <class, class _Alloc, class ..._Args>
+struct __has_construct_impl : false_type { };
+
+template <class _Alloc, class ..._Args>
+struct __has_construct_impl<decltype(
+ (void)declval<_Alloc>().construct(declval<_Args>()...)
+), _Alloc, _Args...> : true_type { };
+
+template <class _Alloc, class ..._Args>
+struct __has_construct : __has_construct_impl<void, _Alloc, _Args...> { };
+
+// __has_destroy
+template <class _Alloc, class _Pointer, class = void>
+struct __has_destroy : false_type { };
+
+template <class _Alloc, class _Pointer>
+struct __has_destroy<_Alloc, _Pointer, decltype(
+ (void)declval<_Alloc>().destroy(declval<_Pointer>())
+)> : true_type { };
+
+// __has_max_size
+template <class _Alloc, class = void>
+struct __has_max_size : false_type { };
+
+template <class _Alloc>
+struct __has_max_size<_Alloc, decltype(
+ (void)declval<_Alloc&>().max_size()
+)> : true_type { };
+
+// __has_select_on_container_copy_construction
+template <class _Alloc, class = void>
+struct __has_select_on_container_copy_construction : false_type { };
+
+template <class _Alloc>
+struct __has_select_on_container_copy_construction<_Alloc, decltype(
+ (void)declval<_Alloc>().select_on_container_copy_construction()
+)> : true_type { };
+
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+
+template <class _Alloc>
+struct _LIBCPP_TEMPLATE_VIS allocator_traits
+{
+ using allocator_type = _Alloc;
+ using value_type = typename allocator_type::value_type;
+ using pointer = typename __pointer<value_type, allocator_type>::type;
+ using const_pointer = typename __const_pointer<value_type, pointer, allocator_type>::type;
+ using void_pointer = typename __void_pointer<pointer, allocator_type>::type;
+ using const_void_pointer = typename __const_void_pointer<pointer, allocator_type>::type;
+ using difference_type = typename __alloc_traits_difference_type<allocator_type, pointer>::type;
+ using size_type = typename __size_type<allocator_type, difference_type>::type;
+ using propagate_on_container_copy_assignment = typename __propagate_on_container_copy_assignment<allocator_type>::type;
+ using propagate_on_container_move_assignment = typename __propagate_on_container_move_assignment<allocator_type>::type;
+ using propagate_on_container_swap = typename __propagate_on_container_swap<allocator_type>::type;
+ using is_always_equal = typename __is_always_equal<allocator_type>::type;
+
+#ifndef _LIBCPP_CXX03_LANG
+ template <class _Tp>
+ using rebind_alloc = __allocator_traits_rebind_t<allocator_type, _Tp>;
+ template <class _Tp>
+ using rebind_traits = allocator_traits<rebind_alloc<_Tp> >;
+#else // _LIBCPP_CXX03_LANG
+ template <class _Tp>
+ struct rebind_alloc {
+ using other = __allocator_traits_rebind_t<allocator_type, _Tp>;
+ };
+ template <class _Tp>
+ struct rebind_traits {
+ using other = allocator_traits<typename rebind_alloc<_Tp>::other>;
+ };
+#endif // _LIBCPP_CXX03_LANG
+
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static pointer allocate(allocator_type& __a, size_type __n) {
+ return __a.allocate(__n);
+ }
+
+ template <class _Ap = _Alloc, class =
+ __enable_if_t<__has_allocate_hint<_Ap, size_type, const_void_pointer>::value> >
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer __hint) {
+ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
+ return __a.allocate(__n, __hint);
+ _LIBCPP_SUPPRESS_DEPRECATED_POP
+ }
+ template <class _Ap = _Alloc, class = void, class =
+ __enable_if_t<!__has_allocate_hint<_Ap, size_type, const_void_pointer>::value> >
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer) {
+ return __a.allocate(__n);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static void deallocate(allocator_type& __a, pointer __p, size_type __n) _NOEXCEPT {
+ __a.deallocate(__p, __n);
+ }
+
+ template <class _Tp, class... _Args, class =
+ __enable_if_t<__has_construct<allocator_type, _Tp*, _Args...>::value> >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static void construct(allocator_type& __a, _Tp* __p, _Args&&... __args) {
+ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
+ __a.construct(__p, _VSTD::forward<_Args>(__args)...);
+ _LIBCPP_SUPPRESS_DEPRECATED_POP
+ }
+ template <class _Tp, class... _Args, class = void, class =
+ __enable_if_t<!__has_construct<allocator_type, _Tp*, _Args...>::value> >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static void construct(allocator_type&, _Tp* __p, _Args&&... __args) {
+#if _LIBCPP_STD_VER > 17
+ _VSTD::construct_at(__p, _VSTD::forward<_Args>(__args)...);
+#else
+ ::new ((void*)__p) _Tp(_VSTD::forward<_Args>(__args)...);
+#endif
+ }
+
+ template <class _Tp, class =
+ __enable_if_t<__has_destroy<allocator_type, _Tp*>::value> >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static void destroy(allocator_type& __a, _Tp* __p) {
+ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
+ __a.destroy(__p);
+ _LIBCPP_SUPPRESS_DEPRECATED_POP
+ }
+ template <class _Tp, class = void, class =
+ __enable_if_t<!__has_destroy<allocator_type, _Tp*>::value> >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static void destroy(allocator_type&, _Tp* __p) {
+#if _LIBCPP_STD_VER > 17
+ _VSTD::destroy_at(__p);
+#else
+ __p->~_Tp();
+#endif
+ }
+
+ template <class _Ap = _Alloc, class =
+ __enable_if_t<__has_max_size<const _Ap>::value> >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static size_type max_size(const allocator_type& __a) _NOEXCEPT {
+ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
+ return __a.max_size();
+ _LIBCPP_SUPPRESS_DEPRECATED_POP
+ }
+ template <class _Ap = _Alloc, class = void, class =
+ __enable_if_t<!__has_max_size<const _Ap>::value> >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static size_type max_size(const allocator_type&) _NOEXCEPT {
+ return numeric_limits<size_type>::max() / sizeof(value_type);
+ }
+
+ template <class _Ap = _Alloc, class =
+ __enable_if_t<__has_select_on_container_copy_construction<const _Ap>::value> >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static allocator_type select_on_container_copy_construction(const allocator_type& __a) {
+ return __a.select_on_container_copy_construction();
+ }
+ template <class _Ap = _Alloc, class = void, class =
+ __enable_if_t<!__has_select_on_container_copy_construction<const _Ap>::value> >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static allocator_type select_on_container_copy_construction(const allocator_type& __a) {
+ return __a;
+ }
+};
+
+template <class _Traits, class _Tp>
+struct __rebind_alloc_helper {
+#ifndef _LIBCPP_CXX03_LANG
+ using type _LIBCPP_NODEBUG = typename _Traits::template rebind_alloc<_Tp>;
+#else
+ using type = typename _Traits::template rebind_alloc<_Tp>::other;
+#endif
+};
+
+// __is_default_allocator
+template <class _Tp>
+struct __is_default_allocator : false_type { };
+
+template <class> class allocator;
+
+template <class _Tp>
+struct __is_default_allocator<allocator<_Tp> > : true_type { };
+
+// __is_cpp17_move_insertable
+template <class _Alloc, class = void>
+struct __is_cpp17_move_insertable
+ : is_move_constructible<typename _Alloc::value_type>
+{ };
+
+template <class _Alloc>
+struct __is_cpp17_move_insertable<_Alloc, __enable_if_t<
+ !__is_default_allocator<_Alloc>::value &&
+ __has_construct<_Alloc, typename _Alloc::value_type*, typename _Alloc::value_type&&>::value
+> > : true_type { };
+
+// __is_cpp17_copy_insertable
+template <class _Alloc, class = void>
+struct __is_cpp17_copy_insertable
+ : integral_constant<bool,
+ is_copy_constructible<typename _Alloc::value_type>::value &&
+ __is_cpp17_move_insertable<_Alloc>::value
+ >
+{ };
+
+template <class _Alloc>
+struct __is_cpp17_copy_insertable<_Alloc, __enable_if_t<
+ !__is_default_allocator<_Alloc>::value &&
+ __has_construct<_Alloc, typename _Alloc::value_type*, const typename _Alloc::value_type&>::value
+> >
+ : __is_cpp17_move_insertable<_Alloc>
+{ };
+
+#undef _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___MEMORY_ALLOCATOR_TRAITS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/auto_ptr.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/auto_ptr.h
new file mode 100644
index 0000000000..163a46b631
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/auto_ptr.h
@@ -0,0 +1,80 @@
+// -*- 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>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___MEMORY_AUTO_PTR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/compressed_pair.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/compressed_pair.h
new file mode 100644
index 0000000000..852031f17d
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/compressed_pair.h
@@ -0,0 +1,166 @@
+// -*- 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 <__utility/move.h>
+#include <tuple> // needed in c++03 for some constructors
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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 {
+ using _ParamT = _Tp;
+ using reference = _Tp&;
+ using const_reference = const _Tp&;
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __compressed_pair_elem(__default_init_tag) {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __compressed_pair_elem(__value_init_tag) : __value_() {}
+
+ template <class _Up, class = __enable_if_t<!is_same<__compressed_pair_elem, typename decay<_Up>::type>::value> >
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit
+ __compressed_pair_elem(_Up&& __u) : __value_(std::forward<_Up>(__u)) {}
+
+#ifndef _LIBCPP_CXX03_LANG
+ template <class... _Args, size_t... _Indices>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ __compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args, __tuple_indices<_Indices...>)
+ : __value_(std::forward<_Args>(std::get<_Indices>(__args))...) {}
+#endif
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference __get() _NOEXCEPT { return __value_; }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __get() const _NOEXCEPT { return __value_; }
+
+private:
+ _Tp __value_;
+};
+
+template <class _Tp, int _Idx>
+struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp {
+ using _ParamT = _Tp;
+ using reference = _Tp&;
+ using const_reference = const _Tp&;
+ using __value_type = _Tp;
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __compressed_pair_elem() = default;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __compressed_pair_elem(__default_init_tag) {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __compressed_pair_elem(__value_init_tag) : __value_type() {}
+
+ template <class _Up, class = __enable_if_t<!is_same<__compressed_pair_elem, typename decay<_Up>::type>::value> >
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
+ explicit __compressed_pair_elem(_Up&& __u) : __value_type(std::forward<_Up>(__u)) {}
+
+#ifndef _LIBCPP_CXX03_LANG
+ template <class... _Args, size_t... _Indices>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ __compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args, __tuple_indices<_Indices...>)
+ : __value_type(std::forward<_Args>(std::get<_Indices>(__args))...) {}
+#endif
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference __get() _NOEXCEPT { return *this; }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR 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");
+
+ using _Base1 _LIBCPP_NODEBUG = __compressed_pair_elem<_T1, 0>;
+ using _Base2 _LIBCPP_NODEBUG = __compressed_pair_elem<_T2, 1>;
+
+ template <bool _Dummy = true,
+ class = __enable_if_t<
+ __dependent_type<is_default_constructible<_T1>, _Dummy>::value &&
+ __dependent_type<is_default_constructible<_T2>, _Dummy>::value
+ >
+ >
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
+ __compressed_pair() : _Base1(__value_init_tag()), _Base2(__value_init_tag()) {}
+
+ template <class _U1, class _U2>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
+ __compressed_pair(_U1&& __t1, _U2&& __t2) : _Base1(std::forward<_U1>(__t1)), _Base2(std::forward<_U2>(__t2)) {}
+
+#ifndef _LIBCPP_CXX03_LANG
+ template <class... _Args1, class... _Args2>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ __compressed_pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args,
+ tuple<_Args2...> __second_args)
+ : _Base1(__pc, std::move(__first_args), typename __make_tuple_indices<sizeof...(_Args1)>::type()),
+ _Base2(__pc, std::move(__second_args), typename __make_tuple_indices<sizeof...(_Args2)>::type()) {}
+#endif
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ typename _Base1::reference first() _NOEXCEPT {
+ return static_cast<_Base1&>(*this).__get();
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
+ typename _Base1::const_reference first() const _NOEXCEPT {
+ return static_cast<_Base1 const&>(*this).__get();
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ typename _Base2::reference second() _NOEXCEPT {
+ return static_cast<_Base2&>(*this).__get();
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
+ typename _Base2::const_reference second() const _NOEXCEPT {
+ return static_cast<_Base2 const&>(*this).__get();
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static
+ _Base1* __get_first_base(__compressed_pair* __pair) _NOEXCEPT {
+ return static_cast<_Base1*>(__pair);
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static
+ _Base2* __get_second_base(__compressed_pair* __pair) _NOEXCEPT {
+ return static_cast<_Base2*>(__pair);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ void swap(__compressed_pair& __x)
+ _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && __is_nothrow_swappable<_T2>::value) {
+ using std::swap;
+ swap(first(), __x.first());
+ swap(second(), __x.second());
+ }
+};
+
+template <class _T1, class _T2>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+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
+
+#endif // _LIBCPP___MEMORY_COMPRESSED_PAIR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/concepts.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/concepts.h
new file mode 100644
index 0000000000..816c553e85
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/concepts.h
@@ -0,0 +1,68 @@
+// -*- 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_CONCEPTS_H
+#define _LIBCPP___MEMORY_CONCEPTS_H
+
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/readable_traits.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <concepts>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+namespace ranges {
+
+// [special.mem.concepts]
+
+// This concept ensures that uninitialized algorithms can construct an object
+// at the address pointed-to by the iterator, which requires an lvalue.
+template <class _Ip>
+concept __nothrow_input_iterator =
+ input_iterator<_Ip> &&
+ is_lvalue_reference_v<iter_reference_t<_Ip>> &&
+ same_as<remove_cvref_t<iter_reference_t<_Ip>>, iter_value_t<_Ip>>;
+
+template <class _Sp, class _Ip>
+concept __nothrow_sentinel_for = sentinel_for<_Sp, _Ip>;
+
+template <class _Rp>
+concept __nothrow_input_range =
+ range<_Rp> &&
+ __nothrow_input_iterator<iterator_t<_Rp>> &&
+ __nothrow_sentinel_for<sentinel_t<_Rp>, iterator_t<_Rp>>;
+
+template <class _Ip>
+concept __nothrow_forward_iterator =
+ __nothrow_input_iterator<_Ip> &&
+ forward_iterator<_Ip> &&
+ __nothrow_sentinel_for<_Ip, _Ip>;
+
+template <class _Rp>
+concept __nothrow_forward_range =
+ __nothrow_input_range<_Rp> &&
+ __nothrow_forward_iterator<iterator_t<_Rp>>;
+
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___MEMORY_CONCEPTS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/construct_at.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/construct_at.h
new file mode 100644
index 0000000000..8a7bf40d7f
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/construct_at.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___MEMORY_CONSTRUCT_AT_H
+#define _LIBCPP___MEMORY_CONSTRUCT_AT_H
+
+#include <__assert>
+#include <__config>
+#include <__iterator/access.h>
+#include <__memory/addressof.h>
+#include <__memory/voidify.h>
+#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_BEGIN_NAMESPACE_STD
+
+// construct_at
+
+#if _LIBCPP_STD_VER > 17
+
+template<class _Tp, class ..._Args, class = decltype(
+ ::new (declval<void*>()) _Tp(declval<_Args>()...)
+)>
+_LIBCPP_HIDE_FROM_ABI
+constexpr _Tp* construct_at(_Tp* __location, _Args&& ...__args) {
+ _LIBCPP_ASSERT(__location, "null pointer given to construct_at");
+ return ::new (_VSTD::__voidify(*__location)) _Tp(_VSTD::forward<_Args>(__args)...);
+}
+
+#endif
+
+// destroy_at
+
+// The internal functions are available regardless of the language version (with the exception of the `__destroy_at`
+// taking an array).
+
+template <class _ForwardIterator>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+_ForwardIterator __destroy(_ForwardIterator, _ForwardIterator);
+
+template <class _Tp, typename enable_if<!is_array<_Tp>::value, int>::type = 0>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+void __destroy_at(_Tp* __loc) {
+ _LIBCPP_ASSERT(__loc, "null pointer given to destroy_at");
+ __loc->~_Tp();
+}
+
+#if _LIBCPP_STD_VER > 17
+template <class _Tp, typename enable_if<is_array<_Tp>::value, int>::type = 0>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+void __destroy_at(_Tp* __loc) {
+ _LIBCPP_ASSERT(__loc, "null pointer given to destroy_at");
+ _VSTD::__destroy(_VSTD::begin(*__loc), _VSTD::end(*__loc));
+}
+#endif
+
+template <class _ForwardIterator>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+_ForwardIterator __destroy(_ForwardIterator __first, _ForwardIterator __last) {
+ for (; __first != __last; ++__first)
+ _VSTD::__destroy_at(_VSTD::addressof(*__first));
+ return __first;
+}
+
+#if _LIBCPP_STD_VER > 14
+
+template <class _Tp, enable_if_t<!is_array_v<_Tp>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+void destroy_at(_Tp* __loc) {
+ _VSTD::__destroy_at(__loc);
+}
+
+#if _LIBCPP_STD_VER > 17
+template <class _Tp, enable_if_t<is_array_v<_Tp>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+void destroy_at(_Tp* __loc) {
+ _VSTD::__destroy_at(__loc);
+}
+#endif
+
+template <class _ForwardIterator>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+void destroy(_ForwardIterator __first, _ForwardIterator __last) {
+ (void)_VSTD::__destroy(_VSTD::move(__first), _VSTD::move(__last));
+}
+
+template <class _ForwardIterator, class _Size>
+_LIBCPP_HIDE_FROM_ABI _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;
+}
+
+#endif // _LIBCPP_STD_VER > 14
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___MEMORY_CONSTRUCT_AT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/pointer_traits.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/pointer_traits.h
new file mode 100644
index 0000000000..0316649e1f
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/pointer_traits.h
@@ -0,0 +1,220 @@
+// -*- 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_TRAITS_H
+#define _LIBCPP___MEMORY_POINTER_TRAITS_H
+
+#include <__config>
+#include <__memory/addressof.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 = void>
+struct __has_element_type : false_type {};
+
+template <class _Tp>
+struct __has_element_type<_Tp,
+ typename __void_t<typename _Tp::element_type>::type> : true_type {};
+
+template <class _Ptr, bool = __has_element_type<_Ptr>::value>
+struct __pointer_traits_element_type;
+
+template <class _Ptr>
+struct __pointer_traits_element_type<_Ptr, true>
+{
+ typedef _LIBCPP_NODEBUG typename _Ptr::element_type type;
+};
+
+template <template <class, class...> class _Sp, class _Tp, class ..._Args>
+struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, true>
+{
+ typedef _LIBCPP_NODEBUG typename _Sp<_Tp, _Args...>::element_type type;
+};
+
+template <template <class, class...> class _Sp, class _Tp, class ..._Args>
+struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, false>
+{
+ typedef _LIBCPP_NODEBUG _Tp type;
+};
+
+template <class _Tp, class = void>
+struct __has_difference_type : false_type {};
+
+template <class _Tp>
+struct __has_difference_type<_Tp,
+ typename __void_t<typename _Tp::difference_type>::type> : true_type {};
+
+template <class _Ptr, bool = __has_difference_type<_Ptr>::value>
+struct __pointer_traits_difference_type
+{
+ typedef _LIBCPP_NODEBUG ptrdiff_t type;
+};
+
+template <class _Ptr>
+struct __pointer_traits_difference_type<_Ptr, true>
+{
+ typedef _LIBCPP_NODEBUG typename _Ptr::difference_type type;
+};
+
+template <class _Tp, class _Up>
+struct __has_rebind
+{
+private:
+ struct __two {char __lx; char __lxx;};
+ template <class _Xp> static __two __test(...);
+ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
+ // Fix for MSVC which allows to reference private types. Wrap into declval to prevent that.
+ template <class _Xp> static char __test(decltype(_VSTD::declval<typename _Xp::template rebind<_Up>*>()) = 0);
+ _LIBCPP_SUPPRESS_DEPRECATED_POP
+public:
+ static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value>
+struct __pointer_traits_rebind
+{
+#ifndef _LIBCPP_CXX03_LANG
+ typedef _LIBCPP_NODEBUG typename _Tp::template rebind<_Up> type;
+#else
+ typedef _LIBCPP_NODEBUG typename _Tp::template rebind<_Up>::other type;
+#endif
+};
+
+template <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up>
+struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, true>
+{
+#ifndef _LIBCPP_CXX03_LANG
+ typedef _LIBCPP_NODEBUG typename _Sp<_Tp, _Args...>::template rebind<_Up> type;
+#else
+ typedef _LIBCPP_NODEBUG typename _Sp<_Tp, _Args...>::template rebind<_Up>::other type;
+#endif
+};
+
+template <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up>
+struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, false>
+{
+ typedef _Sp<_Up, _Args...> type;
+};
+
+template <class _Ptr>
+struct _LIBCPP_TEMPLATE_VIS pointer_traits
+{
+ typedef _Ptr pointer;
+ typedef typename __pointer_traits_element_type<pointer>::type element_type;
+ typedef typename __pointer_traits_difference_type<pointer>::type difference_type;
+
+#ifndef _LIBCPP_CXX03_LANG
+ template <class _Up> using rebind = typename __pointer_traits_rebind<pointer, _Up>::type;
+#else
+ template <class _Up> struct rebind
+ {typedef typename __pointer_traits_rebind<pointer, _Up>::type other;};
+#endif // _LIBCPP_CXX03_LANG
+
+private:
+ struct __nat {};
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ static pointer pointer_to(typename conditional<is_void<element_type>::value,
+ __nat, element_type>::type& __r)
+ {return pointer::pointer_to(__r);}
+};
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS pointer_traits<_Tp*>
+{
+ typedef _Tp* pointer;
+ typedef _Tp element_type;
+ typedef ptrdiff_t difference_type;
+
+#ifndef _LIBCPP_CXX03_LANG
+ template <class _Up> using rebind = _Up*;
+#else
+ template <class _Up> struct rebind {typedef _Up* other;};
+#endif
+
+private:
+ struct __nat {};
+public:
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static pointer pointer_to(typename conditional<is_void<element_type>::value,
+ __nat, element_type>::type& __r) _NOEXCEPT
+ {return _VSTD::addressof(__r);}
+};
+
+template <class _From, class _To>
+struct __rebind_pointer {
+#ifndef _LIBCPP_CXX03_LANG
+ typedef typename pointer_traits<_From>::template rebind<_To> type;
+#else
+ typedef typename pointer_traits<_From>::template rebind<_To>::other type;
+#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 = __enable_if_t<
+ !is_pointer<_Pointer>::value && !is_array<_Pointer>::value && !is_function<_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 _Tp>
+inline _LIBCPP_INLINE_VISIBILITY constexpr
+auto to_address(_Tp *__p) noexcept {
+ return _VSTD::__to_address(__p);
+}
+
+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
+
+#endif // _LIBCPP___MEMORY_POINTER_TRAITS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/ranges_construct_at.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/ranges_construct_at.h
new file mode 100644
index 0000000000..3064f811e9
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/ranges_construct_at.h
@@ -0,0 +1,124 @@
+// -*- 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_RANGES_CONSTRUCT_AT_H
+#define _LIBCPP___MEMORY_RANGES_CONSTRUCT_AT_H
+
+#include <__concepts/destructible.h>
+#include <__config>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/readable_traits.h>
+#include <__memory/concepts.h>
+#include <__memory/construct_at.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/declval.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+namespace ranges {
+
+// construct_at
+
+namespace __construct_at {
+
+struct __fn {
+ template<class _Tp, class... _Args, class = decltype(
+ ::new (declval<void*>()) _Tp(declval<_Args>()...)
+ )>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _Tp* operator()(_Tp* __location, _Args&& ...__args) const {
+ return _VSTD::construct_at(__location, _VSTD::forward<_Args>(__args)...);
+ }
+};
+
+} // namespace __construct_at
+
+inline namespace __cpo {
+ inline constexpr auto construct_at = __construct_at::__fn{};
+} // namespace __cpo
+
+// destroy_at
+
+namespace __destroy_at {
+
+struct __fn {
+ template <destructible _Tp>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr void operator()(_Tp* __location) const noexcept {
+ _VSTD::destroy_at(__location);
+ }
+};
+
+} // namespace __destroy_at
+
+inline namespace __cpo {
+ inline constexpr auto destroy_at = __destroy_at::__fn{};
+} // namespace __cpo
+
+// destroy
+
+namespace __destroy {
+
+struct __fn {
+ template <__nothrow_input_iterator _InputIterator, __nothrow_sentinel_for<_InputIterator> _Sentinel>
+ requires destructible<iter_value_t<_InputIterator>>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _InputIterator operator()(_InputIterator __first, _Sentinel __last) const noexcept {
+ return _VSTD::__destroy(_VSTD::move(__first), _VSTD::move(__last));
+ }
+
+ template <__nothrow_input_range _InputRange>
+ requires destructible<range_value_t<_InputRange>>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr borrowed_iterator_t<_InputRange> operator()(_InputRange&& __range) const noexcept {
+ return (*this)(ranges::begin(__range), ranges::end(__range));
+ }
+};
+
+} // namespace __destroy
+
+inline namespace __cpo {
+ inline constexpr auto destroy = __destroy::__fn{};
+} // namespace __cpo
+
+// destroy_n
+
+namespace __destroy_n {
+
+struct __fn {
+ template <__nothrow_input_iterator _InputIterator>
+ requires destructible<iter_value_t<_InputIterator>>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _InputIterator operator()(_InputIterator __first, iter_difference_t<_InputIterator> __n) const noexcept {
+ return _VSTD::destroy_n(_VSTD::move(__first), __n);
+ }
+};
+
+} // namespace __destroy_n
+
+inline namespace __cpo {
+ inline constexpr auto destroy_n = __destroy_n::__fn{};
+} // namespace __cpo
+
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___MEMORY_RANGES_CONSTRUCT_AT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/ranges_uninitialized_algorithms.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/ranges_uninitialized_algorithms.h
new file mode 100644
index 0000000000..e036c1858b
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/ranges_uninitialized_algorithms.h
@@ -0,0 +1,318 @@
+// -*- 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_RANGES_UNINITIALIZED_ALGORITHMS_H
+#define _LIBCPP___MEMORY_RANGES_UNINITIALIZED_ALGORITHMS_H
+
+#include <__algorithm/in_out_result.h>
+#include <__concepts/constructible.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 <__memory/concepts.h>
+#include <__memory/uninitialized_algorithms.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+namespace ranges {
+
+// uninitialized_default_construct
+
+namespace __uninitialized_default_construct {
+
+struct __fn {
+ template <__nothrow_forward_iterator _ForwardIterator,
+ __nothrow_sentinel_for<_ForwardIterator> _Sentinel>
+ requires default_initializable<iter_value_t<_ForwardIterator>>
+ _ForwardIterator operator()(_ForwardIterator __first, _Sentinel __last) const {
+ using _ValueType = remove_reference_t<iter_reference_t<_ForwardIterator>>;
+ return _VSTD::__uninitialized_default_construct<_ValueType>(
+ _VSTD::move(__first), _VSTD::move(__last));
+ }
+
+ template <__nothrow_forward_range _ForwardRange>
+ requires default_initializable<range_value_t<_ForwardRange>>
+ borrowed_iterator_t<_ForwardRange> operator()(_ForwardRange&& __range) const {
+ return (*this)(ranges::begin(__range), ranges::end(__range));
+ }
+};
+
+} // namespace __uninitialized_default_construct
+
+inline namespace __cpo {
+ inline constexpr auto uninitialized_default_construct = __uninitialized_default_construct::__fn{};
+} // namespace __cpo
+
+// uninitialized_default_construct_n
+
+namespace __uninitialized_default_construct_n {
+
+struct __fn {
+ template <__nothrow_forward_iterator _ForwardIterator>
+ requires default_initializable<iter_value_t<_ForwardIterator>>
+ _ForwardIterator operator()(_ForwardIterator __first,
+ iter_difference_t<_ForwardIterator> __n) const {
+ using _ValueType = remove_reference_t<iter_reference_t<_ForwardIterator>>;
+ return _VSTD::__uninitialized_default_construct_n<_ValueType>(_VSTD::move(__first), __n);
+ }
+};
+
+} // namespace __uninitialized_default_construct_n
+
+inline namespace __cpo {
+ inline constexpr auto uninitialized_default_construct_n = __uninitialized_default_construct_n::__fn{};
+} // namespace __cpo
+
+// uninitialized_value_construct
+
+namespace __uninitialized_value_construct {
+
+struct __fn {
+ template <__nothrow_forward_iterator _ForwardIterator,
+ __nothrow_sentinel_for<_ForwardIterator> _Sentinel>
+ requires default_initializable<iter_value_t<_ForwardIterator>>
+ _ForwardIterator operator()(_ForwardIterator __first, _Sentinel __last) const {
+ using _ValueType = remove_reference_t<iter_reference_t<_ForwardIterator>>;
+ return _VSTD::__uninitialized_value_construct<_ValueType>(
+ _VSTD::move(__first), _VSTD::move(__last));
+ }
+
+ template <__nothrow_forward_range _ForwardRange>
+ requires default_initializable<range_value_t<_ForwardRange>>
+ borrowed_iterator_t<_ForwardRange> operator()(_ForwardRange&& __range) const {
+ return (*this)(ranges::begin(__range), ranges::end(__range));
+ }
+};
+
+} // namespace __uninitialized_value_construct
+
+inline namespace __cpo {
+ inline constexpr auto uninitialized_value_construct = __uninitialized_value_construct::__fn{};
+} // namespace __cpo
+
+// uninitialized_value_construct_n
+
+namespace __uninitialized_value_construct_n {
+
+struct __fn {
+ template <__nothrow_forward_iterator _ForwardIterator>
+ requires default_initializable<iter_value_t<_ForwardIterator>>
+ _ForwardIterator operator()(_ForwardIterator __first,
+ iter_difference_t<_ForwardIterator> __n) const {
+ using _ValueType = remove_reference_t<iter_reference_t<_ForwardIterator>>;
+ return _VSTD::__uninitialized_value_construct_n<_ValueType>(_VSTD::move(__first), __n);
+ }
+};
+
+} // namespace __uninitialized_value_construct_n
+
+inline namespace __cpo {
+ inline constexpr auto uninitialized_value_construct_n = __uninitialized_value_construct_n::__fn{};
+} // namespace __cpo
+
+// uninitialized_fill
+
+namespace __uninitialized_fill {
+
+struct __fn {
+ template <__nothrow_forward_iterator _ForwardIterator,
+ __nothrow_sentinel_for<_ForwardIterator> _Sentinel,
+ class _Tp>
+ requires constructible_from<iter_value_t<_ForwardIterator>, const _Tp&>
+ _ForwardIterator operator()(_ForwardIterator __first, _Sentinel __last, const _Tp& __x) const {
+ using _ValueType = remove_reference_t<iter_reference_t<_ForwardIterator>>;
+ return _VSTD::__uninitialized_fill<_ValueType>(_VSTD::move(__first), _VSTD::move(__last), __x);
+ }
+
+ template <__nothrow_forward_range _ForwardRange, class _Tp>
+ requires constructible_from<range_value_t<_ForwardRange>, const _Tp&>
+ borrowed_iterator_t<_ForwardRange> operator()(_ForwardRange&& __range, const _Tp& __x) const {
+ return (*this)(ranges::begin(__range), ranges::end(__range), __x);
+ }
+};
+
+} // namespace __uninitialized_fill
+
+inline namespace __cpo {
+ inline constexpr auto uninitialized_fill = __uninitialized_fill::__fn{};
+} // namespace __cpo
+
+// uninitialized_fill_n
+
+namespace __uninitialized_fill_n {
+
+struct __fn {
+ template <__nothrow_forward_iterator _ForwardIterator, class _Tp>
+ requires constructible_from<iter_value_t<_ForwardIterator>, const _Tp&>
+ _ForwardIterator operator()(_ForwardIterator __first,
+ iter_difference_t<_ForwardIterator> __n,
+ const _Tp& __x) const {
+ using _ValueType = remove_reference_t<iter_reference_t<_ForwardIterator>>;
+ return _VSTD::__uninitialized_fill_n<_ValueType>(_VSTD::move(__first), __n, __x);
+ }
+};
+
+} // namespace __uninitialized_fill_n
+
+inline namespace __cpo {
+ inline constexpr auto uninitialized_fill_n = __uninitialized_fill_n::__fn{};
+} // namespace __cpo
+
+// uninitialized_copy
+
+template <class _InputIterator, class _OutputIterator>
+using uninitialized_copy_result = in_out_result<_InputIterator, _OutputIterator>;
+
+namespace __uninitialized_copy {
+
+struct __fn {
+ template <input_iterator _InputIterator,
+ sentinel_for<_InputIterator> _Sentinel1,
+ __nothrow_forward_iterator _OutputIterator,
+ __nothrow_sentinel_for<_OutputIterator> _Sentinel2>
+ requires constructible_from<iter_value_t<_OutputIterator>, iter_reference_t<_InputIterator>>
+ uninitialized_copy_result<_InputIterator, _OutputIterator>
+ operator()(_InputIterator __ifirst, _Sentinel1 __ilast, _OutputIterator __ofirst, _Sentinel2 __olast) const {
+ using _ValueType = remove_reference_t<iter_reference_t<_OutputIterator>>;
+
+ auto __result = _VSTD::__uninitialized_copy<_ValueType>(_VSTD::move(__ifirst), _VSTD::move(__ilast),
+ _VSTD::move(__ofirst), _VSTD::move(__olast));
+ return {_VSTD::move(__result.first), _VSTD::move(__result.second)};
+ }
+
+ template <input_range _InputRange, __nothrow_forward_range _OutputRange>
+ requires constructible_from<range_value_t<_OutputRange>, range_reference_t<_InputRange>>
+ uninitialized_copy_result<borrowed_iterator_t<_InputRange>, borrowed_iterator_t<_OutputRange>>
+ operator()( _InputRange&& __in_range, _OutputRange&& __out_range) const {
+ return (*this)(ranges::begin(__in_range), ranges::end(__in_range),
+ ranges::begin(__out_range), ranges::end(__out_range));
+ }
+};
+
+} // namespace __uninitialized_copy
+
+inline namespace __cpo {
+ inline constexpr auto uninitialized_copy = __uninitialized_copy::__fn{};
+} // namespace __cpo
+
+// uninitialized_copy_n
+
+template <class _InputIterator, class _OutputIterator>
+using uninitialized_copy_n_result = in_out_result<_InputIterator, _OutputIterator>;
+
+namespace __uninitialized_copy_n {
+
+struct __fn {
+ template <input_iterator _InputIterator,
+ __nothrow_forward_iterator _OutputIterator,
+ __nothrow_sentinel_for<_OutputIterator> _Sentinel>
+ requires constructible_from<iter_value_t<_OutputIterator>, iter_reference_t<_InputIterator>>
+ uninitialized_copy_n_result<_InputIterator, _OutputIterator>
+ operator()(_InputIterator __ifirst, iter_difference_t<_InputIterator> __n,
+ _OutputIterator __ofirst, _Sentinel __olast) const {
+ using _ValueType = remove_reference_t<iter_reference_t<_OutputIterator>>;
+ auto __result = _VSTD::__uninitialized_copy_n<_ValueType>(_VSTD::move(__ifirst), __n,
+ _VSTD::move(__ofirst), _VSTD::move(__olast));
+ return {_VSTD::move(__result.first), _VSTD::move(__result.second)};
+ }
+};
+
+} // namespace __uninitialized_copy_n
+
+inline namespace __cpo {
+ inline constexpr auto uninitialized_copy_n = __uninitialized_copy_n::__fn{};
+} // namespace __cpo
+
+// uninitialized_move
+
+template <class _InputIterator, class _OutputIterator>
+using uninitialized_move_result = in_out_result<_InputIterator, _OutputIterator>;
+
+namespace __uninitialized_move {
+
+struct __fn {
+ template <input_iterator _InputIterator,
+ sentinel_for<_InputIterator> _Sentinel1,
+ __nothrow_forward_iterator _OutputIterator,
+ __nothrow_sentinel_for<_OutputIterator> _Sentinel2>
+ requires constructible_from<iter_value_t<_OutputIterator>, iter_reference_t<_InputIterator>>
+ uninitialized_move_result<_InputIterator, _OutputIterator>
+ operator()(_InputIterator __ifirst, _Sentinel1 __ilast, _OutputIterator __ofirst, _Sentinel2 __olast) const {
+ using _ValueType = remove_reference_t<iter_reference_t<_OutputIterator>>;
+ auto __iter_move = [](auto&& __iter) -> decltype(auto) { return ranges::iter_move(__iter); };
+ auto __result = _VSTD::__uninitialized_move<_ValueType>(_VSTD::move(__ifirst), _VSTD::move(__ilast),
+ _VSTD::move(__ofirst), _VSTD::move(__olast), __iter_move);
+ return {_VSTD::move(__result.first), _VSTD::move(__result.second)};
+ }
+
+ template <input_range _InputRange, __nothrow_forward_range _OutputRange>
+ requires constructible_from<range_value_t<_OutputRange>, range_reference_t<_InputRange>>
+ uninitialized_move_result<borrowed_iterator_t<_InputRange>, borrowed_iterator_t<_OutputRange>>
+ operator()(_InputRange&& __in_range, _OutputRange&& __out_range) const {
+ return (*this)(ranges::begin(__in_range), ranges::end(__in_range),
+ ranges::begin(__out_range), ranges::end(__out_range));
+ }
+};
+
+} // namespace __uninitialized_move
+
+inline namespace __cpo {
+ inline constexpr auto uninitialized_move = __uninitialized_move::__fn{};
+} // namespace __cpo
+
+// uninitialized_move_n
+
+template <class _InputIterator, class _OutputIterator>
+using uninitialized_move_n_result = in_out_result<_InputIterator, _OutputIterator>;
+
+namespace __uninitialized_move_n {
+
+struct __fn {
+ template <input_iterator _InputIterator,
+ __nothrow_forward_iterator _OutputIterator,
+ __nothrow_sentinel_for<_OutputIterator> _Sentinel>
+ requires constructible_from<iter_value_t<_OutputIterator>, iter_reference_t<_InputIterator>>
+ uninitialized_move_n_result<_InputIterator, _OutputIterator>
+ operator()(_InputIterator __ifirst, iter_difference_t<_InputIterator> __n,
+ _OutputIterator __ofirst, _Sentinel __olast) const {
+ using _ValueType = remove_reference_t<iter_reference_t<_OutputIterator>>;
+ auto __iter_move = [](auto&& __iter) -> decltype(auto) { return ranges::iter_move(__iter); };
+ auto __result = _VSTD::__uninitialized_move_n<_ValueType>(_VSTD::move(__ifirst), __n,
+ _VSTD::move(__ofirst), _VSTD::move(__olast), __iter_move);
+ return {_VSTD::move(__result.first), _VSTD::move(__result.second)};
+ }
+};
+
+} // namespace __uninitialized_move_n
+
+inline namespace __cpo {
+ inline constexpr auto uninitialized_move_n = __uninitialized_move_n::__fn{};
+} // namespace __cpo
+
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___MEMORY_RANGES_UNINITIALIZED_ALGORITHMS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/raw_storage_iterator.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/raw_storage_iterator.h
new file mode 100644
index 0000000000..f25f7b1a72
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/raw_storage_iterator.h
@@ -0,0 +1,68 @@
+// -*- 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 <__utility/move.h>
+#include <cstddef>
+#include <iterator>
+
+#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_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
+
+#endif // _LIBCPP___MEMORY_RAW_STORAGE_ITERATOR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/shared_ptr.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/shared_ptr.h
new file mode 100644
index 0000000000..828513a295
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/shared_ptr.h
@@ -0,0 +1,1746 @@
+// -*- 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/binary_function.h>
+#include <__functional/operations.h>
+#include <__functional/reference_wrapper.h>
+#include <__memory/addressof.h>
+#include <__memory/allocation_guard.h>
+#include <__memory/allocator.h>
+#include <__memory/allocator_traits.h>
+#include <__memory/compressed_pair.h>
+#include <__memory/pointer_traits.h>
+#include <__memory/unique_ptr.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include <cstddef>
+#include <cstdlib> // abort
+#include <iosfwd>
+#include <stdexcept>
+#include <type_traits>
+#include <typeinfo>
+#if !defined(_LIBCPP_HAS_NO_THREADS) // !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_BEGIN_NAMESPACE_STD
+
+template <class _Alloc>
+class __allocator_destructor
+{
+ typedef _LIBCPP_NODEBUG allocator_traits<_Alloc> __alloc_traits;
+public:
+ typedef _LIBCPP_NODEBUG typename __alloc_traits::pointer pointer;
+ typedef _LIBCPP_NODEBUG 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
+}
+
+#ifndef _LIBCPP_COMPILER_MSVC
+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
+}
+#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:
+#ifdef _LIBCPP_HAS_NO_THREADS
+ typedef long __atomic_count;
+#else
+ typedef atomic<long> __atomic_count;
+#endif
+ __atomic_count __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 {
+#ifdef _LIBCPP_HAS_NO_THREADS
+ __libcpp_atomic_refcount_increment(__shared_owners_);
+#else
+ __shared_owners_++;
+#endif
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ bool __release_shared() _NOEXCEPT {
+#ifdef _LIBCPP_HAS_NO_THREADS
+ if (__libcpp_atomic_refcount_decrement(__shared_owners_) == -1) {
+#else
+ if (--__shared_owners_ == -1) {
+#endif
+ __on_zero_shared();
+ return true;
+ }
+ return false;
+ }
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ long use_count() const _NOEXCEPT {
+#ifdef _LIBCPP_HAS_NO_THREADS
+ return __libcpp_relaxed_load(&__shared_owners_) + 1;
+#else
+ return __shared_owners_.load(memory_order_relaxed) + 1;
+#endif
+ }
+};
+
+class _LIBCPP_TYPE_VIS __shared_weak_count
+ : private __shared_count
+{
+#ifdef _LIBCPP_HAS_NO_THREADS
+ typedef long __atomic_count;
+#else
+ typedef atomic<long> __atomic_count;
+#endif
+ __atomic_count __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 {
+#ifdef _LIBCPP_HAS_NO_THREADS
+ __libcpp_atomic_refcount_increment(__shared_weak_owners_);
+#else
+ __shared_weak_owners_++;
+#endif
+ }
+ _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_;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI
+ _LIBCPP_CONSTEXPR shared_ptr() _NOEXCEPT
+ : __ptr_(nullptr),
+ __cntrl_(nullptr)
+ { }
+
+ _LIBCPP_HIDE_FROM_ABI
+ _LIBCPP_CONSTEXPR shared_ptr(nullptr_t) _NOEXCEPT
+ : __ptr_(nullptr),
+ __cntrl_(nullptr)
+ { }
+
+ template<class _Yp, class = __enable_if_t<
+ _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, class = __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, element_type>::value> >
+ _LIBCPP_HIDE_FROM_ABI
+ shared_ptr(_Yp* __p, _Dp __d)
+ : __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 _Yp, class _Dp, class _Alloc, class = __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, element_type>::value> >
+ _LIBCPP_HIDE_FROM_ABI
+ shared_ptr(_Yp* __p, _Dp __d, _Alloc __a)
+ : __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 _Dp>
+ _LIBCPP_HIDE_FROM_ABI
+ 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 _Dp, class _Alloc>
+ _LIBCPP_HIDE_FROM_ABI
+ 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 _Yp>
+ _LIBCPP_HIDE_FROM_ABI
+ shared_ptr(const shared_ptr<_Yp>& __r, element_type *__p) _NOEXCEPT
+ : __ptr_(__p),
+ __cntrl_(__r.__cntrl_)
+ {
+ if (__cntrl_)
+ __cntrl_->__add_shared();
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ shared_ptr(const shared_ptr& __r) _NOEXCEPT
+ : __ptr_(__r.__ptr_),
+ __cntrl_(__r.__cntrl_)
+ {
+ if (__cntrl_)
+ __cntrl_->__add_shared();
+ }
+
+ template<class _Yp, class = __enable_if_t<__compatible_with<_Yp, _Tp>::value> >
+ _LIBCPP_HIDE_FROM_ABI
+ shared_ptr(const shared_ptr<_Yp>& __r) _NOEXCEPT
+ : __ptr_(__r.__ptr_),
+ __cntrl_(__r.__cntrl_)
+ {
+ if (__cntrl_)
+ __cntrl_->__add_shared();
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ shared_ptr(shared_ptr&& __r) _NOEXCEPT
+ : __ptr_(__r.__ptr_),
+ __cntrl_(__r.__cntrl_)
+ {
+ __r.__ptr_ = nullptr;
+ __r.__cntrl_ = nullptr;
+ }
+
+ template<class _Yp, class = __enable_if_t<__compatible_with<_Yp, _Tp>::value> >
+ _LIBCPP_HIDE_FROM_ABI
+ shared_ptr(shared_ptr<_Yp>&& __r) _NOEXCEPT
+ : __ptr_(__r.__ptr_),
+ __cntrl_(__r.__cntrl_)
+ {
+ __r.__ptr_ = nullptr;
+ __r.__cntrl_ = nullptr;
+ }
+
+ template<class _Yp, class = __enable_if_t<__compatible_with<_Yp, _Tp>::value> >
+ _LIBCPP_HIDE_FROM_ABI
+ explicit shared_ptr(const weak_ptr<_Yp>& __r)
+ : __ptr_(__r.__ptr_),
+ __cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_)
+ {
+ if (__cntrl_ == nullptr)
+ __throw_bad_weak_ptr();
+ }
+
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
+ template<class _Yp, class = __enable_if_t<is_convertible<_Yp*, element_type*>::value> >
+ _LIBCPP_HIDE_FROM_ABI
+ shared_ptr(auto_ptr<_Yp>&& __r)
+ : __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 _Yp, class _Dp, class = __enable_if_t<
+ !is_lvalue_reference<_Dp>::value &&
+ is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value
+ > >
+ _LIBCPP_HIDE_FROM_ABI
+ shared_ptr(unique_ptr<_Yp, _Dp>&& __r)
+ : __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 _Yp, class _Dp, class = void, class = __enable_if_t<
+ is_lvalue_reference<_Dp>::value &&
+ is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value
+ > >
+ _LIBCPP_HIDE_FROM_ABI
+ shared_ptr(unique_ptr<_Yp, _Dp>&& __r)
+ : __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();
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ ~shared_ptr()
+ {
+ if (__cntrl_)
+ __cntrl_->__release_shared();
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ shared_ptr<_Tp>& operator=(const shared_ptr& __r) _NOEXCEPT
+ {
+ shared_ptr(__r).swap(*this);
+ return *this;
+ }
+
+ template<class _Yp, class = __enable_if_t<__compatible_with<_Yp, _Tp>::value> >
+ _LIBCPP_HIDE_FROM_ABI
+ shared_ptr<_Tp>& operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT
+ {
+ shared_ptr(__r).swap(*this);
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ shared_ptr<_Tp>& operator=(shared_ptr&& __r) _NOEXCEPT
+ {
+ shared_ptr(_VSTD::move(__r)).swap(*this);
+ return *this;
+ }
+
+ template<class _Yp, class = __enable_if_t<__compatible_with<_Yp, _Tp>::value> >
+ _LIBCPP_HIDE_FROM_ABI
+ 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 _Yp, class = __enable_if_t<
+ !is_array<_Yp>::value &&
+ is_convertible<_Yp*, typename shared_ptr<_Tp>::element_type*>::value
+ > >
+ _LIBCPP_HIDE_FROM_ABI
+ shared_ptr<_Tp>& operator=(auto_ptr<_Yp>&& __r)
+ {
+ shared_ptr(_VSTD::move(__r)).swap(*this);
+ return *this;
+ }
+#endif
+
+ template <class _Yp, class _Dp, class = __enable_if_t<
+ is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value
+ > >
+ _LIBCPP_HIDE_FROM_ABI
+ shared_ptr<_Tp>& operator=(unique_ptr<_Yp, _Dp>&& __r)
+ {
+ shared_ptr(_VSTD::move(__r)).swap(*this);
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ void swap(shared_ptr& __r) _NOEXCEPT
+ {
+ _VSTD::swap(__ptr_, __r.__ptr_);
+ _VSTD::swap(__cntrl_, __r.__cntrl_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ void reset() _NOEXCEPT
+ {
+ shared_ptr().swap(*this);
+ }
+
+ template<class _Yp, class = __enable_if_t<
+ __compatible_with<_Yp, _Tp>::value
+ > >
+ _LIBCPP_HIDE_FROM_ABI
+ void reset(_Yp* __p)
+ {
+ shared_ptr(__p).swap(*this);
+ }
+
+ template<class _Yp, class _Dp, class = __enable_if_t<
+ __compatible_with<_Yp, _Tp>::value
+ > >
+ _LIBCPP_HIDE_FROM_ABI
+ void reset(_Yp* __p, _Dp __d)
+ {
+ shared_ptr(__p, __d).swap(*this);
+ }
+
+ template<class _Yp, class _Dp, class _Alloc, class = __enable_if_t<
+ __compatible_with<_Yp, _Tp>::value
+ > >
+ _LIBCPP_HIDE_FROM_ABI
+ void reset(_Yp* __p, _Dp __d, _Alloc __a)
+ {
+ shared_ptr(__p, __d, __a).swap(*this);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ element_type* get() const _NOEXCEPT
+ {
+ return __ptr_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ typename add_lvalue_reference<element_type>::type operator*() const _NOEXCEPT
+ {
+ return *__ptr_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ 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_HIDE_FROM_ABI
+ long use_count() const _NOEXCEPT
+ {
+ return __cntrl_ ? __cntrl_->use_count() : 0;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ bool unique() const _NOEXCEPT
+ {
+ return use_count() == 1;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ explicit operator bool() const _NOEXCEPT
+ {
+ return get() != nullptr;
+ }
+
+ template <class _Up>
+ _LIBCPP_HIDE_FROM_ABI
+ bool owner_before(shared_ptr<_Up> const& __p) const _NOEXCEPT
+ {
+ return __cntrl_ < __p.__cntrl_;
+ }
+
+ template <class _Up>
+ _LIBCPP_HIDE_FROM_ABI
+ bool owner_before(weak_ptr<_Up> const& __p) const _NOEXCEPT
+ {
+ return __cntrl_ < __p.__cntrl_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ bool __owner_equivalent(const shared_ptr& __p) const
+ {
+ return __cntrl_ == __p.__cntrl_;
+ }
+
+#if _LIBCPP_STD_VER > 14
+ _LIBCPP_HIDE_FROM_ABI
+ typename add_lvalue_reference<element_type>::type 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_HIDE_FROM_ABI
+ _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>
+ _LIBCPP_HIDE_FROM_ABI
+ 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, class = __enable_if_t<
+ is_convertible<_OrigPtr*, const enable_shared_from_this<_Yp>*>::value
+ > >
+ _LIBCPP_HIDE_FROM_ABI
+ void __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_HIDE_FROM_ABI 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;
+};
+
+#if _LIBCPP_STD_VER > 14
+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
+
+//
+// std::allocate_shared and std::make_shared
+//
+template<class _Tp, class _Alloc, class ..._Args, class = __enable_if_t<!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 = __enable_if_t<!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:
+#if _LIBCPP_STD_VER > 14
+ typedef remove_extent_t<_Tp> element_type;
+#else
+ typedef _Tp element_type;
+#endif
+
+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<__compatible_with<_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<__compatible_with<_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<__compatible_with<_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
+ <
+ __compatible_with<_Yp, _Tp>::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
+ <
+ __compatible_with<_Yp, _Tp>::value,
+ weak_ptr&
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT;
+
+ template<class _Yp>
+ typename enable_if
+ <
+ __compatible_with<_Yp, _Tp>::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;
+};
+
+#if _LIBCPP_STD_VER > 14
+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<__compatible_with<_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<__compatible_with<_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<__compatible_with<_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
+<
+ __compatible_with<_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
+<
+ __compatible_with<_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
+<
+ __compatible_with<_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>
+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_THREADS)
+
+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_THREADS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___MEMORY_SHARED_PTR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/temporary_buffer.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/temporary_buffer.h
new file mode 100644
index 0000000000..2c6e333eba
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/temporary_buffer.h
@@ -0,0 +1,84 @@
+// -*- 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 <__utility/pair.h>
+#include <cstddef>
+#include <new>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___MEMORY_TEMPORARY_BUFFER_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/uninitialized_algorithms.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/uninitialized_algorithms.h
new file mode 100644
index 0000000000..fc55b49aef
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/uninitialized_algorithms.h
@@ -0,0 +1,351 @@
+// -*- 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 <__iterator/iterator_traits.h>
+#include <__memory/addressof.h>
+#include <__memory/construct_at.h>
+#include <__memory/voidify.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// This is a simplified version of C++20 `unreachable_sentinel` that doesn't use concepts and thus can be used in any
+// language mode.
+struct __unreachable_sentinel {
+ template <class _Iter>
+ _LIBCPP_HIDE_FROM_ABI friend _LIBCPP_CONSTEXPR bool operator!=(const _Iter&, __unreachable_sentinel) _NOEXCEPT {
+ return true;
+ }
+};
+
+// uninitialized_copy
+
+template <class _ValueType, class _InputIterator, class _Sentinel1, class _ForwardIterator, class _Sentinel2>
+inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator>
+__uninitialized_copy(_InputIterator __ifirst, _Sentinel1 __ilast,
+ _ForwardIterator __ofirst, _Sentinel2 __olast) {
+ _ForwardIterator __idx = __ofirst;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try {
+#endif
+ for (; __ifirst != __ilast && __idx != __olast; ++__ifirst, (void)++__idx)
+ ::new (_VSTD::__voidify(*__idx)) _ValueType(*__ifirst);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ } catch (...) {
+ _VSTD::__destroy(__ofirst, __idx);
+ throw;
+ }
+#endif
+
+ return pair<_InputIterator, _ForwardIterator>(_VSTD::move(__ifirst), _VSTD::move(__idx));
+}
+
+template <class _InputIterator, class _ForwardIterator>
+_ForwardIterator uninitialized_copy(_InputIterator __ifirst, _InputIterator __ilast,
+ _ForwardIterator __ofirst) {
+ typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType;
+ auto __result = _VSTD::__uninitialized_copy<_ValueType>(_VSTD::move(__ifirst), _VSTD::move(__ilast),
+ _VSTD::move(__ofirst), __unreachable_sentinel());
+ return _VSTD::move(__result.second);
+}
+
+// uninitialized_copy_n
+
+template <class _ValueType, class _InputIterator, class _Size, class _ForwardIterator, class _Sentinel>
+inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator>
+__uninitialized_copy_n(_InputIterator __ifirst, _Size __n,
+ _ForwardIterator __ofirst, _Sentinel __olast) {
+ _ForwardIterator __idx = __ofirst;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try {
+#endif
+ for (; __n > 0 && __idx != __olast; ++__ifirst, (void)++__idx, (void)--__n)
+ ::new (_VSTD::__voidify(*__idx)) _ValueType(*__ifirst);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ } catch (...) {
+ _VSTD::__destroy(__ofirst, __idx);
+ throw;
+ }
+#endif
+
+ return pair<_InputIterator, _ForwardIterator>(_VSTD::move(__ifirst), _VSTD::move(__idx));
+}
+
+template <class _InputIterator, class _Size, class _ForwardIterator>
+inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator uninitialized_copy_n(_InputIterator __ifirst, _Size __n,
+ _ForwardIterator __ofirst) {
+ typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType;
+ auto __result = _VSTD::__uninitialized_copy_n<_ValueType>(_VSTD::move(__ifirst), __n, _VSTD::move(__ofirst),
+ __unreachable_sentinel());
+ return _VSTD::move(__result.second);
+}
+
+// uninitialized_fill
+
+template <class _ValueType, class _ForwardIterator, class _Sentinel, class _Tp>
+inline _LIBCPP_HIDE_FROM_ABI
+_ForwardIterator __uninitialized_fill(_ForwardIterator __first, _Sentinel __last, const _Tp& __x)
+{
+ _ForwardIterator __idx = __first;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif
+ for (; __idx != __last; ++__idx)
+ ::new (_VSTD::__voidify(*__idx)) _ValueType(__x);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ _VSTD::__destroy(__first, __idx);
+ throw;
+ }
+#endif
+
+ return __idx;
+}
+
+template <class _ForwardIterator, class _Tp>
+inline _LIBCPP_HIDE_FROM_ABI
+void uninitialized_fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __x)
+{
+ typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType;
+ (void)_VSTD::__uninitialized_fill<_ValueType>(__first, __last, __x);
+}
+
+// uninitialized_fill_n
+
+template <class _ValueType, class _ForwardIterator, class _Size, class _Tp>
+inline _LIBCPP_HIDE_FROM_ABI
+_ForwardIterator __uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x)
+{
+ _ForwardIterator __idx = __first;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif
+ for (; __n > 0; ++__idx, (void) --__n)
+ ::new (_VSTD::__voidify(*__idx)) _ValueType(__x);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ _VSTD::__destroy(__first, __idx);
+ throw;
+ }
+#endif
+
+ return __idx;
+}
+
+template <class _ForwardIterator, class _Size, class _Tp>
+inline _LIBCPP_HIDE_FROM_ABI
+_ForwardIterator uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x)
+{
+ typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType;
+ return _VSTD::__uninitialized_fill_n<_ValueType>(__first, __n, __x);
+}
+
+#if _LIBCPP_STD_VER > 14
+
+// uninitialized_default_construct
+
+template <class _ValueType, class _ForwardIterator, class _Sentinel>
+inline _LIBCPP_HIDE_FROM_ABI
+_ForwardIterator __uninitialized_default_construct(_ForwardIterator __first, _Sentinel __last) {
+ auto __idx = __first;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try {
+#endif
+ for (; __idx != __last; ++__idx)
+ ::new (_VSTD::__voidify(*__idx)) _ValueType;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ } catch (...) {
+ _VSTD::__destroy(__first, __idx);
+ throw;
+ }
+#endif
+
+ return __idx;
+}
+
+template <class _ForwardIterator>
+inline _LIBCPP_HIDE_FROM_ABI
+void uninitialized_default_construct(_ForwardIterator __first, _ForwardIterator __last) {
+ using _ValueType = typename iterator_traits<_ForwardIterator>::value_type;
+ (void)_VSTD::__uninitialized_default_construct<_ValueType>(
+ _VSTD::move(__first), _VSTD::move(__last));
+}
+
+// uninitialized_default_construct_n
+
+template <class _ValueType, class _ForwardIterator, class _Size>
+inline _LIBCPP_HIDE_FROM_ABI
+_ForwardIterator __uninitialized_default_construct_n(_ForwardIterator __first, _Size __n) {
+ auto __idx = __first;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try {
+#endif
+ for (; __n > 0; ++__idx, (void) --__n)
+ ::new (_VSTD::__voidify(*__idx)) _ValueType;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ } catch (...) {
+ _VSTD::__destroy(__first, __idx);
+ throw;
+ }
+#endif
+
+ return __idx;
+}
+
+template <class _ForwardIterator, class _Size>
+inline _LIBCPP_HIDE_FROM_ABI
+_ForwardIterator uninitialized_default_construct_n(_ForwardIterator __first, _Size __n) {
+ using _ValueType = typename iterator_traits<_ForwardIterator>::value_type;
+ return _VSTD::__uninitialized_default_construct_n<_ValueType>(_VSTD::move(__first), __n);
+}
+
+// uninitialized_value_construct
+
+template <class _ValueType, class _ForwardIterator, class _Sentinel>
+inline _LIBCPP_HIDE_FROM_ABI
+_ForwardIterator __uninitialized_value_construct(_ForwardIterator __first, _Sentinel __last) {
+ auto __idx = __first;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try {
+#endif
+ for (; __idx != __last; ++__idx)
+ ::new (_VSTD::__voidify(*__idx)) _ValueType();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ } catch (...) {
+ _VSTD::__destroy(__first, __idx);
+ throw;
+ }
+#endif
+
+ return __idx;
+}
+
+template <class _ForwardIterator>
+inline _LIBCPP_HIDE_FROM_ABI
+void uninitialized_value_construct(_ForwardIterator __first, _ForwardIterator __last) {
+ using _ValueType = typename iterator_traits<_ForwardIterator>::value_type;
+ (void)_VSTD::__uninitialized_value_construct<_ValueType>(
+ _VSTD::move(__first), _VSTD::move(__last));
+}
+
+// uninitialized_value_construct_n
+
+template <class _ValueType, class _ForwardIterator, class _Size>
+inline _LIBCPP_HIDE_FROM_ABI
+_ForwardIterator __uninitialized_value_construct_n(_ForwardIterator __first, _Size __n) {
+ auto __idx = __first;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try {
+#endif
+ for (; __n > 0; ++__idx, (void) --__n)
+ ::new (_VSTD::__voidify(*__idx)) _ValueType();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ } catch (...) {
+ _VSTD::__destroy(__first, __idx);
+ throw;
+ }
+#endif
+
+ return __idx;
+}
+
+template <class _ForwardIterator, class _Size>
+inline _LIBCPP_HIDE_FROM_ABI
+_ForwardIterator uninitialized_value_construct_n(_ForwardIterator __first, _Size __n) {
+ using _ValueType = typename iterator_traits<_ForwardIterator>::value_type;
+ return __uninitialized_value_construct_n<_ValueType>(_VSTD::move(__first), __n);
+}
+
+// uninitialized_move
+
+template <class _ValueType, class _InputIterator, class _Sentinel1, class _ForwardIterator, class _Sentinel2,
+ class _IterMove>
+inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator>
+__uninitialized_move(_InputIterator __ifirst, _Sentinel1 __ilast,
+ _ForwardIterator __ofirst, _Sentinel2 __olast, _IterMove __iter_move) {
+ auto __idx = __ofirst;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try {
+#endif
+ for (; __ifirst != __ilast && __idx != __olast; ++__idx, (void)++__ifirst) {
+ ::new (_VSTD::__voidify(*__idx)) _ValueType(__iter_move(__ifirst));
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ } catch (...) {
+ _VSTD::__destroy(__ofirst, __idx);
+ throw;
+ }
+#endif
+
+ return {_VSTD::move(__ifirst), _VSTD::move(__idx)};
+}
+
+template <class _InputIterator, class _ForwardIterator>
+inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator uninitialized_move(_InputIterator __ifirst, _InputIterator __ilast,
+ _ForwardIterator __ofirst) {
+ using _ValueType = typename iterator_traits<_ForwardIterator>::value_type;
+ auto __iter_move = [](auto&& __iter) -> decltype(auto) { return _VSTD::move(*__iter); };
+
+ auto __result = _VSTD::__uninitialized_move<_ValueType>(_VSTD::move(__ifirst), _VSTD::move(__ilast),
+ _VSTD::move(__ofirst), __unreachable_sentinel(), __iter_move);
+ return _VSTD::move(__result.second);
+}
+
+// uninitialized_move_n
+
+template <class _ValueType, class _InputIterator, class _Size, class _ForwardIterator, class _Sentinel, class _IterMove>
+inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator>
+__uninitialized_move_n(_InputIterator __ifirst, _Size __n,
+ _ForwardIterator __ofirst, _Sentinel __olast, _IterMove __iter_move) {
+ auto __idx = __ofirst;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try {
+#endif
+ for (; __n > 0 && __idx != __olast; ++__idx, (void)++__ifirst, --__n)
+ ::new (_VSTD::__voidify(*__idx)) _ValueType(__iter_move(__ifirst));
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ } catch (...) {
+ _VSTD::__destroy(__ofirst, __idx);
+ throw;
+ }
+#endif
+
+ return {_VSTD::move(__ifirst), _VSTD::move(__idx)};
+}
+
+template <class _InputIterator, class _Size, class _ForwardIterator>
+inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator>
+uninitialized_move_n(_InputIterator __ifirst, _Size __n, _ForwardIterator __ofirst) {
+ using _ValueType = typename iterator_traits<_ForwardIterator>::value_type;
+ auto __iter_move = [](auto&& __iter) -> decltype(auto) { return _VSTD::move(*__iter); };
+
+ return _VSTD::__uninitialized_move_n<_ValueType>(_VSTD::move(__ifirst), __n, _VSTD::move(__ofirst),
+ __unreachable_sentinel(), __iter_move);
+}
+
+#endif // _LIBCPP_STD_VER > 14
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___MEMORY_UNINITIALIZED_ALGORITHMS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/unique_ptr.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/unique_ptr.h
new file mode 100644
index 0000000000..2c1f0aa0d0
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/unique_ptr.h
@@ -0,0 +1,766 @@
+// -*- 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/hash.h>
+#include <__functional/operations.h>
+#include <__memory/allocator_traits.h> // __pointer
+#include <__memory/compressed_pair.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include <cstddef>
+#include <stlfwd>
+#include <type_traits>
+
+#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_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>
+class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr {
+public:
+ typedef _Tp element_type;
+ typedef _Dp deleter_type;
+ typedef _LIBCPP_NODEBUG 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 __unique_ptr_deleter_sfinae<_Dp> _DeleterSFINAE;
+
+ template <bool _Dummy>
+ using _LValRefType _LIBCPP_NODEBUG =
+ typename __dependent_type<_DeleterSFINAE, _Dummy>::__lval_ref_type;
+
+ template <bool _Dummy>
+ using _GoodRValRefType _LIBCPP_NODEBUG =
+ typename __dependent_type<_DeleterSFINAE, _Dummy>::__good_rval_ref_type;
+
+ template <bool _Dummy>
+ using _BadRValRefType _LIBCPP_NODEBUG =
+ 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 =
+ typename enable_if<is_default_constructible<_Deleter>::value &&
+ !is_pointer<_Deleter>::value>::type;
+
+ template <class _ArgType>
+ using _EnableIfDeleterConstructible _LIBCPP_NODEBUG =
+ typename enable_if<is_constructible<deleter_type, _ArgType>::value>::type;
+
+ template <class _UPtr, class _Up>
+ using _EnableIfMoveConvertible _LIBCPP_NODEBUG = typename enable_if<
+ is_convertible<typename _UPtr::pointer, pointer>::value &&
+ !is_array<_Up>::value
+ >::type;
+
+ template <class _UDel>
+ using _EnableIfDeleterConvertible _LIBCPP_NODEBUG = 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_(__value_init_tag(), __value_init_tag()) {}
+
+ template <bool _Dummy = true,
+ class = _EnableIfDeleterDefaultConstructible<_Dummy> >
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(__value_init_tag(), __value_init_tag()) {}
+
+ template <bool _Dummy = true,
+ class = _EnableIfDeleterDefaultConstructible<_Dummy> >
+ _LIBCPP_INLINE_VISIBILITY
+ explicit unique_ptr(pointer __p) _NOEXCEPT : __ptr_(__p, __value_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(), __value_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 =
+ typename __dependent_type<_DeleterSFINAE, _Dummy>::__lval_ref_type;
+
+ template <bool _Dummy>
+ using _GoodRValRefType _LIBCPP_NODEBUG =
+ typename __dependent_type<_DeleterSFINAE, _Dummy>::__good_rval_ref_type;
+
+ template <bool _Dummy>
+ using _BadRValRefType _LIBCPP_NODEBUG =
+ 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 =
+ typename enable_if<is_default_constructible<_Deleter>::value &&
+ !is_pointer<_Deleter>::value>::type;
+
+ template <class _ArgType>
+ using _EnableIfDeleterConstructible _LIBCPP_NODEBUG =
+ typename enable_if<is_constructible<deleter_type, _ArgType>::value>::type;
+
+ template <class _Pp>
+ using _EnableIfPointerConvertible _LIBCPP_NODEBUG = typename enable_if<
+ _CheckArrayPointerConversion<_Pp>::value
+ >::type;
+
+ template <class _UPtr, class _Up,
+ class _ElemT = typename _UPtr::element_type>
+ using _EnableIfMoveConvertible _LIBCPP_NODEBUG = 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 = 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 = 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_(__value_init_tag(), __value_init_tag()) {}
+
+ template <bool _Dummy = true,
+ class = _EnableIfDeleterDefaultConstructible<_Dummy> >
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(__value_init_tag(), __value_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, __value_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
+
+#endif // _LIBCPP___MEMORY_UNIQUE_PTR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/uses_allocator.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/uses_allocator.h
new file mode 100644
index 0000000000..20147c5eb1
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/uses_allocator.h
@@ -0,0 +1,61 @@
+// -*- 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(...);
+ // Fix for MSVC which allows to reference private types. Wrap into declval to prevent that.
+ template <class _Up> static char __test(decltype(_VSTD::declval<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>
+inline 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/libs/cxxsupp/libcxxmsvc/include/__memory/voidify.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/voidify.h
new file mode 100644
index 0000000000..3a65c0e83f
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__memory/voidify.h
@@ -0,0 +1,30 @@
+// -*- 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_VOIDIFY_H
+#define _LIBCPP___MEMORY_VOIDIFY_H
+
+#include <__config>
+#include <__memory/addressof.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <typename _Tp>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void* __voidify(_Tp& __from) {
+ // Cast away cv-qualifiers to allow modifying elements of a range through const iterators.
+ return const_cast<void*>(static_cast<const volatile void*>(_VSTD::addressof(__from)));
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___MEMORY_VOIDIFY_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__mutex_base b/contrib/libs/cxxsupp/libcxxmsvc/include/__mutex_base
new file mode 100644
index 0000000000..78eda0882c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__mutex_base
@@ -0,0 +1,526 @@
+// -*- 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___MUTEX_BASE
+#define _LIBCPP___MUTEX_BASE
+
+#include <__config>
+#include <__threading_support>
+#include <chrono>
+#include <ratio>
+#include <system_error>
+#include <time.h>
+
+#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_HAS_NO_THREADS
+
+class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) mutex
+{
+ __libcpp_mutex_t __m_ = _LIBCPP_MUTEX_INITIALIZER;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR mutex() = default;
+
+ mutex(const mutex&) = delete;
+ mutex& operator=(const mutex&) = delete;
+
+#if defined(_LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION)
+ ~mutex() = default;
+#else
+ ~mutex() _NOEXCEPT;
+#endif
+
+ void lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability());
+ bool try_lock() _NOEXCEPT _LIBCPP_THREAD_SAFETY_ANNOTATION(try_acquire_capability(true));
+ void unlock() _NOEXCEPT _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability());
+
+ typedef __libcpp_mutex_t* native_handle_type;
+ _LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() {return &__m_;}
+};
+
+static_assert(is_nothrow_default_constructible<mutex>::value,
+ "the default constructor for std::mutex must be nothrow");
+
+struct _LIBCPP_TYPE_VIS defer_lock_t { explicit defer_lock_t() = default; };
+struct _LIBCPP_TYPE_VIS try_to_lock_t { explicit try_to_lock_t() = default; };
+struct _LIBCPP_TYPE_VIS adopt_lock_t { explicit adopt_lock_t() = default; };
+
+#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY)
+
+extern _LIBCPP_EXPORTED_FROM_ABI const defer_lock_t defer_lock;
+extern _LIBCPP_EXPORTED_FROM_ABI const try_to_lock_t try_to_lock;
+extern _LIBCPP_EXPORTED_FROM_ABI const adopt_lock_t adopt_lock;
+
+#else
+
+/* inline */ constexpr defer_lock_t defer_lock = defer_lock_t();
+/* inline */ constexpr try_to_lock_t try_to_lock = try_to_lock_t();
+/* inline */ constexpr adopt_lock_t adopt_lock = adopt_lock_t();
+
+#endif
+
+template <class _Mutex>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(scoped_lockable)
+lock_guard
+{
+public:
+ typedef _Mutex mutex_type;
+
+private:
+ mutex_type& __m_;
+public:
+
+ _LIBCPP_NODISCARD_EXT _LIBCPP_INLINE_VISIBILITY
+ explicit lock_guard(mutex_type& __m) _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability(__m))
+ : __m_(__m) {__m_.lock();}
+
+ _LIBCPP_NODISCARD_EXT _LIBCPP_INLINE_VISIBILITY
+ lock_guard(mutex_type& __m, adopt_lock_t) _LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m))
+ : __m_(__m) {}
+ _LIBCPP_INLINE_VISIBILITY
+ ~lock_guard() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) {__m_.unlock();}
+
+private:
+ lock_guard(lock_guard const&) = delete;
+ lock_guard& operator=(lock_guard const&) = delete;
+};
+
+template <class _Mutex>
+class _LIBCPP_TEMPLATE_VIS unique_lock
+{
+public:
+ typedef _Mutex mutex_type;
+
+private:
+ mutex_type* __m_;
+ bool __owns_;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ unique_lock() _NOEXCEPT : __m_(nullptr), __owns_(false) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit unique_lock(mutex_type& __m)
+ : __m_(_VSTD::addressof(__m)), __owns_(true) {__m_->lock();}
+ _LIBCPP_INLINE_VISIBILITY
+ unique_lock(mutex_type& __m, defer_lock_t) _NOEXCEPT
+ : __m_(_VSTD::addressof(__m)), __owns_(false) {}
+ _LIBCPP_INLINE_VISIBILITY
+ unique_lock(mutex_type& __m, try_to_lock_t)
+ : __m_(_VSTD::addressof(__m)), __owns_(__m.try_lock()) {}
+ _LIBCPP_INLINE_VISIBILITY
+ unique_lock(mutex_type& __m, adopt_lock_t)
+ : __m_(_VSTD::addressof(__m)), __owns_(true) {}
+ template <class _Clock, class _Duration>
+ _LIBCPP_INLINE_VISIBILITY
+ unique_lock(mutex_type& __m, const chrono::time_point<_Clock, _Duration>& __t)
+ : __m_(_VSTD::addressof(__m)), __owns_(__m.try_lock_until(__t)) {}
+ template <class _Rep, class _Period>
+ _LIBCPP_INLINE_VISIBILITY
+ unique_lock(mutex_type& __m, const chrono::duration<_Rep, _Period>& __d)
+ : __m_(_VSTD::addressof(__m)), __owns_(__m.try_lock_for(__d)) {}
+ _LIBCPP_INLINE_VISIBILITY
+ ~unique_lock()
+ {
+ if (__owns_)
+ __m_->unlock();
+ }
+
+ unique_lock(unique_lock const&) = delete;
+ unique_lock& operator=(unique_lock const&) = delete;
+
+ _LIBCPP_INLINE_VISIBILITY
+ unique_lock(unique_lock&& __u) _NOEXCEPT
+ : __m_(__u.__m_), __owns_(__u.__owns_)
+ {__u.__m_ = nullptr; __u.__owns_ = false;}
+ _LIBCPP_INLINE_VISIBILITY
+ unique_lock& operator=(unique_lock&& __u) _NOEXCEPT
+ {
+ if (__owns_)
+ __m_->unlock();
+ __m_ = __u.__m_;
+ __owns_ = __u.__owns_;
+ __u.__m_ = nullptr;
+ __u.__owns_ = false;
+ return *this;
+ }
+
+ void lock();
+ bool try_lock();
+
+ template <class _Rep, class _Period>
+ bool try_lock_for(const chrono::duration<_Rep, _Period>& __d);
+ template <class _Clock, class _Duration>
+ bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t);
+
+ void unlock();
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(unique_lock& __u) _NOEXCEPT
+ {
+ _VSTD::swap(__m_, __u.__m_);
+ _VSTD::swap(__owns_, __u.__owns_);
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ mutex_type* release() _NOEXCEPT
+ {
+ mutex_type* __m = __m_;
+ __m_ = nullptr;
+ __owns_ = false;
+ return __m;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool owns_lock() const _NOEXCEPT {return __owns_;}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit operator bool() const _NOEXCEPT {return __owns_;}
+ _LIBCPP_INLINE_VISIBILITY
+ mutex_type* mutex() const _NOEXCEPT {return __m_;}
+};
+
+template <class _Mutex>
+void
+unique_lock<_Mutex>::lock()
+{
+ if (__m_ == nullptr)
+ __throw_system_error(EPERM, "unique_lock::lock: references null mutex");
+ if (__owns_)
+ __throw_system_error(EDEADLK, "unique_lock::lock: already locked");
+ __m_->lock();
+ __owns_ = true;
+}
+
+template <class _Mutex>
+bool
+unique_lock<_Mutex>::try_lock()
+{
+ if (__m_ == nullptr)
+ __throw_system_error(EPERM, "unique_lock::try_lock: references null mutex");
+ if (__owns_)
+ __throw_system_error(EDEADLK, "unique_lock::try_lock: already locked");
+ __owns_ = __m_->try_lock();
+ return __owns_;
+}
+
+template <class _Mutex>
+template <class _Rep, class _Period>
+bool
+unique_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __d)
+{
+ if (__m_ == nullptr)
+ __throw_system_error(EPERM, "unique_lock::try_lock_for: references null mutex");
+ if (__owns_)
+ __throw_system_error(EDEADLK, "unique_lock::try_lock_for: already locked");
+ __owns_ = __m_->try_lock_for(__d);
+ return __owns_;
+}
+
+template <class _Mutex>
+template <class _Clock, class _Duration>
+bool
+unique_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t)
+{
+ if (__m_ == nullptr)
+ __throw_system_error(EPERM, "unique_lock::try_lock_until: references null mutex");
+ if (__owns_)
+ __throw_system_error(EDEADLK, "unique_lock::try_lock_until: already locked");
+ __owns_ = __m_->try_lock_until(__t);
+ return __owns_;
+}
+
+template <class _Mutex>
+void
+unique_lock<_Mutex>::unlock()
+{
+ if (!__owns_)
+ __throw_system_error(EPERM, "unique_lock::unlock: not locked");
+ __m_->unlock();
+ __owns_ = false;
+}
+
+template <class _Mutex>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>& __y) _NOEXCEPT
+ {__x.swap(__y);}
+
+//enum class cv_status
+_LIBCPP_DECLARE_STRONG_ENUM(cv_status)
+{
+ no_timeout,
+ timeout
+};
+_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(cv_status)
+
+class _LIBCPP_TYPE_VIS condition_variable
+{
+ __libcpp_condvar_t __cv_ = _LIBCPP_CONDVAR_INITIALIZER;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR condition_variable() _NOEXCEPT = default;
+
+#ifdef _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION
+ ~condition_variable() = default;
+#else
+ ~condition_variable();
+#endif
+
+ condition_variable(const condition_variable&) = delete;
+ condition_variable& operator=(const condition_variable&) = delete;
+
+ void notify_one() _NOEXCEPT;
+ void notify_all() _NOEXCEPT;
+
+ void wait(unique_lock<mutex>& __lk) _NOEXCEPT;
+ template <class _Predicate>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ void wait(unique_lock<mutex>& __lk, _Predicate __pred);
+
+ template <class _Clock, class _Duration>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ cv_status
+ wait_until(unique_lock<mutex>& __lk,
+ const chrono::time_point<_Clock, _Duration>& __t);
+
+ template <class _Clock, class _Duration, class _Predicate>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ bool
+ wait_until(unique_lock<mutex>& __lk,
+ const chrono::time_point<_Clock, _Duration>& __t,
+ _Predicate __pred);
+
+ template <class _Rep, class _Period>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ cv_status
+ wait_for(unique_lock<mutex>& __lk,
+ const chrono::duration<_Rep, _Period>& __d);
+
+ template <class _Rep, class _Period, class _Predicate>
+ bool
+ _LIBCPP_INLINE_VISIBILITY
+ wait_for(unique_lock<mutex>& __lk,
+ const chrono::duration<_Rep, _Period>& __d,
+ _Predicate __pred);
+
+ typedef __libcpp_condvar_t* native_handle_type;
+ _LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() {return &__cv_;}
+
+private:
+ void __do_timed_wait(unique_lock<mutex>& __lk,
+ chrono::time_point<chrono::system_clock, chrono::nanoseconds>) _NOEXCEPT;
+#if defined(_LIBCPP_HAS_COND_CLOCKWAIT)
+ void __do_timed_wait(unique_lock<mutex>& __lk,
+ chrono::time_point<chrono::steady_clock, chrono::nanoseconds>) _NOEXCEPT;
+#endif
+ template <class _Clock>
+ void __do_timed_wait(unique_lock<mutex>& __lk,
+ chrono::time_point<_Clock, chrono::nanoseconds>) _NOEXCEPT;
+};
+#endif // !_LIBCPP_HAS_NO_THREADS
+
+template <class _Rep, class _Period>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ is_floating_point<_Rep>::value,
+ chrono::nanoseconds
+>::type
+__safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d)
+{
+ using namespace chrono;
+ using __ratio = ratio_divide<_Period, nano>;
+ using __ns_rep = nanoseconds::rep;
+ _Rep __result_float = __d.count() * __ratio::num / __ratio::den;
+
+ _Rep __result_max = numeric_limits<__ns_rep>::max();
+ if (__result_float >= __result_max) {
+ return nanoseconds::max();
+ }
+
+ _Rep __result_min = numeric_limits<__ns_rep>::min();
+ if (__result_float <= __result_min) {
+ return nanoseconds::min();
+ }
+
+ return nanoseconds(static_cast<__ns_rep>(__result_float));
+}
+
+template <class _Rep, class _Period>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ !is_floating_point<_Rep>::value,
+ chrono::nanoseconds
+>::type
+__safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d)
+{
+ using namespace chrono;
+ if (__d.count() == 0) {
+ return nanoseconds(0);
+ }
+
+ using __ratio = ratio_divide<_Period, nano>;
+ using __ns_rep = nanoseconds::rep;
+ __ns_rep __result_max = numeric_limits<__ns_rep>::max();
+ if (__d.count() > 0 && __d.count() > __result_max / __ratio::num) {
+ return nanoseconds::max();
+ }
+
+ __ns_rep __result_min = numeric_limits<__ns_rep>::min();
+ if (__d.count() < 0 && __d.count() < __result_min / __ratio::num) {
+ return nanoseconds::min();
+ }
+
+ __ns_rep __result = __d.count() * __ratio::num / __ratio::den;
+ if (__result == 0) {
+ return nanoseconds(1);
+ }
+
+ return nanoseconds(__result);
+}
+
+#ifndef _LIBCPP_HAS_NO_THREADS
+template <class _Predicate>
+void
+condition_variable::wait(unique_lock<mutex>& __lk, _Predicate __pred)
+{
+ while (!__pred())
+ wait(__lk);
+}
+
+template <class _Clock, class _Duration>
+cv_status
+condition_variable::wait_until(unique_lock<mutex>& __lk,
+ const chrono::time_point<_Clock, _Duration>& __t)
+{
+ using namespace chrono;
+ using __clock_tp_ns = time_point<_Clock, nanoseconds>;
+
+ typename _Clock::time_point __now = _Clock::now();
+ if (__t <= __now)
+ return cv_status::timeout;
+
+ __clock_tp_ns __t_ns = __clock_tp_ns(_VSTD::__safe_nanosecond_cast(__t.time_since_epoch()));
+
+ __do_timed_wait(__lk, __t_ns);
+ return _Clock::now() < __t ? cv_status::no_timeout : cv_status::timeout;
+}
+
+template <class _Clock, class _Duration, class _Predicate>
+bool
+condition_variable::wait_until(unique_lock<mutex>& __lk,
+ const chrono::time_point<_Clock, _Duration>& __t,
+ _Predicate __pred)
+{
+ while (!__pred())
+ {
+ if (wait_until(__lk, __t) == cv_status::timeout)
+ return __pred();
+ }
+ return true;
+}
+
+template <class _Rep, class _Period>
+cv_status
+condition_variable::wait_for(unique_lock<mutex>& __lk,
+ const chrono::duration<_Rep, _Period>& __d)
+{
+ using namespace chrono;
+ if (__d <= __d.zero())
+ return cv_status::timeout;
+ using __ns_rep = nanoseconds::rep;
+ steady_clock::time_point __c_now = steady_clock::now();
+
+#if defined(_LIBCPP_HAS_COND_CLOCKWAIT)
+ using __clock_tp_ns = time_point<steady_clock, nanoseconds>;
+ __ns_rep __now_count_ns = _VSTD::__safe_nanosecond_cast(__c_now.time_since_epoch()).count();
+#else
+ using __clock_tp_ns = time_point<system_clock, nanoseconds>;
+ __ns_rep __now_count_ns = _VSTD::__safe_nanosecond_cast(system_clock::now().time_since_epoch()).count();
+#endif
+
+ __ns_rep __d_ns_count = _VSTD::__safe_nanosecond_cast(__d).count();
+
+ if (__now_count_ns > numeric_limits<__ns_rep>::max() - __d_ns_count) {
+ __do_timed_wait(__lk, __clock_tp_ns::max());
+ } else {
+ __do_timed_wait(__lk, __clock_tp_ns(nanoseconds(__now_count_ns + __d_ns_count)));
+ }
+
+ return steady_clock::now() - __c_now < __d ? cv_status::no_timeout :
+ cv_status::timeout;
+}
+
+template <class _Rep, class _Period, class _Predicate>
+inline
+bool
+condition_variable::wait_for(unique_lock<mutex>& __lk,
+ const chrono::duration<_Rep, _Period>& __d,
+ _Predicate __pred)
+{
+ return wait_until(__lk, chrono::steady_clock::now() + __d,
+ _VSTD::move(__pred));
+}
+
+#if defined(_LIBCPP_HAS_COND_CLOCKWAIT)
+inline
+void
+condition_variable::__do_timed_wait(unique_lock<mutex>& __lk,
+ chrono::time_point<chrono::steady_clock, chrono::nanoseconds> __tp) _NOEXCEPT
+{
+ using namespace chrono;
+ if (!__lk.owns_lock())
+ __throw_system_error(EPERM,
+ "condition_variable::timed wait: mutex not locked");
+ nanoseconds __d = __tp.time_since_epoch();
+ timespec __ts;
+ seconds __s = duration_cast<seconds>(__d);
+ using __ts_sec = decltype(__ts.tv_sec);
+ const __ts_sec __ts_sec_max = numeric_limits<__ts_sec>::max();
+ if (__s.count() < __ts_sec_max)
+ {
+ __ts.tv_sec = static_cast<__ts_sec>(__s.count());
+ __ts.tv_nsec = (__d - __s).count();
+ }
+ else
+ {
+ __ts.tv_sec = __ts_sec_max;
+ __ts.tv_nsec = giga::num - 1;
+ }
+ int __ec = pthread_cond_clockwait(&__cv_, __lk.mutex()->native_handle(), CLOCK_MONOTONIC, &__ts);
+ if (__ec != 0 && __ec != ETIMEDOUT)
+ __throw_system_error(__ec, "condition_variable timed_wait failed");
+}
+#endif // _LIBCPP_HAS_COND_CLOCKWAIT
+
+template <class _Clock>
+inline
+void
+condition_variable::__do_timed_wait(unique_lock<mutex>& __lk,
+ chrono::time_point<_Clock, chrono::nanoseconds> __tp) _NOEXCEPT
+{
+ wait_for(__lk, __tp - _Clock::now());
+}
+
+#endif // !_LIBCPP_HAS_NO_THREADS
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___MUTEX_BASE
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__node_handle b/contrib/libs/cxxsupp/libcxxmsvc/include/__node_handle
new file mode 100644
index 0000000000..71309be62f
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__node_handle
@@ -0,0 +1,253 @@
+// -*- 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___NODE_HANDLE
+#define _LIBCPP___NODE_HANDLE
+
+/*
+
+template<unspecified>
+class node-handle {
+public:
+ using value_type = see below; // not present for map containers
+ using key_type = see below; // not present for set containers
+ using mapped_type = see below; // not present for set containers
+ using allocator_type = see below;
+
+private:
+ using container_node_type = unspecified; // exposition only
+ using ator_traits = allocator_traits<allocator_type>; // exposition only
+
+ typename ator_traits::template
+ rebind_traits<container_node_type>::pointer ptr_; // exposition only
+ optional<allocator_type> alloc_; // exposition only
+
+public:
+ // [container.node.cons], constructors, copy, and assignment
+ constexpr node-handle() noexcept : ptr_(), alloc_() {}
+ node-handle(node-handle&&) noexcept;
+ node-handle& operator=(node-handle&&);
+
+ // [container.node.dtor], destructor
+ ~node-handle();
+
+ // [container.node.observers], observers
+ value_type& value() const; // not present for map containers
+ key_type& key() const; // not present for set containers
+ mapped_type& mapped() const; // not present for set containers
+
+ allocator_type get_allocator() const;
+ explicit operator bool() const noexcept;
+ [[nodiscard]] bool empty() const noexcept; // nodiscard since C++20
+
+ // [container.node.modifiers], modifiers
+ void swap(node-handle&)
+ noexcept(ator_traits::propagate_on_container_swap::value ||
+ ator_traits::is_always_equal::value);
+
+ friend void swap(node-handle& x, node-handle& y) noexcept(noexcept(x.swap(y))) {
+ x.swap(y);
+ }
+};
+
+*/
+
+#include <__assert>
+#include <__config>
+#include <memory>
+#include <optional>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 14
+
+// Specialized in __tree & __hash_table for their _NodeType.
+template <class _NodeType, class _Alloc>
+struct __generic_container_node_destructor;
+
+template <class _NodeType, class _Alloc,
+ template <class, class> class _MapOrSetSpecifics>
+class _LIBCPP_TEMPLATE_VIS __basic_node_handle
+ : public _MapOrSetSpecifics<
+ _NodeType,
+ __basic_node_handle<_NodeType, _Alloc, _MapOrSetSpecifics>>
+{
+ template <class _Tp, class _Compare, class _Allocator>
+ friend class __tree;
+ template <class _Tp, class _Hash, class _Equal, class _Allocator>
+ friend class __hash_table;
+ friend struct _MapOrSetSpecifics<
+ _NodeType, __basic_node_handle<_NodeType, _Alloc, _MapOrSetSpecifics>>;
+
+ typedef allocator_traits<_Alloc> __alloc_traits;
+ typedef typename __rebind_pointer<typename __alloc_traits::void_pointer,
+ _NodeType>::type
+ __node_pointer_type;
+
+public:
+ typedef _Alloc allocator_type;
+
+private:
+ __node_pointer_type __ptr_ = nullptr;
+ optional<allocator_type> __alloc_;
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __release_ptr()
+ {
+ __ptr_ = nullptr;
+ __alloc_ = _VSTD::nullopt;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __destroy_node_pointer()
+ {
+ if (__ptr_ != nullptr)
+ {
+ typedef typename __allocator_traits_rebind<
+ allocator_type, _NodeType>::type __node_alloc_type;
+ __node_alloc_type __alloc(*__alloc_);
+ __generic_container_node_destructor<_NodeType, __node_alloc_type>(
+ __alloc, true)(__ptr_);
+ __ptr_ = nullptr;
+ }
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __basic_node_handle(__node_pointer_type __ptr,
+ allocator_type const& __alloc)
+ : __ptr_(__ptr), __alloc_(__alloc)
+ {
+ }
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ __basic_node_handle() = default;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __basic_node_handle(__basic_node_handle&& __other) noexcept
+ : __ptr_(__other.__ptr_),
+ __alloc_(_VSTD::move(__other.__alloc_))
+ {
+ __other.__ptr_ = nullptr;
+ __other.__alloc_ = _VSTD::nullopt;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __basic_node_handle& operator=(__basic_node_handle&& __other)
+ {
+ _LIBCPP_ASSERT(
+ __alloc_ == _VSTD::nullopt ||
+ __alloc_traits::propagate_on_container_move_assignment::value ||
+ __alloc_ == __other.__alloc_,
+ "node_type with incompatible allocator passed to "
+ "node_type::operator=(node_type&&)");
+
+ __destroy_node_pointer();
+ __ptr_ = __other.__ptr_;
+
+ if (__alloc_traits::propagate_on_container_move_assignment::value ||
+ __alloc_ == _VSTD::nullopt)
+ __alloc_ = _VSTD::move(__other.__alloc_);
+
+ __other.__ptr_ = nullptr;
+ __other.__alloc_ = _VSTD::nullopt;
+
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ allocator_type get_allocator() const { return *__alloc_; }
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit operator bool() const { return __ptr_ != nullptr; }
+
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+ bool empty() const { return __ptr_ == nullptr; }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(__basic_node_handle& __other) noexcept(
+ __alloc_traits::propagate_on_container_swap::value ||
+ __alloc_traits::is_always_equal::value)
+ {
+ using _VSTD::swap;
+ swap(__ptr_, __other.__ptr_);
+ if (__alloc_traits::propagate_on_container_swap::value ||
+ __alloc_ == _VSTD::nullopt || __other.__alloc_ == _VSTD::nullopt)
+ swap(__alloc_, __other.__alloc_);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ friend void swap(__basic_node_handle& __a, __basic_node_handle& __b)
+ noexcept(noexcept(__a.swap(__b))) { __a.swap(__b); }
+
+ _LIBCPP_INLINE_VISIBILITY
+ ~__basic_node_handle()
+ {
+ __destroy_node_pointer();
+ }
+};
+
+template <class _NodeType, class _Derived>
+struct __set_node_handle_specifics
+{
+ typedef typename _NodeType::__node_value_type value_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ value_type& value() const
+ {
+ return static_cast<_Derived const*>(this)->__ptr_->__value_;
+ }
+};
+
+template <class _NodeType, class _Derived>
+struct __map_node_handle_specifics
+{
+ typedef typename _NodeType::__node_value_type::key_type key_type;
+ typedef typename _NodeType::__node_value_type::mapped_type mapped_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ key_type& key() const
+ {
+ return static_cast<_Derived const*>(this)->
+ __ptr_->__value_.__ref().first;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ mapped_type& mapped() const
+ {
+ return static_cast<_Derived const*>(this)->
+ __ptr_->__value_.__ref().second;
+ }
+};
+
+template <class _NodeType, class _Alloc>
+using __set_node_handle =
+ __basic_node_handle< _NodeType, _Alloc, __set_node_handle_specifics>;
+
+template <class _NodeType, class _Alloc>
+using __map_node_handle =
+ __basic_node_handle< _NodeType, _Alloc, __map_node_handle_specifics>;
+
+template <class _Iterator, class _NodeType>
+struct _LIBCPP_TEMPLATE_VIS __insert_return_type
+{
+ _Iterator position;
+ bool inserted;
+ _NodeType node;
+};
+
+#endif // _LIBCPP_STD_VER > 14
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___NODE_HANDLE
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/accumulate.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/accumulate.h
new file mode 100644
index 0000000000..fa759872ce
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/accumulate.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___NUMERIC_ACCUMULATE_H
+#define _LIBCPP___NUMERIC_ACCUMULATE_H
+
+#include <__config>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _InputIterator, class _Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_Tp
+accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
+{
+ for (; __first != __last; ++__first)
+#if _LIBCPP_STD_VER > 17
+ __init = _VSTD::move(__init) + *__first;
+#else
+ __init = __init + *__first;
+#endif
+ return __init;
+}
+
+template <class _InputIterator, class _Tp, class _BinaryOperation>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_Tp
+accumulate(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOperation __binary_op)
+{
+ for (; __first != __last; ++__first)
+#if _LIBCPP_STD_VER > 17
+ __init = __binary_op(_VSTD::move(__init), *__first);
+#else
+ __init = __binary_op(__init, *__first);
+#endif
+ return __init;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___NUMERIC_ACCUMULATE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/adjacent_difference.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/adjacent_difference.h
new file mode 100644
index 0000000000..5c712ecdf7
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/adjacent_difference.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___NUMERIC_ADJACENT_DIFFERENCE_H
+#define _LIBCPP___NUMERIC_ADJACENT_DIFFERENCE_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_BEGIN_NAMESPACE_STD
+
+template <class _InputIterator, class _OutputIterator>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
+{
+ if (__first != __last)
+ {
+ typename iterator_traits<_InputIterator>::value_type __acc(*__first);
+ *__result = __acc;
+ for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result)
+ {
+ typename iterator_traits<_InputIterator>::value_type __val(*__first);
+#if _LIBCPP_STD_VER > 17
+ *__result = __val - _VSTD::move(__acc);
+#else
+ *__result = __val - __acc;
+#endif
+ __acc = _VSTD::move(__val);
+ }
+ }
+ return __result;
+}
+
+template <class _InputIterator, class _OutputIterator, class _BinaryOperation>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
+ _BinaryOperation __binary_op)
+{
+ if (__first != __last)
+ {
+ typename iterator_traits<_InputIterator>::value_type __acc(*__first);
+ *__result = __acc;
+ for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result)
+ {
+ typename iterator_traits<_InputIterator>::value_type __val(*__first);
+#if _LIBCPP_STD_VER > 17
+ *__result = __binary_op(__val, _VSTD::move(__acc));
+#else
+ *__result = __binary_op(__val, __acc);
+#endif
+ __acc = _VSTD::move(__val);
+ }
+ }
+ return __result;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___NUMERIC_ADJACENT_DIFFERENCE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/exclusive_scan.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/exclusive_scan.h
new file mode 100644
index 0000000000..c0c89b3880
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/exclusive_scan.h
@@ -0,0 +1,53 @@
+// -*- 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___NUMERIC_EXCLUSIVE_SCAN_H
+#define _LIBCPP___NUMERIC_EXCLUSIVE_SCAN_H
+
+#include <__config>
+#include <__functional/operations.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 14
+
+template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
+exclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Tp __init, _BinaryOp __b) {
+ if (__first != __last) {
+ _Tp __tmp(__b(__init, *__first));
+ while (true) {
+ *__result = _VSTD::move(__init);
+ ++__result;
+ ++__first;
+ if (__first == __last)
+ break;
+ __init = _VSTD::move(__tmp);
+ __tmp = __b(__init, *__first);
+ }
+ }
+ return __result;
+}
+
+template <class _InputIterator, class _OutputIterator, class _Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
+exclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Tp __init) {
+ return _VSTD::exclusive_scan(__first, __last, __result, __init, _VSTD::plus<>());
+}
+
+#endif // _LIBCPP_STD_VER > 14
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___NUMERIC_EXCLUSIVE_SCAN_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/gcd_lcm.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/gcd_lcm.h
new file mode 100644
index 0000000000..9a53a001f2
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/gcd_lcm.h
@@ -0,0 +1,96 @@
+// -*- 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___NUMERIC_GCD_LCM_H
+#define _LIBCPP___NUMERIC_GCD_LCM_H
+
+#include <__assert>
+#include <__config>
+#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 > 14
+
+template <typename _Result, typename _Source, bool _IsSigned = is_signed<_Source>::value> struct __ct_abs;
+
+template <typename _Result, typename _Source>
+struct __ct_abs<_Result, _Source, true> {
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ _Result operator()(_Source __t) const noexcept
+ {
+ if (__t >= 0) return __t;
+ if (__t == numeric_limits<_Source>::min()) return -static_cast<_Result>(__t);
+ return -__t;
+ }
+};
+
+template <typename _Result, typename _Source>
+struct __ct_abs<_Result, _Source, false> {
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ _Result operator()(_Source __t) const noexcept { return __t; }
+};
+
+
+template<class _Tp>
+_LIBCPP_CONSTEXPR _LIBCPP_HIDDEN
+_Tp __gcd(_Tp __m, _Tp __n)
+{
+ static_assert((!is_signed<_Tp>::value), "");
+ return __n == 0 ? __m : _VSTD::__gcd<_Tp>(__n, __m % __n);
+}
+
+template<class _Tp, class _Up>
+_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+common_type_t<_Tp,_Up>
+gcd(_Tp __m, _Up __n)
+{
+ static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to gcd must be integer types");
+ static_assert((!is_same<typename remove_cv<_Tp>::type, bool>::value), "First argument to gcd cannot be bool" );
+ static_assert((!is_same<typename remove_cv<_Up>::type, bool>::value), "Second argument to gcd cannot be bool" );
+ using _Rp = common_type_t<_Tp,_Up>;
+ using _Wp = make_unsigned_t<_Rp>;
+ return static_cast<_Rp>(_VSTD::__gcd(
+ static_cast<_Wp>(__ct_abs<_Rp, _Tp>()(__m)),
+ static_cast<_Wp>(__ct_abs<_Rp, _Up>()(__n))));
+}
+
+template<class _Tp, class _Up>
+_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+common_type_t<_Tp,_Up>
+lcm(_Tp __m, _Up __n)
+{
+ static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to lcm must be integer types");
+ static_assert((!is_same<typename remove_cv<_Tp>::type, bool>::value), "First argument to lcm cannot be bool" );
+ static_assert((!is_same<typename remove_cv<_Up>::type, bool>::value), "Second argument to lcm cannot be bool" );
+ if (__m == 0 || __n == 0)
+ return 0;
+
+ using _Rp = common_type_t<_Tp,_Up>;
+ _Rp __val1 = __ct_abs<_Rp, _Tp>()(__m) / _VSTD::gcd(__m, __n);
+ _Rp __val2 = __ct_abs<_Rp, _Up>()(__n);
+ _LIBCPP_ASSERT((numeric_limits<_Rp>::max() / __val1 > __val2), "Overflow in lcm");
+ return __val1 * __val2;
+}
+
+#endif // _LIBCPP_STD_VER
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___NUMERIC_GCD_LCM_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/inclusive_scan.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/inclusive_scan.h
new file mode 100644
index 0000000000..a6b0050758
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/inclusive_scan.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___NUMERIC_INCLUSIVE_SCAN_H
+#define _LIBCPP___NUMERIC_INCLUSIVE_SCAN_H
+
+#include <__config>
+#include <__functional/operations.h>
+#include <__iterator/iterator_traits.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 14
+
+template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
+inclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryOp __b, _Tp __init) {
+ for (; __first != __last; ++__first, (void)++__result) {
+ __init = __b(__init, *__first);
+ *__result = __init;
+ }
+ return __result;
+}
+
+template <class _InputIterator, class _OutputIterator, class _BinaryOp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
+inclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryOp __b) {
+ if (__first != __last) {
+ typename iterator_traits<_InputIterator>::value_type __init = *__first;
+ *__result++ = __init;
+ if (++__first != __last)
+ return _VSTD::inclusive_scan(__first, __last, __result, __b, __init);
+ }
+
+ return __result;
+}
+
+template <class _InputIterator, class _OutputIterator>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator inclusive_scan(_InputIterator __first,
+ _InputIterator __last,
+ _OutputIterator __result) {
+ return _VSTD::inclusive_scan(__first, __last, __result, _VSTD::plus<>());
+}
+
+#endif // _LIBCPP_STD_VER > 14
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___NUMERIC_INCLUSIVE_SCAN_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/inner_product.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/inner_product.h
new file mode 100644
index 0000000000..6fe18bb2b1
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/inner_product.h
@@ -0,0 +1,53 @@
+// -*- 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___NUMERIC_INNER_PRODUCT_H
+#define _LIBCPP___NUMERIC_INNER_PRODUCT_H
+
+#include <__config>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _InputIterator1, class _InputIterator2, class _Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_Tp
+inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp __init)
+{
+ for (; __first1 != __last1; ++__first1, (void) ++__first2)
+#if _LIBCPP_STD_VER > 17
+ __init = _VSTD::move(__init) + *__first1 * *__first2;
+#else
+ __init = __init + *__first1 * *__first2;
+#endif
+ return __init;
+}
+
+template <class _InputIterator1, class _InputIterator2, class _Tp, class _BinaryOperation1, class _BinaryOperation2>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_Tp
+inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2,
+ _Tp __init, _BinaryOperation1 __binary_op1, _BinaryOperation2 __binary_op2)
+{
+ for (; __first1 != __last1; ++__first1, (void) ++__first2)
+#if _LIBCPP_STD_VER > 17
+ __init = __binary_op1(_VSTD::move(__init), __binary_op2(*__first1, *__first2));
+#else
+ __init = __binary_op1(__init, __binary_op2(*__first1, *__first2));
+#endif
+ return __init;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___NUMERIC_INNER_PRODUCT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/iota.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/iota.h
new file mode 100644
index 0000000000..b30e0e0a54
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/iota.h
@@ -0,0 +1,32 @@
+// -*- 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___NUMERIC_IOTA_H
+#define _LIBCPP___NUMERIC_IOTA_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _ForwardIterator, class _Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+void
+iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value_)
+{
+ for (; __first != __last; ++__first, (void) ++__value_)
+ *__first = __value_;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___NUMERIC_IOTA_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/midpoint.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/midpoint.h
new file mode 100644
index 0000000000..668030c46b
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/midpoint.h
@@ -0,0 +1,85 @@
+// -*- 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___NUMERIC_MIDPOINT_H
+#define _LIBCPP___NUMERIC_MIDPOINT_H
+
+#include <__config>
+#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
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<is_integral_v<_Tp> && !is_same_v<bool, _Tp> && !is_null_pointer_v<_Tp>, _Tp>
+midpoint(_Tp __a, _Tp __b) noexcept
+_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
+{
+ using _Up = make_unsigned_t<_Tp>;
+ constexpr _Up __bitshift = numeric_limits<_Up>::digits - 1;
+
+ _Up __diff = _Up(__b) - _Up(__a);
+ _Up __sign_bit = __b < __a;
+
+ _Up __half_diff = (__diff / 2) + (__sign_bit << __bitshift) + (__sign_bit & __diff);
+
+ return __a + __half_diff;
+}
+
+
+template <class _TPtr>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<is_pointer_v<_TPtr>
+ && is_object_v<remove_pointer_t<_TPtr>>
+ && ! is_void_v<remove_pointer_t<_TPtr>>
+ && (sizeof(remove_pointer_t<_TPtr>) > 0), _TPtr>
+midpoint(_TPtr __a, _TPtr __b) noexcept
+{
+ return __a + _VSTD::midpoint(ptrdiff_t(0), __b - __a);
+}
+
+
+template <typename _Tp>
+constexpr int __sign(_Tp __val) {
+ return (_Tp(0) < __val) - (__val < _Tp(0));
+}
+
+template <typename _Fp>
+constexpr _Fp __fp_abs(_Fp __f) { return __f >= 0 ? __f : -__f; }
+
+template <class _Fp>
+_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;
+ 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
+ __fp_abs(__b) < __lo ? __a/2 + __b : // not safe to halve b
+ __a/2 + __b/2; // otherwise correctly rounded
+}
+
+#endif // _LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___NUMERIC_MIDPOINT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/partial_sum.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/partial_sum.h
new file mode 100644
index 0000000000..9acee3afc2
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/partial_sum.h
@@ -0,0 +1,70 @@
+// -*- 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___NUMERIC_PARTIAL_SUM_H
+#define _LIBCPP___NUMERIC_PARTIAL_SUM_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_BEGIN_NAMESPACE_STD
+
+template <class _InputIterator, class _OutputIterator>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
+{
+ if (__first != __last)
+ {
+ typename iterator_traits<_InputIterator>::value_type __t(*__first);
+ *__result = __t;
+ for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result)
+ {
+#if _LIBCPP_STD_VER > 17
+ __t = _VSTD::move(__t) + *__first;
+#else
+ __t = __t + *__first;
+#endif
+ *__result = __t;
+ }
+ }
+ return __result;
+}
+
+template <class _InputIterator, class _OutputIterator, class _BinaryOperation>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
+ _BinaryOperation __binary_op)
+{
+ if (__first != __last)
+ {
+ typename iterator_traits<_InputIterator>::value_type __t(*__first);
+ *__result = __t;
+ for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result)
+ {
+#if _LIBCPP_STD_VER > 17
+ __t = __binary_op(_VSTD::move(__t), *__first);
+#else
+ __t = __binary_op(__t, *__first);
+#endif
+ *__result = __t;
+ }
+ }
+ return __result;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___NUMERIC_PARTIAL_SUM_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/reduce.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/reduce.h
new file mode 100644
index 0000000000..90e4d238d8
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/reduce.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___NUMERIC_REDUCE_H
+#define _LIBCPP___NUMERIC_REDUCE_H
+
+#include <__config>
+#include <__functional/operations.h>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 14
+template <class _InputIterator, class _Tp, class _BinaryOp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp reduce(_InputIterator __first, _InputIterator __last,
+ _Tp __init, _BinaryOp __b) {
+ for (; __first != __last; ++__first)
+ __init = __b(__init, *__first);
+ return __init;
+}
+
+template <class _InputIterator, class _Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp reduce(_InputIterator __first, _InputIterator __last,
+ _Tp __init) {
+ return _VSTD::reduce(__first, __last, __init, _VSTD::plus<>());
+}
+
+template <class _InputIterator>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 typename iterator_traits<_InputIterator>::value_type
+reduce(_InputIterator __first, _InputIterator __last) {
+ return _VSTD::reduce(__first, __last, typename iterator_traits<_InputIterator>::value_type{});
+}
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___NUMERIC_REDUCE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/transform_exclusive_scan.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/transform_exclusive_scan.h
new file mode 100644
index 0000000000..45b3077f66
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/transform_exclusive_scan.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___NUMERIC_TRANSFORM_EXCLUSIVE_SCAN_H
+#define _LIBCPP___NUMERIC_TRANSFORM_EXCLUSIVE_SCAN_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 14
+
+template <class _InputIterator, class _OutputIterator, class _Tp,
+ class _BinaryOp, class _UnaryOp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+transform_exclusive_scan(_InputIterator __first, _InputIterator __last,
+ _OutputIterator __result, _Tp __init,
+ _BinaryOp __b, _UnaryOp __u)
+{
+ if (__first != __last)
+ {
+ _Tp __saved = __init;
+ do
+ {
+ __init = __b(__init, __u(*__first));
+ *__result = __saved;
+ __saved = __init;
+ ++__result;
+ } while (++__first != __last);
+ }
+ return __result;
+}
+
+#endif // _LIBCPP_STD_VER > 14
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___NUMERIC_TRANSFORM_EXCLUSIVE_SCAN_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/transform_inclusive_scan.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/transform_inclusive_scan.h
new file mode 100644
index 0000000000..b0d4ab5a88
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/transform_inclusive_scan.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___NUMERIC_TRANSFORM_INCLUSIVE_SCAN_H
+#define _LIBCPP___NUMERIC_TRANSFORM_INCLUSIVE_SCAN_H
+
+#include <__config>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 14
+
+template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp, class _UnaryOp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
+ _OutputIterator __result, _BinaryOp __b, _UnaryOp __u, _Tp __init)
+{
+ for (; __first != __last; ++__first, (void) ++__result) {
+ __init = __b(__init, __u(*__first));
+ *__result = __init;
+ }
+
+ return __result;
+}
+
+template <class _InputIterator, class _OutputIterator, class _BinaryOp, class _UnaryOp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
+ _OutputIterator __result, _BinaryOp __b, _UnaryOp __u)
+{
+ if (__first != __last) {
+ typename iterator_traits<_InputIterator>::value_type __init = __u(*__first);
+ *__result++ = __init;
+ if (++__first != __last)
+ return _VSTD::transform_inclusive_scan(__first, __last, __result, __b, __u, __init);
+ }
+
+ return __result;
+}
+
+#endif // _LIBCPP_STD_VER > 14
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___NUMERIC_TRANSFORM_INCLUSIVE_SCAN_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/transform_reduce.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/transform_reduce.h
new file mode 100644
index 0000000000..da5a77988c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__numeric/transform_reduce.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___NUMERIC_TRANSFORM_REDUCE_H
+#define _LIBCPP___NUMERIC_TRANSFORM_REDUCE_H
+
+#include <__config>
+#include <__functional/operations.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 14
+template <class _InputIterator, class _Tp, class _BinaryOp, class _UnaryOp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp transform_reduce(_InputIterator __first,
+ _InputIterator __last, _Tp __init,
+ _BinaryOp __b, _UnaryOp __u) {
+ for (; __first != __last; ++__first)
+ __init = __b(__init, __u(*__first));
+ return __init;
+}
+
+template <class _InputIterator1, class _InputIterator2, class _Tp, class _BinaryOp1, class _BinaryOp2>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp transform_reduce(_InputIterator1 __first1,
+ _InputIterator1 __last1,
+ _InputIterator2 __first2, _Tp __init,
+ _BinaryOp1 __b1, _BinaryOp2 __b2) {
+ for (; __first1 != __last1; ++__first1, (void)++__first2)
+ __init = __b1(__init, __b2(*__first1, *__first2));
+ return __init;
+}
+
+template <class _InputIterator1, class _InputIterator2, class _Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp transform_reduce(_InputIterator1 __first1,
+ _InputIterator1 __last1,
+ _InputIterator2 __first2, _Tp __init) {
+ return _VSTD::transform_reduce(__first1, __last1, __first2, _VSTD::move(__init), _VSTD::plus<>(),
+ _VSTD::multiplies<>());
+}
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___NUMERIC_TRANSFORM_REDUCE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/bernoulli_distribution.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/bernoulli_distribution.h
new file mode 100644
index 0000000000..cf019519ab
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/bernoulli_distribution.h
@@ -0,0 +1,143 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_BERNOULLI_DISTRIBUTION_H
+#define _LIBCPP___RANDOM_BERNOULLI_DISTRIBUTION_H
+
+#include <__config>
+#include <__random/uniform_real_distribution.h>
+#include <iosfwd>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+class _LIBCPP_TEMPLATE_VIS bernoulli_distribution
+{
+public:
+ // types
+ typedef bool result_type;
+
+ class _LIBCPP_TEMPLATE_VIS param_type
+ {
+ double __p_;
+ public:
+ typedef bernoulli_distribution distribution_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit param_type(double __p = 0.5) : __p_(__p) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ double p() const {return __p_;}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const param_type& __x, const param_type& __y)
+ {return __x.__p_ == __y.__p_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ 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
+ _LIBCPP_INLINE_VISIBILITY
+ bernoulli_distribution() : bernoulli_distribution(0.5) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit bernoulli_distribution(double __p) : __p_(param_type(__p)) {}
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit bernoulli_distribution(double __p = 0.5) : __p_(param_type(__p)) {}
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ explicit bernoulli_distribution(const param_type& __p) : __p_(__p) {}
+ _LIBCPP_INLINE_VISIBILITY
+ void reset() {}
+
+ // generating functions
+ template<class _URNG>
+ _LIBCPP_INLINE_VISIBILITY
+ result_type operator()(_URNG& __g)
+ {return (*this)(__g, __p_);}
+ template<class _URNG> _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g, const param_type& __p);
+
+ // property functions
+ _LIBCPP_INLINE_VISIBILITY
+ double p() const {return __p_.p();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ param_type param() const {return __p_;}
+ _LIBCPP_INLINE_VISIBILITY
+ void param(const param_type& __p) {__p_ = __p;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type min() const {return false;}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type max() const {return true;}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const bernoulli_distribution& __x,
+ const bernoulli_distribution& __y)
+ {return __x.__p_ == __y.__p_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const bernoulli_distribution& __x,
+ const bernoulli_distribution& __y)
+ {return !(__x == __y);}
+};
+
+template<class _URNG>
+inline
+bernoulli_distribution::result_type
+bernoulli_distribution::operator()(_URNG& __g, const param_type& __p)
+{
+ uniform_real_distribution<double> __gen;
+ return __gen(__g) < __p.p();
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const bernoulli_distribution& __x)
+{
+ __save_flags<_CharT, _Traits> __lx(__os);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
+ _CharT __sp = __os.widen(' ');
+ __os.fill(__sp);
+ return __os << __x.p();
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is, bernoulli_distribution& __x)
+{
+ typedef bernoulli_distribution _Eng;
+ 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);
+ double __p;
+ __is >> __p;
+ if (!__is.fail())
+ __x.param(param_type(__p));
+ return __is;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANDOM_BERNOULLI_DISTRIBUTION_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/binomial_distribution.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/binomial_distribution.h
new file mode 100644
index 0000000000..77df98cba0
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/binomial_distribution.h
@@ -0,0 +1,225 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_BINOMIAL_DISTRIBUTION_H
+#define _LIBCPP___RANDOM_BINOMIAL_DISTRIBUTION_H
+
+#include <__config>
+#include <__random/uniform_real_distribution.h>
+#include <cmath>
+#include <iosfwd>
+
+#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 _IntType = int>
+class _LIBCPP_TEMPLATE_VIS binomial_distribution
+{
+public:
+ // types
+ typedef _IntType result_type;
+
+ class _LIBCPP_TEMPLATE_VIS param_type
+ {
+ result_type __t_;
+ double __p_;
+ double __pr_;
+ double __odds_ratio_;
+ result_type __r0_;
+ public:
+ typedef binomial_distribution distribution_type;
+
+ explicit param_type(result_type __t = 1, double __p = 0.5);
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type t() const {return __t_;}
+ _LIBCPP_INLINE_VISIBILITY
+ double p() const {return __p_;}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const param_type& __x, const param_type& __y)
+ {return __x.__t_ == __y.__t_ && __x.__p_ == __y.__p_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const param_type& __x, const param_type& __y)
+ {return !(__x == __y);}
+
+ friend class binomial_distribution;
+ };
+
+private:
+ param_type __p_;
+
+public:
+ // constructors and reset functions
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ binomial_distribution() : binomial_distribution(1) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit binomial_distribution(result_type __t, double __p = 0.5)
+ : __p_(param_type(__t, __p)) {}
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit binomial_distribution(result_type __t = 1, double __p = 0.5)
+ : __p_(param_type(__t, __p)) {}
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ explicit binomial_distribution(const param_type& __p) : __p_(__p) {}
+ _LIBCPP_INLINE_VISIBILITY
+ void reset() {}
+
+ // generating functions
+ template<class _URNG>
+ _LIBCPP_INLINE_VISIBILITY
+ result_type operator()(_URNG& __g)
+ {return (*this)(__g, __p_);}
+ template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+
+ // property functions
+ _LIBCPP_INLINE_VISIBILITY
+ result_type t() const {return __p_.t();}
+ _LIBCPP_INLINE_VISIBILITY
+ double p() const {return __p_.p();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ param_type param() const {return __p_;}
+ _LIBCPP_INLINE_VISIBILITY
+ void param(const param_type& __p) {__p_ = __p;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type min() const {return 0;}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type max() const {return t();}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const binomial_distribution& __x,
+ const binomial_distribution& __y)
+ {return __x.__p_ == __y.__p_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const binomial_distribution& __x,
+ const binomial_distribution& __y)
+ {return !(__x == __y);}
+};
+
+#ifndef _LIBCPP_MSVCRT_LIKE
+extern "C" double lgamma_r(double, int *);
+#endif
+
+inline _LIBCPP_INLINE_VISIBILITY double __libcpp_lgamma(double __d) {
+#if defined(_LIBCPP_MSVCRT_LIKE)
+ return lgamma(__d);
+#else
+ int __sign;
+ return lgamma_r(__d, &__sign);
+#endif
+}
+
+template<class _IntType>
+binomial_distribution<_IntType>::param_type::param_type(result_type __t, double __p)
+ : __t_(__t), __p_(__p)
+{
+ if (0 < __p_ && __p_ < 1)
+ {
+ __r0_ = static_cast<result_type>((__t_ + 1) * __p_);
+ __pr_ = _VSTD::exp(__libcpp_lgamma(__t_ + 1.) -
+ __libcpp_lgamma(__r0_ + 1.) -
+ __libcpp_lgamma(__t_ - __r0_ + 1.) + __r0_ * _VSTD::log(__p_) +
+ (__t_ - __r0_) * _VSTD::log(1 - __p_));
+ __odds_ratio_ = __p_ / (1 - __p_);
+ }
+}
+
+// Reference: Kemp, C.D. (1986). `A modal method for generating binomial
+// variables', Commun. Statist. - Theor. Meth. 15(3), 805-813.
+template<class _IntType>
+template<class _URNG>
+_IntType
+binomial_distribution<_IntType>::operator()(_URNG& __g, const param_type& __pr)
+{
+ if (__pr.__t_ == 0 || __pr.__p_ == 0)
+ return 0;
+ if (__pr.__p_ == 1)
+ return __pr.__t_;
+ uniform_real_distribution<double> __gen;
+ double __u = __gen(__g) - __pr.__pr_;
+ if (__u < 0)
+ return __pr.__r0_;
+ double __pu = __pr.__pr_;
+ double __pd = __pu;
+ result_type __ru = __pr.__r0_;
+ result_type __rd = __ru;
+ while (true)
+ {
+ bool __break = true;
+ if (__rd >= 1)
+ {
+ __pd *= __rd / (__pr.__odds_ratio_ * (__pr.__t_ - __rd + 1));
+ __u -= __pd;
+ __break = false;
+ if (__u < 0)
+ return __rd - 1;
+ }
+ if ( __rd != 0 )
+ --__rd;
+ ++__ru;
+ if (__ru <= __pr.__t_)
+ {
+ __pu *= (__pr.__t_ - __ru + 1) * __pr.__odds_ratio_ / __ru;
+ __u -= __pu;
+ __break = false;
+ if (__u < 0)
+ return __ru;
+ }
+ if (__break)
+ return 0;
+ }
+}
+
+template <class _CharT, class _Traits, class _IntType>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const binomial_distribution<_IntType>& __x)
+{
+ __save_flags<_CharT, _Traits> __lx(__os);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
+ _CharT __sp = __os.widen(' ');
+ __os.fill(__sp);
+ return __os << __x.t() << __sp << __x.p();
+}
+
+template <class _CharT, class _Traits, class _IntType>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ binomial_distribution<_IntType>& __x)
+{
+ typedef binomial_distribution<_IntType> _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 __t;
+ double __p;
+ __is >> __t >> __p;
+ if (!__is.fail())
+ __x.param(param_type(__t, __p));
+ return __is;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANDOM_BINOMIAL_DISTRIBUTION_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/cauchy_distribution.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/cauchy_distribution.h
new file mode 100644
index 0000000000..288118e1d2
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/cauchy_distribution.h
@@ -0,0 +1,162 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_CAUCHY_DISTRIBUTION_H
+#define _LIBCPP___RANDOM_CAUCHY_DISTRIBUTION_H
+
+#include <__config>
+#include <__random/uniform_real_distribution.h>
+#include <cmath>
+#include <iosfwd>
+#include <limits>
+
+#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 _RealType = double>
+class _LIBCPP_TEMPLATE_VIS cauchy_distribution
+{
+public:
+ // types
+ typedef _RealType result_type;
+
+ class _LIBCPP_TEMPLATE_VIS param_type
+ {
+ result_type __a_;
+ result_type __b_;
+ public:
+ typedef cauchy_distribution distribution_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit param_type(result_type __a = 0, result_type __b = 1)
+ : __a_(__a), __b_(__b) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type a() const {return __a_;}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type b() const {return __b_;}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const param_type& __x, const param_type& __y)
+ {return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const param_type& __x, const param_type& __y)
+ {return !(__x == __y);}
+ };
+
+private:
+ param_type __p_;
+
+public:
+ // constructor and reset functions
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ cauchy_distribution() : cauchy_distribution(0) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit cauchy_distribution(result_type __a, result_type __b = 1)
+ : __p_(param_type(__a, __b)) {}
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit cauchy_distribution(result_type __a = 0, result_type __b = 1)
+ : __p_(param_type(__a, __b)) {}
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ explicit cauchy_distribution(const param_type& __p)
+ : __p_(__p) {}
+ _LIBCPP_INLINE_VISIBILITY
+ void reset() {}
+
+ // generating functions
+ template<class _URNG>
+ _LIBCPP_INLINE_VISIBILITY
+ result_type operator()(_URNG& __g)
+ {return (*this)(__g, __p_);}
+ template<class _URNG> _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g, const param_type& __p);
+
+ // property functions
+ _LIBCPP_INLINE_VISIBILITY
+ result_type a() const {return __p_.a();}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type b() const {return __p_.b();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ param_type param() const {return __p_;}
+ _LIBCPP_INLINE_VISIBILITY
+ void param(const param_type& __p) {__p_ = __p;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type min() const {return -numeric_limits<result_type>::infinity();}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type max() const {return numeric_limits<result_type>::infinity();}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const cauchy_distribution& __x,
+ const cauchy_distribution& __y)
+ {return __x.__p_ == __y.__p_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const cauchy_distribution& __x,
+ const cauchy_distribution& __y)
+ {return !(__x == __y);}
+};
+
+template <class _RealType>
+template<class _URNG>
+inline
+_RealType
+cauchy_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
+{
+ uniform_real_distribution<result_type> __gen;
+ // purposefully let tan arg get as close to pi/2 as it wants, tan will return a finite
+ return __p.a() + __p.b() * _VSTD::tan(3.1415926535897932384626433832795 * __gen(__g));
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const cauchy_distribution<_RT>& __x)
+{
+ __save_flags<_CharT, _Traits> __lx(__os);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
+ _CharT __sp = __os.widen(' ');
+ __os.fill(__sp);
+ __os << __x.a() << __sp << __x.b();
+ return __os;
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ cauchy_distribution<_RT>& __x)
+{
+ typedef cauchy_distribution<_RT> _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_CAUCHY_DISTRIBUTION_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/chi_squared_distribution.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/chi_squared_distribution.h
new file mode 100644
index 0000000000..b98488c20d
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/chi_squared_distribution.h
@@ -0,0 +1,144 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_CHI_SQUARED_DISTRIBUTION_H
+#define _LIBCPP___RANDOM_CHI_SQUARED_DISTRIBUTION_H
+
+#include <__config>
+#include <__random/gamma_distribution.h>
+#include <iosfwd>
+#include <limits>
+
+#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 _RealType = double>
+class _LIBCPP_TEMPLATE_VIS chi_squared_distribution
+{
+public:
+ // types
+ typedef _RealType result_type;
+
+ class _LIBCPP_TEMPLATE_VIS param_type
+ {
+ result_type __n_;
+ public:
+ typedef chi_squared_distribution distribution_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit param_type(result_type __n = 1) : __n_(__n) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type n() const {return __n_;}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const param_type& __x, const param_type& __y)
+ {return __x.__n_ == __y.__n_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const param_type& __x, const param_type& __y)
+ {return !(__x == __y);}
+ };
+
+private:
+ param_type __p_;
+
+public:
+ // constructor and reset functions
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ chi_squared_distribution() : chi_squared_distribution(1) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit chi_squared_distribution(result_type __n)
+ : __p_(param_type(__n)) {}
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit chi_squared_distribution(result_type __n = 1)
+ : __p_(param_type(__n)) {}
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ explicit chi_squared_distribution(const param_type& __p)
+ : __p_(__p) {}
+ _LIBCPP_INLINE_VISIBILITY
+ void reset() {}
+
+ // generating functions
+ template<class _URNG>
+ _LIBCPP_INLINE_VISIBILITY
+ result_type operator()(_URNG& __g)
+ {return (*this)(__g, __p_);}
+ template<class _URNG>
+ _LIBCPP_INLINE_VISIBILITY
+ result_type operator()(_URNG& __g, const param_type& __p)
+ {return gamma_distribution<result_type>(__p.n() / 2, 2)(__g);}
+
+ // property functions
+ _LIBCPP_INLINE_VISIBILITY
+ result_type n() const {return __p_.n();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ param_type param() const {return __p_;}
+ _LIBCPP_INLINE_VISIBILITY
+ void param(const param_type& __p) {__p_ = __p;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type min() const {return 0;}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type max() const {return numeric_limits<result_type>::infinity();}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const chi_squared_distribution& __x,
+ const chi_squared_distribution& __y)
+ {return __x.__p_ == __y.__p_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const chi_squared_distribution& __x,
+ const chi_squared_distribution& __y)
+ {return !(__x == __y);}
+};
+
+template <class _CharT, class _Traits, class _RT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const chi_squared_distribution<_RT>& __x)
+{
+ __save_flags<_CharT, _Traits> __lx(__os);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
+ __os << __x.n();
+ return __os;
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ chi_squared_distribution<_RT>& __x)
+{
+ typedef chi_squared_distribution<_RT> _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 __n;
+ __is >> __n;
+ if (!__is.fail())
+ __x.param(param_type(__n));
+ return __is;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANDOM_CHI_SQUARED_DISTRIBUTION_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/clamp_to_integral.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/clamp_to_integral.h
new file mode 100644
index 0000000000..7d44ff9cfc
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/clamp_to_integral.h
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_CLAMP_TO_INTEGRAL_H
+#define _LIBCPP___RANDOM_CLAMP_TO_INTEGRAL_H
+
+#include <__config>
+#include <cmath>
+#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 _IntT, class _FloatT,
+ bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits),
+ int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
+_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR _IntT __max_representable_int_for_float() _NOEXCEPT {
+ static_assert(is_floating_point<_FloatT>::value, "must be a floating point type");
+ static_assert(is_integral<_IntT>::value, "must be an integral type");
+ static_assert(numeric_limits<_FloatT>::radix == 2, "FloatT has incorrect radix");
+ static_assert((_IsSame<_FloatT, float>::value || _IsSame<_FloatT, double>::value
+ || _IsSame<_FloatT,long double>::value), "unsupported floating point type");
+ return _FloatBigger ? numeric_limits<_IntT>::max() : (numeric_limits<_IntT>::max() >> _Bits << _Bits);
+}
+
+// Convert a floating point number to the specified integral type after
+// clamping to the integral type's representable range.
+//
+// The behavior is undefined if `__r` is NaN.
+template <class _IntT, class _RealT>
+_LIBCPP_INLINE_VISIBILITY
+_IntT __clamp_to_integral(_RealT __r) _NOEXCEPT {
+ using _Lim = numeric_limits<_IntT>;
+ const _IntT _MaxVal = __max_representable_int_for_float<_IntT, _RealT>();
+ if (__r >= ::nextafter(static_cast<_RealT>(_MaxVal), INFINITY)) {
+ return _Lim::max();
+ } else if (__r <= _Lim::lowest()) {
+ return _Lim::min();
+ }
+ return static_cast<_IntT>(__r);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANDOM_CLAMP_TO_INTEGRAL_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/default_random_engine.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/default_random_engine.h
new file mode 100644
index 0000000000..89792f4f0d
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/default_random_engine.h
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_DEFAULT_RANDOM_ENGINE_H
+#define _LIBCPP___RANDOM_DEFAULT_RANDOM_ENGINE_H
+
+#include <__config>
+#include <__random/linear_congruential_engine.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+typedef minstd_rand default_random_engine;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANDOM_DEFAULT_RANDOM_ENGINE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/discard_block_engine.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/discard_block_engine.h
new file mode 100644
index 0000000000..c58d66b588
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/discard_block_engine.h
@@ -0,0 +1,203 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_DISCARD_BLOCK_ENGINE_H
+#define _LIBCPP___RANDOM_DISCARD_BLOCK_ENGINE_H
+
+#include <__config>
+#include <__random/is_seed_sequence.h>
+#include <__utility/move.h>
+#include <climits>
+#include <iosfwd>
+#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 _Engine, size_t __p, size_t __r>
+class _LIBCPP_TEMPLATE_VIS discard_block_engine
+{
+ _Engine __e_;
+ int __n_;
+
+ static_assert( 0 < __r, "discard_block_engine invalid parameters");
+ static_assert(__r <= __p, "discard_block_engine invalid parameters");
+ static_assert(__r <= INT_MAX, "discard_block_engine invalid parameters");
+public:
+ // types
+ typedef typename _Engine::result_type result_type;
+
+ // engine characteristics
+ static _LIBCPP_CONSTEXPR const size_t block_size = __p;
+ static _LIBCPP_CONSTEXPR const size_t used_block = __r;
+
+#ifdef _LIBCPP_CXX03_LANG
+ static const result_type _Min = _Engine::_Min;
+ static const result_type _Max = _Engine::_Max;
+#else
+ static _LIBCPP_CONSTEXPR const result_type _Min = _Engine::min();
+ static _LIBCPP_CONSTEXPR const result_type _Max = _Engine::max();
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ static _LIBCPP_CONSTEXPR result_type min() { return _Engine::min(); }
+ _LIBCPP_INLINE_VISIBILITY
+ static _LIBCPP_CONSTEXPR result_type max() { return _Engine::max(); }
+
+ // constructors and seeding functions
+ _LIBCPP_INLINE_VISIBILITY
+ discard_block_engine() : __n_(0) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit discard_block_engine(const _Engine& __e)
+ : __e_(__e), __n_(0) {}
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ explicit discard_block_engine(_Engine&& __e)
+ : __e_(_VSTD::move(__e)), __n_(0) {}
+#endif // _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ explicit discard_block_engine(result_type __sd) : __e_(__sd), __n_(0) {}
+ template<class _Sseq>
+ _LIBCPP_INLINE_VISIBILITY
+ explicit discard_block_engine(_Sseq& __q,
+ typename enable_if<__is_seed_sequence<_Sseq, discard_block_engine>::value &&
+ !is_convertible<_Sseq, _Engine>::value>::type* = 0)
+ : __e_(__q), __n_(0) {}
+ _LIBCPP_INLINE_VISIBILITY
+ void seed() {__e_.seed(); __n_ = 0;}
+ _LIBCPP_INLINE_VISIBILITY
+ void seed(result_type __sd) {__e_.seed(__sd); __n_ = 0;}
+ template<class _Sseq>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if
+ <
+ __is_seed_sequence<_Sseq, discard_block_engine>::value,
+ void
+ >::type
+ seed(_Sseq& __q) {__e_.seed(__q); __n_ = 0;}
+
+ // generating functions
+ result_type operator()();
+ _LIBCPP_INLINE_VISIBILITY
+ void discard(unsigned long long __z) {for (; __z; --__z) operator()();}
+
+ // property functions
+ _LIBCPP_INLINE_VISIBILITY
+ const _Engine& base() const _NOEXCEPT {return __e_;}
+
+ template<class _Eng, size_t _Pp, size_t _Rp>
+ friend
+ bool
+ operator==(
+ const discard_block_engine<_Eng, _Pp, _Rp>& __x,
+ const discard_block_engine<_Eng, _Pp, _Rp>& __y);
+
+ template<class _Eng, size_t _Pp, size_t _Rp>
+ friend
+ bool
+ operator!=(
+ const discard_block_engine<_Eng, _Pp, _Rp>& __x,
+ const discard_block_engine<_Eng, _Pp, _Rp>& __y);
+
+ template <class _CharT, class _Traits,
+ class _Eng, size_t _Pp, size_t _Rp>
+ friend
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const discard_block_engine<_Eng, _Pp, _Rp>& __x);
+
+ template <class _CharT, class _Traits,
+ class _Eng, size_t _Pp, size_t _Rp>
+ friend
+ basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is,
+ discard_block_engine<_Eng, _Pp, _Rp>& __x);
+};
+
+template<class _Engine, size_t __p, size_t __r>
+ _LIBCPP_CONSTEXPR const size_t discard_block_engine<_Engine, __p, __r>::block_size;
+
+template<class _Engine, size_t __p, size_t __r>
+ _LIBCPP_CONSTEXPR const size_t discard_block_engine<_Engine, __p, __r>::used_block;
+
+template<class _Engine, size_t __p, size_t __r>
+typename discard_block_engine<_Engine, __p, __r>::result_type
+discard_block_engine<_Engine, __p, __r>::operator()()
+{
+ if (__n_ >= static_cast<int>(__r))
+ {
+ __e_.discard(__p - __r);
+ __n_ = 0;
+ }
+ ++__n_;
+ return __e_();
+}
+
+template<class _Eng, size_t _Pp, size_t _Rp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const discard_block_engine<_Eng, _Pp, _Rp>& __x,
+ const discard_block_engine<_Eng, _Pp, _Rp>& __y)
+{
+ return __x.__n_ == __y.__n_ && __x.__e_ == __y.__e_;
+}
+
+template<class _Eng, size_t _Pp, size_t _Rp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const discard_block_engine<_Eng, _Pp, _Rp>& __x,
+ const discard_block_engine<_Eng, _Pp, _Rp>& __y)
+{
+ return !(__x == __y);
+}
+
+template <class _CharT, class _Traits,
+ class _Eng, size_t _Pp, size_t _Rp>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const discard_block_engine<_Eng, _Pp, _Rp>& __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.__e_ << __sp << __x.__n_;
+}
+
+template <class _CharT, class _Traits,
+ class _Eng, size_t _Pp, size_t _Rp>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ discard_block_engine<_Eng, _Pp, _Rp>& __x)
+{
+ __save_flags<_CharT, _Traits> __lx(__is);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
+ _Eng __e;
+ int __n;
+ __is >> __e >> __n;
+ if (!__is.fail())
+ {
+ __x.__e_ = __e;
+ __x.__n_ = __n;
+ }
+ return __is;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANDOM_DISCARD_BLOCK_ENGINE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/discrete_distribution.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/discrete_distribution.h
new file mode 100644
index 0000000000..fc19068eb0
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/discrete_distribution.h
@@ -0,0 +1,260 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_DISCRETE_DISTRIBUTION_H
+#define _LIBCPP___RANDOM_DISCRETE_DISTRIBUTION_H
+
+#include <__algorithm/upper_bound.h>
+#include <__config>
+#include <__random/uniform_real_distribution.h>
+#include <cstddef>
+#include <iosfwd>
+#include <numeric>
+#include <vector>
+
+#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 _IntType = int>
+class _LIBCPP_TEMPLATE_VIS discrete_distribution
+{
+public:
+ // types
+ typedef _IntType result_type;
+
+ class _LIBCPP_TEMPLATE_VIS param_type
+ {
+ vector<double> __p_;
+ public:
+ typedef discrete_distribution distribution_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ param_type() {}
+ template<class _InputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ param_type(_InputIterator __f, _InputIterator __l)
+ : __p_(__f, __l) {__init();}
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ param_type(initializer_list<double> __wl)
+ : __p_(__wl.begin(), __wl.end()) {__init();}
+#endif // _LIBCPP_CXX03_LANG
+ template<class _UnaryOperation>
+ param_type(size_t __nw, double __xmin, double __xmax,
+ _UnaryOperation __fw);
+
+ vector<double> probabilities() const;
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const param_type& __x, const param_type& __y)
+ {return __x.__p_ == __y.__p_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const param_type& __x, const param_type& __y)
+ {return !(__x == __y);}
+
+ private:
+ void __init();
+
+ friend class discrete_distribution;
+
+ template <class _CharT, class _Traits, class _IT>
+ friend
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const discrete_distribution<_IT>& __x);
+
+ template <class _CharT, class _Traits, class _IT>
+ friend
+ basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is,
+ discrete_distribution<_IT>& __x);
+ };
+
+private:
+ param_type __p_;
+
+public:
+ // constructor and reset functions
+ _LIBCPP_INLINE_VISIBILITY
+ discrete_distribution() {}
+ template<class _InputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ discrete_distribution(_InputIterator __f, _InputIterator __l)
+ : __p_(__f, __l) {}
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ discrete_distribution(initializer_list<double> __wl)
+ : __p_(__wl) {}
+#endif // _LIBCPP_CXX03_LANG
+ template<class _UnaryOperation>
+ _LIBCPP_INLINE_VISIBILITY
+ discrete_distribution(size_t __nw, double __xmin, double __xmax,
+ _UnaryOperation __fw)
+ : __p_(__nw, __xmin, __xmax, __fw) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit discrete_distribution(const param_type& __p)
+ : __p_(__p) {}
+ _LIBCPP_INLINE_VISIBILITY
+ void reset() {}
+
+ // generating functions
+ template<class _URNG>
+ _LIBCPP_INLINE_VISIBILITY
+ result_type operator()(_URNG& __g)
+ {return (*this)(__g, __p_);}
+ template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+
+ // property functions
+ _LIBCPP_INLINE_VISIBILITY
+ vector<double> probabilities() const {return __p_.probabilities();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ param_type param() const {return __p_;}
+ _LIBCPP_INLINE_VISIBILITY
+ void param(const param_type& __p) {__p_ = __p;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type min() const {return 0;}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type max() const {return __p_.__p_.size();}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const discrete_distribution& __x,
+ const discrete_distribution& __y)
+ {return __x.__p_ == __y.__p_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const discrete_distribution& __x,
+ const discrete_distribution& __y)
+ {return !(__x == __y);}
+
+ template <class _CharT, class _Traits, class _IT>
+ friend
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const discrete_distribution<_IT>& __x);
+
+ template <class _CharT, class _Traits, class _IT>
+ friend
+ basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is,
+ discrete_distribution<_IT>& __x);
+};
+
+template<class _IntType>
+template<class _UnaryOperation>
+discrete_distribution<_IntType>::param_type::param_type(size_t __nw,
+ double __xmin,
+ double __xmax,
+ _UnaryOperation __fw)
+{
+ if (__nw > 1)
+ {
+ __p_.reserve(__nw - 1);
+ double __d = (__xmax - __xmin) / __nw;
+ double __d2 = __d / 2;
+ for (size_t __k = 0; __k < __nw; ++__k)
+ __p_.push_back(__fw(__xmin + __k * __d + __d2));
+ __init();
+ }
+}
+
+template<class _IntType>
+void
+discrete_distribution<_IntType>::param_type::__init()
+{
+ if (!__p_.empty())
+ {
+ if (__p_.size() > 1)
+ {
+ double __s = _VSTD::accumulate(__p_.begin(), __p_.end(), 0.0);
+ 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());
+ swap(__p_, __t);
+ }
+ else
+ {
+ __p_.clear();
+ __p_.shrink_to_fit();
+ }
+ }
+}
+
+template<class _IntType>
+vector<double>
+discrete_distribution<_IntType>::param_type::probabilities() const
+{
+ size_t __n = __p_.size();
+ vector<double> __p(__n+1);
+ _VSTD::adjacent_difference(__p_.begin(), __p_.end(), __p.begin());
+ if (__n > 0)
+ __p[__n] = 1 - __p_[__n-1];
+ else
+ __p[0] = 1;
+ return __p;
+}
+
+template<class _IntType>
+template<class _URNG>
+_IntType
+discrete_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p)
+{
+ uniform_real_distribution<double> __gen;
+ return static_cast<_IntType>(
+ _VSTD::upper_bound(__p.__p_.begin(), __p.__p_.end(), __gen(__g)) -
+ __p.__p_.begin());
+}
+
+template <class _CharT, class _Traits, class _IT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const discrete_distribution<_IT>& __x)
+{
+ __save_flags<_CharT, _Traits> __lx(__os);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
+ _CharT __sp = __os.widen(' ');
+ __os.fill(__sp);
+ size_t __n = __x.__p_.__p_.size();
+ __os << __n;
+ for (size_t __i = 0; __i < __n; ++__i)
+ __os << __sp << __x.__p_.__p_[__i];
+ return __os;
+}
+
+template <class _CharT, class _Traits, class _IT>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ discrete_distribution<_IT>& __x)
+{
+ __save_flags<_CharT, _Traits> __lx(__is);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
+ size_t __n;
+ __is >> __n;
+ vector<double> __p(__n);
+ for (size_t __i = 0; __i < __n; ++__i)
+ __is >> __p[__i];
+ if (!__is.fail())
+ swap(__x.__p_.__p_, __p);
+ return __is;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANDOM_DISCRETE_DISTRIBUTION_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/exponential_distribution.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/exponential_distribution.h
new file mode 100644
index 0000000000..e51871dd53
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/exponential_distribution.h
@@ -0,0 +1,155 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_EXPONENTIAL_DISTRIBUTION_H
+#define _LIBCPP___RANDOM_EXPONENTIAL_DISTRIBUTION_H
+
+#include <__config>
+#include <__random/generate_canonical.h>
+#include <__random/uniform_real_distribution.h>
+#include <cmath>
+#include <iosfwd>
+#include <limits>
+
+#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 _RealType = double>
+class _LIBCPP_TEMPLATE_VIS exponential_distribution
+{
+public:
+ // types
+ typedef _RealType result_type;
+
+ class _LIBCPP_TEMPLATE_VIS param_type
+ {
+ result_type __lambda_;
+ public:
+ typedef exponential_distribution distribution_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit param_type(result_type __lambda = 1) : __lambda_(__lambda) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type lambda() const {return __lambda_;}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const param_type& __x, const param_type& __y)
+ {return __x.__lambda_ == __y.__lambda_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ 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
+ _LIBCPP_INLINE_VISIBILITY
+ exponential_distribution() : exponential_distribution(1) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit exponential_distribution(result_type __lambda)
+ : __p_(param_type(__lambda)) {}
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit exponential_distribution(result_type __lambda = 1)
+ : __p_(param_type(__lambda)) {}
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ explicit exponential_distribution(const param_type& __p) : __p_(__p) {}
+ _LIBCPP_INLINE_VISIBILITY
+ void reset() {}
+
+ // generating functions
+ template<class _URNG>
+ _LIBCPP_INLINE_VISIBILITY
+ result_type operator()(_URNG& __g)
+ {return (*this)(__g, __p_);}
+ template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+
+ // property functions
+ _LIBCPP_INLINE_VISIBILITY
+ result_type lambda() const {return __p_.lambda();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ param_type param() const {return __p_;}
+ _LIBCPP_INLINE_VISIBILITY
+ void param(const param_type& __p) {__p_ = __p;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type min() const {return 0;}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type max() const {return numeric_limits<result_type>::infinity();}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const exponential_distribution& __x,
+ const exponential_distribution& __y)
+ {return __x.__p_ == __y.__p_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const exponential_distribution& __x,
+ const exponential_distribution& __y)
+ {return !(__x == __y);}
+};
+
+template <class _RealType>
+template<class _URNG>
+_RealType
+exponential_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
+{
+ return -_VSTD::log
+ (
+ result_type(1) -
+ _VSTD::generate_canonical<result_type,
+ numeric_limits<result_type>::digits>(__g)
+ )
+ / __p.lambda();
+}
+
+template <class _CharT, class _Traits, class _RealType>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const exponential_distribution<_RealType>& __x)
+{
+ __save_flags<_CharT, _Traits> __lx(__os);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
+ return __os << __x.lambda();
+}
+
+template <class _CharT, class _Traits, class _RealType>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ exponential_distribution<_RealType>& __x)
+{
+ typedef exponential_distribution<_RealType> _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 __lambda;
+ __is >> __lambda;
+ if (!__is.fail())
+ __x.param(param_type(__lambda));
+ return __is;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANDOM_EXPONENTIAL_DISTRIBUTION_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/extreme_value_distribution.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/extreme_value_distribution.h
new file mode 100644
index 0000000000..15cebd8e95
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/extreme_value_distribution.h
@@ -0,0 +1,161 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_EXTREME_VALUE_DISTRIBUTION_H
+#define _LIBCPP___RANDOM_EXTREME_VALUE_DISTRIBUTION_H
+
+#include <__config>
+#include <__random/uniform_real_distribution.h>
+#include <cmath>
+#include <iosfwd>
+#include <limits>
+
+#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 _RealType = double>
+class _LIBCPP_TEMPLATE_VIS extreme_value_distribution
+{
+public:
+ // types
+ typedef _RealType result_type;
+
+ class _LIBCPP_TEMPLATE_VIS param_type
+ {
+ result_type __a_;
+ result_type __b_;
+ public:
+ typedef extreme_value_distribution distribution_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit param_type(result_type __a = 0, result_type __b = 1)
+ : __a_(__a), __b_(__b) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type a() const {return __a_;}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type b() const {return __b_;}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const param_type& __x, const param_type& __y)
+ {return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const param_type& __x, const param_type& __y)
+ {return !(__x == __y);}
+ };
+
+private:
+ param_type __p_;
+
+public:
+ // constructor and reset functions
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ extreme_value_distribution() : extreme_value_distribution(0) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit extreme_value_distribution(result_type __a, result_type __b = 1)
+ : __p_(param_type(__a, __b)) {}
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit extreme_value_distribution(result_type __a = 0,
+ result_type __b = 1)
+ : __p_(param_type(__a, __b)) {}
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ explicit extreme_value_distribution(const param_type& __p)
+ : __p_(__p) {}
+ _LIBCPP_INLINE_VISIBILITY
+ void reset() {}
+
+ // generating functions
+ template<class _URNG>
+ _LIBCPP_INLINE_VISIBILITY
+ result_type operator()(_URNG& __g)
+ {return (*this)(__g, __p_);}
+ template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+
+ // property functions
+ _LIBCPP_INLINE_VISIBILITY
+ result_type a() const {return __p_.a();}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type b() const {return __p_.b();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ param_type param() const {return __p_;}
+ _LIBCPP_INLINE_VISIBILITY
+ void param(const param_type& __p) {__p_ = __p;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type min() const {return -numeric_limits<result_type>::infinity();}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type max() const {return numeric_limits<result_type>::infinity();}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const extreme_value_distribution& __x,
+ const extreme_value_distribution& __y)
+ {return __x.__p_ == __y.__p_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const extreme_value_distribution& __x,
+ const extreme_value_distribution& __y)
+ {return !(__x == __y);}
+};
+
+template<class _RealType>
+template<class _URNG>
+_RealType
+extreme_value_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
+{
+ return __p.a() - __p.b() *
+ _VSTD::log(-_VSTD::log(1-uniform_real_distribution<result_type>()(__g)));
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const extreme_value_distribution<_RT>& __x)
+{
+ __save_flags<_CharT, _Traits> __lx(__os);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
+ _CharT __sp = __os.widen(' ');
+ __os.fill(__sp);
+ __os << __x.a() << __sp << __x.b();
+ return __os;
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ extreme_value_distribution<_RT>& __x)
+{
+ typedef extreme_value_distribution<_RT> _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_EXTREME_VALUE_DISTRIBUTION_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/fisher_f_distribution.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/fisher_f_distribution.h
new file mode 100644
index 0000000000..72f1f40aaa
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/fisher_f_distribution.h
@@ -0,0 +1,160 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_FISHER_F_DISTRIBUTION_H
+#define _LIBCPP___RANDOM_FISHER_F_DISTRIBUTION_H
+
+#include <__config>
+#include <__random/gamma_distribution.h>
+#include <iosfwd>
+#include <limits>
+
+#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 _RealType = double>
+class _LIBCPP_TEMPLATE_VIS fisher_f_distribution
+{
+public:
+ // types
+ typedef _RealType result_type;
+
+ class _LIBCPP_TEMPLATE_VIS param_type
+ {
+ result_type __m_;
+ result_type __n_;
+ public:
+ typedef fisher_f_distribution distribution_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit param_type(result_type __m = 1, result_type __n = 1)
+ : __m_(__m), __n_(__n) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type m() const {return __m_;}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type n() const {return __n_;}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const param_type& __x, const param_type& __y)
+ {return __x.__m_ == __y.__m_ && __x.__n_ == __y.__n_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const param_type& __x, const param_type& __y)
+ {return !(__x == __y);}
+ };
+
+private:
+ param_type __p_;
+
+public:
+ // constructor and reset functions
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ fisher_f_distribution() : fisher_f_distribution(1) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit fisher_f_distribution(result_type __m, result_type __n = 1)
+ : __p_(param_type(__m, __n)) {}
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit fisher_f_distribution(result_type __m = 1, result_type __n = 1)
+ : __p_(param_type(__m, __n)) {}
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ explicit fisher_f_distribution(const param_type& __p)
+ : __p_(__p) {}
+ _LIBCPP_INLINE_VISIBILITY
+ void reset() {}
+
+ // generating functions
+ template<class _URNG>
+ _LIBCPP_INLINE_VISIBILITY
+ result_type operator()(_URNG& __g)
+ {return (*this)(__g, __p_);}
+ template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+
+ // property functions
+ _LIBCPP_INLINE_VISIBILITY
+ result_type m() const {return __p_.m();}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type n() const {return __p_.n();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ param_type param() const {return __p_;}
+ _LIBCPP_INLINE_VISIBILITY
+ void param(const param_type& __p) {__p_ = __p;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type min() const {return 0;}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type max() const {return numeric_limits<result_type>::infinity();}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const fisher_f_distribution& __x,
+ const fisher_f_distribution& __y)
+ {return __x.__p_ == __y.__p_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const fisher_f_distribution& __x,
+ const fisher_f_distribution& __y)
+ {return !(__x == __y);}
+};
+
+template <class _RealType>
+template<class _URNG>
+_RealType
+fisher_f_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
+{
+ gamma_distribution<result_type> __gdm(__p.m() * result_type(.5));
+ gamma_distribution<result_type> __gdn(__p.n() * result_type(.5));
+ return __p.n() * __gdm(__g) / (__p.m() * __gdn(__g));
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const fisher_f_distribution<_RT>& __x)
+{
+ __save_flags<_CharT, _Traits> __lx(__os);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
+ _CharT __sp = __os.widen(' ');
+ __os.fill(__sp);
+ __os << __x.m() << __sp << __x.n();
+ return __os;
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ fisher_f_distribution<_RT>& __x)
+{
+ typedef fisher_f_distribution<_RT> _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 __m;
+ result_type __n;
+ __is >> __m >> __n;
+ if (!__is.fail())
+ __x.param(param_type(__m, __n));
+ return __is;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANDOM_FISHER_F_DISTRIBUTION_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/gamma_distribution.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/gamma_distribution.h
new file mode 100644
index 0000000000..a8504961b2
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/gamma_distribution.h
@@ -0,0 +1,213 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_GAMMA_DISTRIBUTION_H
+#define _LIBCPP___RANDOM_GAMMA_DISTRIBUTION_H
+
+#include <__config>
+#include <__random/exponential_distribution.h>
+#include <__random/uniform_real_distribution.h>
+#include <cmath>
+#include <iosfwd>
+#include <limits>
+
+#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 _RealType = double>
+class _LIBCPP_TEMPLATE_VIS gamma_distribution
+{
+public:
+ // types
+ typedef _RealType result_type;
+
+ class _LIBCPP_TEMPLATE_VIS param_type
+ {
+ result_type __alpha_;
+ result_type __beta_;
+ public:
+ typedef gamma_distribution distribution_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit param_type(result_type __alpha = 1, result_type __beta = 1)
+ : __alpha_(__alpha), __beta_(__beta) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type alpha() const {return __alpha_;}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type beta() const {return __beta_;}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const param_type& __x, const param_type& __y)
+ {return __x.__alpha_ == __y.__alpha_ && __x.__beta_ == __y.__beta_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ 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
+ _LIBCPP_INLINE_VISIBILITY
+ gamma_distribution() : gamma_distribution(1) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit gamma_distribution(result_type __alpha, result_type __beta = 1)
+ : __p_(param_type(__alpha, __beta)) {}
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit gamma_distribution(result_type __alpha = 1,
+ result_type __beta = 1)
+ : __p_(param_type(__alpha, __beta)) {}
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ explicit gamma_distribution(const param_type& __p)
+ : __p_(__p) {}
+ _LIBCPP_INLINE_VISIBILITY
+ void reset() {}
+
+ // generating functions
+ template<class _URNG>
+ _LIBCPP_INLINE_VISIBILITY
+ result_type operator()(_URNG& __g)
+ {return (*this)(__g, __p_);}
+ template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+
+ // property functions
+ _LIBCPP_INLINE_VISIBILITY
+ result_type alpha() const {return __p_.alpha();}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type beta() const {return __p_.beta();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ param_type param() const {return __p_;}
+ _LIBCPP_INLINE_VISIBILITY
+ void param(const param_type& __p) {__p_ = __p;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type min() const {return 0;}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type max() const {return numeric_limits<result_type>::infinity();}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const gamma_distribution& __x,
+ const gamma_distribution& __y)
+ {return __x.__p_ == __y.__p_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const gamma_distribution& __x,
+ const gamma_distribution& __y)
+ {return !(__x == __y);}
+};
+
+template <class _RealType>
+template<class _URNG>
+_RealType
+gamma_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
+{
+ result_type __a = __p.alpha();
+ uniform_real_distribution<result_type> __gen(0, 1);
+ exponential_distribution<result_type> __egen;
+ result_type __x;
+ if (__a == 1)
+ __x = __egen(__g);
+ else if (__a > 1)
+ {
+ const result_type __b = __a - 1;
+ const result_type __c = 3 * __a - result_type(0.75);
+ while (true)
+ {
+ const result_type __u = __gen(__g);
+ const result_type __v = __gen(__g);
+ const result_type __w = __u * (1 - __u);
+ if (__w != 0)
+ {
+ const result_type __y = _VSTD::sqrt(__c / __w) *
+ (__u - result_type(0.5));
+ __x = __b + __y;
+ if (__x >= 0)
+ {
+ const result_type __z = 64 * __w * __w * __w * __v * __v;
+ if (__z <= 1 - 2 * __y * __y / __x)
+ break;
+ if (_VSTD::log(__z) <= 2 * (__b * _VSTD::log(__x / __b) - __y))
+ break;
+ }
+ }
+ }
+ }
+ else // __a < 1
+ {
+ while (true)
+ {
+ const result_type __u = __gen(__g);
+ const result_type __es = __egen(__g);
+ if (__u <= 1 - __a)
+ {
+ __x = _VSTD::pow(__u, 1 / __a);
+ if (__x <= __es)
+ break;
+ }
+ else
+ {
+ const result_type __e = -_VSTD::log((1-__u)/__a);
+ __x = _VSTD::pow(1 - __a + __a * __e, 1 / __a);
+ if (__x <= __e + __es)
+ break;
+ }
+ }
+ }
+ return __x * __p.beta();
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const gamma_distribution<_RT>& __x)
+{
+ __save_flags<_CharT, _Traits> __lx(__os);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
+ _CharT __sp = __os.widen(' ');
+ __os.fill(__sp);
+ __os << __x.alpha() << __sp << __x.beta();
+ return __os;
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ gamma_distribution<_RT>& __x)
+{
+ typedef gamma_distribution<_RT> _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 __alpha;
+ result_type __beta;
+ __is >> __alpha >> __beta;
+ if (!__is.fail())
+ __x.param(param_type(__alpha, __beta));
+ return __is;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANDOM_GAMMA_DISTRIBUTION_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/generate_canonical.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/generate_canonical.h
new file mode 100644
index 0000000000..84efa7803c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/generate_canonical.h
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_GENERATE_CANONICAL_H
+#define _LIBCPP___RANDOM_GENERATE_CANONICAL_H
+
+#include <__config>
+#include <__random/log2.h>
+#include <cstdint>
+#include <initializer_list>
+#include <limits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// generate_canonical
+
+template<class _RealType, size_t __bits, class _URNG>
+_RealType
+generate_canonical(_URNG& __g)
+{
+ const size_t _Dt = numeric_limits<_RealType>::digits;
+ const size_t __b = _Dt < __bits ? _Dt : __bits;
+#ifdef _LIBCPP_CXX03_LANG
+ const size_t __logR = __log2<uint64_t, _URNG::_Max - _URNG::_Min + uint64_t(1)>::value;
+#else
+ const size_t __logR = __log2<uint64_t, _URNG::max() - _URNG::min() + uint64_t(1)>::value;
+#endif
+ const size_t __k = __b / __logR + (__b % __logR != 0) + (__b == 0);
+ const _RealType _Rp = static_cast<_RealType>(_URNG::max() - _URNG::min()) + _RealType(1);
+ _RealType __base = _Rp;
+ _RealType _Sp = __g() - _URNG::min();
+ for (size_t __i = 1; __i < __k; ++__i, __base *= _Rp)
+ _Sp += (__g() - _URNG::min()) * __base;
+ return _Sp / __base;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANDOM_GENERATE_CANONICAL_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/geometric_distribution.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/geometric_distribution.h
new file mode 100644
index 0000000000..b9cc151b34
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/geometric_distribution.h
@@ -0,0 +1,141 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_GEOMETRIC_DISTRIBUTION_H
+#define _LIBCPP___RANDOM_GEOMETRIC_DISTRIBUTION_H
+
+#include <__config>
+#include <__random/negative_binomial_distribution.h>
+#include <iosfwd>
+#include <limits>
+
+#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 _IntType = int>
+class _LIBCPP_TEMPLATE_VIS geometric_distribution
+{
+public:
+ // types
+ typedef _IntType result_type;
+
+ class _LIBCPP_TEMPLATE_VIS param_type
+ {
+ double __p_;
+ public:
+ typedef geometric_distribution distribution_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit param_type(double __p = 0.5) : __p_(__p) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ double p() const {return __p_;}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const param_type& __x, const param_type& __y)
+ {return __x.__p_ == __y.__p_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ 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
+ _LIBCPP_INLINE_VISIBILITY
+ geometric_distribution() : geometric_distribution(0.5) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit geometric_distribution(double __p)
+ : __p_(__p) {}
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit geometric_distribution(double __p = 0.5)
+ : __p_(__p) {}
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ explicit geometric_distribution(const param_type& __p) : __p_(__p) {}
+ _LIBCPP_INLINE_VISIBILITY
+ void reset() {}
+
+ // generating functions
+ template<class _URNG>
+ _LIBCPP_INLINE_VISIBILITY
+ result_type operator()(_URNG& __g)
+ {return (*this)(__g, __p_);}
+ template<class _URNG>
+ _LIBCPP_INLINE_VISIBILITY
+ result_type operator()(_URNG& __g, const param_type& __p)
+ {return negative_binomial_distribution<result_type>(1, __p.p())(__g);}
+
+ // property functions
+ _LIBCPP_INLINE_VISIBILITY
+ double p() const {return __p_.p();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ param_type param() const {return __p_;}
+ _LIBCPP_INLINE_VISIBILITY
+ void param(const param_type& __p) {__p_ = __p;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type min() const {return 0;}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type max() const {return numeric_limits<result_type>::max();}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const geometric_distribution& __x,
+ const geometric_distribution& __y)
+ {return __x.__p_ == __y.__p_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const geometric_distribution& __x,
+ const geometric_distribution& __y)
+ {return !(__x == __y);}
+};
+
+template <class _CharT, class _Traits, class _IntType>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const geometric_distribution<_IntType>& __x)
+{
+ __save_flags<_CharT, _Traits> __lx(__os);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
+ return __os << __x.p();
+}
+
+template <class _CharT, class _Traits, class _IntType>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ geometric_distribution<_IntType>& __x)
+{
+ typedef geometric_distribution<_IntType> _Eng;
+ 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);
+ double __p;
+ __is >> __p;
+ if (!__is.fail())
+ __x.param(param_type(__p));
+ return __is;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANDOM_GEOMETRIC_DISTRIBUTION_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/independent_bits_engine.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/independent_bits_engine.h
new file mode 100644
index 0000000000..e80d6eec49
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/independent_bits_engine.h
@@ -0,0 +1,271 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_INDEPENDENT_BITS_ENGINE_H
+#define _LIBCPP___RANDOM_INDEPENDENT_BITS_ENGINE_H
+
+#include <__config>
+#include <__random/is_seed_sequence.h>
+#include <__random/log2.h>
+#include <__utility/move.h>
+#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
+
+template<class _Engine, size_t __w, class _UIntType>
+class _LIBCPP_TEMPLATE_VIS independent_bits_engine
+{
+ template <class _UInt, _UInt _R0, size_t _Wp, size_t _Mp>
+ class __get_n
+ {
+ static _LIBCPP_CONSTEXPR const size_t _Dt = numeric_limits<_UInt>::digits;
+ static _LIBCPP_CONSTEXPR const size_t _Np = _Wp / _Mp + (_Wp % _Mp != 0);
+ static _LIBCPP_CONSTEXPR const size_t _W0 = _Wp / _Np;
+ static _LIBCPP_CONSTEXPR const _UInt _Y0 = _W0 >= _Dt ? 0 : (_R0 >> _W0) << _W0;
+ public:
+ static _LIBCPP_CONSTEXPR const size_t value = _R0 - _Y0 > _Y0 / _Np ? _Np + 1 : _Np;
+ };
+public:
+ // types
+ typedef _UIntType result_type;
+
+private:
+ _Engine __e_;
+
+ static _LIBCPP_CONSTEXPR const result_type _Dt = numeric_limits<result_type>::digits;
+ static_assert( 0 < __w, "independent_bits_engine invalid parameters");
+ static_assert(__w <= _Dt, "independent_bits_engine invalid parameters");
+
+ 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;
+#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 __n = __get_n<_Working_result_type, _Rp, __w, __m>::value;
+ static _LIBCPP_CONSTEXPR const size_t __w0 = __w / __n;
+ static _LIBCPP_CONSTEXPR const size_t __n0 = __n - __w % __n;
+ 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;
+ static _LIBCPP_CONSTEXPR const _Working_result_type __y0 = __w0 >= _WDt ? 0 :
+ (_Rp >> __w0) << __w0;
+ static _LIBCPP_CONSTEXPR const _Working_result_type __y1 = __w0 >= _WDt - 1 ? 0 :
+ (_Rp >> (__w0+1)) << (__w0+1);
+ static _LIBCPP_CONSTEXPR const _Engine_result_type __mask0 = __w0 > 0 ?
+ _Engine_result_type(~0) >> (_EDt - __w0) :
+ _Engine_result_type(0);
+ static _LIBCPP_CONSTEXPR const _Engine_result_type __mask1 = __w0 < _EDt - 1 ?
+ _Engine_result_type(~0) >> (_EDt - (__w0 + 1)) :
+ _Engine_result_type(~0);
+public:
+ static _LIBCPP_CONSTEXPR const result_type _Min = 0;
+ static _LIBCPP_CONSTEXPR const result_type _Max = __w == _Dt ? result_type(~0) :
+ (result_type(1) << __w) - result_type(1);
+ static_assert(_Min < _Max, "independent_bits_engine invalid parameters");
+
+ // engine characteristics
+ _LIBCPP_INLINE_VISIBILITY
+ static _LIBCPP_CONSTEXPR result_type min() { return _Min; }
+ _LIBCPP_INLINE_VISIBILITY
+ static _LIBCPP_CONSTEXPR result_type max() { return _Max; }
+
+ // constructors and seeding functions
+ _LIBCPP_INLINE_VISIBILITY
+ independent_bits_engine() {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit independent_bits_engine(const _Engine& __e)
+ : __e_(__e) {}
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ explicit independent_bits_engine(_Engine&& __e)
+ : __e_(_VSTD::move(__e)) {}
+#endif // _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ explicit independent_bits_engine(result_type __sd) : __e_(__sd) {}
+ template<class _Sseq>
+ _LIBCPP_INLINE_VISIBILITY
+ explicit independent_bits_engine(_Sseq& __q,
+ typename enable_if<__is_seed_sequence<_Sseq, independent_bits_engine>::value &&
+ !is_convertible<_Sseq, _Engine>::value>::type* = 0)
+ : __e_(__q) {}
+ _LIBCPP_INLINE_VISIBILITY
+ void seed() {__e_.seed();}
+ _LIBCPP_INLINE_VISIBILITY
+ void seed(result_type __sd) {__e_.seed(__sd);}
+ template<class _Sseq>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if
+ <
+ __is_seed_sequence<_Sseq, independent_bits_engine>::value,
+ void
+ >::type
+ seed(_Sseq& __q) {__e_.seed(__q);}
+
+ // generating functions
+ _LIBCPP_INLINE_VISIBILITY
+ result_type operator()() {return __eval(integral_constant<bool, _Rp != 0>());}
+ _LIBCPP_INLINE_VISIBILITY
+ void discard(unsigned long long __z) {for (; __z; --__z) operator()();}
+
+ // property functions
+ _LIBCPP_INLINE_VISIBILITY
+ const _Engine& base() const _NOEXCEPT {return __e_;}
+
+ template<class _Eng, size_t _Wp, class _UInt>
+ friend
+ bool
+ operator==(
+ const independent_bits_engine<_Eng, _Wp, _UInt>& __x,
+ const independent_bits_engine<_Eng, _Wp, _UInt>& __y);
+
+ template<class _Eng, size_t _Wp, class _UInt>
+ friend
+ bool
+ operator!=(
+ const independent_bits_engine<_Eng, _Wp, _UInt>& __x,
+ const independent_bits_engine<_Eng, _Wp, _UInt>& __y);
+
+ template <class _CharT, class _Traits,
+ class _Eng, size_t _Wp, class _UInt>
+ friend
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const independent_bits_engine<_Eng, _Wp, _UInt>& __x);
+
+ template <class _CharT, class _Traits,
+ class _Eng, size_t _Wp, class _UInt>
+ friend
+ basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is,
+ independent_bits_engine<_Eng, _Wp, _UInt>& __x);
+
+private:
+ _LIBCPP_INLINE_VISIBILITY
+ result_type __eval(false_type);
+ result_type __eval(true_type);
+
+ template <size_t __count>
+ _LIBCPP_INLINE_VISIBILITY
+ static
+ typename enable_if
+ <
+ __count < _Dt,
+ result_type
+ >::type
+ __lshift(result_type __x) {return __x << __count;}
+
+ template <size_t __count>
+ _LIBCPP_INLINE_VISIBILITY
+ static
+ typename enable_if
+ <
+ (__count >= _Dt),
+ result_type
+ >::type
+ __lshift(result_type) {return result_type(0);}
+};
+
+template<class _Engine, size_t __w, class _UIntType>
+inline
+_UIntType
+independent_bits_engine<_Engine, __w, _UIntType>::__eval(false_type)
+{
+ return static_cast<result_type>(__e_() & __mask0);
+}
+
+template<class _Engine, size_t __w, class _UIntType>
+_UIntType
+independent_bits_engine<_Engine, __w, _UIntType>::__eval(true_type)
+{
+ result_type _Sp = 0;
+ for (size_t __k = 0; __k < __n0; ++__k)
+ {
+ _Engine_result_type __u;
+ do
+ {
+ __u = __e_() - _Engine::min();
+ } while (__u >= __y0);
+ _Sp = static_cast<result_type>(__lshift<__w0>(_Sp) + (__u & __mask0));
+ }
+ for (size_t __k = __n0; __k < __n; ++__k)
+ {
+ _Engine_result_type __u;
+ do
+ {
+ __u = __e_() - _Engine::min();
+ } while (__u >= __y1);
+ _Sp = static_cast<result_type>(__lshift<__w0+1>(_Sp) + (__u & __mask1));
+ }
+ return _Sp;
+}
+
+template<class _Eng, size_t _Wp, class _UInt>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(
+ const independent_bits_engine<_Eng, _Wp, _UInt>& __x,
+ const independent_bits_engine<_Eng, _Wp, _UInt>& __y)
+{
+ return __x.base() == __y.base();
+}
+
+template<class _Eng, size_t _Wp, class _UInt>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(
+ const independent_bits_engine<_Eng, _Wp, _UInt>& __x,
+ const independent_bits_engine<_Eng, _Wp, _UInt>& __y)
+{
+ return !(__x == __y);
+}
+
+template <class _CharT, class _Traits,
+ class _Eng, size_t _Wp, class _UInt>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const independent_bits_engine<_Eng, _Wp, _UInt>& __x)
+{
+ return __os << __x.base();
+}
+
+template <class _CharT, class _Traits,
+ class _Eng, size_t _Wp, class _UInt>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ independent_bits_engine<_Eng, _Wp, _UInt>& __x)
+{
+ _Eng __e;
+ __is >> __e;
+ if (!__is.fail())
+ __x.__e_ = __e;
+ return __is;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANDOM_INDEPENDENT_BITS_ENGINE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/is_seed_sequence.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/is_seed_sequence.h
new file mode 100644
index 0000000000..a6832f51c1
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/is_seed_sequence.h
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_IS_SEED_SEQUENCE_H
+#define _LIBCPP___RANDOM_IS_SEED_SEQUENCE_H
+
+#include <__config>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Sseq, class _Engine>
+struct __is_seed_sequence
+{
+ static _LIBCPP_CONSTEXPR const bool value =
+ !is_convertible<_Sseq, typename _Engine::result_type>::value &&
+ !is_same<typename remove_cv<_Sseq>::type, _Engine>::value;
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANDOM_IS_SEED_SEQUENCE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/knuth_b.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/knuth_b.h
new file mode 100644
index 0000000000..f5b31cb64f
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/knuth_b.h
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_KNUTH_B_H
+#define _LIBCPP___RANDOM_KNUTH_B_H
+
+#include <__config>
+#include <__random/linear_congruential_engine.h>
+#include <__random/shuffle_order_engine.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+typedef shuffle_order_engine<minstd_rand0, 256> knuth_b;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANDOM_KNUTH_B_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/linear_congruential_engine.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/linear_congruential_engine.h
new file mode 100644
index 0000000000..f5aba75d57
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/linear_congruential_engine.h
@@ -0,0 +1,398 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_LINEAR_CONGRUENTIAL_ENGINE_H
+#define _LIBCPP___RANDOM_LINEAR_CONGRUENTIAL_ENGINE_H
+
+#include <__config>
+#include <__random/is_seed_sequence.h>
+#include <cstdint>
+#include <iosfwd>
+#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 <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 _SchrageOK = (__a != 0 && __m != 0 && __m % __a <= __m / __a)> // r <= q
+struct __lce_alg_picker
+{
+ static_assert(__a != 0 || __m != 0 || !_MightOverflow || _OverflowOK || _SchrageOK,
+ "The current values of a, c, and m cannot generate a number "
+ "within bounds of linear_congruential_engine.");
+
+ static _LIBCPP_CONSTEXPR const bool __use_schrage = _MightOverflow &&
+ !_OverflowOK &&
+ _SchrageOK;
+};
+
+template <unsigned long long __a, unsigned long long __c,
+ unsigned long long __m, unsigned long long _Mp,
+ bool _UseSchrage = __lce_alg_picker<__a, __c, __m, _Mp>::__use_schrage>
+struct __lce_ta;
+
+// 64
+
+template <unsigned long long __a, unsigned long long __c, unsigned long long __m>
+struct __lce_ta<__a, __c, __m, (unsigned long long)(~0), true>
+{
+ typedef unsigned long long result_type;
+ _LIBCPP_INLINE_VISIBILITY
+ static result_type next(result_type __x)
+ {
+ // Schrage's algorithm
+ const result_type __q = __m / __a;
+ const result_type __r = __m % __a;
+ const result_type __t0 = __a * (__x % __q);
+ const result_type __t1 = __r * (__x / __q);
+ __x = __t0 + (__t0 < __t1) * __m - __t1;
+ __x += __c - (__x >= __m - __c) * __m;
+ return __x;
+ }
+};
+
+template <unsigned long long __a, unsigned long long __m>
+struct __lce_ta<__a, 0, __m, (unsigned long long)(~0), true>
+{
+ typedef unsigned long long result_type;
+ _LIBCPP_INLINE_VISIBILITY
+ static result_type next(result_type __x)
+ {
+ // Schrage's algorithm
+ const result_type __q = __m / __a;
+ const result_type __r = __m % __a;
+ const result_type __t0 = __a * (__x % __q);
+ const result_type __t1 = __r * (__x / __q);
+ __x = __t0 + (__t0 < __t1) * __m - __t1;
+ return __x;
+ }
+};
+
+template <unsigned long long __a, unsigned long long __c, unsigned long long __m>
+struct __lce_ta<__a, __c, __m, (unsigned long long)(~0), false>
+{
+ typedef unsigned long long result_type;
+ _LIBCPP_INLINE_VISIBILITY
+ static result_type next(result_type __x)
+ {
+ return (__a * __x + __c) % __m;
+ }
+};
+
+template <unsigned long long __a, unsigned long long __c>
+struct __lce_ta<__a, __c, 0, (unsigned long long)(~0), false>
+{
+ typedef unsigned long long result_type;
+ _LIBCPP_INLINE_VISIBILITY
+ static result_type next(result_type __x)
+ {
+ return __a * __x + __c;
+ }
+};
+
+// 32
+
+template <unsigned long long _Ap, unsigned long long _Cp, unsigned long long _Mp>
+struct __lce_ta<_Ap, _Cp, _Mp, unsigned(~0), true>
+{
+ typedef unsigned result_type;
+ _LIBCPP_INLINE_VISIBILITY
+ static result_type next(result_type __x)
+ {
+ const result_type __a = static_cast<result_type>(_Ap);
+ const result_type __c = static_cast<result_type>(_Cp);
+ const result_type __m = static_cast<result_type>(_Mp);
+ // Schrage's algorithm
+ const result_type __q = __m / __a;
+ const result_type __r = __m % __a;
+ const result_type __t0 = __a * (__x % __q);
+ const result_type __t1 = __r * (__x / __q);
+ __x = __t0 + (__t0 < __t1) * __m - __t1;
+ __x += __c - (__x >= __m - __c) * __m;
+ return __x;
+ }
+};
+
+template <unsigned long long _Ap, unsigned long long _Mp>
+struct __lce_ta<_Ap, 0, _Mp, unsigned(~0), true>
+{
+ typedef unsigned result_type;
+ _LIBCPP_INLINE_VISIBILITY
+ static result_type next(result_type __x)
+ {
+ const result_type __a = static_cast<result_type>(_Ap);
+ const result_type __m = static_cast<result_type>(_Mp);
+ // Schrage's algorithm
+ const result_type __q = __m / __a;
+ const result_type __r = __m % __a;
+ const result_type __t0 = __a * (__x % __q);
+ const result_type __t1 = __r * (__x / __q);
+ __x = __t0 + (__t0 < __t1) * __m - __t1;
+ return __x;
+ }
+};
+
+template <unsigned long long _Ap, unsigned long long _Cp, unsigned long long _Mp>
+struct __lce_ta<_Ap, _Cp, _Mp, unsigned(~0), false>
+{
+ typedef unsigned result_type;
+ _LIBCPP_INLINE_VISIBILITY
+ static result_type next(result_type __x)
+ {
+ const result_type __a = static_cast<result_type>(_Ap);
+ const result_type __c = static_cast<result_type>(_Cp);
+ const result_type __m = static_cast<result_type>(_Mp);
+ return (__a * __x + __c) % __m;
+ }
+};
+
+template <unsigned long long _Ap, unsigned long long _Cp>
+struct __lce_ta<_Ap, _Cp, 0, unsigned(~0), false>
+{
+ typedef unsigned result_type;
+ _LIBCPP_INLINE_VISIBILITY
+ static result_type next(result_type __x)
+ {
+ const result_type __a = static_cast<result_type>(_Ap);
+ const result_type __c = static_cast<result_type>(_Cp);
+ return __a * __x + __c;
+ }
+};
+
+// 16
+
+template <unsigned long long __a, unsigned long long __c, unsigned long long __m, bool __b>
+struct __lce_ta<__a, __c, __m, (unsigned short)(~0), __b>
+{
+ typedef unsigned short result_type;
+ _LIBCPP_INLINE_VISIBILITY
+ static result_type next(result_type __x)
+ {
+ return static_cast<result_type>(__lce_ta<__a, __c, __m, unsigned(~0)>::next(__x));
+ }
+};
+
+template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
+class _LIBCPP_TEMPLATE_VIS linear_congruential_engine;
+
+template <class _CharT, class _Traits,
+ class _Up, _Up _Ap, _Up _Cp, _Up _Np>
+_LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const linear_congruential_engine<_Up, _Ap, _Cp, _Np>&);
+
+template <class _CharT, class _Traits,
+ class _Up, _Up _Ap, _Up _Cp, _Up _Np>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ linear_congruential_engine<_Up, _Ap, _Cp, _Np>& __x);
+
+template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
+class _LIBCPP_TEMPLATE_VIS linear_congruential_engine
+{
+public:
+ // types
+ typedef _UIntType result_type;
+
+private:
+ result_type __x_;
+
+ static _LIBCPP_CONSTEXPR const result_type _Mp = result_type(~0);
+
+ static_assert(__m == 0 || __a < __m, "linear_congruential_engine invalid parameters");
+ static_assert(__m == 0 || __c < __m, "linear_congruential_engine invalid parameters");
+ 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;
+ static_assert(_Min < _Max, "linear_congruential_engine invalid parameters");
+
+ // engine characteristics
+ static _LIBCPP_CONSTEXPR const result_type multiplier = __a;
+ static _LIBCPP_CONSTEXPR const result_type increment = __c;
+ static _LIBCPP_CONSTEXPR const result_type modulus = __m;
+ _LIBCPP_INLINE_VISIBILITY
+ static _LIBCPP_CONSTEXPR result_type min() {return _Min;}
+ _LIBCPP_INLINE_VISIBILITY
+ static _LIBCPP_CONSTEXPR result_type max() {return _Max;}
+ static _LIBCPP_CONSTEXPR const result_type default_seed = 1u;
+
+ // constructors and seeding functions
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ linear_congruential_engine() : linear_congruential_engine(default_seed) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit linear_congruential_engine(result_type __s) { seed(__s); }
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit linear_congruential_engine(result_type __s = default_seed) {
+ seed(__s);
+ }
+#endif
+ template<class _Sseq>
+ _LIBCPP_INLINE_VISIBILITY
+ explicit linear_congruential_engine(_Sseq& __q,
+ typename enable_if<__is_seed_sequence<_Sseq, linear_congruential_engine>::value>::type* = 0)
+ {seed(__q);}
+ _LIBCPP_INLINE_VISIBILITY
+ void seed(result_type __s = default_seed)
+ {seed(integral_constant<bool, __m == 0>(),
+ integral_constant<bool, __c == 0>(), __s);}
+ template<class _Sseq>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if
+ <
+ __is_seed_sequence<_Sseq, linear_congruential_engine>::value,
+ void
+ >::type
+ seed(_Sseq& __q)
+ {__seed(__q, integral_constant<unsigned,
+ 1 + (__m == 0 ? (sizeof(result_type) * __CHAR_BIT__ - 1)/32
+ : (__m > 0x100000000ull))>());}
+
+ // generating functions
+ _LIBCPP_INLINE_VISIBILITY
+ result_type operator()()
+ {return __x_ = static_cast<result_type>(__lce_ta<__a, __c, __m, _Mp>::next(__x_));}
+ _LIBCPP_INLINE_VISIBILITY
+ void discard(unsigned long long __z) {for (; __z; --__z) operator()();}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const linear_congruential_engine& __x,
+ const linear_congruential_engine& __y)
+ {return __x.__x_ == __y.__x_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const linear_congruential_engine& __x,
+ const linear_congruential_engine& __y)
+ {return !(__x == __y);}
+
+private:
+
+ _LIBCPP_INLINE_VISIBILITY
+ void seed(true_type, true_type, result_type __s) {__x_ = __s == 0 ? 1 : __s;}
+ _LIBCPP_INLINE_VISIBILITY
+ void seed(true_type, false_type, result_type __s) {__x_ = __s;}
+ _LIBCPP_INLINE_VISIBILITY
+ void seed(false_type, true_type, result_type __s) {__x_ = __s % __m == 0 ?
+ 1 : __s % __m;}
+ _LIBCPP_INLINE_VISIBILITY
+ void seed(false_type, false_type, result_type __s) {__x_ = __s % __m;}
+
+ template<class _Sseq>
+ void __seed(_Sseq& __q, integral_constant<unsigned, 1>);
+ template<class _Sseq>
+ void __seed(_Sseq& __q, integral_constant<unsigned, 2>);
+
+ template <class _CharT, class _Traits,
+ class _Up, _Up _Ap, _Up _Cp, _Up _Np>
+ friend
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const linear_congruential_engine<_Up, _Ap, _Cp, _Np>&);
+
+ template <class _CharT, class _Traits,
+ class _Up, _Up _Ap, _Up _Cp, _Up _Np>
+ friend
+ basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is,
+ linear_congruential_engine<_Up, _Ap, _Cp, _Np>& __x);
+};
+
+template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
+ _LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type
+ linear_congruential_engine<_UIntType, __a, __c, __m>::multiplier;
+
+template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
+ _LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type
+ linear_congruential_engine<_UIntType, __a, __c, __m>::increment;
+
+template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
+ _LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type
+ linear_congruential_engine<_UIntType, __a, __c, __m>::modulus;
+
+template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
+ _LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type
+ linear_congruential_engine<_UIntType, __a, __c, __m>::default_seed;
+
+template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
+template<class _Sseq>
+void
+linear_congruential_engine<_UIntType, __a, __c, __m>::__seed(_Sseq& __q,
+ integral_constant<unsigned, 1>)
+{
+ const unsigned __k = 1;
+ uint32_t __ar[__k+3];
+ __q.generate(__ar, __ar + __k + 3);
+ result_type __s = static_cast<result_type>(__ar[3] % __m);
+ __x_ = __c == 0 && __s == 0 ? result_type(1) : __s;
+}
+
+template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
+template<class _Sseq>
+void
+linear_congruential_engine<_UIntType, __a, __c, __m>::__seed(_Sseq& __q,
+ integral_constant<unsigned, 2>)
+{
+ const unsigned __k = 2;
+ uint32_t __ar[__k+3];
+ __q.generate(__ar, __ar + __k + 3);
+ result_type __s = static_cast<result_type>((__ar[3] +
+ ((uint64_t)__ar[4] << 32)) % __m);
+ __x_ = __c == 0 && __s == 0 ? result_type(1) : __s;
+}
+
+template <class _CharT, class _Traits,
+ class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const linear_congruential_engine<_UIntType, __a, __c, __m>& __x)
+{
+ __save_flags<_CharT, _Traits> __lx(__os);
+ typedef basic_ostream<_CharT, _Traits> _Ostream;
+ __os.flags(_Ostream::dec | _Ostream::left);
+ __os.fill(__os.widen(' '));
+ return __os << __x.__x_;
+}
+
+template <class _CharT, class _Traits,
+ class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ linear_congruential_engine<_UIntType, __a, __c, __m>& __x)
+{
+ __save_flags<_CharT, _Traits> __lx(__is);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
+ _UIntType __t;
+ __is >> __t;
+ if (!__is.fail())
+ __x.__x_ = __t;
+ return __is;
+}
+
+typedef linear_congruential_engine<uint_fast32_t, 16807, 0, 2147483647>
+ minstd_rand0;
+typedef linear_congruential_engine<uint_fast32_t, 48271, 0, 2147483647>
+ minstd_rand;
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANDOM_LINEAR_CONGRUENTIAL_ENGINE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/log2.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/log2.h
new file mode 100644
index 0000000000..f4f837764c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/log2.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___RANDOM_LOG2_H
+#define _LIBCPP___RANDOM_LOG2_H
+
+#include <__config>
+#include <cstddef>
+#include <limits>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _UIntType, _UIntType _Xp, size_t _Rp>
+struct __log2_imp;
+
+template <unsigned long long _Xp, size_t _Rp>
+struct __log2_imp<unsigned long long, _Xp, _Rp>
+{
+ static const size_t value = _Xp & ((unsigned long long)(1) << _Rp) ? _Rp
+ : __log2_imp<unsigned long long, _Xp, _Rp - 1>::value;
+};
+
+template <unsigned long long _Xp>
+struct __log2_imp<unsigned long long, _Xp, 0>
+{
+ static const size_t value = 0;
+};
+
+template <size_t _Rp>
+struct __log2_imp<unsigned long long, 0, _Rp>
+{
+ static const size_t value = _Rp + 1;
+};
+
+#ifndef _LIBCPP_HAS_NO_INT128
+
+template <__uint128_t _Xp, size_t _Rp>
+struct __log2_imp<__uint128_t, _Xp, _Rp>
+{
+ static const size_t value = (_Xp >> 64)
+ ? (64 + __log2_imp<unsigned long long, (_Xp >> 64), 63>::value)
+ : __log2_imp<unsigned long long, _Xp, 63>::value;
+};
+
+#endif // _LIBCPP_HAS_NO_INT128
+
+template <class _UIntType, _UIntType _Xp>
+struct __log2
+{
+ static const size_t value = __log2_imp<
+#ifndef _LIBCPP_HAS_NO_INT128
+ typename conditional<
+ sizeof(_UIntType) <= sizeof(unsigned long long),
+ unsigned long long,
+ __uint128_t
+ >::type,
+#else
+ unsigned long long,
+#endif // _LIBCPP_HAS_NO_INT128
+ _Xp, sizeof(_UIntType) * __CHAR_BIT__ - 1>::value;
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANDOM_LOG2_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/lognormal_distribution.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/lognormal_distribution.h
new file mode 100644
index 0000000000..048d7dade9
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/lognormal_distribution.h
@@ -0,0 +1,299 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_LOGNORMAL_DISTRIBUTION_H
+#define _LIBCPP___RANDOM_LOGNORMAL_DISTRIBUTION_H
+
+#include <__config>
+#include <__random/normal_distribution.h>
+#include <cmath>
+#include <iosfwd>
+#include <limits>
+
+#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_ABI_OLD_LOGNORMAL_DISTRIBUTION
+
+template<class _RealType = double>
+class _LIBCPP_TEMPLATE_VIS lognormal_distribution
+{
+public:
+ // types
+ typedef _RealType result_type;
+
+ class _LIBCPP_TEMPLATE_VIS param_type
+ {
+ normal_distribution<result_type> __nd_;
+ public:
+ typedef lognormal_distribution distribution_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit param_type(result_type __m = 0, result_type __s = 1)
+ : __nd_(__m, __s) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type m() const {return __nd_.mean();}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type s() const {return __nd_.stddev();}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const param_type& __x, const param_type& __y)
+ {return __x.__nd_ == __y.__nd_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const param_type& __x, const param_type& __y)
+ {return !(__x == __y);}
+ friend class lognormal_distribution;
+
+ template <class _CharT, class _Traits, class _RT>
+ friend
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const lognormal_distribution<_RT>& __x);
+
+ template <class _CharT, class _Traits, class _RT>
+ friend
+ basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is,
+ lognormal_distribution<_RT>& __x);
+ };
+
+private:
+ param_type __p_;
+
+public:
+ // constructor and reset functions
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ lognormal_distribution() : lognormal_distribution(0) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit lognormal_distribution(result_type __m, result_type __s = 1)
+ : __p_(param_type(__m, __s)) {}
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit lognormal_distribution(result_type __m = 0,
+ result_type __s = 1)
+ : __p_(param_type(__m, __s)) {}
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ explicit lognormal_distribution(const param_type& __p)
+ : __p_(__p) {}
+ _LIBCPP_INLINE_VISIBILITY
+ void reset() {__p_.__nd_.reset();}
+
+ // generating functions
+ template<class _URNG>
+ _LIBCPP_INLINE_VISIBILITY
+ result_type operator()(_URNG& __g)
+ {return (*this)(__g, __p_);}
+ template<class _URNG>
+ _LIBCPP_INLINE_VISIBILITY
+ result_type operator()(_URNG& __g, const param_type& __p)
+ {return _VSTD::exp(const_cast<normal_distribution<result_type>&>(__p.__nd_)(__g));}
+
+ // property functions
+ _LIBCPP_INLINE_VISIBILITY
+ result_type m() const {return __p_.m();}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type s() const {return __p_.s();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ param_type param() const {return __p_;}
+ _LIBCPP_INLINE_VISIBILITY
+ void param(const param_type& __p) {__p_ = __p;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type min() const {return 0;}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type max() const {return numeric_limits<result_type>::infinity();}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const lognormal_distribution& __x,
+ const lognormal_distribution& __y)
+ {return __x.__p_ == __y.__p_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const lognormal_distribution& __x,
+ const lognormal_distribution& __y)
+ {return !(__x == __y);}
+
+ template <class _CharT, class _Traits, class _RT>
+ friend
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const lognormal_distribution<_RT>& __x);
+
+ template <class _CharT, class _Traits, class _RT>
+ friend
+ basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is,
+ lognormal_distribution<_RT>& __x);
+};
+
+template <class _CharT, class _Traits, class _RT>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const lognormal_distribution<_RT>& __x)
+{
+ return __os << __x.__p_.__nd_;
+}
+
+template <class _CharT, class _Traits, class _RT>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ lognormal_distribution<_RT>& __x)
+{
+ return __is >> __x.__p_.__nd_;
+}
+
+#else // _LIBCPP_ABI_OLD_LOGNORMAL_DISTRIBUTION
+
+template<class _RealType = double>
+class _LIBCPP_TEMPLATE_VIS lognormal_distribution
+{
+public:
+ // types
+ typedef _RealType result_type;
+
+ class _LIBCPP_TEMPLATE_VIS param_type
+ {
+ result_type __m_;
+ result_type __s_;
+ public:
+ typedef lognormal_distribution distribution_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit param_type(result_type __m = 0, result_type __s = 1)
+ : __m_(__m), __s_(__s) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type m() const {return __m_;}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type s() const {return __s_;}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const param_type& __x, const param_type& __y)
+ {return __x.__m_ == __y.__m_ && __x.__s_ == __y.__s_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const param_type& __x, const param_type& __y)
+ {return !(__x == __y);}
+ };
+
+private:
+ normal_distribution<result_type> __nd_;
+
+public:
+ // constructor and reset functions
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ lognormal_distribution() : lognormal_distribution(0) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit lognormal_distribution(result_type __m, result_type __s = 1)
+ : __nd_(__m, __s) {}
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit lognormal_distribution(result_type __m = 0,
+ result_type __s = 1)
+ : __nd_(__m, __s) {}
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ explicit lognormal_distribution(const param_type& __p)
+ : __nd_(__p.m(), __p.s()) {}
+ _LIBCPP_INLINE_VISIBILITY
+ void reset() {__nd_.reset();}
+
+ // generating functions
+ template<class _URNG>
+ _LIBCPP_INLINE_VISIBILITY
+ result_type operator()(_URNG& __g)
+ {
+ return _VSTD::exp(__nd_(__g));
+ }
+
+ template<class _URNG>
+ _LIBCPP_INLINE_VISIBILITY
+ result_type operator()(_URNG& __g, const param_type& __p)
+ {
+ typename normal_distribution<result_type>::param_type __pn(__p.m(), __p.s());
+ return _VSTD::exp(__nd_(__g, __pn));
+ }
+
+ // property functions
+ _LIBCPP_INLINE_VISIBILITY
+ result_type m() const {return __nd_.mean();}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type s() const {return __nd_.stddev();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ param_type param() const {return param_type(__nd_.mean(), __nd_.stddev());}
+ _LIBCPP_INLINE_VISIBILITY
+ void param(const param_type& __p)
+ {
+ typename normal_distribution<result_type>::param_type __pn(__p.m(), __p.s());
+ __nd_.param(__pn);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type min() const {return 0;}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type max() const {return numeric_limits<result_type>::infinity();}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const lognormal_distribution& __x,
+ const lognormal_distribution& __y)
+ {return __x.__nd_ == __y.__nd_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const lognormal_distribution& __x,
+ const lognormal_distribution& __y)
+ {return !(__x == __y);}
+
+ template <class _CharT, class _Traits, class _RT>
+ friend
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const lognormal_distribution<_RT>& __x);
+
+ template <class _CharT, class _Traits, class _RT>
+ friend
+ basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is,
+ lognormal_distribution<_RT>& __x);
+};
+
+template <class _CharT, class _Traits, class _RT>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const lognormal_distribution<_RT>& __x)
+{
+ return __os << __x.__nd_;
+}
+
+template <class _CharT, class _Traits, class _RT>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ lognormal_distribution<_RT>& __x)
+{
+ return __is >> __x.__nd_;
+}
+
+#endif // _LIBCPP_ABI_OLD_LOGNORMAL_DISTRIBUTION
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANDOM_LOGNORMAL_DISTRIBUTION_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/mersenne_twister_engine.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/mersenne_twister_engine.h
new file mode 100644
index 0000000000..8bceac05dc
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/mersenne_twister_engine.h
@@ -0,0 +1,534 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_MERSENNE_TWISTER_ENGINE_H
+#define _LIBCPP___RANDOM_MERSENNE_TWISTER_ENGINE_H
+
+#include <__algorithm/equal.h>
+#include <__algorithm/min.h>
+#include <__config>
+#include <__random/is_seed_sequence.h>
+#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
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+ _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+ _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+class _LIBCPP_TEMPLATE_VIS mersenne_twister_engine;
+
+template <class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
+ _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp,
+ _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp>
+bool
+operator==(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+ _Bp, _Tp, _Cp, _Lp, _Fp>& __x,
+ const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+ _Bp, _Tp, _Cp, _Lp, _Fp>& __y);
+
+template <class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
+ _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp,
+ _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp>
+_LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+ _Bp, _Tp, _Cp, _Lp, _Fp>& __x,
+ const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+ _Bp, _Tp, _Cp, _Lp, _Fp>& __y);
+
+template <class _CharT, class _Traits,
+ class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
+ _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp,
+ _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+ _Bp, _Tp, _Cp, _Lp, _Fp>& __x);
+
+template <class _CharT, class _Traits,
+ class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
+ _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp,
+ _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+ _Bp, _Tp, _Cp, _Lp, _Fp>& __x);
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+ _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+ _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+class _LIBCPP_TEMPLATE_VIS mersenne_twister_engine
+{
+public:
+ // types
+ typedef _UIntType result_type;
+
+private:
+ result_type __x_[__n];
+ size_t __i_;
+
+ static_assert( 0 < __m, "mersenne_twister_engine invalid parameters");
+ static_assert(__m <= __n, "mersenne_twister_engine invalid parameters");
+ static _LIBCPP_CONSTEXPR const result_type _Dt = numeric_limits<result_type>::digits;
+ static_assert(__w <= _Dt, "mersenne_twister_engine invalid parameters");
+ static_assert( 2 <= __w, "mersenne_twister_engine invalid parameters");
+ static_assert(__r <= __w, "mersenne_twister_engine invalid parameters");
+ static_assert(__u <= __w, "mersenne_twister_engine invalid parameters");
+ static_assert(__s <= __w, "mersenne_twister_engine invalid parameters");
+ static_assert(__t <= __w, "mersenne_twister_engine invalid parameters");
+ static_assert(__l <= __w, "mersenne_twister_engine invalid parameters");
+public:
+ static _LIBCPP_CONSTEXPR const result_type _Min = 0;
+ static _LIBCPP_CONSTEXPR const result_type _Max = __w == _Dt ? result_type(~0) :
+ (result_type(1) << __w) - result_type(1);
+ static_assert(_Min < _Max, "mersenne_twister_engine invalid parameters");
+ static_assert(__a <= _Max, "mersenne_twister_engine invalid parameters");
+ static_assert(__b <= _Max, "mersenne_twister_engine invalid parameters");
+ static_assert(__c <= _Max, "mersenne_twister_engine invalid parameters");
+ static_assert(__d <= _Max, "mersenne_twister_engine invalid parameters");
+ static_assert(__f <= _Max, "mersenne_twister_engine invalid parameters");
+
+ // engine characteristics
+ static _LIBCPP_CONSTEXPR const size_t word_size = __w;
+ static _LIBCPP_CONSTEXPR const size_t state_size = __n;
+ static _LIBCPP_CONSTEXPR const size_t shift_size = __m;
+ static _LIBCPP_CONSTEXPR const size_t mask_bits = __r;
+ static _LIBCPP_CONSTEXPR const result_type xor_mask = __a;
+ static _LIBCPP_CONSTEXPR const size_t tempering_u = __u;
+ static _LIBCPP_CONSTEXPR const result_type tempering_d = __d;
+ static _LIBCPP_CONSTEXPR const size_t tempering_s = __s;
+ static _LIBCPP_CONSTEXPR const result_type tempering_b = __b;
+ static _LIBCPP_CONSTEXPR const size_t tempering_t = __t;
+ static _LIBCPP_CONSTEXPR const result_type tempering_c = __c;
+ static _LIBCPP_CONSTEXPR const size_t tempering_l = __l;
+ static _LIBCPP_CONSTEXPR const result_type initialization_multiplier = __f;
+ _LIBCPP_INLINE_VISIBILITY
+ static _LIBCPP_CONSTEXPR result_type min() { return _Min; }
+ _LIBCPP_INLINE_VISIBILITY
+ static _LIBCPP_CONSTEXPR result_type max() { return _Max; }
+ static _LIBCPP_CONSTEXPR const result_type default_seed = 5489u;
+
+ // constructors and seeding functions
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ mersenne_twister_engine() : mersenne_twister_engine(default_seed) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit mersenne_twister_engine(result_type __sd) { seed(__sd); }
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit mersenne_twister_engine(result_type __sd = default_seed) {
+ seed(__sd);
+ }
+#endif
+ template<class _Sseq>
+ _LIBCPP_INLINE_VISIBILITY
+ explicit mersenne_twister_engine(_Sseq& __q,
+ typename enable_if<__is_seed_sequence<_Sseq, mersenne_twister_engine>::value>::type* = 0)
+ {seed(__q);}
+ void seed(result_type __sd = default_seed);
+ template<class _Sseq>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if
+ <
+ __is_seed_sequence<_Sseq, mersenne_twister_engine>::value,
+ void
+ >::type
+ seed(_Sseq& __q)
+ {__seed(__q, integral_constant<unsigned, 1 + (__w - 1) / 32>());}
+
+ // generating functions
+ result_type operator()();
+ _LIBCPP_INLINE_VISIBILITY
+ void discard(unsigned long long __z) {for (; __z; --__z) operator()();}
+
+ template <class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
+ _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp,
+ _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp>
+ friend
+ bool
+ operator==(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+ _Bp, _Tp, _Cp, _Lp, _Fp>& __x,
+ const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+ _Bp, _Tp, _Cp, _Lp, _Fp>& __y);
+
+ template <class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
+ _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp,
+ _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp>
+ friend
+ bool
+ operator!=(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+ _Bp, _Tp, _Cp, _Lp, _Fp>& __x,
+ const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+ _Bp, _Tp, _Cp, _Lp, _Fp>& __y);
+
+ template <class _CharT, class _Traits,
+ class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
+ _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp,
+ _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp>
+ friend
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+ _Bp, _Tp, _Cp, _Lp, _Fp>& __x);
+
+ template <class _CharT, class _Traits,
+ class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
+ _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp,
+ _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp>
+ friend
+ basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is,
+ mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+ _Bp, _Tp, _Cp, _Lp, _Fp>& __x);
+private:
+
+ template<class _Sseq>
+ void __seed(_Sseq& __q, integral_constant<unsigned, 1>);
+ template<class _Sseq>
+ void __seed(_Sseq& __q, integral_constant<unsigned, 2>);
+
+ template <size_t __count>
+ _LIBCPP_INLINE_VISIBILITY
+ static
+ typename enable_if
+ <
+ __count < __w,
+ result_type
+ >::type
+ __lshift(result_type __x) {return (__x << __count) & _Max;}
+
+ template <size_t __count>
+ _LIBCPP_INLINE_VISIBILITY
+ static
+ typename enable_if
+ <
+ (__count >= __w),
+ result_type
+ >::type
+ __lshift(result_type) {return result_type(0);}
+
+ template <size_t __count>
+ _LIBCPP_INLINE_VISIBILITY
+ static
+ typename enable_if
+ <
+ __count < _Dt,
+ result_type
+ >::type
+ __rshift(result_type __x) {return __x >> __count;}
+
+ template <size_t __count>
+ _LIBCPP_INLINE_VISIBILITY
+ static
+ typename enable_if
+ <
+ (__count >= _Dt),
+ result_type
+ >::type
+ __rshift(result_type) {return result_type(0);}
+};
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+ _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+ _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+ _LIBCPP_CONSTEXPR const size_t
+ mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::word_size;
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+ _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+ _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+ _LIBCPP_CONSTEXPR const size_t
+ mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::state_size;
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+ _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+ _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+ _LIBCPP_CONSTEXPR const size_t
+ mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::shift_size;
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+ _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+ _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+ _LIBCPP_CONSTEXPR const size_t
+ mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::mask_bits;
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+ _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+ _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+ _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type
+ mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::xor_mask;
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+ _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+ _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+ _LIBCPP_CONSTEXPR const size_t
+ mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_u;
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+ _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+ _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+ _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type
+ mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_d;
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+ _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+ _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+ _LIBCPP_CONSTEXPR const size_t
+ mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_s;
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+ _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+ _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+ _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type
+ mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_b;
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+ _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+ _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+ _LIBCPP_CONSTEXPR const size_t
+ mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_t;
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+ _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+ _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+ _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type
+ mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_c;
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+ _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+ _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+ _LIBCPP_CONSTEXPR const size_t
+ mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_l;
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+ _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+ _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+ _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type
+ mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::initialization_multiplier;
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+ _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+ _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+ _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type
+ mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::default_seed;
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+ _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+ _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+void
+mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b,
+ __t, __c, __l, __f>::seed(result_type __sd)
+ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
+{ // __w >= 2
+ __x_[0] = __sd & _Max;
+ for (size_t __i = 1; __i < __n; ++__i)
+ __x_[__i] = (__f * (__x_[__i-1] ^ __rshift<__w - 2>(__x_[__i-1])) + __i) & _Max;
+ __i_ = 0;
+}
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+ _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+ _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+template<class _Sseq>
+void
+mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b,
+ __t, __c, __l, __f>::__seed(_Sseq& __q, integral_constant<unsigned, 1>)
+{
+ const unsigned __k = 1;
+ uint32_t __ar[__n * __k];
+ __q.generate(__ar, __ar + __n * __k);
+ for (size_t __i = 0; __i < __n; ++__i)
+ __x_[__i] = static_cast<result_type>(__ar[__i] & _Max);
+ const result_type __mask = __r == _Dt ? result_type(~0) :
+ (result_type(1) << __r) - result_type(1);
+ __i_ = 0;
+ if ((__x_[0] & ~__mask) == 0)
+ {
+ for (size_t __i = 1; __i < __n; ++__i)
+ if (__x_[__i] != 0)
+ return;
+ __x_[0] = result_type(1) << (__w - 1);
+ }
+}
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+ _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+ _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+template<class _Sseq>
+void
+mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b,
+ __t, __c, __l, __f>::__seed(_Sseq& __q, integral_constant<unsigned, 2>)
+{
+ const unsigned __k = 2;
+ uint32_t __ar[__n * __k];
+ __q.generate(__ar, __ar + __n * __k);
+ for (size_t __i = 0; __i < __n; ++__i)
+ __x_[__i] = static_cast<result_type>(
+ (__ar[2 * __i] + ((uint64_t)__ar[2 * __i + 1] << 32)) & _Max);
+ const result_type __mask = __r == _Dt ? result_type(~0) :
+ (result_type(1) << __r) - result_type(1);
+ __i_ = 0;
+ if ((__x_[0] & ~__mask) == 0)
+ {
+ for (size_t __i = 1; __i < __n; ++__i)
+ if (__x_[__i] != 0)
+ return;
+ __x_[0] = result_type(1) << (__w - 1);
+ }
+}
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+ _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+ _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+_UIntType
+mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b,
+ __t, __c, __l, __f>::operator()()
+{
+ const size_t __j = (__i_ + 1) % __n;
+ const result_type __mask = __r == _Dt ? result_type(~0) :
+ (result_type(1) << __r) - result_type(1);
+ const result_type _Yp = (__x_[__i_] & ~__mask) | (__x_[__j] & __mask);
+ const size_t __k = (__i_ + __m) % __n;
+ __x_[__i_] = __x_[__k] ^ __rshift<1>(_Yp) ^ (__a * (_Yp & 1));
+ result_type __z = __x_[__i_] ^ (__rshift<__u>(__x_[__i_]) & __d);
+ __i_ = __j;
+ __z ^= __lshift<__s>(__z) & __b;
+ __z ^= __lshift<__t>(__z) & __c;
+ return __z ^ __rshift<__l>(__z);
+}
+
+template <class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
+ _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp,
+ _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp>
+bool
+operator==(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+ _Bp, _Tp, _Cp, _Lp, _Fp>& __x,
+ const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+ _Bp, _Tp, _Cp, _Lp, _Fp>& __y)
+{
+ if (__x.__i_ == __y.__i_)
+ return _VSTD::equal(__x.__x_, __x.__x_ + _Np, __y.__x_);
+ if (__x.__i_ == 0 || __y.__i_ == 0)
+ {
+ size_t __j = _VSTD::min(_Np - __x.__i_, _Np - __y.__i_);
+ if (!_VSTD::equal(__x.__x_ + __x.__i_, __x.__x_ + __x.__i_ + __j,
+ __y.__x_ + __y.__i_))
+ return false;
+ if (__x.__i_ == 0)
+ return _VSTD::equal(__x.__x_ + __j, __x.__x_ + _Np, __y.__x_);
+ return _VSTD::equal(__x.__x_, __x.__x_ + (_Np - __j), __y.__x_ + __j);
+ }
+ if (__x.__i_ < __y.__i_)
+ {
+ size_t __j = _Np - __y.__i_;
+ if (!_VSTD::equal(__x.__x_ + __x.__i_, __x.__x_ + (__x.__i_ + __j),
+ __y.__x_ + __y.__i_))
+ return false;
+ if (!_VSTD::equal(__x.__x_ + (__x.__i_ + __j), __x.__x_ + _Np,
+ __y.__x_))
+ return false;
+ return _VSTD::equal(__x.__x_, __x.__x_ + __x.__i_,
+ __y.__x_ + (_Np - (__x.__i_ + __j)));
+ }
+ size_t __j = _Np - __x.__i_;
+ if (!_VSTD::equal(__y.__x_ + __y.__i_, __y.__x_ + (__y.__i_ + __j),
+ __x.__x_ + __x.__i_))
+ return false;
+ if (!_VSTD::equal(__y.__x_ + (__y.__i_ + __j), __y.__x_ + _Np,
+ __x.__x_))
+ return false;
+ return _VSTD::equal(__y.__x_, __y.__x_ + __y.__i_,
+ __x.__x_ + (_Np - (__y.__i_ + __j)));
+}
+
+template <class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
+ _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp,
+ _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+ _Bp, _Tp, _Cp, _Lp, _Fp>& __x,
+ const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+ _Bp, _Tp, _Cp, _Lp, _Fp>& __y)
+{
+ return !(__x == __y);
+}
+
+template <class _CharT, class _Traits,
+ class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
+ _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp,
+ _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+ _Bp, _Tp, _Cp, _Lp, _Fp>& __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);
+ __os << __x.__x_[__x.__i_];
+ for (size_t __j = __x.__i_ + 1; __j < _Np; ++__j)
+ __os << __sp << __x.__x_[__j];
+ for (size_t __j = 0; __j < __x.__i_; ++__j)
+ __os << __sp << __x.__x_[__j];
+ return __os;
+}
+
+template <class _CharT, class _Traits,
+ class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
+ _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp,
+ _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+ _Bp, _Tp, _Cp, _Lp, _Fp>& __x)
+{
+ __save_flags<_CharT, _Traits> __lx(__is);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
+ _UInt __t[_Np];
+ for (size_t __i = 0; __i < _Np; ++__i)
+ __is >> __t[__i];
+ if (!__is.fail())
+ {
+ for (size_t __i = 0; __i < _Np; ++__i)
+ __x.__x_[__i] = __t[__i];
+ __x.__i_ = 0;
+ }
+ return __is;
+}
+
+typedef mersenne_twister_engine<uint_fast32_t, 32, 624, 397, 31,
+ 0x9908b0df, 11, 0xffffffff,
+ 7, 0x9d2c5680,
+ 15, 0xefc60000,
+ 18, 1812433253> mt19937;
+typedef mersenne_twister_engine<uint_fast64_t, 64, 312, 156, 31,
+ 0xb5026f5aa96619e9ULL, 29, 0x5555555555555555ULL,
+ 17, 0x71d67fffeda60000ULL,
+ 37, 0xfff7eee000000000ULL,
+ 43, 6364136223846793005ULL> mt19937_64;
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANDOM_MERSENNE_TWISTER_ENGINE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/negative_binomial_distribution.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/negative_binomial_distribution.h
new file mode 100644
index 0000000000..01e9c303a7
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/negative_binomial_distribution.h
@@ -0,0 +1,176 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_NEGATIVE_BINOMIAL_DISTRIBUTION_H
+#define _LIBCPP___RANDOM_NEGATIVE_BINOMIAL_DISTRIBUTION_H
+
+#include <__config>
+#include <__random/bernoulli_distribution.h>
+#include <__random/gamma_distribution.h>
+#include <__random/poisson_distribution.h>
+#include <iosfwd>
+#include <limits>
+
+#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 _IntType = int>
+class _LIBCPP_TEMPLATE_VIS negative_binomial_distribution
+{
+public:
+ // types
+ typedef _IntType result_type;
+
+ class _LIBCPP_TEMPLATE_VIS param_type
+ {
+ result_type __k_;
+ double __p_;
+ public:
+ typedef negative_binomial_distribution distribution_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit param_type(result_type __k = 1, double __p = 0.5)
+ : __k_(__k), __p_(__p) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type k() const {return __k_;}
+ _LIBCPP_INLINE_VISIBILITY
+ double p() const {return __p_;}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const param_type& __x, const param_type& __y)
+ {return __x.__k_ == __y.__k_ && __x.__p_ == __y.__p_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const param_type& __x, const param_type& __y)
+ {return !(__x == __y);}
+ };
+
+private:
+ param_type __p_;
+
+public:
+ // constructor and reset functions
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ negative_binomial_distribution() : negative_binomial_distribution(1) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit negative_binomial_distribution(result_type __k, double __p = 0.5)
+ : __p_(__k, __p) {}
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit negative_binomial_distribution(result_type __k = 1,
+ double __p = 0.5)
+ : __p_(__k, __p) {}
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ explicit negative_binomial_distribution(const param_type& __p) : __p_(__p) {}
+ _LIBCPP_INLINE_VISIBILITY
+ void reset() {}
+
+ // generating functions
+ template<class _URNG>
+ _LIBCPP_INLINE_VISIBILITY
+ result_type operator()(_URNG& __g)
+ {return (*this)(__g, __p_);}
+ template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+
+ // property functions
+ _LIBCPP_INLINE_VISIBILITY
+ result_type k() const {return __p_.k();}
+ _LIBCPP_INLINE_VISIBILITY
+ double p() const {return __p_.p();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ param_type param() const {return __p_;}
+ _LIBCPP_INLINE_VISIBILITY
+ void param(const param_type& __p) {__p_ = __p;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type min() const {return 0;}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type max() const {return numeric_limits<result_type>::max();}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const negative_binomial_distribution& __x,
+ const negative_binomial_distribution& __y)
+ {return __x.__p_ == __y.__p_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const negative_binomial_distribution& __x,
+ const negative_binomial_distribution& __y)
+ {return !(__x == __y);}
+};
+
+template <class _IntType>
+template<class _URNG>
+_IntType
+negative_binomial_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr)
+{
+ result_type __k = __pr.k();
+ double __p = __pr.p();
+ if (__k <= 21 * __p)
+ {
+ bernoulli_distribution __gen(__p);
+ result_type __f = 0;
+ result_type __s = 0;
+ while (__s < __k)
+ {
+ if (__gen(__urng))
+ ++__s;
+ else
+ ++__f;
+ }
+ return __f;
+ }
+ return poisson_distribution<result_type>(gamma_distribution<double>
+ (__k, (1-__p)/__p)(__urng))(__urng);
+}
+
+template <class _CharT, class _Traits, class _IntType>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const negative_binomial_distribution<_IntType>& __x)
+{
+ __save_flags<_CharT, _Traits> __lx(__os);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
+ _CharT __sp = __os.widen(' ');
+ __os.fill(__sp);
+ return __os << __x.k() << __sp << __x.p();
+}
+
+template <class _CharT, class _Traits, class _IntType>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ negative_binomial_distribution<_IntType>& __x)
+{
+ typedef negative_binomial_distribution<_IntType> _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 __k;
+ double __p;
+ __is >> __k >> __p;
+ if (!__is.fail())
+ __x.param(param_type(__k, __p));
+ return __is;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANDOM_NEGATIVE_BINOMIAL_DISTRIBUTION_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/normal_distribution.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/normal_distribution.h
new file mode 100644
index 0000000000..dc4de78e92
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/normal_distribution.h
@@ -0,0 +1,208 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_NORMAL_DISTRIBUTION_H
+#define _LIBCPP___RANDOM_NORMAL_DISTRIBUTION_H
+
+#include <__config>
+#include <__random/uniform_real_distribution.h>
+#include <cmath>
+#include <iosfwd>
+#include <limits>
+
+#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 _RealType = double>
+class _LIBCPP_TEMPLATE_VIS normal_distribution
+{
+public:
+ // types
+ typedef _RealType result_type;
+
+ class _LIBCPP_TEMPLATE_VIS param_type
+ {
+ result_type __mean_;
+ result_type __stddev_;
+ public:
+ typedef normal_distribution distribution_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit param_type(result_type __mean = 0, result_type __stddev = 1)
+ : __mean_(__mean), __stddev_(__stddev) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type mean() const {return __mean_;}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type stddev() const {return __stddev_;}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const param_type& __x, const param_type& __y)
+ {return __x.__mean_ == __y.__mean_ && __x.__stddev_ == __y.__stddev_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const param_type& __x, const param_type& __y)
+ {return !(__x == __y);}
+ };
+
+private:
+ param_type __p_;
+ result_type _V_;
+ bool _V_hot_;
+
+public:
+ // constructors and reset functions
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ normal_distribution() : normal_distribution(0) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit normal_distribution(result_type __mean, result_type __stddev = 1)
+ : __p_(param_type(__mean, __stddev)), _V_hot_(false) {}
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit normal_distribution(result_type __mean = 0,
+ result_type __stddev = 1)
+ : __p_(param_type(__mean, __stddev)), _V_hot_(false) {}
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ explicit normal_distribution(const param_type& __p)
+ : __p_(__p), _V_hot_(false) {}
+ _LIBCPP_INLINE_VISIBILITY
+ void reset() {_V_hot_ = false;}
+
+ // generating functions
+ template<class _URNG>
+ _LIBCPP_INLINE_VISIBILITY
+ result_type operator()(_URNG& __g)
+ {return (*this)(__g, __p_);}
+ template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+
+ // property functions
+ _LIBCPP_INLINE_VISIBILITY
+ result_type mean() const {return __p_.mean();}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type stddev() const {return __p_.stddev();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ param_type param() const {return __p_;}
+ _LIBCPP_INLINE_VISIBILITY
+ void param(const param_type& __p) {__p_ = __p;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type min() const {return -numeric_limits<result_type>::infinity();}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type max() const {return numeric_limits<result_type>::infinity();}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const normal_distribution& __x,
+ const normal_distribution& __y)
+ {return __x.__p_ == __y.__p_ && __x._V_hot_ == __y._V_hot_ &&
+ (!__x._V_hot_ || __x._V_ == __y._V_);}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const normal_distribution& __x,
+ const normal_distribution& __y)
+ {return !(__x == __y);}
+
+ template <class _CharT, class _Traits, class _RT>
+ friend
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const normal_distribution<_RT>& __x);
+
+ template <class _CharT, class _Traits, class _RT>
+ friend
+ basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is,
+ normal_distribution<_RT>& __x);
+};
+
+template <class _RealType>
+template<class _URNG>
+_RealType
+normal_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
+{
+ result_type _Up;
+ if (_V_hot_)
+ {
+ _V_hot_ = false;
+ _Up = _V_;
+ }
+ else
+ {
+ uniform_real_distribution<result_type> _Uni(-1, 1);
+ result_type __u;
+ result_type __v;
+ result_type __s;
+ do
+ {
+ __u = _Uni(__g);
+ __v = _Uni(__g);
+ __s = __u * __u + __v * __v;
+ } while (__s > 1 || __s == 0);
+ result_type _Fp = _VSTD::sqrt(-2 * _VSTD::log(__s) / __s);
+ _V_ = __v * _Fp;
+ _V_hot_ = true;
+ _Up = __u * _Fp;
+ }
+ return _Up * __p.stddev() + __p.mean();
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const normal_distribution<_RT>& __x)
+{
+ __save_flags<_CharT, _Traits> __lx(__os);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
+ _CharT __sp = __os.widen(' ');
+ __os.fill(__sp);
+ __os << __x.mean() << __sp << __x.stddev() << __sp << __x._V_hot_;
+ if (__x._V_hot_)
+ __os << __sp << __x._V_;
+ return __os;
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ normal_distribution<_RT>& __x)
+{
+ typedef normal_distribution<_RT> _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 __mean;
+ result_type __stddev;
+ result_type _Vp = 0;
+ bool _V_hot = false;
+ __is >> __mean >> __stddev >> _V_hot;
+ if (_V_hot)
+ __is >> _Vp;
+ if (!__is.fail())
+ {
+ __x.param(param_type(__mean, __stddev));
+ __x._V_hot_ = _V_hot;
+ __x._V_ = _Vp;
+ }
+ return __is;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANDOM_NORMAL_DISTRIBUTION_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/piecewise_constant_distribution.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/piecewise_constant_distribution.h
new file mode 100644
index 0000000000..eec9b7540a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/piecewise_constant_distribution.h
@@ -0,0 +1,356 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_PIECEWISE_CONSTANT_DISTRIBUTION_H
+#define _LIBCPP___RANDOM_PIECEWISE_CONSTANT_DISTRIBUTION_H
+
+#include <__algorithm/upper_bound.h>
+#include <__config>
+#include <__random/uniform_real_distribution.h>
+#include <iosfwd>
+#include <numeric>
+#include <vector>
+
+#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 _RealType = double>
+class _LIBCPP_TEMPLATE_VIS piecewise_constant_distribution
+{
+public:
+ // types
+ typedef _RealType result_type;
+
+ class _LIBCPP_TEMPLATE_VIS param_type
+ {
+ vector<result_type> __b_;
+ vector<result_type> __densities_;
+ vector<result_type> __areas_;
+ public:
+ typedef piecewise_constant_distribution distribution_type;
+
+ param_type();
+ template<class _InputIteratorB, class _InputIteratorW>
+ param_type(_InputIteratorB __fB, _InputIteratorB __lB,
+ _InputIteratorW __fW);
+#ifndef _LIBCPP_CXX03_LANG
+ template<class _UnaryOperation>
+ param_type(initializer_list<result_type> __bl, _UnaryOperation __fw);
+#endif // _LIBCPP_CXX03_LANG
+ template<class _UnaryOperation>
+ param_type(size_t __nw, result_type __xmin, result_type __xmax,
+ _UnaryOperation __fw);
+ param_type(param_type const&) = default;
+ param_type & operator=(const param_type& __rhs);
+
+ _LIBCPP_INLINE_VISIBILITY
+ vector<result_type> intervals() const {return __b_;}
+ _LIBCPP_INLINE_VISIBILITY
+ vector<result_type> densities() const {return __densities_;}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const param_type& __x, const param_type& __y)
+ {return __x.__densities_ == __y.__densities_ && __x.__b_ == __y.__b_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const param_type& __x, const param_type& __y)
+ {return !(__x == __y);}
+
+ private:
+ void __init();
+
+ friend class piecewise_constant_distribution;
+
+ template <class _CharT, class _Traits, class _RT>
+ friend
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const piecewise_constant_distribution<_RT>& __x);
+
+ template <class _CharT, class _Traits, class _RT>
+ friend
+ basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is,
+ piecewise_constant_distribution<_RT>& __x);
+ };
+
+private:
+ param_type __p_;
+
+public:
+ // constructor and reset functions
+ _LIBCPP_INLINE_VISIBILITY
+ piecewise_constant_distribution() {}
+ template<class _InputIteratorB, class _InputIteratorW>
+ _LIBCPP_INLINE_VISIBILITY
+ piecewise_constant_distribution(_InputIteratorB __fB,
+ _InputIteratorB __lB,
+ _InputIteratorW __fW)
+ : __p_(__fB, __lB, __fW) {}
+
+#ifndef _LIBCPP_CXX03_LANG
+ template<class _UnaryOperation>
+ _LIBCPP_INLINE_VISIBILITY
+ piecewise_constant_distribution(initializer_list<result_type> __bl,
+ _UnaryOperation __fw)
+ : __p_(__bl, __fw) {}
+#endif // _LIBCPP_CXX03_LANG
+
+ template<class _UnaryOperation>
+ _LIBCPP_INLINE_VISIBILITY
+ piecewise_constant_distribution(size_t __nw, result_type __xmin,
+ result_type __xmax, _UnaryOperation __fw)
+ : __p_(__nw, __xmin, __xmax, __fw) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit piecewise_constant_distribution(const param_type& __p)
+ : __p_(__p) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void reset() {}
+
+ // generating functions
+ template<class _URNG>
+ _LIBCPP_INLINE_VISIBILITY
+ result_type operator()(_URNG& __g)
+ {return (*this)(__g, __p_);}
+ template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+
+ // property functions
+ _LIBCPP_INLINE_VISIBILITY
+ vector<result_type> intervals() const {return __p_.intervals();}
+ _LIBCPP_INLINE_VISIBILITY
+ vector<result_type> densities() const {return __p_.densities();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ param_type param() const {return __p_;}
+ _LIBCPP_INLINE_VISIBILITY
+ void param(const param_type& __p) {__p_ = __p;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type min() const {return __p_.__b_.front();}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type max() const {return __p_.__b_.back();}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const piecewise_constant_distribution& __x,
+ const piecewise_constant_distribution& __y)
+ {return __x.__p_ == __y.__p_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const piecewise_constant_distribution& __x,
+ const piecewise_constant_distribution& __y)
+ {return !(__x == __y);}
+
+ template <class _CharT, class _Traits, class _RT>
+ friend
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const piecewise_constant_distribution<_RT>& __x);
+
+ template <class _CharT, class _Traits, class _RT>
+ friend
+ basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is,
+ piecewise_constant_distribution<_RT>& __x);
+};
+
+template<class _RealType>
+typename piecewise_constant_distribution<_RealType>::param_type &
+piecewise_constant_distribution<_RealType>::param_type::operator=
+ (const param_type& __rhs)
+{
+// These can throw
+ __b_.reserve (__rhs.__b_.size ());
+ __densities_.reserve(__rhs.__densities_.size());
+ __areas_.reserve (__rhs.__areas_.size());
+
+// These can not throw
+ __b_ = __rhs.__b_;
+ __densities_ = __rhs.__densities_;
+ __areas_ = __rhs.__areas_;
+ return *this;
+}
+
+template<class _RealType>
+void
+piecewise_constant_distribution<_RealType>::param_type::__init()
+{
+ // __densities_ contains non-normalized areas
+ result_type __total_area = _VSTD::accumulate(__densities_.begin(),
+ __densities_.end(),
+ result_type());
+ for (size_t __i = 0; __i < __densities_.size(); ++__i)
+ __densities_[__i] /= __total_area;
+ // __densities_ contains normalized areas
+ __areas_.assign(__densities_.size(), result_type());
+ _VSTD::partial_sum(__densities_.begin(), __densities_.end() - 1,
+ __areas_.begin() + 1);
+ // __areas_ contains partial sums of normalized areas: [0, __densities_ - 1]
+ __densities_.back() = 1 - __areas_.back(); // correct round off error
+ for (size_t __i = 0; __i < __densities_.size(); ++__i)
+ __densities_[__i] /= (__b_[__i+1] - __b_[__i]);
+ // __densities_ now contains __densities_
+}
+
+template<class _RealType>
+piecewise_constant_distribution<_RealType>::param_type::param_type()
+ : __b_(2),
+ __densities_(1, 1.0),
+ __areas_(1, 0.0)
+{
+ __b_[1] = 1;
+}
+
+template<class _RealType>
+template<class _InputIteratorB, class _InputIteratorW>
+piecewise_constant_distribution<_RealType>::param_type::param_type(
+ _InputIteratorB __fB, _InputIteratorB __lB, _InputIteratorW __fW)
+ : __b_(__fB, __lB)
+{
+ if (__b_.size() < 2)
+ {
+ __b_.resize(2);
+ __b_[0] = 0;
+ __b_[1] = 1;
+ __densities_.assign(1, 1.0);
+ __areas_.assign(1, 0.0);
+ }
+ else
+ {
+ __densities_.reserve(__b_.size() - 1);
+ for (size_t __i = 0; __i < __b_.size() - 1; ++__i, ++__fW)
+ __densities_.push_back(*__fW);
+ __init();
+ }
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template<class _RealType>
+template<class _UnaryOperation>
+piecewise_constant_distribution<_RealType>::param_type::param_type(
+ initializer_list<result_type> __bl, _UnaryOperation __fw)
+ : __b_(__bl.begin(), __bl.end())
+{
+ if (__b_.size() < 2)
+ {
+ __b_.resize(2);
+ __b_[0] = 0;
+ __b_[1] = 1;
+ __densities_.assign(1, 1.0);
+ __areas_.assign(1, 0.0);
+ }
+ else
+ {
+ __densities_.reserve(__b_.size() - 1);
+ for (size_t __i = 0; __i < __b_.size() - 1; ++__i)
+ __densities_.push_back(__fw((__b_[__i+1] + __b_[__i])*.5));
+ __init();
+ }
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template<class _RealType>
+template<class _UnaryOperation>
+piecewise_constant_distribution<_RealType>::param_type::param_type(
+ size_t __nw, result_type __xmin, result_type __xmax, _UnaryOperation __fw)
+ : __b_(__nw == 0 ? 2 : __nw + 1)
+{
+ size_t __n = __b_.size() - 1;
+ result_type __d = (__xmax - __xmin) / __n;
+ __densities_.reserve(__n);
+ for (size_t __i = 0; __i < __n; ++__i)
+ {
+ __b_[__i] = __xmin + __i * __d;
+ __densities_.push_back(__fw(__b_[__i] + __d*.5));
+ }
+ __b_[__n] = __xmax;
+ __init();
+}
+
+template<class _RealType>
+template<class _URNG>
+_RealType
+piecewise_constant_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
+{
+ typedef uniform_real_distribution<result_type> _Gen;
+ result_type __u = _Gen()(__g);
+ ptrdiff_t __k = _VSTD::upper_bound(__p.__areas_.begin(), __p.__areas_.end(),
+ __u) - __p.__areas_.begin() - 1;
+ return (__u - __p.__areas_[__k]) / __p.__densities_[__k] + __p.__b_[__k];
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const piecewise_constant_distribution<_RT>& __x)
+{
+ __save_flags<_CharT, _Traits> __lx(__os);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
+ _CharT __sp = __os.widen(' ');
+ __os.fill(__sp);
+ size_t __n = __x.__p_.__b_.size();
+ __os << __n;
+ for (size_t __i = 0; __i < __n; ++__i)
+ __os << __sp << __x.__p_.__b_[__i];
+ __n = __x.__p_.__densities_.size();
+ __os << __sp << __n;
+ for (size_t __i = 0; __i < __n; ++__i)
+ __os << __sp << __x.__p_.__densities_[__i];
+ __n = __x.__p_.__areas_.size();
+ __os << __sp << __n;
+ for (size_t __i = 0; __i < __n; ++__i)
+ __os << __sp << __x.__p_.__areas_[__i];
+ return __os;
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ piecewise_constant_distribution<_RT>& __x)
+{
+ typedef piecewise_constant_distribution<_RT> _Eng;
+ typedef typename _Eng::result_type result_type;
+ __save_flags<_CharT, _Traits> __lx(__is);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
+ size_t __n;
+ __is >> __n;
+ vector<result_type> __b(__n);
+ for (size_t __i = 0; __i < __n; ++__i)
+ __is >> __b[__i];
+ __is >> __n;
+ vector<result_type> __densities(__n);
+ for (size_t __i = 0; __i < __n; ++__i)
+ __is >> __densities[__i];
+ __is >> __n;
+ vector<result_type> __areas(__n);
+ for (size_t __i = 0; __i < __n; ++__i)
+ __is >> __areas[__i];
+ if (!__is.fail())
+ {
+ swap(__x.__p_.__b_, __b);
+ swap(__x.__p_.__densities_, __densities);
+ swap(__x.__p_.__areas_, __areas);
+ }
+ return __is;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANDOM_PIECEWISE_CONSTANT_DISTRIBUTION_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/piecewise_linear_distribution.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/piecewise_linear_distribution.h
new file mode 100644
index 0000000000..0d7591af10
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/piecewise_linear_distribution.h
@@ -0,0 +1,372 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_PIECEWISE_LINEAR_DISTRIBUTION_H
+#define _LIBCPP___RANDOM_PIECEWISE_LINEAR_DISTRIBUTION_H
+
+#include <__algorithm/upper_bound.h>
+#include <__config>
+#include <__random/uniform_real_distribution.h>
+#include <iosfwd>
+#include <numeric>
+#include <vector>
+
+#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 _RealType = double>
+class _LIBCPP_TEMPLATE_VIS piecewise_linear_distribution
+{
+public:
+ // types
+ typedef _RealType result_type;
+
+ class _LIBCPP_TEMPLATE_VIS param_type
+ {
+ vector<result_type> __b_;
+ vector<result_type> __densities_;
+ vector<result_type> __areas_;
+ public:
+ typedef piecewise_linear_distribution distribution_type;
+
+ param_type();
+ template<class _InputIteratorB, class _InputIteratorW>
+ param_type(_InputIteratorB __fB, _InputIteratorB __lB,
+ _InputIteratorW __fW);
+#ifndef _LIBCPP_CXX03_LANG
+ template<class _UnaryOperation>
+ param_type(initializer_list<result_type> __bl, _UnaryOperation __fw);
+#endif // _LIBCPP_CXX03_LANG
+ template<class _UnaryOperation>
+ param_type(size_t __nw, result_type __xmin, result_type __xmax,
+ _UnaryOperation __fw);
+ param_type(param_type const&) = default;
+ param_type & operator=(const param_type& __rhs);
+
+ _LIBCPP_INLINE_VISIBILITY
+ vector<result_type> intervals() const {return __b_;}
+ _LIBCPP_INLINE_VISIBILITY
+ vector<result_type> densities() const {return __densities_;}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const param_type& __x, const param_type& __y)
+ {return __x.__densities_ == __y.__densities_ && __x.__b_ == __y.__b_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const param_type& __x, const param_type& __y)
+ {return !(__x == __y);}
+
+ private:
+ void __init();
+
+ friend class piecewise_linear_distribution;
+
+ template <class _CharT, class _Traits, class _RT>
+ friend
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const piecewise_linear_distribution<_RT>& __x);
+
+ template <class _CharT, class _Traits, class _RT>
+ friend
+ basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is,
+ piecewise_linear_distribution<_RT>& __x);
+ };
+
+private:
+ param_type __p_;
+
+public:
+ // constructor and reset functions
+ _LIBCPP_INLINE_VISIBILITY
+ piecewise_linear_distribution() {}
+ template<class _InputIteratorB, class _InputIteratorW>
+ _LIBCPP_INLINE_VISIBILITY
+ piecewise_linear_distribution(_InputIteratorB __fB,
+ _InputIteratorB __lB,
+ _InputIteratorW __fW)
+ : __p_(__fB, __lB, __fW) {}
+
+#ifndef _LIBCPP_CXX03_LANG
+ template<class _UnaryOperation>
+ _LIBCPP_INLINE_VISIBILITY
+ piecewise_linear_distribution(initializer_list<result_type> __bl,
+ _UnaryOperation __fw)
+ : __p_(__bl, __fw) {}
+#endif // _LIBCPP_CXX03_LANG
+
+ template<class _UnaryOperation>
+ _LIBCPP_INLINE_VISIBILITY
+ piecewise_linear_distribution(size_t __nw, result_type __xmin,
+ result_type __xmax, _UnaryOperation __fw)
+ : __p_(__nw, __xmin, __xmax, __fw) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit piecewise_linear_distribution(const param_type& __p)
+ : __p_(__p) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void reset() {}
+
+ // generating functions
+ template<class _URNG>
+ _LIBCPP_INLINE_VISIBILITY
+ result_type operator()(_URNG& __g)
+ {return (*this)(__g, __p_);}
+ template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+
+ // property functions
+ _LIBCPP_INLINE_VISIBILITY
+ vector<result_type> intervals() const {return __p_.intervals();}
+ _LIBCPP_INLINE_VISIBILITY
+ vector<result_type> densities() const {return __p_.densities();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ param_type param() const {return __p_;}
+ _LIBCPP_INLINE_VISIBILITY
+ void param(const param_type& __p) {__p_ = __p;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type min() const {return __p_.__b_.front();}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type max() const {return __p_.__b_.back();}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const piecewise_linear_distribution& __x,
+ const piecewise_linear_distribution& __y)
+ {return __x.__p_ == __y.__p_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const piecewise_linear_distribution& __x,
+ const piecewise_linear_distribution& __y)
+ {return !(__x == __y);}
+
+ template <class _CharT, class _Traits, class _RT>
+ friend
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const piecewise_linear_distribution<_RT>& __x);
+
+ template <class _CharT, class _Traits, class _RT>
+ friend
+ basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is,
+ piecewise_linear_distribution<_RT>& __x);
+};
+
+template<class _RealType>
+typename piecewise_linear_distribution<_RealType>::param_type &
+piecewise_linear_distribution<_RealType>::param_type::operator=
+ (const param_type& __rhs)
+{
+// These can throw
+ __b_.reserve (__rhs.__b_.size ());
+ __densities_.reserve(__rhs.__densities_.size());
+ __areas_.reserve (__rhs.__areas_.size());
+
+// These can not throw
+ __b_ = __rhs.__b_;
+ __densities_ = __rhs.__densities_;
+ __areas_ = __rhs.__areas_;
+ return *this;
+}
+
+
+template<class _RealType>
+void
+piecewise_linear_distribution<_RealType>::param_type::__init()
+{
+ __areas_.assign(__densities_.size() - 1, result_type());
+ result_type _Sp = 0;
+ for (size_t __i = 0; __i < __areas_.size(); ++__i)
+ {
+ __areas_[__i] = (__densities_[__i+1] + __densities_[__i]) *
+ (__b_[__i+1] - __b_[__i]) * .5;
+ _Sp += __areas_[__i];
+ }
+ for (size_t __i = __areas_.size(); __i > 1;)
+ {
+ --__i;
+ __areas_[__i] = __areas_[__i-1] / _Sp;
+ }
+ __areas_[0] = 0;
+ for (size_t __i = 1; __i < __areas_.size(); ++__i)
+ __areas_[__i] += __areas_[__i-1];
+ for (size_t __i = 0; __i < __densities_.size(); ++__i)
+ __densities_[__i] /= _Sp;
+}
+
+template<class _RealType>
+piecewise_linear_distribution<_RealType>::param_type::param_type()
+ : __b_(2),
+ __densities_(2, 1.0),
+ __areas_(1, 0.0)
+{
+ __b_[1] = 1;
+}
+
+template<class _RealType>
+template<class _InputIteratorB, class _InputIteratorW>
+piecewise_linear_distribution<_RealType>::param_type::param_type(
+ _InputIteratorB __fB, _InputIteratorB __lB, _InputIteratorW __fW)
+ : __b_(__fB, __lB)
+{
+ if (__b_.size() < 2)
+ {
+ __b_.resize(2);
+ __b_[0] = 0;
+ __b_[1] = 1;
+ __densities_.assign(2, 1.0);
+ __areas_.assign(1, 0.0);
+ }
+ else
+ {
+ __densities_.reserve(__b_.size());
+ for (size_t __i = 0; __i < __b_.size(); ++__i, ++__fW)
+ __densities_.push_back(*__fW);
+ __init();
+ }
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template<class _RealType>
+template<class _UnaryOperation>
+piecewise_linear_distribution<_RealType>::param_type::param_type(
+ initializer_list<result_type> __bl, _UnaryOperation __fw)
+ : __b_(__bl.begin(), __bl.end())
+{
+ if (__b_.size() < 2)
+ {
+ __b_.resize(2);
+ __b_[0] = 0;
+ __b_[1] = 1;
+ __densities_.assign(2, 1.0);
+ __areas_.assign(1, 0.0);
+ }
+ else
+ {
+ __densities_.reserve(__b_.size());
+ for (size_t __i = 0; __i < __b_.size(); ++__i)
+ __densities_.push_back(__fw(__b_[__i]));
+ __init();
+ }
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template<class _RealType>
+template<class _UnaryOperation>
+piecewise_linear_distribution<_RealType>::param_type::param_type(
+ size_t __nw, result_type __xmin, result_type __xmax, _UnaryOperation __fw)
+ : __b_(__nw == 0 ? 2 : __nw + 1)
+{
+ size_t __n = __b_.size() - 1;
+ result_type __d = (__xmax - __xmin) / __n;
+ __densities_.reserve(__b_.size());
+ for (size_t __i = 0; __i < __n; ++__i)
+ {
+ __b_[__i] = __xmin + __i * __d;
+ __densities_.push_back(__fw(__b_[__i]));
+ }
+ __b_[__n] = __xmax;
+ __densities_.push_back(__fw(__b_[__n]));
+ __init();
+}
+
+template<class _RealType>
+template<class _URNG>
+_RealType
+piecewise_linear_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
+{
+ typedef uniform_real_distribution<result_type> _Gen;
+ result_type __u = _Gen()(__g);
+ ptrdiff_t __k = _VSTD::upper_bound(__p.__areas_.begin(), __p.__areas_.end(),
+ __u) - __p.__areas_.begin() - 1;
+ __u -= __p.__areas_[__k];
+ const result_type __dk = __p.__densities_[__k];
+ const result_type __dk1 = __p.__densities_[__k+1];
+ const result_type __deltad = __dk1 - __dk;
+ const result_type __bk = __p.__b_[__k];
+ if (__deltad == 0)
+ return __u / __dk + __bk;
+ const result_type __bk1 = __p.__b_[__k+1];
+ const result_type __deltab = __bk1 - __bk;
+ return (__bk * __dk1 - __bk1 * __dk +
+ _VSTD::sqrt(__deltab * (__deltab * __dk * __dk + 2 * __deltad * __u))) /
+ __deltad;
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const piecewise_linear_distribution<_RT>& __x)
+{
+ __save_flags<_CharT, _Traits> __lx(__os);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
+ _CharT __sp = __os.widen(' ');
+ __os.fill(__sp);
+ size_t __n = __x.__p_.__b_.size();
+ __os << __n;
+ for (size_t __i = 0; __i < __n; ++__i)
+ __os << __sp << __x.__p_.__b_[__i];
+ __n = __x.__p_.__densities_.size();
+ __os << __sp << __n;
+ for (size_t __i = 0; __i < __n; ++__i)
+ __os << __sp << __x.__p_.__densities_[__i];
+ __n = __x.__p_.__areas_.size();
+ __os << __sp << __n;
+ for (size_t __i = 0; __i < __n; ++__i)
+ __os << __sp << __x.__p_.__areas_[__i];
+ return __os;
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ piecewise_linear_distribution<_RT>& __x)
+{
+ typedef piecewise_linear_distribution<_RT> _Eng;
+ typedef typename _Eng::result_type result_type;
+ __save_flags<_CharT, _Traits> __lx(__is);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
+ size_t __n;
+ __is >> __n;
+ vector<result_type> __b(__n);
+ for (size_t __i = 0; __i < __n; ++__i)
+ __is >> __b[__i];
+ __is >> __n;
+ vector<result_type> __densities(__n);
+ for (size_t __i = 0; __i < __n; ++__i)
+ __is >> __densities[__i];
+ __is >> __n;
+ vector<result_type> __areas(__n);
+ for (size_t __i = 0; __i < __n; ++__i)
+ __is >> __areas[__i];
+ if (!__is.fail())
+ {
+ swap(__x.__p_.__b_, __b);
+ swap(__x.__p_.__densities_, __densities);
+ swap(__x.__p_.__areas_, __areas);
+ }
+ return __is;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANDOM_PIECEWISE_LINEAR_DISTRIBUTION_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/poisson_distribution.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/poisson_distribution.h
new file mode 100644
index 0000000000..c54d783b7c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/poisson_distribution.h
@@ -0,0 +1,277 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_POISSON_DISTRIBUTION_H
+#define _LIBCPP___RANDOM_POISSON_DISTRIBUTION_H
+
+#include <__config>
+#include <__random/clamp_to_integral.h>
+#include <__random/exponential_distribution.h>
+#include <__random/normal_distribution.h>
+#include <__random/uniform_real_distribution.h>
+#include <cmath>
+#include <iosfwd>
+#include <limits>
+
+#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 _IntType = int>
+class _LIBCPP_TEMPLATE_VIS poisson_distribution
+{
+public:
+ // types
+ typedef _IntType result_type;
+
+ class _LIBCPP_TEMPLATE_VIS param_type
+ {
+ double __mean_;
+ double __s_;
+ double __d_;
+ double __l_;
+ double __omega_;
+ double __c0_;
+ double __c1_;
+ double __c2_;
+ double __c3_;
+ double __c_;
+
+ public:
+ typedef poisson_distribution distribution_type;
+
+ explicit param_type(double __mean = 1.0);
+
+ _LIBCPP_INLINE_VISIBILITY
+ double mean() const {return __mean_;}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const param_type& __x, const param_type& __y)
+ {return __x.__mean_ == __y.__mean_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const param_type& __x, const param_type& __y)
+ {return !(__x == __y);}
+
+ friend class poisson_distribution;
+ };
+
+private:
+ param_type __p_;
+
+public:
+ // constructors and reset functions
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ poisson_distribution() : poisson_distribution(1.0) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit poisson_distribution(double __mean)
+ : __p_(__mean) {}
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit poisson_distribution(double __mean = 1.0)
+ : __p_(__mean) {}
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ explicit poisson_distribution(const param_type& __p) : __p_(__p) {}
+ _LIBCPP_INLINE_VISIBILITY
+ void reset() {}
+
+ // generating functions
+ template<class _URNG>
+ _LIBCPP_INLINE_VISIBILITY
+ result_type operator()(_URNG& __g)
+ {return (*this)(__g, __p_);}
+ template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+
+ // property functions
+ _LIBCPP_INLINE_VISIBILITY
+ double mean() const {return __p_.mean();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ param_type param() const {return __p_;}
+ _LIBCPP_INLINE_VISIBILITY
+ void param(const param_type& __p) {__p_ = __p;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type min() const {return 0;}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type max() const {return numeric_limits<result_type>::max();}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const poisson_distribution& __x,
+ const poisson_distribution& __y)
+ {return __x.__p_ == __y.__p_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const poisson_distribution& __x,
+ const poisson_distribution& __y)
+ {return !(__x == __y);}
+};
+
+template<class _IntType>
+poisson_distribution<_IntType>::param_type::param_type(double __mean)
+ // According to the standard `inf` is a valid input, but it causes the
+ // distribution to hang, so we replace it with the maximum representable
+ // mean.
+ : __mean_(isinf(__mean) ? numeric_limits<double>::max() : __mean)
+{
+ if (__mean_ < 10)
+ {
+ __s_ = 0;
+ __d_ = 0;
+ __l_ = _VSTD::exp(-__mean_);
+ __omega_ = 0;
+ __c3_ = 0;
+ __c2_ = 0;
+ __c1_ = 0;
+ __c0_ = 0;
+ __c_ = 0;
+ }
+ else
+ {
+ __s_ = _VSTD::sqrt(__mean_);
+ __d_ = 6 * __mean_ * __mean_;
+ __l_ = _VSTD::trunc(__mean_ - 1.1484);
+ __omega_ = .3989423 / __s_;
+ double __b1_ = .4166667E-1 / __mean_;
+ double __b2_ = .3 * __b1_ * __b1_;
+ __c3_ = .1428571 * __b1_ * __b2_;
+ __c2_ = __b2_ - 15. * __c3_;
+ __c1_ = __b1_ - 6. * __b2_ + 45. * __c3_;
+ __c0_ = 1. - __b1_ + 3. * __b2_ - 15. * __c3_;
+ __c_ = .1069 / __mean_;
+ }
+}
+
+template <class _IntType>
+template<class _URNG>
+_IntType
+poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr)
+{
+ double __tx;
+ uniform_real_distribution<double> __urd;
+ if (__pr.__mean_ < 10)
+ {
+ __tx = 0;
+ for (double __p = __urd(__urng); __p > __pr.__l_; ++__tx)
+ __p *= __urd(__urng);
+ }
+ else
+ {
+ double __difmuk;
+ double __g = __pr.__mean_ + __pr.__s_ * normal_distribution<double>()(__urng);
+ double __u;
+ if (__g > 0)
+ {
+ __tx = _VSTD::trunc(__g);
+ if (__tx >= __pr.__l_)
+ return _VSTD::__clamp_to_integral<result_type>(__tx);
+ __difmuk = __pr.__mean_ - __tx;
+ __u = __urd(__urng);
+ if (__pr.__d_ * __u >= __difmuk * __difmuk * __difmuk)
+ return _VSTD::__clamp_to_integral<result_type>(__tx);
+ }
+ exponential_distribution<double> __edist;
+ for (bool __using_exp_dist = false; true; __using_exp_dist = true)
+ {
+ double __e;
+ if (__using_exp_dist || __g <= 0)
+ {
+ double __t;
+ do
+ {
+ __e = __edist(__urng);
+ __u = __urd(__urng);
+ __u += __u - 1;
+ __t = 1.8 + (__u < 0 ? -__e : __e);
+ } while (__t <= -.6744);
+ __tx = _VSTD::trunc(__pr.__mean_ + __pr.__s_ * __t);
+ __difmuk = __pr.__mean_ - __tx;
+ __using_exp_dist = true;
+ }
+ double __px;
+ double __py;
+ if (__tx < 10 && __tx >= 0)
+ {
+ const double __fac[] = {1, 1, 2, 6, 24, 120, 720, 5040,
+ 40320, 362880};
+ __px = -__pr.__mean_;
+ __py = _VSTD::pow(__pr.__mean_, (double)__tx) / __fac[static_cast<int>(__tx)];
+ }
+ else
+ {
+ double __del = .8333333E-1 / __tx;
+ __del -= 4.8 * __del * __del * __del;
+ double __v = __difmuk / __tx;
+ if (_VSTD::abs(__v) > 0.25)
+ __px = __tx * _VSTD::log(1 + __v) - __difmuk - __del;
+ else
+ __px = __tx * __v * __v * (((((((.1250060 * __v + -.1384794) *
+ __v + .1421878) * __v + -.1661269) * __v + .2000118) *
+ __v + -.2500068) * __v + .3333333) * __v + -.5) - __del;
+ __py = .3989423 / _VSTD::sqrt(__tx);
+ }
+ double __r = (0.5 - __difmuk) / __pr.__s_;
+ double __r2 = __r * __r;
+ double __fx = -0.5 * __r2;
+ double __fy = __pr.__omega_ * (((__pr.__c3_ * __r2 + __pr.__c2_) *
+ __r2 + __pr.__c1_) * __r2 + __pr.__c0_);
+ if (__using_exp_dist)
+ {
+ if (__pr.__c_ * _VSTD::abs(__u) <= __py * _VSTD::exp(__px + __e) -
+ __fy * _VSTD::exp(__fx + __e))
+ break;
+ }
+ else
+ {
+ if (__fy - __u * __fy <= __py * _VSTD::exp(__px - __fx))
+ break;
+ }
+ }
+ }
+ return _VSTD::__clamp_to_integral<result_type>(__tx);
+}
+
+template <class _CharT, class _Traits, class _IntType>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const poisson_distribution<_IntType>& __x)
+{
+ __save_flags<_CharT, _Traits> __lx(__os);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
+ return __os << __x.mean();
+}
+
+template <class _CharT, class _Traits, class _IntType>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ poisson_distribution<_IntType>& __x)
+{
+ typedef poisson_distribution<_IntType> _Eng;
+ 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);
+ double __mean;
+ __is >> __mean;
+ if (!__is.fail())
+ __x.param(param_type(__mean));
+ return __is;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANDOM_POISSON_DISTRIBUTION_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/random_device.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/random_device.h
new file mode 100644
index 0000000000..e82b437a3b
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/random_device.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___RANDOM_RANDOM_DEVICE_H
+#define _LIBCPP___RANDOM_RANDOM_DEVICE_H
+
+#include <__config>
+#include <string>
+
+#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_RANDOM_DEVICE)
+
+class _LIBCPP_TYPE_VIS random_device
+{
+#ifdef _LIBCPP_USING_DEV_RANDOM
+ int __f_;
+#elif !defined(_LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT)
+ _LIBCPP_DIAGNOSTIC_PUSH
+ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wunused-private-field")
+
+ // Apple platforms used to use the `_LIBCPP_USING_DEV_RANDOM` code path, and now
+ // use `arc4random()` as of this comment. In order to avoid breaking the ABI, we
+ // retain the same layout as before.
+# if defined(__APPLE__)
+ int __padding_; // padding to fake the `__f_` field above
+# endif
+
+ // ... vendors can add workarounds here if they switch to a different representation ...
+
+ _LIBCPP_DIAGNOSTIC_POP
+#endif
+
+public:
+ // types
+ typedef unsigned result_type;
+
+ // generator characteristics
+ static _LIBCPP_CONSTEXPR const result_type _Min = 0;
+ static _LIBCPP_CONSTEXPR const result_type _Max = 0xFFFFFFFFu;
+
+ _LIBCPP_INLINE_VISIBILITY
+ static _LIBCPP_CONSTEXPR result_type min() { return _Min;}
+ _LIBCPP_INLINE_VISIBILITY
+ static _LIBCPP_CONSTEXPR result_type max() { return _Max;}
+
+ // constructors
+#ifndef _LIBCPP_CXX03_LANG
+ random_device() : random_device("/dev/urandom") {}
+ explicit random_device(const string& __token);
+#else
+ explicit random_device(const string& __token = "/dev/urandom");
+#endif
+ ~random_device();
+
+ // generating functions
+ result_type operator()();
+
+ // property functions
+ double entropy() const _NOEXCEPT;
+
+ random_device(const random_device&) = delete;
+ void operator=(const random_device&) = delete;
+};
+
+#endif // !_LIBCPP_HAS_NO_RANDOM_DEVICE
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANDOM_RANDOM_DEVICE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/ranlux.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/ranlux.h
new file mode 100644
index 0000000000..e44cece39d
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/ranlux.h
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_RANLUX_H
+#define _LIBCPP___RANDOM_RANLUX_H
+
+#include <__config>
+#include <__random/discard_block_engine.h>
+#include <__random/subtract_with_carry_engine.h>
+#include <cstdint>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+typedef subtract_with_carry_engine<uint_fast32_t, 24, 10, 24> ranlux24_base;
+typedef subtract_with_carry_engine<uint_fast64_t, 48, 5, 12> ranlux48_base;
+
+typedef discard_block_engine<ranlux24_base, 223, 23> ranlux24;
+typedef discard_block_engine<ranlux48_base, 389, 11> ranlux48;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANDOM_RANLUX_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/seed_seq.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/seed_seq.h
new file mode 100644
index 0000000000..8640cd1b4e
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/seed_seq.h
@@ -0,0 +1,153 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_SEED_SEQ_H
+#define _LIBCPP___RANDOM_SEED_SEQ_H
+
+#include <__algorithm/copy.h>
+#include <__algorithm/fill.h>
+#include <__algorithm/max.h>
+#include <__config>
+#include <initializer_list>
+#include <vector>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+class _LIBCPP_TEMPLATE_VIS seed_seq
+{
+public:
+ // types
+ typedef uint32_t result_type;
+
+ // constructors
+ _LIBCPP_INLINE_VISIBILITY
+ seed_seq() _NOEXCEPT {}
+#ifndef _LIBCPP_CXX03_LANG
+ template<class _Tp, __enable_if_t<is_integral<_Tp>::value>* = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ seed_seq(initializer_list<_Tp> __il) {
+ __init(__il.begin(), __il.end());
+ }
+#endif // _LIBCPP_CXX03_LANG
+
+ template<class _InputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ seed_seq(_InputIterator __first, _InputIterator __last) {
+ static_assert(is_integral<typename iterator_traits<_InputIterator>::value_type>::value,
+ "Mandates: iterator_traits<InputIterator>::value_type is an integer type");
+ __init(__first, __last);
+ }
+
+ // generating functions
+ template<class _RandomAccessIterator>
+ void generate(_RandomAccessIterator __first, _RandomAccessIterator __last);
+
+ // property functions
+ _LIBCPP_INLINE_VISIBILITY
+ size_t size() const _NOEXCEPT {return __v_.size();}
+ template<class _OutputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ void param(_OutputIterator __dest) const
+ {_VSTD::copy(__v_.begin(), __v_.end(), __dest);}
+
+ seed_seq(const seed_seq&) = delete;
+ void operator=(const seed_seq&) = delete;
+
+ _LIBCPP_INLINE_VISIBILITY
+ static result_type _Tp(result_type __x) {return __x ^ (__x >> 27);}
+
+private:
+ template<class _InputIterator>
+ void __init(_InputIterator __first, _InputIterator __last);
+
+ vector<result_type> __v_;
+};
+
+template<class _InputIterator>
+void
+seed_seq::__init(_InputIterator __first, _InputIterator __last)
+{
+ for (_InputIterator __s = __first; __s != __last; ++__s)
+ __v_.push_back(*__s & 0xFFFFFFFF);
+}
+
+template<class _RandomAccessIterator>
+void
+seed_seq::generate(_RandomAccessIterator __first, _RandomAccessIterator __last)
+{
+ if (__first != __last)
+ {
+ _VSTD::fill(__first, __last, 0x8b8b8b8b);
+ const size_t __n = static_cast<size_t>(__last - __first);
+ const size_t __s = __v_.size();
+ const size_t __t = (__n >= 623) ? 11
+ : (__n >= 68) ? 7
+ : (__n >= 39) ? 5
+ : (__n >= 7) ? 3
+ : (__n - 1) / 2;
+ const size_t __p = (__n - __t) / 2;
+ const size_t __q = __p + __t;
+ const size_t __m = _VSTD::max(__s + 1, __n);
+ // __k = 0;
+ {
+ result_type __r = 1664525 * _Tp(__first[0] ^ __first[__p]
+ ^ __first[__n - 1]);
+ __first[__p] += __r;
+ __r += __s;
+ __first[__q] += __r;
+ __first[0] = __r;
+ }
+ for (size_t __k = 1; __k <= __s; ++__k)
+ {
+ const size_t __kmodn = __k % __n;
+ const size_t __kpmodn = (__k + __p) % __n;
+ result_type __r = 1664525 * _Tp(__first[__kmodn] ^ __first[__kpmodn]
+ ^ __first[(__k - 1) % __n]);
+ __first[__kpmodn] += __r;
+ __r += __kmodn + __v_[__k-1];
+ __first[(__k + __q) % __n] += __r;
+ __first[__kmodn] = __r;
+ }
+ for (size_t __k = __s + 1; __k < __m; ++__k)
+ {
+ const size_t __kmodn = __k % __n;
+ const size_t __kpmodn = (__k + __p) % __n;
+ result_type __r = 1664525 * _Tp(__first[__kmodn] ^ __first[__kpmodn]
+ ^ __first[(__k - 1) % __n]);
+ __first[__kpmodn] += __r;
+ __r += __kmodn;
+ __first[(__k + __q) % __n] += __r;
+ __first[__kmodn] = __r;
+ }
+ for (size_t __k = __m; __k < __m + __n; ++__k)
+ {
+ const size_t __kmodn = __k % __n;
+ const size_t __kpmodn = (__k + __p) % __n;
+ result_type __r = 1566083941 * _Tp(__first[__kmodn] +
+ __first[__kpmodn] +
+ __first[(__k - 1) % __n]);
+ __first[__kpmodn] ^= __r;
+ __r -= __kmodn;
+ __first[(__k + __q) % __n] ^= __r;
+ __first[__kmodn] = __r;
+ }
+ }
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANDOM_SEED_SEQ_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/shuffle_order_engine.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/shuffle_order_engine.h
new file mode 100644
index 0000000000..c2f76f609a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/shuffle_order_engine.h
@@ -0,0 +1,283 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_SHUFFLE_ORDER_ENGINE_H
+#define _LIBCPP___RANDOM_SHUFFLE_ORDER_ENGINE_H
+
+#include <__algorithm/equal.h>
+#include <__config>
+#include <__random/is_seed_sequence.h>
+#include <__utility/move.h>
+#include <cstdint>
+#include <iosfwd>
+#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 <uint64_t _Xp, uint64_t _Yp>
+struct __ugcd
+{
+ static _LIBCPP_CONSTEXPR const uint64_t value = __ugcd<_Yp, _Xp % _Yp>::value;
+};
+
+template <uint64_t _Xp>
+struct __ugcd<_Xp, 0>
+{
+ static _LIBCPP_CONSTEXPR const uint64_t value = _Xp;
+};
+
+template <uint64_t _Np, uint64_t _Dp>
+class __uratio
+{
+ static_assert(_Dp != 0, "__uratio divide by 0");
+ static _LIBCPP_CONSTEXPR const uint64_t __gcd = __ugcd<_Np, _Dp>::value;
+public:
+ static _LIBCPP_CONSTEXPR const uint64_t num = _Np / __gcd;
+ static _LIBCPP_CONSTEXPR const uint64_t den = _Dp / __gcd;
+
+ typedef __uratio<num, den> type;
+};
+
+template<class _Engine, size_t __k>
+class _LIBCPP_TEMPLATE_VIS shuffle_order_engine
+{
+ static_assert(0 < __k, "shuffle_order_engine invalid parameters");
+public:
+ // types
+ typedef typename _Engine::result_type result_type;
+
+private:
+ _Engine __e_;
+ result_type _V_[__k];
+ result_type _Y_;
+
+public:
+ // engine characteristics
+ static _LIBCPP_CONSTEXPR const size_t table_size = __k;
+
+#ifdef _LIBCPP_CXX03_LANG
+ static const result_type _Min = _Engine::_Min;
+ static const result_type _Max = _Engine::_Max;
+#else
+ static _LIBCPP_CONSTEXPR const result_type _Min = _Engine::min();
+ static _LIBCPP_CONSTEXPR const result_type _Max = _Engine::max();
+#endif
+ static_assert(_Min < _Max, "shuffle_order_engine invalid parameters");
+ _LIBCPP_INLINE_VISIBILITY
+ static _LIBCPP_CONSTEXPR result_type min() { return _Min; }
+ _LIBCPP_INLINE_VISIBILITY
+ static _LIBCPP_CONSTEXPR result_type max() { return _Max; }
+
+ static _LIBCPP_CONSTEXPR const unsigned long long _Rp = _Max - _Min + 1ull;
+
+ // constructors and seeding functions
+ _LIBCPP_INLINE_VISIBILITY
+ shuffle_order_engine() {__init();}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit shuffle_order_engine(const _Engine& __e)
+ : __e_(__e) {__init();}
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ explicit shuffle_order_engine(_Engine&& __e)
+ : __e_(_VSTD::move(__e)) {__init();}
+#endif // _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ explicit shuffle_order_engine(result_type __sd) : __e_(__sd) {__init();}
+ template<class _Sseq>
+ _LIBCPP_INLINE_VISIBILITY
+ explicit shuffle_order_engine(_Sseq& __q,
+ typename enable_if<__is_seed_sequence<_Sseq, shuffle_order_engine>::value &&
+ !is_convertible<_Sseq, _Engine>::value>::type* = 0)
+ : __e_(__q) {__init();}
+ _LIBCPP_INLINE_VISIBILITY
+ void seed() {__e_.seed(); __init();}
+ _LIBCPP_INLINE_VISIBILITY
+ void seed(result_type __sd) {__e_.seed(__sd); __init();}
+ template<class _Sseq>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if
+ <
+ __is_seed_sequence<_Sseq, shuffle_order_engine>::value,
+ void
+ >::type
+ seed(_Sseq& __q) {__e_.seed(__q); __init();}
+
+ // generating functions
+ _LIBCPP_INLINE_VISIBILITY
+ result_type operator()() {return __eval(integral_constant<bool, _Rp != 0>());}
+ _LIBCPP_INLINE_VISIBILITY
+ void discard(unsigned long long __z) {for (; __z; --__z) operator()();}
+
+ // property functions
+ _LIBCPP_INLINE_VISIBILITY
+ const _Engine& base() const _NOEXCEPT {return __e_;}
+
+private:
+ template<class _Eng, size_t _Kp>
+ friend
+ bool
+ operator==(
+ const shuffle_order_engine<_Eng, _Kp>& __x,
+ const shuffle_order_engine<_Eng, _Kp>& __y);
+
+ template<class _Eng, size_t _Kp>
+ friend
+ bool
+ operator!=(
+ const shuffle_order_engine<_Eng, _Kp>& __x,
+ const shuffle_order_engine<_Eng, _Kp>& __y);
+
+ template <class _CharT, class _Traits,
+ class _Eng, size_t _Kp>
+ friend
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const shuffle_order_engine<_Eng, _Kp>& __x);
+
+ template <class _CharT, class _Traits,
+ class _Eng, size_t _Kp>
+ friend
+ basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is,
+ shuffle_order_engine<_Eng, _Kp>& __x);
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __init()
+ {
+ for (size_t __i = 0; __i < __k; ++__i)
+ _V_[__i] = __e_();
+ _Y_ = __e_();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type __eval(false_type) {return __eval2(integral_constant<bool, __k & 1>());}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type __eval(true_type) {return __eval(__uratio<__k, _Rp>());}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type __eval2(false_type) {return __eval(__uratio<__k/2, 0x8000000000000000ull>());}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type __eval2(true_type) {return __evalf<__k, 0>();}
+
+ template <uint64_t _Np, uint64_t _Dp>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if
+ <
+ (__uratio<_Np, _Dp>::num > 0xFFFFFFFFFFFFFFFFull / (_Max - _Min)),
+ result_type
+ >::type
+ __eval(__uratio<_Np, _Dp>)
+ {return __evalf<__uratio<_Np, _Dp>::num, __uratio<_Np, _Dp>::den>();}
+
+ template <uint64_t _Np, uint64_t _Dp>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if
+ <
+ __uratio<_Np, _Dp>::num <= 0xFFFFFFFFFFFFFFFFull / (_Max - _Min),
+ result_type
+ >::type
+ __eval(__uratio<_Np, _Dp>)
+ {
+ const size_t __j = static_cast<size_t>(__uratio<_Np, _Dp>::num * (_Y_ - _Min)
+ / __uratio<_Np, _Dp>::den);
+ _Y_ = _V_[__j];
+ _V_[__j] = __e_();
+ return _Y_;
+ }
+
+ template <uint64_t __n, uint64_t __d>
+ _LIBCPP_INLINE_VISIBILITY
+ result_type __evalf()
+ {
+ const double _Fp = __d == 0 ?
+ __n / (2. * 0x8000000000000000ull) :
+ __n / (double)__d;
+ const size_t __j = static_cast<size_t>(_Fp * (_Y_ - _Min));
+ _Y_ = _V_[__j];
+ _V_[__j] = __e_();
+ return _Y_;
+ }
+};
+
+template<class _Engine, size_t __k>
+ _LIBCPP_CONSTEXPR const size_t shuffle_order_engine<_Engine, __k>::table_size;
+
+template<class _Eng, size_t _Kp>
+bool
+operator==(
+ const shuffle_order_engine<_Eng, _Kp>& __x,
+ const shuffle_order_engine<_Eng, _Kp>& __y)
+{
+ return __x._Y_ == __y._Y_ && _VSTD::equal(__x._V_, __x._V_ + _Kp, __y._V_) &&
+ __x.__e_ == __y.__e_;
+}
+
+template<class _Eng, size_t _Kp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(
+ const shuffle_order_engine<_Eng, _Kp>& __x,
+ const shuffle_order_engine<_Eng, _Kp>& __y)
+{
+ return !(__x == __y);
+}
+
+template <class _CharT, class _Traits,
+ class _Eng, size_t _Kp>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const shuffle_order_engine<_Eng, _Kp>& __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);
+ __os << __x.__e_ << __sp << __x._V_[0];
+ for (size_t __i = 1; __i < _Kp; ++__i)
+ __os << __sp << __x._V_[__i];
+ return __os << __sp << __x._Y_;
+}
+
+template <class _CharT, class _Traits,
+ class _Eng, size_t _Kp>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ shuffle_order_engine<_Eng, _Kp>& __x)
+{
+ typedef typename shuffle_order_engine<_Eng, _Kp>::result_type result_type;
+ __save_flags<_CharT, _Traits> __lx(__is);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
+ _Eng __e;
+ result_type _Vp[_Kp+1];
+ __is >> __e;
+ for (size_t __i = 0; __i < _Kp+1; ++__i)
+ __is >> _Vp[__i];
+ if (!__is.fail())
+ {
+ __x.__e_ = __e;
+ for (size_t __i = 0; __i < _Kp; ++__i)
+ __x._V_[__i] = _Vp[__i];
+ __x._Y_ = _Vp[_Kp];
+ }
+ return __is;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANDOM_SHUFFLE_ORDER_ENGINE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/student_t_distribution.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/student_t_distribution.h
new file mode 100644
index 0000000000..dc38a8b3d2
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/student_t_distribution.h
@@ -0,0 +1,153 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_STUDENT_T_DISTRIBUTION_H
+#define _LIBCPP___RANDOM_STUDENT_T_DISTRIBUTION_H
+
+#include <__config>
+#include <__random/gamma_distribution.h>
+#include <__random/normal_distribution.h>
+#include <cmath>
+#include <iosfwd>
+#include <limits>
+
+#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 _RealType = double>
+class _LIBCPP_TEMPLATE_VIS student_t_distribution
+{
+public:
+ // types
+ typedef _RealType result_type;
+
+ class _LIBCPP_TEMPLATE_VIS param_type
+ {
+ result_type __n_;
+ public:
+ typedef student_t_distribution distribution_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit param_type(result_type __n = 1) : __n_(__n) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type n() const {return __n_;}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const param_type& __x, const param_type& __y)
+ {return __x.__n_ == __y.__n_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const param_type& __x, const param_type& __y)
+ {return !(__x == __y);}
+ };
+
+private:
+ param_type __p_;
+ normal_distribution<result_type> __nd_;
+
+public:
+ // constructor and reset functions
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ student_t_distribution() : student_t_distribution(1) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit student_t_distribution(result_type __n)
+ : __p_(param_type(__n)) {}
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit student_t_distribution(result_type __n = 1)
+ : __p_(param_type(__n)) {}
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ explicit student_t_distribution(const param_type& __p)
+ : __p_(__p) {}
+ _LIBCPP_INLINE_VISIBILITY
+ void reset() {__nd_.reset();}
+
+ // generating functions
+ template<class _URNG>
+ _LIBCPP_INLINE_VISIBILITY
+ result_type operator()(_URNG& __g)
+ {return (*this)(__g, __p_);}
+ template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+
+ // property functions
+ _LIBCPP_INLINE_VISIBILITY
+ result_type n() const {return __p_.n();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ param_type param() const {return __p_;}
+ _LIBCPP_INLINE_VISIBILITY
+ void param(const param_type& __p) {__p_ = __p;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type min() const {return -numeric_limits<result_type>::infinity();}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type max() const {return numeric_limits<result_type>::infinity();}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const student_t_distribution& __x,
+ const student_t_distribution& __y)
+ {return __x.__p_ == __y.__p_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const student_t_distribution& __x,
+ const student_t_distribution& __y)
+ {return !(__x == __y);}
+};
+
+template <class _RealType>
+template<class _URNG>
+_RealType
+student_t_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
+{
+ gamma_distribution<result_type> __gd(__p.n() * .5, 2);
+ return __nd_(__g) * _VSTD::sqrt(__p.n()/__gd(__g));
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const student_t_distribution<_RT>& __x)
+{
+ __save_flags<_CharT, _Traits> __lx(__os);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
+ __os << __x.n();
+ return __os;
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ student_t_distribution<_RT>& __x)
+{
+ typedef student_t_distribution<_RT> _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 __n;
+ __is >> __n;
+ if (!__is.fail())
+ __x.param(param_type(__n));
+ return __is;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANDOM_STUDENT_T_DISTRIBUTION_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/subtract_with_carry_engine.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/subtract_with_carry_engine.h
new file mode 100644
index 0000000000..fdbe2d2e9b
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/subtract_with_carry_engine.h
@@ -0,0 +1,352 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_SUBTRACT_WITH_CARRY_ENGINE_H
+#define _LIBCPP___RANDOM_SUBTRACT_WITH_CARRY_ENGINE_H
+
+#include <__algorithm/equal.h>
+#include <__algorithm/min.h>
+#include <__config>
+#include <__random/is_seed_sequence.h>
+#include <__random/linear_congruential_engine.h>
+#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
+
+template<class _UIntType, size_t __w, size_t __s, size_t __r>
+class _LIBCPP_TEMPLATE_VIS subtract_with_carry_engine;
+
+template<class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>
+bool
+operator==(
+ const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x,
+ const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y);
+
+template<class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>
+_LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(
+ const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x,
+ const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y);
+
+template <class _CharT, class _Traits,
+ class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x);
+
+template <class _CharT, class _Traits,
+ class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x);
+
+template<class _UIntType, size_t __w, size_t __s, size_t __r>
+class _LIBCPP_TEMPLATE_VIS subtract_with_carry_engine
+{
+public:
+ // types
+ typedef _UIntType result_type;
+
+private:
+ result_type __x_[__r];
+ result_type __c_;
+ size_t __i_;
+
+ static _LIBCPP_CONSTEXPR const result_type _Dt = numeric_limits<result_type>::digits;
+ static_assert( 0 < __w, "subtract_with_carry_engine invalid parameters");
+ static_assert(__w <= _Dt, "subtract_with_carry_engine invalid parameters");
+ static_assert( 0 < __s, "subtract_with_carry_engine invalid parameters");
+ static_assert(__s < __r, "subtract_with_carry_engine invalid parameters");
+public:
+ static _LIBCPP_CONSTEXPR const result_type _Min = 0;
+ static _LIBCPP_CONSTEXPR const result_type _Max = __w == _Dt ? result_type(~0) :
+ (result_type(1) << __w) - result_type(1);
+ static_assert(_Min < _Max, "subtract_with_carry_engine invalid parameters");
+
+ // engine characteristics
+ static _LIBCPP_CONSTEXPR const size_t word_size = __w;
+ static _LIBCPP_CONSTEXPR const size_t short_lag = __s;
+ static _LIBCPP_CONSTEXPR const size_t long_lag = __r;
+ _LIBCPP_INLINE_VISIBILITY
+ static _LIBCPP_CONSTEXPR result_type min() { return _Min; }
+ _LIBCPP_INLINE_VISIBILITY
+ static _LIBCPP_CONSTEXPR result_type max() { return _Max; }
+ static _LIBCPP_CONSTEXPR const result_type default_seed = 19780503u;
+
+ // constructors and seeding functions
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ subtract_with_carry_engine() : subtract_with_carry_engine(default_seed) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit subtract_with_carry_engine(result_type __sd) { seed(__sd); }
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit subtract_with_carry_engine(result_type __sd = default_seed) {
+ seed(__sd);
+ }
+#endif
+ template<class _Sseq>
+ _LIBCPP_INLINE_VISIBILITY
+ explicit subtract_with_carry_engine(_Sseq& __q,
+ typename enable_if<__is_seed_sequence<_Sseq, subtract_with_carry_engine>::value>::type* = 0)
+ {seed(__q);}
+ _LIBCPP_INLINE_VISIBILITY
+ void seed(result_type __sd = default_seed)
+ {seed(__sd, integral_constant<unsigned, 1 + (__w - 1) / 32>());}
+ template<class _Sseq>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if
+ <
+ __is_seed_sequence<_Sseq, subtract_with_carry_engine>::value,
+ void
+ >::type
+ seed(_Sseq& __q)
+ {__seed(__q, integral_constant<unsigned, 1 + (__w - 1) / 32>());}
+
+ // generating functions
+ result_type operator()();
+ _LIBCPP_INLINE_VISIBILITY
+ void discard(unsigned long long __z) {for (; __z; --__z) operator()();}
+
+ template<class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>
+ friend
+ bool
+ operator==(
+ const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x,
+ const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y);
+
+ template<class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>
+ friend
+ bool
+ operator!=(
+ const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x,
+ const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y);
+
+ template <class _CharT, class _Traits,
+ class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>
+ friend
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x);
+
+ template <class _CharT, class _Traits,
+ class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>
+ friend
+ basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is,
+ subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x);
+
+private:
+
+ void seed(result_type __sd, integral_constant<unsigned, 1>);
+ void seed(result_type __sd, integral_constant<unsigned, 2>);
+ template<class _Sseq>
+ void __seed(_Sseq& __q, integral_constant<unsigned, 1>);
+ template<class _Sseq>
+ void __seed(_Sseq& __q, integral_constant<unsigned, 2>);
+};
+
+template<class _UIntType, size_t __w, size_t __s, size_t __r>
+ _LIBCPP_CONSTEXPR const size_t subtract_with_carry_engine<_UIntType, __w, __s, __r>::word_size;
+
+template<class _UIntType, size_t __w, size_t __s, size_t __r>
+ _LIBCPP_CONSTEXPR const size_t subtract_with_carry_engine<_UIntType, __w, __s, __r>::short_lag;
+
+template<class _UIntType, size_t __w, size_t __s, size_t __r>
+ _LIBCPP_CONSTEXPR const size_t subtract_with_carry_engine<_UIntType, __w, __s, __r>::long_lag;
+
+template<class _UIntType, size_t __w, size_t __s, size_t __r>
+ _LIBCPP_CONSTEXPR const typename subtract_with_carry_engine<_UIntType, __w, __s, __r>::result_type
+ subtract_with_carry_engine<_UIntType, __w, __s, __r>::default_seed;
+
+template<class _UIntType, size_t __w, size_t __s, size_t __r>
+void
+subtract_with_carry_engine<_UIntType, __w, __s, __r>::seed(result_type __sd,
+ integral_constant<unsigned, 1>)
+{
+ linear_congruential_engine<result_type, 40014u, 0u, 2147483563u>
+ __e(__sd == 0u ? default_seed : __sd);
+ for (size_t __i = 0; __i < __r; ++__i)
+ __x_[__i] = static_cast<result_type>(__e() & _Max);
+ __c_ = __x_[__r-1] == 0;
+ __i_ = 0;
+}
+
+template<class _UIntType, size_t __w, size_t __s, size_t __r>
+void
+subtract_with_carry_engine<_UIntType, __w, __s, __r>::seed(result_type __sd,
+ integral_constant<unsigned, 2>)
+{
+ linear_congruential_engine<result_type, 40014u, 0u, 2147483563u>
+ __e(__sd == 0u ? default_seed : __sd);
+ for (size_t __i = 0; __i < __r; ++__i)
+ {
+ result_type __e0 = __e();
+ __x_[__i] = static_cast<result_type>(
+ (__e0 + ((uint64_t)__e() << 32)) & _Max);
+ }
+ __c_ = __x_[__r-1] == 0;
+ __i_ = 0;
+}
+
+template<class _UIntType, size_t __w, size_t __s, size_t __r>
+template<class _Sseq>
+void
+subtract_with_carry_engine<_UIntType, __w, __s, __r>::__seed(_Sseq& __q,
+ integral_constant<unsigned, 1>)
+{
+ const unsigned __k = 1;
+ uint32_t __ar[__r * __k];
+ __q.generate(__ar, __ar + __r * __k);
+ for (size_t __i = 0; __i < __r; ++__i)
+ __x_[__i] = static_cast<result_type>(__ar[__i] & _Max);
+ __c_ = __x_[__r-1] == 0;
+ __i_ = 0;
+}
+
+template<class _UIntType, size_t __w, size_t __s, size_t __r>
+template<class _Sseq>
+void
+subtract_with_carry_engine<_UIntType, __w, __s, __r>::__seed(_Sseq& __q,
+ integral_constant<unsigned, 2>)
+{
+ const unsigned __k = 2;
+ uint32_t __ar[__r * __k];
+ __q.generate(__ar, __ar + __r * __k);
+ for (size_t __i = 0; __i < __r; ++__i)
+ __x_[__i] = static_cast<result_type>(
+ (__ar[2 * __i] + ((uint64_t)__ar[2 * __i + 1] << 32)) & _Max);
+ __c_ = __x_[__r-1] == 0;
+ __i_ = 0;
+}
+
+template<class _UIntType, size_t __w, size_t __s, size_t __r>
+_UIntType
+subtract_with_carry_engine<_UIntType, __w, __s, __r>::operator()()
+{
+ const result_type& __xs = __x_[(__i_ + (__r - __s)) % __r];
+ result_type& __xr = __x_[__i_];
+ result_type __new_c = __c_ == 0 ? __xs < __xr : __xs != 0 ? __xs <= __xr : 1;
+ __xr = (__xs - __xr - __c_) & _Max;
+ __c_ = __new_c;
+ __i_ = (__i_ + 1) % __r;
+ return __xr;
+}
+
+template<class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>
+bool
+operator==(
+ const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x,
+ const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y)
+{
+ if (__x.__c_ != __y.__c_)
+ return false;
+ if (__x.__i_ == __y.__i_)
+ return _VSTD::equal(__x.__x_, __x.__x_ + _Rp, __y.__x_);
+ if (__x.__i_ == 0 || __y.__i_ == 0)
+ {
+ size_t __j = _VSTD::min(_Rp - __x.__i_, _Rp - __y.__i_);
+ if (!_VSTD::equal(__x.__x_ + __x.__i_, __x.__x_ + __x.__i_ + __j,
+ __y.__x_ + __y.__i_))
+ return false;
+ if (__x.__i_ == 0)
+ return _VSTD::equal(__x.__x_ + __j, __x.__x_ + _Rp, __y.__x_);
+ return _VSTD::equal(__x.__x_, __x.__x_ + (_Rp - __j), __y.__x_ + __j);
+ }
+ if (__x.__i_ < __y.__i_)
+ {
+ size_t __j = _Rp - __y.__i_;
+ if (!_VSTD::equal(__x.__x_ + __x.__i_, __x.__x_ + (__x.__i_ + __j),
+ __y.__x_ + __y.__i_))
+ return false;
+ if (!_VSTD::equal(__x.__x_ + (__x.__i_ + __j), __x.__x_ + _Rp,
+ __y.__x_))
+ return false;
+ return _VSTD::equal(__x.__x_, __x.__x_ + __x.__i_,
+ __y.__x_ + (_Rp - (__x.__i_ + __j)));
+ }
+ size_t __j = _Rp - __x.__i_;
+ if (!_VSTD::equal(__y.__x_ + __y.__i_, __y.__x_ + (__y.__i_ + __j),
+ __x.__x_ + __x.__i_))
+ return false;
+ if (!_VSTD::equal(__y.__x_ + (__y.__i_ + __j), __y.__x_ + _Rp,
+ __x.__x_))
+ return false;
+ return _VSTD::equal(__y.__x_, __y.__x_ + __y.__i_,
+ __x.__x_ + (_Rp - (__y.__i_ + __j)));
+}
+
+template<class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(
+ const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x,
+ const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y)
+{
+ return !(__x == __y);
+}
+
+template <class _CharT, class _Traits,
+ class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __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);
+ __os << __x.__x_[__x.__i_];
+ for (size_t __j = __x.__i_ + 1; __j < _Rp; ++__j)
+ __os << __sp << __x.__x_[__j];
+ for (size_t __j = 0; __j < __x.__i_; ++__j)
+ __os << __sp << __x.__x_[__j];
+ __os << __sp << __x.__c_;
+ return __os;
+}
+
+template <class _CharT, class _Traits,
+ class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x)
+{
+ __save_flags<_CharT, _Traits> __lx(__is);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
+ _UInt __t[_Rp+1];
+ for (size_t __i = 0; __i < _Rp+1; ++__i)
+ __is >> __t[__i];
+ if (!__is.fail())
+ {
+ for (size_t __i = 0; __i < _Rp; ++__i)
+ __x.__x_[__i] = __t[__i];
+ __x.__c_ = __t[_Rp];
+ __x.__i_ = 0;
+ }
+ return __is;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANDOM_SUBTRACT_WITH_CARRY_ENGINE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/uniform_int_distribution.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/uniform_int_distribution.h
new file mode 100644
index 0000000000..4e961f0c8a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/uniform_int_distribution.h
@@ -0,0 +1,290 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <__random/log2.h>
+#include <bit>
+#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
+
+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> // __int128_t is also supported as an extension here
+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,
+ typename make_unsigned<result_type>::type>::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 - __countl_zero(_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/libs/cxxsupp/libcxxmsvc/include/__random/uniform_random_bit_generator.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/uniform_random_bit_generator.h
new file mode 100644
index 0000000000..99f2e6bc30
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/uniform_random_bit_generator.h
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_RANDOM_BIT_GENERATOR_H
+#define _LIBCPP___RANDOM_UNIFORM_RANDOM_BIT_GENERATOR_H
+
+#include <__concepts/arithmetic.h>
+#include <__concepts/invocable.h>
+#include <__concepts/same_as.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 !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 // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANDOM_UNIFORM_RANDOM_BIT_GENERATOR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/uniform_real_distribution.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/uniform_real_distribution.h
new file mode 100644
index 0000000000..e11222540b
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/uniform_real_distribution.h
@@ -0,0 +1,160 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_REAL_DISTRIBUTION_H
+#define _LIBCPP___RANDOM_UNIFORM_REAL_DISTRIBUTION_H
+
+#include <__config>
+#include <__random/generate_canonical.h>
+#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
+
+template<class _RealType = double>
+class _LIBCPP_TEMPLATE_VIS uniform_real_distribution
+{
+public:
+ // types
+ typedef _RealType result_type;
+
+ class _LIBCPP_TEMPLATE_VIS param_type
+ {
+ result_type __a_;
+ result_type __b_;
+ public:
+ typedef uniform_real_distribution distribution_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit param_type(result_type __a = 0,
+ result_type __b = 1)
+ : __a_(__a), __b_(__b) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type a() const {return __a_;}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type b() const {return __b_;}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const param_type& __x, const param_type& __y)
+ {return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ 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
+ _LIBCPP_INLINE_VISIBILITY
+ uniform_real_distribution() : uniform_real_distribution(0) {}
+ explicit uniform_real_distribution(result_type __a, result_type __b = 1)
+ : __p_(param_type(__a, __b)) {}
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit uniform_real_distribution(result_type __a = 0, result_type __b = 1)
+ : __p_(param_type(__a, __b)) {}
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ explicit uniform_real_distribution(const param_type& __p) : __p_(__p) {}
+ _LIBCPP_INLINE_VISIBILITY
+ void reset() {}
+
+ // generating functions
+ template<class _URNG>
+ _LIBCPP_INLINE_VISIBILITY
+ result_type operator()(_URNG& __g)
+ {return (*this)(__g, __p_);}
+ template<class _URNG> _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g, const param_type& __p);
+
+ // property functions
+ _LIBCPP_INLINE_VISIBILITY
+ result_type a() const {return __p_.a();}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type b() const {return __p_.b();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ param_type param() const {return __p_;}
+ _LIBCPP_INLINE_VISIBILITY
+ void param(const param_type& __p) {__p_ = __p;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type min() const {return a();}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type max() const {return b();}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const uniform_real_distribution& __x,
+ const uniform_real_distribution& __y)
+ {return __x.__p_ == __y.__p_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const uniform_real_distribution& __x,
+ const uniform_real_distribution& __y)
+ {return !(__x == __y);}
+};
+
+template<class _RealType>
+template<class _URNG>
+inline
+typename uniform_real_distribution<_RealType>::result_type
+uniform_real_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
+{
+ return (__p.b() - __p.a())
+ * _VSTD::generate_canonical<_RealType, numeric_limits<_RealType>::digits>(__g)
+ + __p.a();
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const uniform_real_distribution<_RT>& __x)
+{
+ __save_flags<_CharT, _Traits> __lx(__os);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
+ _CharT __sp = __os.widen(' ');
+ __os.fill(__sp);
+ return __os << __x.a() << __sp << __x.b();
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ uniform_real_distribution<_RT>& __x)
+{
+ typedef uniform_real_distribution<_RT> _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_REAL_DISTRIBUTION_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__random/weibull_distribution.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/weibull_distribution.h
new file mode 100644
index 0000000000..85bae65096
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__random/weibull_distribution.h
@@ -0,0 +1,155 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_WEIBULL_DISTRIBUTION_H
+#define _LIBCPP___RANDOM_WEIBULL_DISTRIBUTION_H
+
+#include <__config>
+#include <__random/exponential_distribution.h>
+#include <cmath>
+#include <iosfwd>
+#include <limits>
+
+#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 _RealType = double>
+class _LIBCPP_TEMPLATE_VIS weibull_distribution
+{
+public:
+ // types
+ typedef _RealType result_type;
+
+ class _LIBCPP_TEMPLATE_VIS param_type
+ {
+ result_type __a_;
+ result_type __b_;
+ public:
+ typedef weibull_distribution distribution_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit param_type(result_type __a = 1, result_type __b = 1)
+ : __a_(__a), __b_(__b) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type a() const {return __a_;}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type b() const {return __b_;}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const param_type& __x, const param_type& __y)
+ {return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const param_type& __x, const param_type& __y)
+ {return !(__x == __y);}
+ };
+
+private:
+ param_type __p_;
+
+public:
+ // constructor and reset functions
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ weibull_distribution() : weibull_distribution(1) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit weibull_distribution(result_type __a, result_type __b = 1)
+ : __p_(param_type(__a, __b)) {}
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit weibull_distribution(result_type __a = 1, result_type __b = 1)
+ : __p_(param_type(__a, __b)) {}
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ explicit weibull_distribution(const param_type& __p)
+ : __p_(__p) {}
+ _LIBCPP_INLINE_VISIBILITY
+ void reset() {}
+
+ // generating functions
+ template<class _URNG>
+ _LIBCPP_INLINE_VISIBILITY
+ result_type operator()(_URNG& __g)
+ {return (*this)(__g, __p_);}
+ template<class _URNG>
+ _LIBCPP_INLINE_VISIBILITY
+ result_type operator()(_URNG& __g, const param_type& __p)
+ {return __p.b() *
+ _VSTD::pow(exponential_distribution<result_type>()(__g), 1/__p.a());}
+
+ // property functions
+ _LIBCPP_INLINE_VISIBILITY
+ result_type a() const {return __p_.a();}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type b() const {return __p_.b();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ param_type param() const {return __p_;}
+ _LIBCPP_INLINE_VISIBILITY
+ void param(const param_type& __p) {__p_ = __p;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type min() const {return 0;}
+ _LIBCPP_INLINE_VISIBILITY
+ result_type max() const {return numeric_limits<result_type>::infinity();}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const weibull_distribution& __x,
+ const weibull_distribution& __y)
+ {return __x.__p_ == __y.__p_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const weibull_distribution& __x,
+ const weibull_distribution& __y)
+ {return !(__x == __y);}
+};
+
+template <class _CharT, class _Traits, class _RT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const weibull_distribution<_RT>& __x)
+{
+ __save_flags<_CharT, _Traits> __lx(__os);
+ typedef basic_ostream<_CharT, _Traits> _OStream;
+ __os.flags(_OStream::dec | _OStream::left | _OStream::fixed |
+ _OStream::scientific);
+ _CharT __sp = __os.widen(' ');
+ __os.fill(__sp);
+ __os << __x.a() << __sp << __x.b();
+ return __os;
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ weibull_distribution<_RT>& __x)
+{
+ typedef weibull_distribution<_RT> _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_WEIBULL_DISTRIBUTION_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/access.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/access.h
new file mode 100644
index 0000000000..2ebdab4eb8
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/access.h
@@ -0,0 +1,225 @@
+// -*- 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_ACCESS_H
+#define _LIBCPP___RANGES_ACCESS_H
+
+#include <__concepts/class_or_enum.h>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/readable_traits.h>
+#include <__ranges/enable_borrowed_range.h>
+#include <__utility/auto_cast.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+namespace ranges {
+ template <class _Tp>
+ concept __can_borrow =
+ is_lvalue_reference_v<_Tp> || enable_borrowed_range<remove_cvref_t<_Tp>>;
+} // namespace ranges
+
+// [range.access.begin]
+
+namespace ranges {
+namespace __begin {
+ template <class _Tp>
+ concept __member_begin =
+ __can_borrow<_Tp> &&
+ __workaround_52970<_Tp> &&
+ requires(_Tp&& __t) {
+ { _LIBCPP_AUTO_CAST(__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) {
+ { _LIBCPP_AUTO_CAST(begin(__t)) } -> input_or_output_iterator;
+ };
+
+ struct __fn {
+ template <class _Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp (&__t)[]) const noexcept
+ requires (sizeof(_Tp) != 0) // Disallow incomplete element types.
+ {
+ return __t + 0;
+ }
+
+ template <class _Tp, size_t _Np>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp (&__t)[_Np]) const noexcept
+ requires (sizeof(_Tp) != 0) // Disallow incomplete element types.
+ {
+ return __t + 0;
+ }
+
+ template <class _Tp>
+ requires __member_begin<_Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.begin())))
+ {
+ return _LIBCPP_AUTO_CAST(__t.begin());
+ }
+
+ template <class _Tp>
+ requires __unqualified_begin<_Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(_LIBCPP_AUTO_CAST(begin(__t))))
+ {
+ return _LIBCPP_AUTO_CAST(begin(__t));
+ }
+
+ void operator()(auto&&) const = delete;
+ };
+} // namespace __begin
+
+inline namespace __cpo {
+ inline constexpr auto begin = __begin::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+// [range.range]
+
+namespace ranges {
+ template <class _Tp>
+ using iterator_t = decltype(ranges::begin(declval<_Tp&>()));
+} // namespace ranges
+
+// [range.access.end]
+
+namespace ranges {
+namespace __end {
+ template <class _Tp>
+ concept __member_end =
+ __can_borrow<_Tp> &&
+ __workaround_52970<_Tp> &&
+ requires(_Tp&& __t) {
+ typename iterator_t<_Tp>;
+ { _LIBCPP_AUTO_CAST(__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>;
+ { _LIBCPP_AUTO_CAST(end(__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
+ requires (sizeof(_Tp) != 0) // Disallow incomplete element types.
+ {
+ return __t + _Np;
+ }
+
+ template <class _Tp>
+ requires __member_end<_Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.end())))
+ {
+ return _LIBCPP_AUTO_CAST(__t.end());
+ }
+
+ template <class _Tp>
+ requires __unqualified_end<_Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(_LIBCPP_AUTO_CAST(end(__t))))
+ {
+ return _LIBCPP_AUTO_CAST(end(__t));
+ }
+
+ void operator()(auto&&) const = delete;
+ };
+} // namespace __end
+
+inline namespace __cpo {
+ inline constexpr auto end = __end::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+// [range.access.cbegin]
+
+namespace ranges {
+namespace __cbegin {
+ struct __fn {
+ template <class _Tp>
+ requires is_lvalue_reference_v<_Tp&&>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(ranges::begin(static_cast<const remove_reference_t<_Tp>&>(__t))))
+ -> decltype( ranges::begin(static_cast<const remove_reference_t<_Tp>&>(__t)))
+ { return ranges::begin(static_cast<const remove_reference_t<_Tp>&>(__t)); }
+
+ template <class _Tp>
+ requires is_rvalue_reference_v<_Tp&&>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(ranges::begin(static_cast<const _Tp&&>(__t))))
+ -> decltype( ranges::begin(static_cast<const _Tp&&>(__t)))
+ { return ranges::begin(static_cast<const _Tp&&>(__t)); }
+ };
+} // namespace __cbegin
+
+inline namespace __cpo {
+ inline constexpr auto cbegin = __cbegin::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+// [range.access.cend]
+
+namespace ranges {
+namespace __cend {
+ struct __fn {
+ template <class _Tp>
+ requires is_lvalue_reference_v<_Tp&&>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(ranges::end(static_cast<const remove_reference_t<_Tp>&>(__t))))
+ -> decltype( ranges::end(static_cast<const remove_reference_t<_Tp>&>(__t)))
+ { return ranges::end(static_cast<const remove_reference_t<_Tp>&>(__t)); }
+
+ template <class _Tp>
+ requires is_rvalue_reference_v<_Tp&&>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(ranges::end(static_cast<const _Tp&&>(__t))))
+ -> decltype( ranges::end(static_cast<const _Tp&&>(__t)))
+ { return ranges::end(static_cast<const _Tp&&>(__t)); }
+ };
+} // namespace __cend
+
+inline namespace __cpo {
+ inline constexpr auto cend = __cend::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_ACCESS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/all.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/all.h
new file mode 100644
index 0000000000..77396222d6
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/all.h
@@ -0,0 +1,82 @@
+// -*- 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/owning_view.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/ref_view.h>
+#include <__utility/auto_cast.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_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+namespace ranges::views {
+
+namespace __all {
+ struct __fn : __range_adaptor_closure<__fn> {
+ template<class _Tp>
+ requires ranges::view<decay_t<_Tp>>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(_LIBCPP_AUTO_CAST(std::forward<_Tp>(__t))))
+ {
+ return _LIBCPP_AUTO_CAST(std::forward<_Tp>(__t));
+ }
+
+ template<class _Tp>
+ requires (!ranges::view<decay_t<_Tp>>) &&
+ requires (_Tp&& __t) { ranges::ref_view{std::forward<_Tp>(__t)}; }
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(ranges::ref_view{std::forward<_Tp>(__t)}))
+ {
+ return ranges::ref_view{std::forward<_Tp>(__t)};
+ }
+
+ template<class _Tp>
+ requires (!ranges::view<decay_t<_Tp>> &&
+ !requires (_Tp&& __t) { ranges::ref_view{std::forward<_Tp>(__t)}; } &&
+ requires (_Tp&& __t) { ranges::owning_view{std::forward<_Tp>(__t)}; })
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(ranges::owning_view{std::forward<_Tp>(__t)}))
+ {
+ return ranges::owning_view{std::forward<_Tp>(__t)};
+ }
+ };
+} // namespace __all
+
+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 ranges::views
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_ALL_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/common_view.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/common_view.h
new file mode 100644
index 0000000000..78911284bb
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/common_view.h
@@ -0,0 +1,135 @@
+// -*- 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/range_adaptor.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include <concepts>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_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_(std::move(__v)) { }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _View base() const& requires copy_constructible<_View> { return __base_; }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _View base() && { return std::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 views {
+namespace __common {
+ struct __fn : __range_adaptor_closure<__fn> {
+ template<class _Range>
+ requires common_range<_Range>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Range&& __range) const
+ noexcept(noexcept(views::all(std::forward<_Range>(__range))))
+ -> decltype( views::all(std::forward<_Range>(__range)))
+ { return views::all(std::forward<_Range>(__range)); }
+
+ template<class _Range>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Range&& __range) const
+ noexcept(noexcept(common_view{std::forward<_Range>(__range)}))
+ -> decltype( common_view{std::forward<_Range>(__range)})
+ { return common_view{std::forward<_Range>(__range)}; }
+ };
+} // namespace __common
+
+inline namespace __cpo {
+ inline constexpr auto common = __common::__fn{};
+} // namespace __cpo
+} // namespace views
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_COMMON_VIEW_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/concepts.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/concepts.h
new file mode 100644
index 0000000000..709f3d80f7
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/concepts.h
@@ -0,0 +1,146 @@
+// -*- 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_CONCEPTS_H
+#define _LIBCPP___RANGES_CONCEPTS_H
+
+#include <__concepts/constructible.h>
+#include <__concepts/movable.h>
+#include <__concepts/same_as.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/data.h>
+#include <__ranges/enable_borrowed_range.h>
+#include <__ranges/enable_view.h>
+#include <__ranges/size.h>
+#include <initializer_list>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+namespace ranges {
+
+ // [range.range]
+
+ template <class _Tp>
+ concept range = requires(_Tp& __t) {
+ ranges::begin(__t); // sometimes equality-preserving
+ ranges::end(__t);
+ };
+
+ template <class _Tp>
+ concept input_range = range<_Tp> && input_iterator<iterator_t<_Tp>>;
+
+ 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>>;
+
+#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+ // [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>, sentinel_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 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>
+ inline constexpr bool __is_std_initializer_list = false;
+
+ template <class _Ep>
+ inline constexpr bool __is_std_initializer_list<initializer_list<_Ep>> = true;
+
+ 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>> &&
+ (is_lvalue_reference_v<_Tp> ||
+ (movable<remove_reference_t<_Tp>> && !__is_std_initializer_list<remove_cvref_t<_Tp>>))));
+
+#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_CONCEPTS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/copyable_box.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/copyable_box.h
new file mode 100644
index 0000000000..e1c08a7ea1
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/copyable_box.h
@@ -0,0 +1,178 @@
+// -*- 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_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_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 {
+ _LIBCPP_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, std::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 != std::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 != std::addressof(__other)) {
+ if (__other.__has_value()) __val_.emplace(std::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 const _Tp *operator->() const noexcept { return __val_.operator->(); }
+ _LIBCPP_HIDE_FROM_ABI constexpr _Tp *operator->() noexcept { return __val_.operator->(); }
+
+ _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> {
+ _LIBCPP_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_(std::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 != std::addressof(__other)) {
+ std::destroy_at(std::addressof(__val_));
+ std::construct_at(std::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 != std::addressof(__other)) {
+ std::destroy_at(std::addressof(__val_));
+ std::construct_at(std::addressof(__val_), std::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 const _Tp *operator->() const noexcept { return std::addressof(__val_); }
+ _LIBCPP_HIDE_FROM_ABI constexpr _Tp *operator->() noexcept { return std::addressof(__val_); }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr bool __has_value() const noexcept { return true; }
+ };
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_COPYABLE_BOX_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/counted.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/counted.h
new file mode 100644
index 0000000000..0a2d828578
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/counted.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___RANGES_COUNTED_H
+#define _LIBCPP___RANGES_COUNTED_H
+
+#include <__concepts/convertible_to.h>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/counted_iterator.h>
+#include <__iterator/default_sentinel.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iterator_traits.h>
+#include <__memory/pointer_traits.h>
+#include <__ranges/subrange.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include <span>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+namespace ranges::views {
+
+namespace __counted {
+
+ struct __fn {
+ template<contiguous_iterator _It>
+ _LIBCPP_HIDE_FROM_ABI
+ static constexpr auto __go(_It __it, iter_difference_t<_It> __count)
+ noexcept(noexcept(span(std::to_address(__it), static_cast<size_t>(__count))))
+ // Deliberately omit return-type SFINAE, because to_address is not SFINAE-friendly
+ { return span(std::to_address(__it), static_cast<size_t>(__count)); }
+
+ template<random_access_iterator _It>
+ _LIBCPP_HIDE_FROM_ABI
+ static constexpr auto __go(_It __it, iter_difference_t<_It> __count)
+ noexcept(noexcept(subrange(__it, __it + __count)))
+ -> decltype( subrange(__it, __it + __count))
+ { return subrange(__it, __it + __count); }
+
+ template<class _It>
+ _LIBCPP_HIDE_FROM_ABI
+ static constexpr auto __go(_It __it, iter_difference_t<_It> __count)
+ noexcept(noexcept(subrange(counted_iterator(std::move(__it), __count), default_sentinel)))
+ -> decltype( subrange(counted_iterator(std::move(__it), __count), default_sentinel))
+ { return subrange(counted_iterator(std::move(__it), __count), default_sentinel); }
+
+ template<class _It, convertible_to<iter_difference_t<_It>> _Diff>
+ requires input_or_output_iterator<decay_t<_It>>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_It&& __it, _Diff&& __count) const
+ noexcept(noexcept(__go(std::forward<_It>(__it), std::forward<_Diff>(__count))))
+ -> decltype( __go(std::forward<_It>(__it), std::forward<_Diff>(__count)))
+ { return __go(std::forward<_It>(__it), std::forward<_Diff>(__count)); }
+ };
+
+} // namespace __counted
+
+inline namespace __cpo {
+ inline constexpr auto counted = __counted::__fn{};
+} // namespace __cpo
+
+} // namespace ranges::views
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_COUNTED_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/dangling.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/dangling.h
new file mode 100644
index 0000000000..3a200ed965
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/dangling.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_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_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+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 // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_DANGLING_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/data.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/data.h
new file mode 100644
index 0000000000..dbb4767e53
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/data.h
@@ -0,0 +1,106 @@
+// -*- 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_DATA_H
+#define _LIBCPP___RANGES_DATA_H
+
+#include <__concepts/class_or_enum.h>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__memory/pointer_traits.h>
+#include <__ranges/access.h>
+#include <__utility/auto_cast.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+// [range.prim.data]
+
+namespace ranges {
+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 =
+ __can_borrow<_Tp> &&
+ __workaround_52970<_Tp> &&
+ requires(_Tp&& __t) {
+ { _LIBCPP_AUTO_CAST(__t.data()) } -> __ptr_to_object;
+ };
+
+ template <class _Tp>
+ concept __ranges_begin_invocable =
+ !__member_data<_Tp> &&
+ __can_borrow<_Tp> &&
+ requires(_Tp&& __t) {
+ { ranges::begin(__t) } -> contiguous_iterator;
+ };
+
+ struct __fn {
+ template <__member_data _Tp>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(__t.data())) {
+ return __t.data();
+ }
+
+ template<__ranges_begin_invocable _Tp>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(std::to_address(ranges::begin(__t)))) {
+ return std::to_address(ranges::begin(__t));
+ }
+ };
+} // namespace __data
+
+inline namespace __cpo {
+ inline constexpr auto data = __data::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+// [range.prim.cdata]
+
+namespace ranges {
+namespace __cdata {
+ struct __fn {
+ template <class _Tp>
+ requires is_lvalue_reference_v<_Tp&&>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(ranges::data(static_cast<const remove_reference_t<_Tp>&>(__t))))
+ -> decltype( ranges::data(static_cast<const remove_reference_t<_Tp>&>(__t)))
+ { return ranges::data(static_cast<const remove_reference_t<_Tp>&>(__t)); }
+
+ template <class _Tp>
+ requires is_rvalue_reference_v<_Tp&&>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(ranges::data(static_cast<const _Tp&&>(__t))))
+ -> decltype( ranges::data(static_cast<const _Tp&&>(__t)))
+ { return ranges::data(static_cast<const _Tp&&>(__t)); }
+ };
+} // namespace __cdata
+
+inline namespace __cpo {
+ inline constexpr auto cdata = __cdata::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_DATA_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/drop_view.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/drop_view.h
new file mode 100644
index 0000000000..079a74d4b8
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/drop_view.h
@@ -0,0 +1,127 @@
+// -*- 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 <__assert>
+#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_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_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>;
+ _LIBCPP_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_(std::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 std::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_.__emplace(__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_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_DROP_VIEW_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/empty.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/empty.h
new file mode 100644
index 0000000000..c0b55b221a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/empty.h
@@ -0,0 +1,82 @@
+// -*- 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 <__concepts/class_or_enum.h>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__ranges/access.h>
+#include <__ranges/size.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+// [range.prim.empty]
+
+namespace ranges {
+namespace __empty {
+ template <class _Tp>
+ concept __member_empty =
+ __workaround_52970<_Tp> &&
+ requires(_Tp&& __t) {
+ bool(__t.empty());
+ };
+
+ template<class _Tp>
+ concept __can_invoke_size =
+ !__member_empty<_Tp> &&
+ requires(_Tp&& __t) { ranges::size(__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 bool(__t.empty());
+ }
+
+ template <__can_invoke_size _Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp&& __t) const
+ noexcept(noexcept(ranges::size(__t))) {
+ return ranges::size(__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);
+ }
+ };
+} // namespace __empty
+
+inline namespace __cpo {
+ inline constexpr auto empty = __empty::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_EMPTY_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/empty_view.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/empty_view.h
new file mode 100644
index 0000000000..6a08727678
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/empty_view.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___RANGES_EMPTY_VIEW_H
+#define _LIBCPP___RANGES_EMPTY_VIEW_H
+
+#include <__config>
+#include <__ranges/enable_borrowed_range.h>
+#include <__ranges/view_interface.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_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; }
+ };
+
+ template<class _Tp>
+ inline constexpr bool enable_borrowed_range<empty_view<_Tp>> = true;
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_EMPTY_VIEW_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/enable_borrowed_range.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/enable_borrowed_range.h
new file mode 100644
index 0000000000..b8f809b6ce
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/enable_borrowed_range.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___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_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+namespace ranges {
+
+// [range.range], ranges
+
+template <class>
+inline constexpr bool enable_borrowed_range = false;
+
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_ENABLE_BORROWED_RANGE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/enable_view.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/enable_view.h
new file mode 100644
index 0000000000..4b4b63a42c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/enable_view.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_ENABLE_VIEW_H
+#define _LIBCPP___RANGES_ENABLE_VIEW_H
+
+#include <__config>
+#include <concepts>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+namespace ranges {
+
+struct view_base { };
+
+template<class _Derived>
+ requires is_class_v<_Derived> && same_as<_Derived, remove_cv_t<_Derived>>
+class view_interface;
+
+template<class _Op, class _Yp>
+ requires is_convertible_v<_Op*, view_interface<_Yp>*>
+void __is_derived_from_view_interface(const _Op*, const view_interface<_Yp>*);
+
+template <class _Tp>
+inline constexpr bool enable_view = derived_from<_Tp, view_base> ||
+ requires { ranges::__is_derived_from_view_interface((_Tp*)nullptr, (_Tp*)nullptr); };
+
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_ENABLE_VIEW_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/iota_view.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/iota_view.h
new file mode 100644
index 0000000000..b7c099e049
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/iota_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_IOTA_VIEW_H
+#define _LIBCPP___RANGES_IOTA_VIEW_H
+
+#include <__assert>
+#include <__compare/three_way_comparable.h>
+#include <__concepts/arithmetic.h>
+#include <__concepts/constructible.h>
+#include <__concepts/convertible_to.h>
+#include <__concepts/copyable.h>
+#include <__concepts/equality_comparable.h>
+#include <__concepts/invocable.h>
+#include <__concepts/same_as.h>
+#include <__concepts/semiregular.h>
+#include <__concepts/totally_ordered.h>
+#include <__config>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/unreachable_sentinel.h>
+#include <__ranges/copyable_box.h>
+#include <__ranges/enable_borrowed_range.h>
+#include <__ranges/view_interface.h>
+#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_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+namespace ranges {
+ template<class _Int>
+ struct __get_wider_signed {
+ static auto __call() {
+ if constexpr (sizeof(_Int) < sizeof(short)) return type_identity<short>{};
+ else if constexpr (sizeof(_Int) < sizeof(int)) return type_identity<int>{};
+ else if constexpr (sizeof(_Int) < sizeof(long)) return type_identity<long>{};
+ else return type_identity<long long>{};
+
+ static_assert(sizeof(_Int) <= sizeof(long long),
+ "Found integer-like type that is bigger than largest integer like type.");
+ }
+
+ using type = typename decltype(__call())::type;
+ };
+
+ template<class _Start>
+ using _IotaDiffT = typename _If<
+ (!integral<_Start> || sizeof(iter_difference_t<_Start>) > sizeof(_Start)),
+ type_identity<iter_difference_t<_Start>>,
+ __get_wider_signed<_Start>
+ >::type;
+
+ template<class _Iter>
+ concept __decrementable = incrementable<_Iter> && requires(_Iter __i) {
+ { --__i } -> same_as<_Iter&>;
+ { __i-- } -> same_as<_Iter>;
+ };
+
+ template<class _Iter>
+ concept __advanceable =
+ __decrementable<_Iter> && totally_ordered<_Iter> &&
+ requires(_Iter __i, const _Iter __j, const _IotaDiffT<_Iter> __n) {
+ { __i += __n } -> same_as<_Iter&>;
+ { __i -= __n } -> same_as<_Iter&>;
+ _Iter(__j + __n);
+ _Iter(__n + __j);
+ _Iter(__j - __n);
+ { __j - __j } -> convertible_to<_IotaDiffT<_Iter>>;
+ };
+
+ template<class>
+ struct __iota_iterator_category {};
+
+ template<incrementable _Tp>
+ struct __iota_iterator_category<_Tp> {
+ using iterator_category = input_iterator_tag;
+ };
+
+ template<weakly_incrementable _Start, semiregular _Bound = unreachable_sentinel_t>
+ requires __weakly_equality_comparable_with<_Start, _Bound> && copyable<_Start>
+ class iota_view : public view_interface<iota_view<_Start, _Bound>> {
+ struct __iterator : public __iota_iterator_category<_Start> {
+ friend class iota_view;
+
+ using iterator_concept =
+ _If<__advanceable<_Start>, random_access_iterator_tag,
+ _If<__decrementable<_Start>, bidirectional_iterator_tag,
+ _If<incrementable<_Start>, forward_iterator_tag,
+ /*Else*/ input_iterator_tag>>>;
+
+ using value_type = _Start;
+ using difference_type = _IotaDiffT<_Start>;
+
+ _Start __value_ = _Start();
+
+ _LIBCPP_HIDE_FROM_ABI
+ __iterator() requires default_initializable<_Start> = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit __iterator(_Start __value) : __value_(std::move(__value)) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _Start operator*() const noexcept(is_nothrow_copy_constructible_v<_Start>) {
+ return __value_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator& operator++() {
+ ++__value_;
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr void operator++(int) { ++*this; }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator operator++(int) requires incrementable<_Start> {
+ auto __tmp = *this;
+ ++*this;
+ return __tmp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator& operator--() requires __decrementable<_Start> {
+ --__value_;
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator operator--(int) requires __decrementable<_Start> {
+ auto __tmp = *this;
+ --*this;
+ return __tmp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator& operator+=(difference_type __n)
+ requires __advanceable<_Start>
+ {
+ if constexpr (__integer_like<_Start> && !__signed_integer_like<_Start>) {
+ if (__n >= difference_type(0)) {
+ __value_ += static_cast<_Start>(__n);
+ } else {
+ __value_ -= static_cast<_Start>(-__n);
+ }
+ } else {
+ __value_ += __n;
+ }
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator& operator-=(difference_type __n)
+ requires __advanceable<_Start>
+ {
+ if constexpr (__integer_like<_Start> && !__signed_integer_like<_Start>) {
+ if (__n >= difference_type(0)) {
+ __value_ -= static_cast<_Start>(__n);
+ } else {
+ __value_ += static_cast<_Start>(-__n);
+ }
+ } else {
+ __value_ -= __n;
+ }
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _Start operator[](difference_type __n) const
+ requires __advanceable<_Start>
+ {
+ return _Start(__value_ + __n);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator==(const __iterator& __x, const __iterator& __y)
+ requires equality_comparable<_Start>
+ {
+ return __x.__value_ == __y.__value_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator<(const __iterator& __x, const __iterator& __y)
+ requires totally_ordered<_Start>
+ {
+ return __x.__value_ < __y.__value_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator>(const __iterator& __x, const __iterator& __y)
+ requires totally_ordered<_Start>
+ {
+ return __y < __x;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator<=(const __iterator& __x, const __iterator& __y)
+ requires totally_ordered<_Start>
+ {
+ return !(__y < __x);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator>=(const __iterator& __x, const __iterator& __y)
+ requires totally_ordered<_Start>
+ {
+ return !(__x < __y);
+ }
+
+ friend constexpr auto operator<=>(const __iterator& __x, const __iterator& __y)
+ requires totally_ordered<_Start> && three_way_comparable<_Start>
+ {
+ return __x.__value_ <=> __y.__value_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr __iterator operator+(__iterator __i, difference_type __n)
+ requires __advanceable<_Start>
+ {
+ __i += __n;
+ return __i;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr __iterator operator+(difference_type __n, __iterator __i)
+ requires __advanceable<_Start>
+ {
+ return __i + __n;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr __iterator operator-(__iterator __i, difference_type __n)
+ requires __advanceable<_Start>
+ {
+ __i -= __n;
+ return __i;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr difference_type operator-(const __iterator& __x, const __iterator& __y)
+ requires __advanceable<_Start>
+ {
+ if constexpr (__integer_like<_Start>) {
+ if constexpr (__signed_integer_like<_Start>) {
+ return difference_type(difference_type(__x.__value_) - difference_type(__y.__value_));
+ }
+ if (__y.__value_ > __x.__value_) {
+ return difference_type(-difference_type(__y.__value_ - __x.__value_));
+ }
+ return difference_type(__x.__value_ - __y.__value_);
+ }
+ return __x.__value_ - __y.__value_;
+ }
+ };
+
+ struct __sentinel {
+ friend class iota_view;
+
+ private:
+ _Bound __bound_ = _Bound();
+
+ public:
+ _LIBCPP_HIDE_FROM_ABI
+ __sentinel() = default;
+ constexpr explicit __sentinel(_Bound __bound) : __bound_(std::move(__bound)) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator==(const __iterator& __x, const __sentinel& __y) {
+ return __x.__value_ == __y.__bound_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr iter_difference_t<_Start> operator-(const __iterator& __x, const __sentinel& __y)
+ requires sized_sentinel_for<_Bound, _Start>
+ {
+ return __x.__value_ - __y.__bound_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr iter_difference_t<_Start> operator-(const __sentinel& __x, const __iterator& __y)
+ requires sized_sentinel_for<_Bound, _Start>
+ {
+ return -(__y - __x);
+ }
+ };
+
+ _Start __value_ = _Start();
+ _Bound __bound_ = _Bound();
+
+ public:
+ _LIBCPP_HIDE_FROM_ABI
+ iota_view() requires default_initializable<_Start> = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit iota_view(_Start __value) : __value_(std::move(__value)) { }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr iota_view(type_identity_t<_Start> __value, type_identity_t<_Bound> __bound)
+ : __value_(std::move(__value)), __bound_(std::move(__bound)) {
+ // Validate the precondition if possible.
+ if constexpr (totally_ordered_with<_Start, _Bound>) {
+ _LIBCPP_ASSERT(ranges::less_equal()(__value_, __bound_),
+ "Precondition violated: value is greater than bound.");
+ }
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr iota_view(__iterator __first, __iterator __last)
+ requires same_as<_Start, _Bound>
+ : iota_view(std::move(__first.__value_), std::move(__last.__value_)) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr iota_view(__iterator __first, _Bound __last)
+ requires same_as<_Bound, unreachable_sentinel_t>
+ : iota_view(std::move(__first.__value_), std::move(__last)) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr iota_view(__iterator __first, __sentinel __last)
+ requires (!same_as<_Start, _Bound> && !same_as<_Start, unreachable_sentinel_t>)
+ : iota_view(std::move(__first.__value_), std::move(__last.__bound_)) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator begin() const { return __iterator{__value_}; }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto end() const {
+ if constexpr (same_as<_Bound, unreachable_sentinel_t>)
+ return unreachable_sentinel;
+ else
+ return __sentinel{__bound_};
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator end() const requires same_as<_Start, _Bound> {
+ return __iterator{__bound_};
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto size() const
+ requires (same_as<_Start, _Bound> && __advanceable<_Start>) ||
+ (integral<_Start> && integral<_Bound>) ||
+ sized_sentinel_for<_Bound, _Start>
+ {
+ if constexpr (__integer_like<_Start> && __integer_like<_Bound>) {
+ if (__value_ < 0) {
+ if (__bound_ < 0) {
+ return std::__to_unsigned_like(-__value_) - std::__to_unsigned_like(-__bound_);
+ }
+ return std::__to_unsigned_like(__bound_) + std::__to_unsigned_like(-__value_);
+ }
+ return std::__to_unsigned_like(__bound_) - std::__to_unsigned_like(__value_);
+ }
+ return std::__to_unsigned_like(__bound_ - __value_);
+ }
+ };
+
+ template<class _Start, class _Bound>
+ requires (!__integer_like<_Start> || !__integer_like<_Bound> ||
+ (__signed_integer_like<_Start> == __signed_integer_like<_Bound>))
+ iota_view(_Start, _Bound) -> iota_view<_Start, _Bound>;
+
+ template<class _Start, class _Bound>
+ inline constexpr bool enable_borrowed_range<iota_view<_Start, _Bound>> = true;
+
+namespace views {
+namespace __iota {
+ struct __fn {
+ template<class _Start>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Start&& __start) const
+ noexcept(noexcept(ranges::iota_view(std::forward<_Start>(__start))))
+ -> decltype( ranges::iota_view(std::forward<_Start>(__start)))
+ { return ranges::iota_view(std::forward<_Start>(__start)); }
+
+ template<class _Start, class _Bound>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Start&& __start, _Bound&& __bound) const
+ noexcept(noexcept(ranges::iota_view(std::forward<_Start>(__start), std::forward<_Bound>(__bound))))
+ -> decltype( ranges::iota_view(std::forward<_Start>(__start), std::forward<_Bound>(__bound)))
+ { return ranges::iota_view(std::forward<_Start>(__start), std::forward<_Bound>(__bound)); }
+ };
+} // namespace __iota
+
+inline namespace __cpo {
+ inline constexpr auto iota = __iota::__fn{};
+} // namespace __cpo
+} // namespace views
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_IOTA_VIEW_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/join_view.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/join_view.h
new file mode 100644
index 0000000000..395e5c7ece
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/join_view.h
@@ -0,0 +1,350 @@
+// -*- 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_JOIN_VIEW_H
+#define _LIBCPP___RANGES_JOIN_VIEW_H
+
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/non_propagating_cache.h>
+#include <__ranges/ref_view.h>
+#include <__ranges/subrange.h>
+#include <__ranges/view_interface.h>
+#include <__utility/declval.h>
+#include <__utility/forward.h>
+#include <optional>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+namespace ranges {
+ template<class>
+ struct __join_view_iterator_category {};
+
+ template<class _View>
+ requires is_reference_v<range_reference_t<_View>> &&
+ forward_range<_View> &&
+ forward_range<range_reference_t<_View>>
+ struct __join_view_iterator_category<_View> {
+ using _OuterC = typename iterator_traits<iterator_t<_View>>::iterator_category;
+ using _InnerC = typename iterator_traits<iterator_t<range_reference_t<_View>>>::iterator_category;
+
+ using iterator_category = _If<
+ derived_from<_OuterC, bidirectional_iterator_tag> && derived_from<_InnerC, bidirectional_iterator_tag>,
+ bidirectional_iterator_tag,
+ _If<
+ derived_from<_OuterC, forward_iterator_tag> && derived_from<_InnerC, forward_iterator_tag>,
+ forward_iterator_tag,
+ input_iterator_tag
+ >
+ >;
+ };
+
+ template<input_range _View>
+ requires view<_View> && input_range<range_reference_t<_View>>
+ class join_view
+ : public view_interface<join_view<_View>> {
+ private:
+ using _InnerRange = range_reference_t<_View>;
+
+ template<bool> struct __iterator;
+ template<bool> struct __sentinel;
+
+ static constexpr bool _UseCache = !is_reference_v<_InnerRange>;
+ using _Cache = _If<_UseCache, __non_propagating_cache<remove_cvref_t<_InnerRange>>, __empty_cache>;
+ _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cache_;
+ _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
+
+ public:
+ _LIBCPP_HIDE_FROM_ABI
+ join_view() requires default_initializable<_View> = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit join_view(_View __base)
+ : __base_(std::move(__base)) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _View base() const& requires copy_constructible<_View> { return __base_; }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _View base() && { return std::move(__base_); }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto begin() {
+ constexpr bool __use_const = __simple_view<_View> &&
+ is_reference_v<range_reference_t<_View>>;
+ return __iterator<__use_const>{*this, ranges::begin(__base_)};
+ }
+
+ template<class _V2 = _View>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto begin() const
+ requires input_range<const _V2> &&
+ is_reference_v<range_reference_t<const _V2>>
+ {
+ return __iterator<true>{*this, ranges::begin(__base_)};
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto end() {
+ if constexpr (forward_range<_View> &&
+ is_reference_v<_InnerRange> &&
+ forward_range<_InnerRange> &&
+ common_range<_View> &&
+ common_range<_InnerRange>)
+ return __iterator<__simple_view<_View>>{*this, ranges::end(__base_)};
+ else
+ return __sentinel<__simple_view<_View>>{*this};
+ }
+
+ template<class _V2 = _View>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto end() const
+ requires input_range<const _V2> &&
+ is_reference_v<range_reference_t<const _V2>>
+ {
+ using _ConstInnerRange = range_reference_t<const _View>;
+ if constexpr (forward_range<const _View> &&
+ is_reference_v<_ConstInnerRange> &&
+ forward_range<_ConstInnerRange> &&
+ common_range<const _View> &&
+ common_range<_ConstInnerRange>) {
+ return __iterator<true>{*this, ranges::end(__base_)};
+ } else {
+ return __sentinel<true>{*this};
+ }
+ }
+ };
+
+ template<input_range _View>
+ requires view<_View> && input_range<range_reference_t<_View>>
+ template<bool _Const> struct join_view<_View>::__sentinel {
+ template<bool> friend struct __sentinel;
+
+ private:
+ using _Parent = __maybe_const<_Const, join_view>;
+ using _Base = __maybe_const<_Const, _View>;
+ sentinel_t<_Base> __end_ = sentinel_t<_Base>();
+
+ public:
+ _LIBCPP_HIDE_FROM_ABI
+ __sentinel() = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit __sentinel(_Parent& __parent)
+ : __end_(ranges::end(__parent.__base_)) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __sentinel(__sentinel<!_Const> __s)
+ requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>>
+ : __end_(std::move(__s.__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.__outer_ == __y.__end_;
+ }
+ };
+
+ template<input_range _View>
+ requires view<_View> && input_range<range_reference_t<_View>>
+ template<bool _Const> struct join_view<_View>::__iterator
+ : public __join_view_iterator_category<__maybe_const<_Const, _View>> {
+
+ template<bool> friend struct __iterator;
+
+ private:
+ using _Parent = __maybe_const<_Const, join_view>;
+ using _Base = __maybe_const<_Const, _View>;
+ using _Outer = iterator_t<_Base>;
+ using _Inner = iterator_t<range_reference_t<_Base>>;
+
+ static constexpr bool __ref_is_glvalue = is_reference_v<range_reference_t<_Base>>;
+
+ public:
+ _Outer __outer_ = _Outer();
+
+ private:
+ optional<_Inner> __inner_;
+ _Parent *__parent_ = nullptr;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr void __satisfy() {
+ for (; __outer_ != ranges::end(__parent_->__base_); ++__outer_) {
+ auto&& __inner = [&]() -> auto&& {
+ if constexpr (__ref_is_glvalue)
+ return *__outer_;
+ else
+ return __parent_->__cache_.__emplace_from([&]() -> decltype(auto) { return *__outer_; });
+ }();
+ __inner_ = ranges::begin(__inner);
+ if (*__inner_ != ranges::end(__inner))
+ return;
+ }
+
+ if constexpr (__ref_is_glvalue)
+ __inner_.reset();
+ }
+
+ public:
+ using iterator_concept = _If<
+ __ref_is_glvalue && bidirectional_range<_Base> && bidirectional_range<range_reference_t<_Base>>,
+ bidirectional_iterator_tag,
+ _If<
+ __ref_is_glvalue && forward_range<_Base> && forward_range<range_reference_t<_Base>>,
+ forward_iterator_tag,
+ input_iterator_tag
+ >
+ >;
+
+ using value_type = range_value_t<range_reference_t<_Base>>;
+
+ using difference_type = common_type_t<
+ range_difference_t<_Base>, range_difference_t<range_reference_t<_Base>>>;
+
+ _LIBCPP_HIDE_FROM_ABI
+ __iterator() requires default_initializable<_Outer> = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator(_Parent& __parent, _Outer __outer)
+ : __outer_(std::move(__outer))
+ , __parent_(std::addressof(__parent)) {
+ __satisfy();
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator(__iterator<!_Const> __i)
+ requires _Const &&
+ convertible_to<iterator_t<_View>, _Outer> &&
+ convertible_to<iterator_t<_InnerRange>, _Inner>
+ : __outer_(std::move(__i.__outer_))
+ , __inner_(std::move(__i.__inner_))
+ , __parent_(__i.__parent_) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr decltype(auto) operator*() const {
+ return **__inner_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _Inner operator->() const
+ requires __has_arrow<_Inner> && copyable<_Inner>
+ {
+ return *__inner_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator& operator++() {
+ auto&& __inner = [&]() -> auto&& {
+ if constexpr (__ref_is_glvalue)
+ return *__outer_;
+ else
+ return *__parent_->__cache_;
+ }();
+ if (++*__inner_ == ranges::end(__inner)) {
+ ++__outer_;
+ __satisfy();
+ }
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr void operator++(int) {
+ ++*this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator operator++(int)
+ requires __ref_is_glvalue &&
+ forward_range<_Base> &&
+ forward_range<range_reference_t<_Base>>
+ {
+ auto __tmp = *this;
+ ++*this;
+ return __tmp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator& operator--()
+ requires __ref_is_glvalue &&
+ bidirectional_range<_Base> &&
+ bidirectional_range<range_reference_t<_Base>> &&
+ common_range<range_reference_t<_Base>>
+ {
+ if (__outer_ == ranges::end(__parent_->__base_))
+ __inner_ = ranges::end(*--__outer_);
+
+ // Skip empty inner ranges when going backwards.
+ while (*__inner_ == ranges::begin(*__outer_)) {
+ __inner_ = ranges::end(*--__outer_);
+ }
+
+ --*__inner_;
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator operator--(int)
+ requires __ref_is_glvalue &&
+ bidirectional_range<_Base> &&
+ bidirectional_range<range_reference_t<_Base>> &&
+ common_range<range_reference_t<_Base>>
+ {
+ auto __tmp = *this;
+ --*this;
+ return __tmp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator==(const __iterator& __x, const __iterator& __y)
+ requires __ref_is_glvalue &&
+ equality_comparable<iterator_t<_Base>> &&
+ equality_comparable<iterator_t<range_reference_t<_Base>>>
+ {
+ return __x.__outer_ == __y.__outer_ && __x.__inner_ == __y.__inner_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr decltype(auto) iter_move(const __iterator& __i)
+ noexcept(noexcept(ranges::iter_move(*__i.__inner_)))
+ {
+ return ranges::iter_move(*__i.__inner_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr void iter_swap(const __iterator& __x, const __iterator& __y)
+ noexcept(noexcept(ranges::iter_swap(*__x.__inner_, *__y.__inner_)))
+ requires indirectly_swappable<_Inner>
+ {
+ return ranges::iter_swap(*__x.__inner_, *__y.__inner_);
+ }
+ };
+
+ template<class _Range>
+ explicit join_view(_Range&&) -> join_view<views::all_t<_Range>>;
+
+} // namespace ranges
+
+#undef _CONSTEXPR_TERNARY
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_JOIN_VIEW_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/non_propagating_cache.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/non_propagating_cache.h
new file mode 100644
index 0000000000..d9589ae46c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/non_propagating_cache.h
@@ -0,0 +1,114 @@
+// -*- 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 <__utility/forward.h>
+#include <concepts> // constructible_from
+#include <optional>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_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 {
+ struct __from_tag { };
+ struct __forward_tag { };
+
+ // This helper class is needed to perform copy and move elision when
+ // constructing the contained type from an iterator.
+ struct __wrapper {
+ template<class ..._Args>
+ constexpr explicit __wrapper(__forward_tag, _Args&& ...__args) : __t_(std::forward<_Args>(__args)...) { }
+ template<class _Fn>
+ constexpr explicit __wrapper(__from_tag, _Fn const& __f) : __t_(__f()) { }
+ _Tp __t_;
+ };
+
+ optional<__wrapper> __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 != std::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_->__t_; }
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _Tp const& operator*() const { return __value_->__t_; }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr bool __has_value() const { return __value_.has_value(); }
+
+ template<class _Fn>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _Tp& __emplace_from(_Fn const& __f) {
+ return __value_.emplace(__from_tag{}, __f).__t_;
+ }
+
+ template<class ..._Args>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _Tp& __emplace(_Args&& ...__args) {
+ return __value_.emplace(__forward_tag{}, std::forward<_Args>(__args)...).__t_;
+ }
+ };
+
+ struct __empty_cache { };
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_NON_PROPAGATING_CACHE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/owning_view.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/owning_view.h
new file mode 100644
index 0000000000..7987c60751
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/owning_view.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___RANGES_OWNING_VIEW_H
+#define _LIBCPP___RANGES_OWNING_VIEW_H
+
+#include <__concepts/constructible.h>
+#include <__concepts/movable.h>
+#include <__config>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/data.h>
+#include <__ranges/empty.h>
+#include <__ranges/enable_borrowed_range.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <__utility/move.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+namespace ranges {
+ template<range _Rp>
+ requires movable<_Rp> && (!__is_std_initializer_list<remove_cvref_t<_Rp>>)
+ class owning_view : public view_interface<owning_view<_Rp>> {
+ _Rp __r_ = _Rp();
+
+public:
+ owning_view() requires default_initializable<_Rp> = default;
+ _LIBCPP_HIDE_FROM_ABI constexpr owning_view(_Rp&& __r) : __r_(std::move(__r)) {}
+
+ owning_view(owning_view&&) = default;
+ owning_view& operator=(owning_view&&) = default;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr _Rp& base() & noexcept { return __r_; }
+ _LIBCPP_HIDE_FROM_ABI constexpr const _Rp& base() const& noexcept { return __r_; }
+ _LIBCPP_HIDE_FROM_ABI constexpr _Rp&& base() && noexcept { return std::move(__r_); }
+ _LIBCPP_HIDE_FROM_ABI constexpr const _Rp&& base() const&& noexcept { return std::move(__r_); }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_Rp> begin() { return ranges::begin(__r_); }
+ _LIBCPP_HIDE_FROM_ABI constexpr sentinel_t<_Rp> end() { return ranges::end(__r_); }
+ _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const requires range<const _Rp> { return ranges::begin(__r_); }
+ _LIBCPP_HIDE_FROM_ABI constexpr auto end() const requires range<const _Rp> { return ranges::end(__r_); }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr bool empty() requires requires { ranges::empty(__r_); }
+ { return ranges::empty(__r_); }
+ _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const requires requires { ranges::empty(__r_); }
+ { return ranges::empty(__r_); }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto size() requires sized_range<_Rp>
+ { return ranges::size(__r_); }
+ _LIBCPP_HIDE_FROM_ABI constexpr auto size() const requires sized_range<const _Rp>
+ { return ranges::size(__r_); }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto data() requires contiguous_range<_Rp>
+ { return ranges::data(__r_); }
+ _LIBCPP_HIDE_FROM_ABI constexpr auto data() const requires contiguous_range<const _Rp>
+ { return ranges::data(__r_); }
+ };
+
+ template<class _Tp>
+ inline constexpr bool enable_borrowed_range<owning_view<_Tp>> = enable_borrowed_range<_Tp>;
+
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_OWNING_VIEW_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/range_adaptor.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/range_adaptor.h
new file mode 100644
index 0000000000..9c53488ba6
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/range_adaptor.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___RANGES_RANGE_ADAPTOR_H
+#define _LIBCPP___RANGES_RANGE_ADAPTOR_H
+
+#include <__config>
+#include <__functional/compose.h>
+#include <__functional/invoke.h>
+#include <__ranges/concepts.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include <concepts>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+// CRTP base that one can derive from in order to be considered a range adaptor closure
+// by the library. When deriving from this class, a pipe operator will be provided to
+// make the following hold:
+// - `x | f` is equivalent to `f(x)`
+// - `f1 | f2` is an adaptor closure `g` such that `g(x)` is equivalent to `f2(f1(x))`
+template <class _Tp>
+struct __range_adaptor_closure;
+
+// Type that wraps an arbitrary function object and makes it into a range adaptor closure,
+// i.e. something that can be called via the `x | f` notation.
+template <class _Fn>
+struct __range_adaptor_closure_t : _Fn, __range_adaptor_closure<__range_adaptor_closure_t<_Fn>> {
+ constexpr explicit __range_adaptor_closure_t(_Fn&& __f) : _Fn(std::move(__f)) { }
+};
+
+template <class _Tp>
+concept _RangeAdaptorClosure = derived_from<remove_cvref_t<_Tp>, __range_adaptor_closure<remove_cvref_t<_Tp>>>;
+
+template <class _Tp>
+struct __range_adaptor_closure {
+ template <ranges::viewable_range _View, _RangeAdaptorClosure _Closure>
+ requires same_as<_Tp, remove_cvref_t<_Closure>> &&
+ invocable<_Closure, _View>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ friend constexpr decltype(auto) operator|(_View&& __view, _Closure&& __closure)
+ noexcept(is_nothrow_invocable_v<_Closure, _View>)
+ { return std::invoke(std::forward<_Closure>(__closure), std::forward<_View>(__view)); }
+
+ template <_RangeAdaptorClosure _Closure, _RangeAdaptorClosure _OtherClosure>
+ requires same_as<_Tp, remove_cvref_t<_Closure>> &&
+ constructible_from<decay_t<_Closure>, _Closure> &&
+ constructible_from<decay_t<_OtherClosure>, _OtherClosure>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ friend constexpr auto operator|(_Closure&& __c1, _OtherClosure&& __c2)
+ noexcept(is_nothrow_constructible_v<decay_t<_Closure>, _Closure> &&
+ is_nothrow_constructible_v<decay_t<_OtherClosure>, _OtherClosure>)
+ { return __range_adaptor_closure_t(std::__compose(std::forward<_OtherClosure>(__c2), std::forward<_Closure>(__c1))); }
+};
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_RANGE_ADAPTOR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/rbegin.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/rbegin.h
new file mode 100644
index 0000000000..20f5489c50
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/rbegin.h
@@ -0,0 +1,130 @@
+// -*- 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_RBEGIN_H
+#define _LIBCPP___RANGES_RBEGIN_H
+
+#include <__concepts/class_or_enum.h>
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/readable_traits.h>
+#include <__iterator/reverse_iterator.h>
+#include <__ranges/access.h>
+#include <__utility/auto_cast.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+// [ranges.access.rbegin]
+
+namespace ranges {
+namespace __rbegin {
+template <class _Tp>
+concept __member_rbegin =
+ __can_borrow<_Tp> &&
+ __workaround_52970<_Tp> &&
+ requires(_Tp&& __t) {
+ { _LIBCPP_AUTO_CAST(__t.rbegin()) } -> input_or_output_iterator;
+ };
+
+void rbegin(auto&) = delete;
+void rbegin(const auto&) = delete;
+
+template <class _Tp>
+concept __unqualified_rbegin =
+ !__member_rbegin<_Tp> &&
+ __can_borrow<_Tp> &&
+ __class_or_enum<remove_cvref_t<_Tp>> &&
+ requires(_Tp&& __t) {
+ { _LIBCPP_AUTO_CAST(rbegin(__t)) } -> input_or_output_iterator;
+ };
+
+template <class _Tp>
+concept __can_reverse =
+ __can_borrow<_Tp> &&
+ !__member_rbegin<_Tp> &&
+ !__unqualified_rbegin<_Tp> &&
+ requires(_Tp&& __t) {
+ { ranges::begin(__t) } -> same_as<decltype(ranges::end(__t))>;
+ { ranges::begin(__t) } -> bidirectional_iterator;
+ };
+
+struct __fn {
+ template <class _Tp>
+ requires __member_rbegin<_Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.rbegin())))
+ {
+ return _LIBCPP_AUTO_CAST(__t.rbegin());
+ }
+
+ template <class _Tp>
+ requires __unqualified_rbegin<_Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(_LIBCPP_AUTO_CAST(rbegin(__t))))
+ {
+ return _LIBCPP_AUTO_CAST(rbegin(__t));
+ }
+
+ template <class _Tp>
+ requires __can_reverse<_Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(ranges::end(__t)))
+ {
+ return std::make_reverse_iterator(ranges::end(__t));
+ }
+
+ void operator()(auto&&) const = delete;
+};
+} // namespace __rbegin
+
+inline namespace __cpo {
+ inline constexpr auto rbegin = __rbegin::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+// [range.access.crbegin]
+
+namespace ranges {
+namespace __crbegin {
+struct __fn {
+ template <class _Tp>
+ requires is_lvalue_reference_v<_Tp&&>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(ranges::rbegin(static_cast<const remove_reference_t<_Tp>&>(__t))))
+ -> decltype( ranges::rbegin(static_cast<const remove_reference_t<_Tp>&>(__t)))
+ { return ranges::rbegin(static_cast<const remove_reference_t<_Tp>&>(__t)); }
+
+ template <class _Tp>
+ requires is_rvalue_reference_v<_Tp&&>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(ranges::rbegin(static_cast<const _Tp&&>(__t))))
+ -> decltype( ranges::rbegin(static_cast<const _Tp&&>(__t)))
+ { return ranges::rbegin(static_cast<const _Tp&&>(__t)); }
+};
+} // namespace __crbegin
+
+inline namespace __cpo {
+ inline constexpr auto crbegin = __crbegin::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_RBEGIN_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/ref_view.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/ref_view.h
new file mode 100644
index 0000000000..255a468606
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/ref_view.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_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/enable_borrowed_range.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <__utility/forward.h>
+#include <concepts>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_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_(std::addressof(static_cast<_Range&>(std::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>;
+
+ template<class _Tp>
+ inline constexpr bool enable_borrowed_range<ref_view<_Tp>> = true;
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_REF_VIEW_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/rend.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/rend.h
new file mode 100644
index 0000000000..4f1597e073
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/rend.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___RANGES_REND_H
+#define _LIBCPP___RANGES_REND_H
+
+#include <__concepts/class_or_enum.h>
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/readable_traits.h>
+#include <__iterator/reverse_iterator.h>
+#include <__ranges/access.h>
+#include <__ranges/rbegin.h>
+#include <__utility/auto_cast.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+// [range.access.rend]
+
+namespace ranges {
+namespace __rend {
+template <class _Tp>
+concept __member_rend =
+ __can_borrow<_Tp> &&
+ __workaround_52970<_Tp> &&
+ requires(_Tp&& __t) {
+ ranges::rbegin(__t);
+ { _LIBCPP_AUTO_CAST(__t.rend()) } -> sentinel_for<decltype(ranges::rbegin(__t))>;
+ };
+
+void rend(auto&) = delete;
+void rend(const auto&) = delete;
+
+template <class _Tp>
+concept __unqualified_rend =
+ !__member_rend<_Tp> &&
+ __can_borrow<_Tp> &&
+ __class_or_enum<remove_cvref_t<_Tp>> &&
+ requires(_Tp&& __t) {
+ ranges::rbegin(__t);
+ { _LIBCPP_AUTO_CAST(rend(__t)) } -> sentinel_for<decltype(ranges::rbegin(__t))>;
+ };
+
+template <class _Tp>
+concept __can_reverse =
+ __can_borrow<_Tp> &&
+ !__member_rend<_Tp> &&
+ !__unqualified_rend<_Tp> &&
+ requires(_Tp&& __t) {
+ { ranges::begin(__t) } -> same_as<decltype(ranges::end(__t))>;
+ { ranges::begin(__t) } -> bidirectional_iterator;
+ };
+
+class __fn {
+public:
+ template <class _Tp>
+ requires __member_rend<_Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.rend())))
+ {
+ return _LIBCPP_AUTO_CAST(__t.rend());
+ }
+
+ template <class _Tp>
+ requires __unqualified_rend<_Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(_LIBCPP_AUTO_CAST(rend(__t))))
+ {
+ return _LIBCPP_AUTO_CAST(rend(__t));
+ }
+
+ template <class _Tp>
+ requires __can_reverse<_Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(ranges::begin(__t)))
+ {
+ return std::make_reverse_iterator(ranges::begin(__t));
+ }
+
+ void operator()(auto&&) const = delete;
+};
+} // namespace __rend
+
+inline namespace __cpo {
+ inline constexpr auto rend = __rend::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+// [range.access.crend]
+
+namespace ranges {
+namespace __crend {
+struct __fn {
+ template <class _Tp>
+ requires is_lvalue_reference_v<_Tp&&>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(ranges::rend(static_cast<const remove_reference_t<_Tp>&>(__t))))
+ -> decltype( ranges::rend(static_cast<const remove_reference_t<_Tp>&>(__t)))
+ { return ranges::rend(static_cast<const remove_reference_t<_Tp>&>(__t)); }
+
+ template <class _Tp>
+ requires is_rvalue_reference_v<_Tp&&>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(ranges::rend(static_cast<const _Tp&&>(__t))))
+ -> decltype( ranges::rend(static_cast<const _Tp&&>(__t)))
+ { return ranges::rend(static_cast<const _Tp&&>(__t)); }
+};
+} // namespace __crend
+
+inline namespace __cpo {
+ inline constexpr auto crend = __crend::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_REND_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/reverse_view.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/reverse_view.h
new file mode 100644
index 0000000000..c3ab6261f0
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/reverse_view.h
@@ -0,0 +1,190 @@
+// -*- 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_REVERSE_VIEW_H
+#define _LIBCPP___RANGES_REVERSE_VIEW_H
+
+#include <__concepts/constructible.h>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/next.h>
+#include <__iterator/reverse_iterator.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/range_adaptor.h>
+#include <__ranges/size.h>
+#include <__ranges/subrange.h>
+#include <__ranges/view_interface.h>
+#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_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+namespace ranges {
+ template<view _View>
+ requires bidirectional_range<_View>
+ class reverse_view : public view_interface<reverse_view<_View>> {
+ // We cache begin() whenever ranges::next is not guaranteed O(1) to provide an
+ // amortized O(1) begin() method.
+ static constexpr bool _UseCache = !random_access_range<_View> && !common_range<_View>;
+ using _Cache = _If<_UseCache, __non_propagating_cache<reverse_iterator<iterator_t<_View>>>, __empty_cache>;
+ _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cached_begin_ = _Cache();
+ _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
+
+ public:
+ _LIBCPP_HIDE_FROM_ABI
+ reverse_view() requires default_initializable<_View> = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit reverse_view(_View __view) : __base_(std::move(__view)) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _View base() const& requires copy_constructible<_View> { return __base_; }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _View base() && { return std::move(__base_); }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr reverse_iterator<iterator_t<_View>> begin() {
+ if constexpr (_UseCache)
+ if (__cached_begin_.__has_value())
+ return *__cached_begin_;
+
+ auto __tmp = std::make_reverse_iterator(ranges::next(ranges::begin(__base_), ranges::end(__base_)));
+ if constexpr (_UseCache)
+ __cached_begin_.__emplace(__tmp);
+ return __tmp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr reverse_iterator<iterator_t<_View>> begin() requires common_range<_View> {
+ return std::make_reverse_iterator(ranges::end(__base_));
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto begin() const requires common_range<const _View> {
+ return std::make_reverse_iterator(ranges::end(__base_));
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr reverse_iterator<iterator_t<_View>> end() {
+ return std::make_reverse_iterator(ranges::begin(__base_));
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto end() const requires common_range<const _View> {
+ return std::make_reverse_iterator(ranges::begin(__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>
+ reverse_view(_Range&&) -> reverse_view<views::all_t<_Range>>;
+
+ template<class _Tp>
+ inline constexpr bool enable_borrowed_range<reverse_view<_Tp>> = enable_borrowed_range<_Tp>;
+
+ namespace views {
+ namespace __reverse {
+ template<class _Tp>
+ constexpr bool __is_reverse_view = false;
+
+ template<class _Tp>
+ constexpr bool __is_reverse_view<reverse_view<_Tp>> = true;
+
+ template<class _Tp>
+ constexpr bool __is_sized_reverse_subrange = false;
+
+ template<class _Iter>
+ constexpr bool __is_sized_reverse_subrange<subrange<reverse_iterator<_Iter>, reverse_iterator<_Iter>, subrange_kind::sized>> = true;
+
+ template<class _Tp>
+ constexpr bool __is_unsized_reverse_subrange = false;
+
+ template<class _Iter, subrange_kind _Kind>
+ constexpr bool __is_unsized_reverse_subrange<subrange<reverse_iterator<_Iter>, reverse_iterator<_Iter>, _Kind>> = _Kind == subrange_kind::unsized;
+
+ template<class _Tp>
+ struct __unwrapped_reverse_subrange {
+ using type = void; // avoid SFINAE-ing out the overload below -- let the concept requirements do it for better diagnostics
+ };
+
+ template<class _Iter, subrange_kind _Kind>
+ struct __unwrapped_reverse_subrange<subrange<reverse_iterator<_Iter>, reverse_iterator<_Iter>, _Kind>> {
+ using type = subrange<_Iter, _Iter, _Kind>;
+ };
+
+ struct __fn : __range_adaptor_closure<__fn> {
+ template<class _Range>
+ requires __is_reverse_view<remove_cvref_t<_Range>>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Range&& __range) const
+ noexcept(noexcept(std::forward<_Range>(__range).base()))
+ -> decltype( std::forward<_Range>(__range).base())
+ { return std::forward<_Range>(__range).base(); }
+
+ template<class _Range,
+ class _UnwrappedSubrange = typename __unwrapped_reverse_subrange<remove_cvref_t<_Range>>::type>
+ requires __is_sized_reverse_subrange<remove_cvref_t<_Range>>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Range&& __range) const
+ noexcept(noexcept(_UnwrappedSubrange(__range.end().base(), __range.begin().base(), __range.size())))
+ -> decltype( _UnwrappedSubrange(__range.end().base(), __range.begin().base(), __range.size()))
+ { return _UnwrappedSubrange(__range.end().base(), __range.begin().base(), __range.size()); }
+
+ template<class _Range,
+ class _UnwrappedSubrange = typename __unwrapped_reverse_subrange<remove_cvref_t<_Range>>::type>
+ requires __is_unsized_reverse_subrange<remove_cvref_t<_Range>>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Range&& __range) const
+ noexcept(noexcept(_UnwrappedSubrange(__range.end().base(), __range.begin().base())))
+ -> decltype( _UnwrappedSubrange(__range.end().base(), __range.begin().base()))
+ { return _UnwrappedSubrange(__range.end().base(), __range.begin().base()); }
+
+ template<class _Range>
+ requires (!__is_reverse_view<remove_cvref_t<_Range>> &&
+ !__is_sized_reverse_subrange<remove_cvref_t<_Range>> &&
+ !__is_unsized_reverse_subrange<remove_cvref_t<_Range>>)
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Range&& __range) const
+ noexcept(noexcept(reverse_view{std::forward<_Range>(__range)}))
+ -> decltype( reverse_view{std::forward<_Range>(__range)})
+ { return reverse_view{std::forward<_Range>(__range)}; }
+ };
+ } // namespace __reverse
+
+ inline namespace __cpo {
+ inline constexpr auto reverse = __reverse::__fn{};
+ } // namespace __cpo
+ } // namespace views
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_REVERSE_VIEW_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/single_view.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/single_view.h
new file mode 100644
index 0000000000..e0fd4849f4
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/single_view.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___RANGES_SINGLE_VIEW_H
+#define _LIBCPP___RANGES_SINGLE_VIEW_H
+
+#include <__config>
+#include <__ranges/copyable_box.h>
+#include <__ranges/view_interface.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include <concepts>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+namespace ranges {
+ template<copy_constructible _Tp>
+ requires is_object_v<_Tp>
+ class single_view : public view_interface<single_view<_Tp>> {
+ __copyable_box<_Tp> __value_;
+
+ public:
+ _LIBCPP_HIDE_FROM_ABI
+ single_view() requires default_initializable<_Tp> = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit single_view(const _Tp& __t) : __value_(in_place, __t) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit single_view(_Tp&& __t) : __value_(in_place, std::move(__t)) {}
+
+ template<class... _Args>
+ requires constructible_from<_Tp, _Args...>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit single_view(in_place_t, _Args&&... __args)
+ : __value_{in_place, std::forward<_Args>(__args)...} {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _Tp* begin() noexcept { return data(); }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr const _Tp* begin() const noexcept { return data(); }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _Tp* end() noexcept { return data() + 1; }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr const _Tp* end() const noexcept { return data() + 1; }
+
+ _LIBCPP_HIDE_FROM_ABI
+ static constexpr size_t size() noexcept { return 1; }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _Tp* data() noexcept { return __value_.operator->(); }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr const _Tp* data() const noexcept { return __value_.operator->(); }
+ };
+
+ template<class _Tp>
+ single_view(_Tp) -> single_view<_Tp>;
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_SINGLE_VIEW_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/size.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/size.h
new file mode 100644
index 0000000000..2c5a96e63b
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/size.h
@@ -0,0 +1,135 @@
+// -*- 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 <__concepts/class_or_enum.h>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__ranges/access.h>
+#include <__utility/auto_cast.h>
+#include <concepts>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+namespace ranges {
+ template<class>
+ inline constexpr bool disable_sized_range = false;
+} // namespace ranges
+
+// [range.prim.size]
+
+namespace ranges {
+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> &&
+ __workaround_52970<_Tp> &&
+ requires(_Tp&& __t) {
+ { _LIBCPP_AUTO_CAST(__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) {
+ { _LIBCPP_AUTO_CAST(size(__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(_LIBCPP_AUTO_CAST(__t.size()))) {
+ return _LIBCPP_AUTO_CAST(__t.size());
+ }
+
+ template <__unqualified_size _Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __integer_like auto operator()(_Tp&& __t) const
+ noexcept(noexcept(_LIBCPP_AUTO_CAST(size(__t)))) {
+ return _LIBCPP_AUTO_CAST(size(__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 std::__to_unsigned_like(ranges::end(__t) - ranges::begin(__t));
+ }
+ };
+} // namespace __size
+
+inline namespace __cpo {
+ inline constexpr auto size = __size::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+// [range.prim.ssize]
+
+namespace ranges {
+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));
+ }
+ };
+} // namespace __ssize
+
+inline namespace __cpo {
+ inline constexpr auto ssize = __ssize::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_SIZE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/subrange.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/subrange.h
new file mode 100644
index 0000000000..c54f7710fc
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/subrange.h
@@ -0,0 +1,289 @@
+// -*- 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 <__assert>
+#include <__concepts/constructible.h>
+#include <__concepts/convertible_to.h>
+#include <__concepts/copyable.h>
+#include <__concepts/derived_from.h>
+#include <__concepts/different_from.h>
+#include <__config>
+#include <__iterator/advance.h>
+#include <__iterator/concepts.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iterator_traits.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 <__tuple>
+#include <__utility/move.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+namespace ranges {
+ template<class _From, class _To>
+ concept __uses_nonqualification_pointer_conversion =
+ is_pointer_v<_From> && is_pointer_v<_To> &&
+ !convertible_to<remove_pointer_t<_From>(*)[], remove_pointer_t<_To>(*)[]>;
+
+ template<class _From, class _To>
+ concept __convertible_to_non_slicing =
+ convertible_to<_From, _To> &&
+ !__uses_nonqualification_pointer_conversion<decay_t<_From>, 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>>;
+ { std::get<0>(__t) } -> convertible_to<const tuple_element_t<0, _Tp>&>;
+ { std::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<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>)
+ class _LIBCPP_TEMPLATE_VIS subrange
+ : public view_interface<subrange<_Iter, _Sent, _Kind>>
+ {
+ private:
+ static constexpr bool _StoreSize = (_Kind == subrange_kind::sized && !sized_sentinel_for<_Sent, _Iter>);
+ static constexpr bool _MustProvideSizeAtConstruction = !_StoreSize; // just to improve compiler diagnostics
+ struct _Empty { constexpr _Empty(auto) noexcept { } };
+ using _Size = conditional_t<_StoreSize, make_unsigned_t<iter_difference_t<_Iter>>, _Empty>;
+ _LIBCPP_NO_UNIQUE_ADDRESS _Iter __begin_ = _Iter();
+ _LIBCPP_NO_UNIQUE_ADDRESS _Sent __end_ = _Sent();
+ _LIBCPP_NO_UNIQUE_ADDRESS _Size __size_ = 0;
+
+ public:
+ _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 _MustProvideSizeAtConstruction
+ : __begin_(std::move(__iter)), __end_(std::move(__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)
+ : __begin_(std::move(__iter)), __end_(std::move(__sent)), __size_(__n)
+ {
+ if constexpr (sized_sentinel_for<_Sent, _Iter>)
+ _LIBCPP_ASSERT((__end_ - __begin_) == static_cast<iter_difference_t<_Iter>>(__n),
+ "std::ranges::subrange was passed an invalid size hint");
+ }
+
+ 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 (!_StoreSize)
+ : 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 _StoreSize && 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(__begin_, __end_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _Iter begin() const requires copyable<_Iter> {
+ return __begin_;
+ }
+
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Iter begin() requires (!copyable<_Iter>) {
+ return std::move(__begin_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _Sent end() const {
+ return __end_;
+ }
+
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const {
+ return __begin_ == __end_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr make_unsigned_t<iter_difference_t<_Iter>> size() const
+ requires (_Kind == subrange_kind::sized)
+ {
+ if constexpr (_StoreSize)
+ return __size_;
+ else
+ return std::__to_unsigned_like(__end_ - __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 std::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(__begin_, __n);
+ if constexpr (_StoreSize)
+ __size_ += std::__to_unsigned_like(-__n);
+ return *this;
+ }
+ }
+
+ auto __d = __n - ranges::advance(__begin_, __n, __end_);
+ if constexpr (_StoreSize)
+ __size_ -= std::__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 == 0 && copyable<_Iter>) || _Index == 1)
+ _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
+
+// [range.subrange.general]
+
+using ranges::get;
+
+// [ranges.syn]
+
+template<class _Ip, class _Sp, ranges::subrange_kind _Kp>
+struct tuple_size<ranges::subrange<_Ip, _Sp, _Kp>> : integral_constant<size_t, 2> {};
+
+template<class _Ip, class _Sp, ranges::subrange_kind _Kp>
+struct tuple_element<0, ranges::subrange<_Ip, _Sp, _Kp>> {
+ using type = _Ip;
+};
+
+template<class _Ip, class _Sp, ranges::subrange_kind _Kp>
+struct tuple_element<1, ranges::subrange<_Ip, _Sp, _Kp>> {
+ using type = _Sp;
+};
+
+template<class _Ip, class _Sp, ranges::subrange_kind _Kp>
+struct tuple_element<0, const ranges::subrange<_Ip, _Sp, _Kp>> {
+ using type = _Ip;
+};
+
+template<class _Ip, class _Sp, ranges::subrange_kind _Kp>
+struct tuple_element<1, const ranges::subrange<_Ip, _Sp, _Kp>> {
+ using type = _Sp;
+};
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_SUBRANGE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/take_view.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/take_view.h
new file mode 100644
index 0000000000..b5f194f9a0
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/take_view.h
@@ -0,0 +1,185 @@
+// -*- 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_TAKE_VIEW_H
+#define _LIBCPP___RANGES_TAKE_VIEW_H
+
+#include <__algorithm/min.h>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/counted_iterator.h>
+#include <__iterator/default_sentinel.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 <__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_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+namespace ranges {
+ template<view _View>
+ class take_view : public view_interface<take_view<_View>> {
+ _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
+ range_difference_t<_View> __count_ = 0;
+
+ template<bool> class __sentinel;
+
+ public:
+ _LIBCPP_HIDE_FROM_ABI
+ take_view() requires default_initializable<_View> = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr take_view(_View __base, range_difference_t<_View> __count)
+ : __base_(std::move(__base)), __count_(__count) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _View base() const& requires copy_constructible<_View> { return __base_; }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _View base() && { return std::move(__base_); }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto begin() requires (!__simple_view<_View>) {
+ if constexpr (sized_range<_View>) {
+ if constexpr (random_access_range<_View>) {
+ return ranges::begin(__base_);
+ } else {
+ using _DifferenceT = range_difference_t<_View>;
+ auto __size = size();
+ return counted_iterator(ranges::begin(__base_), static_cast<_DifferenceT>(__size));
+ }
+ } else {
+ return counted_iterator(ranges::begin(__base_), __count_);
+ }
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto begin() const requires range<const _View> {
+ if constexpr (sized_range<const _View>) {
+ if constexpr (random_access_range<const _View>) {
+ return ranges::begin(__base_);
+ } else {
+ using _DifferenceT = range_difference_t<const _View>;
+ auto __size = size();
+ return counted_iterator(ranges::begin(__base_), static_cast<_DifferenceT>(__size));
+ }
+ } else {
+ return counted_iterator(ranges::begin(__base_), __count_);
+ }
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto end() requires (!__simple_view<_View>) {
+ if constexpr (sized_range<_View>) {
+ if constexpr (random_access_range<_View>) {
+ return ranges::begin(__base_) + size();
+ } else {
+ return default_sentinel;
+ }
+ } else {
+ return __sentinel<false>{ranges::end(__base_)};
+ }
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto end() const requires range<const _View> {
+ if constexpr (sized_range<const _View>) {
+ if constexpr (random_access_range<const _View>) {
+ return ranges::begin(__base_) + size();
+ } else {
+ return default_sentinel;
+ }
+ } else {
+ return __sentinel<true>{ranges::end(__base_)};
+ }
+ }
+
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto size() requires sized_range<_View> {
+ auto __n = ranges::size(__base_);
+ // TODO: use ranges::min here.
+ return std::min(__n, static_cast<decltype(__n)>(__count_));
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto size() const requires sized_range<const _View> {
+ auto __n = ranges::size(__base_);
+ // TODO: use ranges::min here.
+ return std::min(__n, static_cast<decltype(__n)>(__count_));
+ }
+ };
+
+ template<view _View>
+ template<bool _Const>
+ class take_view<_View>::__sentinel {
+ using _Base = __maybe_const<_Const, _View>;
+ template<bool _OtherConst>
+ using _Iter = counted_iterator<iterator_t<__maybe_const<_OtherConst, _View>>>;
+ _LIBCPP_NO_UNIQUE_ADDRESS sentinel_t<_Base> __end_ = sentinel_t<_Base>();
+
+ template<bool>
+ friend class take_view<_View>::__sentinel;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI
+ __sentinel() = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit __sentinel(sentinel_t<_Base> __end) : __end_(std::move(__end)) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __sentinel(__sentinel<!_Const> __s)
+ requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>>
+ : __end_(std::move(__s.__end_)) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr sentinel_t<_Base> base() const { return __end_; }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator==(const _Iter<_Const>& __lhs, const __sentinel& __rhs) {
+ return __lhs.count() == 0 || __lhs.base() == __rhs.__end_;
+ }
+
+ template<bool _OtherConst = !_Const>
+ requires sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator==(const _Iter<_Const>& __lhs, const __sentinel& __rhs) {
+ return __lhs.count() == 0 || __lhs.base() == __rhs.__end_;
+ }
+ };
+
+ template<class _Range>
+ take_view(_Range&&, range_difference_t<_Range>) -> take_view<views::all_t<_Range>>;
+
+ template<class _Tp>
+ inline constexpr bool enable_borrowed_range<take_view<_Tp>> = enable_borrowed_range<_Tp>;
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANGES_TAKE_VIEW_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/transform_view.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/transform_view.h
new file mode 100644
index 0000000000..4cc582faeb
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/transform_view.h
@@ -0,0 +1,440 @@
+// -*- 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 <__compare/three_way_comparable.h>
+#include <__concepts/constructible.h>
+#include <__concepts/convertible_to.h>
+#include <__concepts/copyable.h>
+#include <__concepts/derived_from.h>
+#include <__concepts/equality_comparable.h>
+#include <__concepts/invocable.h>
+#include <__config>
+#include <__functional/bind_back.h>
+#include <__functional/invoke.h>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__memory/addressof.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/copyable_box.h>
+#include <__ranges/empty.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+namespace ranges {
+
+template<class _Fn, class _View>
+concept __regular_invocable_with_range_ref =
+ regular_invocable<_Fn, range_reference_t<_View>>;
+
+template<class _View, class _Fn>
+concept __transform_view_constraints =
+ view<_View> && is_object_v<_Fn> &&
+ regular_invocable<_Fn&, range_reference_t<_View>> &&
+ __can_reference<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;
+
+ _LIBCPP_NO_UNIQUE_ADDRESS __copyable_box<_Fn> __func_;
+ _LIBCPP_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_(std::in_place, std::move(__func)), __base_(std::move(__base)) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _View base() const& requires copy_constructible<_View> { return __base_; }
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _View base() && { return std::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_with_range_ref<const _Fn&, 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_with_range_ref<const _Fn&, const _View>
+ {
+ return __sentinel<true>(ranges::end(__base_));
+ }
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator<true> end() const
+ requires common_range<const _View> &&
+ __regular_invocable_with_range_ref<const _Fn&, 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_(std::addressof(__parent)), __current_(std::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_(std::move(__i.__current_)) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr const iterator_t<_Base>& base() const& noexcept {
+ return __current_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr iterator_t<_Base> base() && {
+ return std::move(__current_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr decltype(auto) operator*() const
+ noexcept(noexcept(std::invoke(*__parent_->__func_, *__current_)))
+ {
+ return std::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(std::invoke(*__parent_->__func_, __current_[__n])))
+ requires random_access_range<_Base>
+ {
+ return std::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_;
+ }
+
+ _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 std::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_(std::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 views {
+namespace __transform {
+ struct __fn {
+ template<class _Range, class _Fn>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Range&& __range, _Fn&& __f) const
+ noexcept(noexcept(transform_view(std::forward<_Range>(__range), std::forward<_Fn>(__f))))
+ -> decltype( transform_view(std::forward<_Range>(__range), std::forward<_Fn>(__f)))
+ { return transform_view(std::forward<_Range>(__range), std::forward<_Fn>(__f)); }
+
+ template<class _Fn>
+ requires constructible_from<decay_t<_Fn>, _Fn>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Fn&& __f) const
+ noexcept(is_nothrow_constructible_v<decay_t<_Fn>, _Fn>)
+ { return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Fn>(__f))); }
+ };
+} // namespace __transform
+
+inline namespace __cpo {
+ inline constexpr auto transform = __transform::__fn{};
+} // namespace __cpo
+} // namespace views
+
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_TRANSFORM_VIEW_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/view_interface.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/view_interface.h
new file mode 100644
index 0000000000..eecc475111
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/view_interface.h
@@ -0,0 +1,174 @@
+// -*- 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 <__assert>
+#include <__concepts/derived_from.h>
+#include <__concepts/same_as.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 <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+namespace ranges {
+
+template<class _Derived>
+ requires is_class_v<_Derived> && same_as<_Derived, remove_cv_t<_Derived>>
+class view_interface {
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _Derived& __derived() noexcept {
+ static_assert(sizeof(_Derived) && derived_from<_Derived, view_interface> && view<_Derived>);
+ return static_cast<_Derived&>(*this);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _Derived const& __derived() const noexcept {
+ static_assert(sizeof(_Derived) && derived_from<_Derived, view_interface> && view<_Derived>);
+ return static_cast<_Derived const&>(*this);
+ }
+
+public:
+ template<class _D2 = _Derived>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty()
+ requires forward_range<_D2>
+ {
+ return ranges::begin(__derived()) == ranges::end(__derived());
+ }
+
+ template<class _D2 = _Derived>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const
+ requires forward_range<const _D2>
+ {
+ return ranges::begin(__derived()) == ranges::end(__derived());
+ }
+
+ template<class _D2 = _Derived>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit operator bool()
+ requires requires (_D2& __t) { ranges::empty(__t); }
+ {
+ return !ranges::empty(__derived());
+ }
+
+ template<class _D2 = _Derived>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit operator bool() const
+ requires requires (const _D2& __t) { ranges::empty(__t); }
+ {
+ return !ranges::empty(__derived());
+ }
+
+ template<class _D2 = _Derived>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto data()
+ requires contiguous_iterator<iterator_t<_D2>>
+ {
+ return std::to_address(ranges::begin(__derived()));
+ }
+
+ template<class _D2 = _Derived>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto data() const
+ requires range<const _D2> && contiguous_iterator<iterator_t<const _D2>>
+ {
+ return std::to_address(ranges::begin(__derived()));
+ }
+
+ template<class _D2 = _Derived>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto size()
+ 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
+ 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()
+ 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
+ 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()
+ 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
+ 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)
+ {
+ 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
+ {
+ return ranges::begin(__derived())[__index];
+ }
+};
+
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_VIEW_INTERFACE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/views.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/views.h
new file mode 100644
index 0000000000..8cc5ba3d2a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__ranges/views.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___RANGES_VIEWS
+#define _LIBCPP___RANGES_VIEWS
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+namespace ranges {
+
+namespace views { }
+
+} // namespace ranges
+
+namespace views = ranges::views;
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_VIEWS
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__split_buffer b/contrib/libs/cxxsupp/libcxxmsvc/include/__split_buffer
new file mode 100644
index 0000000000..dd789e8e9d
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__split_buffer
@@ -0,0 +1,636 @@
+// -*- C++ -*-
+#ifndef _LIBCPP_SPLIT_BUFFER
+#define _LIBCPP_SPLIT_BUFFER
+
+#include <__algorithm/max.h>
+#include <__algorithm/move.h>
+#include <__algorithm/move_backward.h>
+#include <__config>
+#include <__iterator/distance.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/move_iterator.h>
+#include <__memory/allocator.h>
+#include <__memory/compressed_pair.h>
+#include <__utility/forward.h>
+#include <memory>
+#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 = allocator<_Tp> >
+struct __split_buffer
+{
+private:
+ __split_buffer(const __split_buffer&);
+ __split_buffer& operator=(const __split_buffer&);
+public:
+ typedef _Tp value_type;
+ typedef _Allocator allocator_type;
+ typedef typename remove_reference<allocator_type>::type __alloc_rr;
+ typedef allocator_traits<__alloc_rr> __alloc_traits;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef typename __alloc_traits::size_type size_type;
+ typedef typename __alloc_traits::difference_type difference_type;
+ typedef typename __alloc_traits::pointer pointer;
+ typedef typename __alloc_traits::const_pointer const_pointer;
+ typedef pointer iterator;
+ typedef const_pointer const_iterator;
+
+ pointer __first_;
+ pointer __begin_;
+ pointer __end_;
+ __compressed_pair<pointer, allocator_type> __end_cap_;
+
+ typedef typename add_lvalue_reference<allocator_type>::type __alloc_ref;
+ typedef typename add_lvalue_reference<allocator_type>::type __alloc_const_ref;
+
+ _LIBCPP_INLINE_VISIBILITY __alloc_rr& __alloc() _NOEXCEPT {return __end_cap_.second();}
+ _LIBCPP_INLINE_VISIBILITY const __alloc_rr& __alloc() const _NOEXCEPT {return __end_cap_.second();}
+ _LIBCPP_INLINE_VISIBILITY pointer& __end_cap() _NOEXCEPT {return __end_cap_.first();}
+ _LIBCPP_INLINE_VISIBILITY const pointer& __end_cap() const _NOEXCEPT {return __end_cap_.first();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __split_buffer()
+ _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __split_buffer(__alloc_rr& __a);
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __split_buffer(const __alloc_rr& __a);
+ __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);
+ ~__split_buffer();
+
+ __split_buffer(__split_buffer&& __c)
+ _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
+ __split_buffer(__split_buffer&& __c, const __alloc_rr& __a);
+ __split_buffer& operator=(__split_buffer&& __c)
+ _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&
+ is_nothrow_move_assignable<allocator_type>::value) ||
+ !__alloc_traits::propagate_on_container_move_assignment::value);
+
+ _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return __begin_;}
+ _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return __begin_;}
+ _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT {return __end_;}
+ _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT {return __end_;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void clear() _NOEXCEPT
+ {__destruct_at_end(__begin_);}
+ _LIBCPP_INLINE_VISIBILITY size_type size() const {return static_cast<size_type>(__end_ - __begin_);}
+ _LIBCPP_INLINE_VISIBILITY bool empty() const {return __end_ == __begin_;}
+ _LIBCPP_INLINE_VISIBILITY size_type capacity() const {return static_cast<size_type>(__end_cap() - __first_);}
+ _LIBCPP_INLINE_VISIBILITY size_type __front_spare() const {return static_cast<size_type>(__begin_ - __first_);}
+ _LIBCPP_INLINE_VISIBILITY size_type __back_spare() const {return static_cast<size_type>(__end_cap() - __end_);}
+
+ _LIBCPP_INLINE_VISIBILITY reference front() {return *__begin_;}
+ _LIBCPP_INLINE_VISIBILITY const_reference front() const {return *__begin_;}
+ _LIBCPP_INLINE_VISIBILITY reference back() {return *(__end_ - 1);}
+ _LIBCPP_INLINE_VISIBILITY const_reference back() const {return *(__end_ - 1);}
+
+ void reserve(size_type __n);
+ void shrink_to_fit() _NOEXCEPT;
+ void push_front(const_reference __x);
+ _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
+ void push_front(value_type&& __x);
+ void push_back(value_type&& __x);
+ template <class... _Args>
+ void emplace_back(_Args&&... __args);
+
+ _LIBCPP_INLINE_VISIBILITY void pop_front() {__destruct_at_begin(__begin_+1);}
+ _LIBCPP_INLINE_VISIBILITY void pop_back() {__destruct_at_end(__end_-1);}
+
+ void __uninitialized_at_end(size_type __n);
+ void __construct_at_end(size_type __n);
+ void __construct_at_end(size_type __n, const_reference __x);
+ template <class _InputIter>
+ typename enable_if
+ <
+ __is_cpp17_input_iterator<_InputIter>::value &&
+ !__is_cpp17_forward_iterator<_InputIter>::value,
+ void
+ >::type
+ __construct_at_end(_InputIter __first, _InputIter __last);
+ template <class _ForwardIterator>
+ typename enable_if
+ <
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
+ void
+ >::type
+ __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
+
+ _LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin)
+ {__destruct_at_begin(__new_begin, is_trivially_destructible<value_type>());}
+ _LIBCPP_INLINE_VISIBILITY
+ void __destruct_at_begin(pointer __new_begin, false_type);
+ _LIBCPP_INLINE_VISIBILITY
+ void __destruct_at_begin(pointer __new_begin, true_type);
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __destruct_at_end(pointer __new_last) _NOEXCEPT
+ {__destruct_at_end(__new_last, false_type());}
+ _LIBCPP_INLINE_VISIBILITY
+ void __destruct_at_end(pointer __new_last, false_type) _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ void __destruct_at_end(pointer __new_last, true_type) _NOEXCEPT;
+
+ void swap(__split_buffer& __x)
+ _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||
+ __is_nothrow_swappable<__alloc_rr>::value);
+
+ bool __invariants() const;
+
+private:
+ _LIBCPP_INLINE_VISIBILITY
+ void __move_assign_alloc(__split_buffer& __c, true_type)
+ _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
+ {
+ __alloc() = _VSTD::move(__c.__alloc());
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT
+ {}
+
+ struct _ConstructTransaction {
+ explicit _ConstructTransaction(pointer* __p, size_type __n) _NOEXCEPT
+ : __pos_(*__p), __end_(*__p + __n), __dest_(__p) {
+ }
+ ~_ConstructTransaction() {
+ *__dest_ = __pos_;
+ }
+ pointer __pos_;
+ const pointer __end_;
+ private:
+ pointer *__dest_;
+ };
+};
+
+template <class _Tp, class _Allocator>
+bool
+__split_buffer<_Tp, _Allocator>::__invariants() const
+{
+ if (__first_ == nullptr)
+ {
+ if (__begin_ != nullptr)
+ return false;
+ if (__end_ != nullptr)
+ return false;
+ if (__end_cap() != nullptr)
+ return false;
+ }
+ else
+ {
+ if (__begin_ < __first_)
+ return false;
+ if (__end_ < __begin_)
+ return false;
+ if (__end_cap() < __end_)
+ return false;
+ }
+ return true;
+}
+
+template <class _Tp, class _Allocator>
+void
+__split_buffer<_Tp, _Allocator>::__uninitialized_at_end(size_type __n)
+{
+ this->__end_ += __n;
+}
+
+// Default constructs __n objects starting at __end_
+// throws if construction throws
+// Precondition: __n > 0
+// Precondition: size() + __n <= capacity()
+// Postcondition: size() == size() + __n
+template <class _Tp, class _Allocator>
+void
+__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n)
+{
+ _ConstructTransaction __tx(&this->__end_, __n);
+ for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {
+ __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__tx.__pos_));
+ }
+}
+
+// Copy constructs __n objects starting at __end_ from __x
+// throws if construction throws
+// Precondition: __n > 0
+// Precondition: size() + __n <= capacity()
+// Postcondition: size() == old size() + __n
+// Postcondition: [i] == __x for all i in [size() - __n, __n)
+template <class _Tp, class _Allocator>
+void
+__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
+{
+ _ConstructTransaction __tx(&this->__end_, __n);
+ for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {
+ __alloc_traits::construct(this->__alloc(),
+ _VSTD::__to_address(__tx.__pos_), __x);
+ }
+}
+
+template <class _Tp, class _Allocator>
+template <class _InputIter>
+typename enable_if
+<
+ __is_cpp17_input_iterator<_InputIter>::value &&
+ !__is_cpp17_forward_iterator<_InputIter>::value,
+ void
+>::type
+__split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIter __last)
+{
+ __alloc_rr& __a = this->__alloc();
+ for (; __first != __last; ++__first)
+ {
+ if (__end_ == __end_cap())
+ {
+ size_type __old_cap = __end_cap() - __first_;
+ size_type __new_cap = _VSTD::max<size_type>(2 * __old_cap, 8);
+ __split_buffer __buf(__new_cap, 0, __a);
+ for (pointer __p = __begin_; __p != __end_; ++__p, (void) ++__buf.__end_)
+ __alloc_traits::construct(__buf.__alloc(),
+ _VSTD::__to_address(__buf.__end_), _VSTD::move(*__p));
+ swap(__buf);
+ }
+ __alloc_traits::construct(__a, _VSTD::__to_address(this->__end_), *__first);
+ ++this->__end_;
+ }
+}
+
+template <class _Tp, class _Allocator>
+template <class _ForwardIterator>
+typename enable_if
+<
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
+ void
+>::type
+__split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)
+{
+ _ConstructTransaction __tx(&this->__end_, _VSTD::distance(__first, __last));
+ for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_, (void) ++__first) {
+ __alloc_traits::construct(this->__alloc(),
+ _VSTD::__to_address(__tx.__pos_), *__first);
+ }
+}
+
+template <class _Tp, class _Allocator>
+inline
+void
+__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type)
+{
+ while (__begin_ != __new_begin)
+ __alloc_traits::destroy(__alloc(), _VSTD::__to_address(__begin_++));
+}
+
+template <class _Tp, class _Allocator>
+inline
+void
+__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_type)
+{
+ __begin_ = __new_begin;
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT
+{
+ while (__new_last != __end_)
+ __alloc_traits::destroy(__alloc(), _VSTD::__to_address(--__end_));
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type) _NOEXCEPT
+{
+ __end_ = __new_last;
+}
+
+template <class _Tp, class _Allocator>
+__split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a)
+ : __end_cap_(nullptr, __a)
+{
+ __first_ = __cap != 0 ? __alloc_traits::allocate(__alloc(), __cap) : nullptr;
+ __begin_ = __end_ = __first_ + __start;
+ __end_cap() = __first_ + __cap;
+}
+
+template <class _Tp, class _Allocator>
+inline
+__split_buffer<_Tp, _Allocator>::__split_buffer()
+ _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
+ : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __default_init_tag())
+{
+}
+
+template <class _Tp, class _Allocator>
+inline
+__split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a)
+ : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)
+{
+}
+
+template <class _Tp, class _Allocator>
+inline
+__split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a)
+ : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)
+{
+}
+
+template <class _Tp, class _Allocator>
+__split_buffer<_Tp, _Allocator>::~__split_buffer()
+{
+ clear();
+ if (__first_)
+ __alloc_traits::deallocate(__alloc(), __first_, capacity());
+}
+
+template <class _Tp, class _Allocator>
+__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)
+ _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
+ : __first_(_VSTD::move(__c.__first_)),
+ __begin_(_VSTD::move(__c.__begin_)),
+ __end_(_VSTD::move(__c.__end_)),
+ __end_cap_(_VSTD::move(__c.__end_cap_))
+{
+ __c.__first_ = nullptr;
+ __c.__begin_ = nullptr;
+ __c.__end_ = nullptr;
+ __c.__end_cap() = nullptr;
+}
+
+template <class _Tp, class _Allocator>
+__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __alloc_rr& __a)
+ : __end_cap_(nullptr, __a)
+{
+ if (__a == __c.__alloc())
+ {
+ __first_ = __c.__first_;
+ __begin_ = __c.__begin_;
+ __end_ = __c.__end_;
+ __end_cap() = __c.__end_cap();
+ __c.__first_ = nullptr;
+ __c.__begin_ = nullptr;
+ __c.__end_ = nullptr;
+ __c.__end_cap() = nullptr;
+ }
+ else
+ {
+ size_type __cap = __c.size();
+ __first_ = __alloc_traits::allocate(__alloc(), __cap);
+ __begin_ = __end_ = __first_;
+ __end_cap() = __first_ + __cap;
+ typedef move_iterator<iterator> _Ip;
+ __construct_at_end(_Ip(__c.begin()), _Ip(__c.end()));
+ }
+}
+
+template <class _Tp, class _Allocator>
+__split_buffer<_Tp, _Allocator>&
+__split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)
+ _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&
+ is_nothrow_move_assignable<allocator_type>::value) ||
+ !__alloc_traits::propagate_on_container_move_assignment::value)
+{
+ clear();
+ shrink_to_fit();
+ __first_ = __c.__first_;
+ __begin_ = __c.__begin_;
+ __end_ = __c.__end_;
+ __end_cap() = __c.__end_cap();
+ __move_assign_alloc(__c,
+ integral_constant<bool,
+ __alloc_traits::propagate_on_container_move_assignment::value>());
+ __c.__first_ = __c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr;
+ return *this;
+}
+
+template <class _Tp, class _Allocator>
+void
+__split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)
+ _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||
+ __is_nothrow_swappable<__alloc_rr>::value)
+{
+ _VSTD::swap(__first_, __x.__first_);
+ _VSTD::swap(__begin_, __x.__begin_);
+ _VSTD::swap(__end_, __x.__end_);
+ _VSTD::swap(__end_cap(), __x.__end_cap());
+ _VSTD::__swap_allocator(__alloc(), __x.__alloc());
+}
+
+template <class _Tp, class _Allocator>
+void
+__split_buffer<_Tp, _Allocator>::reserve(size_type __n)
+{
+ if (__n < capacity())
+ {
+ __split_buffer<value_type, __alloc_rr&> __t(__n, 0, __alloc());
+ __t.__construct_at_end(move_iterator<pointer>(__begin_),
+ move_iterator<pointer>(__end_));
+ _VSTD::swap(__first_, __t.__first_);
+ _VSTD::swap(__begin_, __t.__begin_);
+ _VSTD::swap(__end_, __t.__end_);
+ _VSTD::swap(__end_cap(), __t.__end_cap());
+ }
+}
+
+template <class _Tp, class _Allocator>
+void
+__split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
+{
+ if (capacity() > size())
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#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_));
+ __t.__end_ = __t.__begin_ + (__end_ - __begin_);
+ _VSTD::swap(__first_, __t.__first_);
+ _VSTD::swap(__begin_, __t.__begin_);
+ _VSTD::swap(__end_, __t.__end_);
+ _VSTD::swap(__end_cap(), __t.__end_cap());
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ }
+}
+
+template <class _Tp, class _Allocator>
+void
+__split_buffer<_Tp, _Allocator>::push_front(const_reference __x)
+{
+ if (__begin_ == __first_)
+ {
+ if (__end_ < __end_cap())
+ {
+ difference_type __d = __end_cap() - __end_;
+ __d = (__d + 1) / 2;
+ __begin_ = _VSTD::move_backward(__begin_, __end_, __end_ + __d);
+ __end_ += __d;
+ }
+ else
+ {
+ size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
+ __split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, __alloc());
+ __t.__construct_at_end(move_iterator<pointer>(__begin_),
+ move_iterator<pointer>(__end_));
+ _VSTD::swap(__first_, __t.__first_);
+ _VSTD::swap(__begin_, __t.__begin_);
+ _VSTD::swap(__end_, __t.__end_);
+ _VSTD::swap(__end_cap(), __t.__end_cap());
+ }
+ }
+ __alloc_traits::construct(__alloc(), _VSTD::__to_address(__begin_-1), __x);
+ --__begin_;
+}
+
+template <class _Tp, class _Allocator>
+void
+__split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)
+{
+ if (__begin_ == __first_)
+ {
+ if (__end_ < __end_cap())
+ {
+ difference_type __d = __end_cap() - __end_;
+ __d = (__d + 1) / 2;
+ __begin_ = _VSTD::move_backward(__begin_, __end_, __end_ + __d);
+ __end_ += __d;
+ }
+ else
+ {
+ size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
+ __split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, __alloc());
+ __t.__construct_at_end(move_iterator<pointer>(__begin_),
+ move_iterator<pointer>(__end_));
+ _VSTD::swap(__first_, __t.__first_);
+ _VSTD::swap(__begin_, __t.__begin_);
+ _VSTD::swap(__end_, __t.__end_);
+ _VSTD::swap(__end_cap(), __t.__end_cap());
+ }
+ }
+ __alloc_traits::construct(__alloc(), _VSTD::__to_address(__begin_-1),
+ _VSTD::move(__x));
+ --__begin_;
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__split_buffer<_Tp, _Allocator>::push_back(const_reference __x)
+{
+ if (__end_ == __end_cap())
+ {
+ if (__begin_ > __first_)
+ {
+ difference_type __d = __begin_ - __first_;
+ __d = (__d + 1) / 2;
+ __end_ = _VSTD::move(__begin_, __end_, __begin_ - __d);
+ __begin_ -= __d;
+ }
+ else
+ {
+ size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
+ __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc());
+ __t.__construct_at_end(move_iterator<pointer>(__begin_),
+ move_iterator<pointer>(__end_));
+ _VSTD::swap(__first_, __t.__first_);
+ _VSTD::swap(__begin_, __t.__begin_);
+ _VSTD::swap(__end_, __t.__end_);
+ _VSTD::swap(__end_cap(), __t.__end_cap());
+ }
+ }
+ __alloc_traits::construct(__alloc(), _VSTD::__to_address(__end_), __x);
+ ++__end_;
+}
+
+template <class _Tp, class _Allocator>
+void
+__split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)
+{
+ if (__end_ == __end_cap())
+ {
+ if (__begin_ > __first_)
+ {
+ difference_type __d = __begin_ - __first_;
+ __d = (__d + 1) / 2;
+ __end_ = _VSTD::move(__begin_, __end_, __begin_ - __d);
+ __begin_ -= __d;
+ }
+ else
+ {
+ size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
+ __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc());
+ __t.__construct_at_end(move_iterator<pointer>(__begin_),
+ move_iterator<pointer>(__end_));
+ _VSTD::swap(__first_, __t.__first_);
+ _VSTD::swap(__begin_, __t.__begin_);
+ _VSTD::swap(__end_, __t.__end_);
+ _VSTD::swap(__end_cap(), __t.__end_cap());
+ }
+ }
+ __alloc_traits::construct(__alloc(), _VSTD::__to_address(__end_),
+ _VSTD::move(__x));
+ ++__end_;
+}
+
+template <class _Tp, class _Allocator>
+template <class... _Args>
+void
+__split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)
+{
+ if (__end_ == __end_cap())
+ {
+ if (__begin_ > __first_)
+ {
+ difference_type __d = __begin_ - __first_;
+ __d = (__d + 1) / 2;
+ __end_ = _VSTD::move(__begin_, __end_, __begin_ - __d);
+ __begin_ -= __d;
+ }
+ else
+ {
+ size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
+ __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc());
+ __t.__construct_at_end(move_iterator<pointer>(__begin_),
+ move_iterator<pointer>(__end_));
+ _VSTD::swap(__first_, __t.__first_);
+ _VSTD::swap(__begin_, __t.__begin_);
+ _VSTD::swap(__end_, __t.__end_);
+ _VSTD::swap(__end_cap(), __t.__end_cap());
+ }
+ }
+ __alloc_traits::construct(__alloc(), _VSTD::__to_address(__end_),
+ _VSTD::forward<_Args>(__args)...);
+ ++__end_;
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(__split_buffer<_Tp, _Allocator>& __x, __split_buffer<_Tp, _Allocator>& __y)
+ _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+ __x.swap(__y);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_SPLIT_BUFFER
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__std_stream b/contrib/libs/cxxsupp/libcxxmsvc/include/__std_stream
new file mode 100644
index 0000000000..e419e8c03a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__std_stream
@@ -0,0 +1,361 @@
+// -*- 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___STD_STREAM
+#define _LIBCPP___STD_STREAM
+
+#include <__config>
+#include <__locale>
+#include <cstdio>
+#include <istream>
+#include <ostream>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+static const int __limit = 8;
+
+// __stdinbuf
+
+template <class _CharT>
+class _LIBCPP_HIDDEN __stdinbuf
+ : public basic_streambuf<_CharT, char_traits<_CharT> >
+{
+public:
+ typedef _CharT char_type;
+ typedef char_traits<char_type> traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+ typedef typename traits_type::state_type state_type;
+
+ __stdinbuf(FILE* __fp, state_type* __st);
+
+protected:
+ virtual int_type underflow();
+ virtual int_type uflow();
+ virtual int_type pbackfail(int_type __c = traits_type::eof());
+ virtual void imbue(const locale& __loc);
+
+private:
+
+ FILE* __file_;
+ const codecvt<char_type, char, state_type>* __cv_;
+ state_type* __st_;
+ int __encoding_;
+ int_type __last_consumed_;
+ bool __last_consumed_is_next_;
+ bool __always_noconv_;
+
+ __stdinbuf(const __stdinbuf&);
+ __stdinbuf& operator=(const __stdinbuf&);
+
+ int_type __getchar(bool __consume);
+};
+
+template <class _CharT>
+__stdinbuf<_CharT>::__stdinbuf(FILE* __fp, state_type* __st)
+ : __file_(__fp),
+ __st_(__st),
+ __last_consumed_(traits_type::eof()),
+ __last_consumed_is_next_(false)
+{
+ imbue(this->getloc());
+}
+
+template <class _CharT>
+void
+__stdinbuf<_CharT>::imbue(const locale& __loc)
+{
+ __cv_ = &use_facet<codecvt<char_type, char, state_type> >(__loc);
+ __encoding_ = __cv_->encoding();
+ __always_noconv_ = __cv_->always_noconv();
+ if (__encoding_ > __limit)
+ __throw_runtime_error("unsupported locale for standard input");
+}
+
+template <class _CharT>
+typename __stdinbuf<_CharT>::int_type
+__stdinbuf<_CharT>::underflow()
+{
+ return __getchar(false);
+}
+
+template <class _CharT>
+typename __stdinbuf<_CharT>::int_type
+__stdinbuf<_CharT>::uflow()
+{
+ return __getchar(true);
+}
+
+template <class _CharT>
+typename __stdinbuf<_CharT>::int_type
+__stdinbuf<_CharT>::__getchar(bool __consume)
+{
+ if (__last_consumed_is_next_)
+ {
+ int_type __result = __last_consumed_;
+ if (__consume)
+ {
+ __last_consumed_ = traits_type::eof();
+ __last_consumed_is_next_ = false;
+ }
+ return __result;
+ }
+ char __extbuf[__limit];
+ int __nread = _VSTD::max(1, __encoding_);
+ for (int __i = 0; __i < __nread; ++__i)
+ {
+ int __c = getc(__file_);
+ if (__c == EOF)
+ return traits_type::eof();
+ __extbuf[__i] = static_cast<char>(__c);
+ }
+ char_type __1buf;
+ if (__always_noconv_)
+ __1buf = static_cast<char_type>(__extbuf[0]);
+ else
+ {
+ const char* __enxt;
+ char_type* __inxt;
+ codecvt_base::result __r;
+ do
+ {
+ state_type __sv_st = *__st_;
+ __r = __cv_->in(*__st_, __extbuf, __extbuf + __nread, __enxt,
+ &__1buf, &__1buf + 1, __inxt);
+ switch (__r)
+ {
+ case _VSTD::codecvt_base::ok:
+ break;
+ case codecvt_base::partial:
+ *__st_ = __sv_st;
+ if (__nread == sizeof(__extbuf))
+ return traits_type::eof();
+ {
+ int __c = getc(__file_);
+ if (__c == EOF)
+ return traits_type::eof();
+ __extbuf[__nread] = static_cast<char>(__c);
+ }
+ ++__nread;
+ break;
+ case codecvt_base::error:
+ return traits_type::eof();
+ case _VSTD::codecvt_base::noconv:
+ __1buf = static_cast<char_type>(__extbuf[0]);
+ break;
+ }
+ } while (__r == _VSTD::codecvt_base::partial);
+ }
+ if (!__consume)
+ {
+ for (int __i = __nread; __i > 0;)
+ {
+ if (ungetc(traits_type::to_int_type(__extbuf[--__i]), __file_) == EOF)
+ return traits_type::eof();
+ }
+ }
+ else
+ __last_consumed_ = traits_type::to_int_type(__1buf);
+ return traits_type::to_int_type(__1buf);
+}
+
+template <class _CharT>
+typename __stdinbuf<_CharT>::int_type
+__stdinbuf<_CharT>::pbackfail(int_type __c)
+{
+ if (traits_type::eq_int_type(__c, traits_type::eof()))
+ {
+ if (!__last_consumed_is_next_)
+ {
+ __c = __last_consumed_;
+ __last_consumed_is_next_ = !traits_type::eq_int_type(__last_consumed_,
+ traits_type::eof());
+ }
+ return __c;
+ }
+ if (__last_consumed_is_next_)
+ {
+ char __extbuf[__limit];
+ char* __enxt;
+ const char_type __ci = traits_type::to_char_type(__last_consumed_);
+ const char_type* __inxt;
+ switch (__cv_->out(*__st_, &__ci, &__ci + 1, __inxt,
+ __extbuf, __extbuf + sizeof(__extbuf), __enxt))
+ {
+ case _VSTD::codecvt_base::ok:
+ break;
+ case _VSTD::codecvt_base::noconv:
+ __extbuf[0] = static_cast<char>(__last_consumed_);
+ __enxt = __extbuf + 1;
+ break;
+ case codecvt_base::partial:
+ case codecvt_base::error:
+ return traits_type::eof();
+ }
+ while (__enxt > __extbuf)
+ if (ungetc(*--__enxt, __file_) == EOF)
+ return traits_type::eof();
+ }
+ __last_consumed_ = __c;
+ __last_consumed_is_next_ = true;
+ return __c;
+}
+
+// __stdoutbuf
+
+template <class _CharT>
+class _LIBCPP_HIDDEN __stdoutbuf
+ : public basic_streambuf<_CharT, char_traits<_CharT> >
+{
+public:
+ typedef _CharT char_type;
+ typedef char_traits<char_type> traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+ typedef typename traits_type::state_type state_type;
+
+ __stdoutbuf(FILE* __fp, state_type* __st);
+
+protected:
+ virtual int_type overflow (int_type __c = traits_type::eof());
+ virtual streamsize xsputn(const char_type* __s, streamsize __n);
+ virtual int sync();
+ virtual void imbue(const locale& __loc);
+
+private:
+ FILE* __file_;
+ const codecvt<char_type, char, state_type>* __cv_;
+ state_type* __st_;
+ bool __always_noconv_;
+
+ __stdoutbuf(const __stdoutbuf&);
+ __stdoutbuf& operator=(const __stdoutbuf&);
+};
+
+template <class _CharT>
+__stdoutbuf<_CharT>::__stdoutbuf(FILE* __fp, state_type* __st)
+ : __file_(__fp),
+ __cv_(&use_facet<codecvt<char_type, char, state_type> >(this->getloc())),
+ __st_(__st),
+ __always_noconv_(__cv_->always_noconv())
+{
+}
+
+template <class _CharT>
+typename __stdoutbuf<_CharT>::int_type
+__stdoutbuf<_CharT>::overflow(int_type __c)
+{
+ char __extbuf[__limit];
+ char_type __1buf;
+ if (!traits_type::eq_int_type(__c, traits_type::eof()))
+ {
+ __1buf = traits_type::to_char_type(__c);
+ if (__always_noconv_)
+ {
+ if (fwrite(&__1buf, sizeof(char_type), 1, __file_) != 1)
+ return traits_type::eof();
+ }
+ else
+ {
+ char* __extbe = __extbuf;
+ codecvt_base::result __r;
+ char_type* pbase = &__1buf;
+ char_type* pptr = pbase + 1;
+ do
+ {
+ const char_type* __e;
+ __r = __cv_->out(*__st_, pbase, pptr, __e,
+ __extbuf,
+ __extbuf + sizeof(__extbuf),
+ __extbe);
+ if (__e == pbase)
+ return traits_type::eof();
+ if (__r == codecvt_base::noconv)
+ {
+ if (fwrite(pbase, 1, 1, __file_) != 1)
+ return traits_type::eof();
+ }
+ else if (__r == codecvt_base::ok || __r == codecvt_base::partial)
+ {
+ size_t __nmemb = static_cast<size_t>(__extbe - __extbuf);
+ if (fwrite(__extbuf, 1, __nmemb, __file_) != __nmemb)
+ return traits_type::eof();
+ if (__r == codecvt_base::partial)
+ {
+ pbase = const_cast<char_type*>(__e);
+ }
+ }
+ else
+ return traits_type::eof();
+ } while (__r == codecvt_base::partial);
+ }
+ }
+ return traits_type::not_eof(__c);
+}
+
+template <class _CharT>
+streamsize
+__stdoutbuf<_CharT>::xsputn(const char_type* __s, streamsize __n)
+{
+ if (__always_noconv_)
+ return fwrite(__s, sizeof(char_type), __n, __file_);
+ streamsize __i = 0;
+ for (; __i < __n; ++__i, ++__s)
+ if (overflow(traits_type::to_int_type(*__s)) == traits_type::eof())
+ break;
+ return __i;
+}
+
+template <class _CharT>
+int
+__stdoutbuf<_CharT>::sync()
+{
+ char __extbuf[__limit];
+ codecvt_base::result __r;
+ do
+ {
+ char* __extbe;
+ __r = __cv_->unshift(*__st_, __extbuf,
+ __extbuf + sizeof(__extbuf),
+ __extbe);
+ size_t __nmemb = static_cast<size_t>(__extbe - __extbuf);
+ if (fwrite(__extbuf, 1, __nmemb, __file_) != __nmemb)
+ return -1;
+ } while (__r == codecvt_base::partial);
+ if (__r == codecvt_base::error)
+ return -1;
+ if (fflush(__file_))
+ return -1;
+ return 0;
+}
+
+template <class _CharT>
+void
+__stdoutbuf<_CharT>::imbue(const locale& __loc)
+{
+ sync();
+ __cv_ = &use_facet<codecvt<char_type, char, state_type> >(__loc);
+ __always_noconv_ = __cv_->always_noconv();
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___STD_STREAM
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__string b/contrib/libs/cxxsupp/libcxxmsvc/include/__string
new file mode 100644
index 0000000000..57ac5379ed
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__string
@@ -0,0 +1,1189 @@
+// -*- 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___STRING
+#define _LIBCPP___STRING
+
+#include <__algorithm/copy.h>
+#include <__algorithm/copy_backward.h>
+#include <__algorithm/copy_n.h>
+#include <__algorithm/fill_n.h>
+#include <__algorithm/find_end.h>
+#include <__algorithm/find_first_of.h>
+#include <__algorithm/min.h>
+#include <__assert>
+#include <__config>
+#include <__debug>
+#include <__functional/hash.h> // for __murmur2_or_cityhash
+#include <__iterator/iterator_traits.h>
+#include <cstdint> // for uint_least16_t
+#include <cstdio> // for EOF
+#include <cstring> // for memcpy
+#include <iosfwd> // for streampos & friends
+#include <type_traits> // for __libcpp_is_constant_evaluated
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# include <cwchar> // for wmemcpy
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// The extern template ABI lists are kept outside of <string> to improve the
+// readability of that header. We maintain 2 ABI lists:
+// - _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST
+// - _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST
+// As the name implies, the ABI lists define the V1 (Stable) and unstable ABI.
+//
+// For unstable, we may explicitly remove function that are external in V1,
+// and add (new) external functions to better control inlining and compiler
+// optimization opportunities.
+//
+// For stable, the ABI list should rarely change, except for adding new
+// functions supporting new c++ version / API changes. Typically entries
+// must never be removed from the stable list.
+#define _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_Func, _CharType) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type const*, size_type, size_type) const _NOEXCEPT) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, allocator<_CharType> const&)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_not_of(value_type const*, size_type, size_type) const _NOEXCEPT) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::~basic_string()) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_not_of(value_type const*, size_type, size_type) const _NOEXCEPT) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, size_type, value_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::operator=(value_type)) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS const _CharType& basic_string<_CharType>::at(size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_of(value_type const*, size_type, size_type) const _NOEXCEPT) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, size_type, value_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(value_type const*, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::reserve(size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(basic_string const&, size_type, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::copy(value_type*, size_type, size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, allocator<_CharType> const&)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type, size_type) const _NOEXCEPT) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(size_type, value_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_of(value_type const*, size_type, size_type) const _NOEXCEPT) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by(size_type, size_type, size_type, size_type, size_type, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by_and_replace(size_type, size_type, size_type, size_type, size_type, size_type, value_type const*)) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::push_back(value_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(size_type, value_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type, size_type) const _NOEXCEPT) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(size_type, value_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::erase(size_type, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(basic_string const&, size_type, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(value_type const*) const _NOEXCEPT) \
+ _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*) const) \
+ _Func(_LIBCPP_FUNC_VIS _CharType& basic_string<_CharType>::at(size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(value_type const*)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type const*, size_type, size_type) const _NOEXCEPT) \
+ _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, basic_string const&, size_type, size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*, size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::operator=(basic_string const&)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, basic_string const&, size_type, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::iterator basic_string<_CharType>::insert(basic_string::const_iterator, value_type)) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::resize(size_type, value_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, basic_string const&, size_type, size_type)) \
+ _LIBCPP_STRING_EXTERN_TEMPLATE_VARIABLE_LIST(_Func, _CharType)
+
+#define _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_Func, _CharType) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type const*, size_type, size_type) const _NOEXCEPT) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_not_of(value_type const*, size_type, size_type) const _NOEXCEPT) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::~basic_string()) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_not_of(value_type const*, size_type, size_type) const _NOEXCEPT) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, size_type, value_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::operator=(value_type)) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init_copy_ctor_external(value_type const*, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS const _CharType& basic_string<_CharType>::at(size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_of(value_type const*, size_type, size_type) const _NOEXCEPT) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, size_type, value_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_external(value_type const*, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_external(value_type const*)) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::reserve(size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(basic_string const&, size_type, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::copy(value_type*, size_type, size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, allocator<_CharType> const&)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type, size_type) const _NOEXCEPT) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(size_type, value_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_of(value_type const*, size_type, size_type) const _NOEXCEPT) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by(size_type, size_type, size_type, size_type, size_type, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by_and_replace(size_type, size_type, size_type, size_type, size_type, size_type, value_type const*)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_no_alias<false>(value_type const*, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_no_alias<true>(value_type const*, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::push_back(value_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(size_type, value_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type, size_type) const _NOEXCEPT) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(size_type, value_type)) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__erase_external_with_move(size_type, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(basic_string const&, size_type, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(value_type const*) const _NOEXCEPT) \
+ _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*) const) \
+ _Func(_LIBCPP_FUNC_VIS _CharType& basic_string<_CharType>::at(size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type const*, size_type, size_type) const _NOEXCEPT) \
+ _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, basic_string const&, size_type, size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*, size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, basic_string const&, size_type, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::iterator basic_string<_CharType>::insert(basic_string::const_iterator, value_type)) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::resize(size_type, value_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, basic_string const&, size_type, size_type)) \
+ _LIBCPP_STRING_EXTERN_TEMPLATE_VARIABLE_LIST(_Func, _CharType)
+
+// Workaround for CUDA which doesn't like extern templates for variables.
+#ifdef __CUDACC__
+#define _LIBCPP_STRING_EXTERN_TEMPLATE_VARIABLE_LIST(_Func, _CharType)
+#else
+#define _LIBCPP_STRING_EXTERN_TEMPLATE_VARIABLE_LIST(_Func, _CharType) \
+ _Func(_LIBCPP_FUNC_VIS const basic_string<_CharType>::size_type basic_string<_CharType>::npos)
+#endif
+
+// char_traits
+
+template <class _CharT>
+struct _LIBCPP_TEMPLATE_VIS char_traits
+{
+ typedef _CharT char_type;
+ typedef int int_type;
+ typedef streamoff off_type;
+ typedef streampos pos_type;
+ typedef mbstate_t state_type;
+
+ static inline void _LIBCPP_CONSTEXPR_AFTER_CXX14
+ assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
+ static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
+ {return __c1 == __c2;}
+ static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
+ {return __c1 < __c2;}
+
+ static _LIBCPP_CONSTEXPR_AFTER_CXX14
+ int compare(const char_type* __s1, const char_type* __s2, size_t __n);
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
+ size_t length(const char_type* __s);
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
+ const char_type* find(const char_type* __s, size_t __n, const char_type& __a);
+ static _LIBCPP_CONSTEXPR_AFTER_CXX17
+ char_type* move(char_type* __s1, const char_type* __s2, size_t __n);
+ _LIBCPP_INLINE_VISIBILITY
+ static _LIBCPP_CONSTEXPR_AFTER_CXX17
+ char_type* copy(char_type* __s1, const char_type* __s2, size_t __n);
+ _LIBCPP_INLINE_VISIBILITY
+ static _LIBCPP_CONSTEXPR_AFTER_CXX17
+ char_type* assign(char_type* __s, size_t __n, char_type __a);
+
+ static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
+ {return eq_int_type(__c, eof()) ? ~eof() : __c;}
+ static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
+ {return char_type(__c);}
+ static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
+ {return int_type(__c);}
+ static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
+ {return __c1 == __c2;}
+ static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
+ {return int_type(EOF);}
+};
+
+template <class _CharT>
+_LIBCPP_CONSTEXPR_AFTER_CXX14 int
+char_traits<_CharT>::compare(const char_type* __s1, const char_type* __s2, size_t __n)
+{
+ for (; __n; --__n, ++__s1, ++__s2)
+ {
+ if (lt(*__s1, *__s2))
+ return -1;
+ if (lt(*__s2, *__s1))
+ return 1;
+ }
+ return 0;
+}
+
+template <class _CharT>
+inline
+_LIBCPP_CONSTEXPR_AFTER_CXX14 size_t
+char_traits<_CharT>::length(const char_type* __s)
+{
+ size_t __len = 0;
+ for (; !eq(*__s, char_type(0)); ++__s)
+ ++__len;
+ return __len;
+}
+
+template <class _CharT>
+inline
+_LIBCPP_CONSTEXPR_AFTER_CXX14 const _CharT*
+char_traits<_CharT>::find(const char_type* __s, size_t __n, const char_type& __a)
+{
+ for (; __n; --__n)
+ {
+ if (eq(*__s, __a))
+ return __s;
+ ++__s;
+ }
+ return nullptr;
+}
+
+template <class _CharT>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _CharT*
+char_traits<_CharT>::move(char_type* __s1, const char_type* __s2, size_t __n)
+{
+ if (__n == 0) return __s1;
+ char_type* __r = __s1;
+ if (__s1 < __s2)
+ {
+ for (; __n; --__n, ++__s1, ++__s2)
+ assign(*__s1, *__s2);
+ }
+ else if (__s2 < __s1)
+ {
+ __s1 += __n;
+ __s2 += __n;
+ for (; __n; --__n)
+ assign(*--__s1, *--__s2);
+ }
+ return __r;
+}
+
+template <class _CharT>
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+_CharT*
+char_traits<_CharT>::copy(char_type* __s1, const char_type* __s2, size_t __n)
+{
+ if (!__libcpp_is_constant_evaluated()) {
+ _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
+ }
+ char_type* __r = __s1;
+ for (; __n; --__n, ++__s1, ++__s2)
+ assign(*__s1, *__s2);
+ return __r;
+}
+
+template <class _CharT>
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+_CharT*
+char_traits<_CharT>::assign(char_type* __s, size_t __n, char_type __a)
+{
+ char_type* __r = __s;
+ for (; __n; --__n, ++__s)
+ assign(*__s, __a);
+ return __r;
+}
+
+// constexpr versions of move/copy/assign.
+
+template <class _CharT>
+static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+_CharT* __copy_constexpr(_CharT* __dest, const _CharT* __source, size_t __n) _NOEXCEPT
+{
+ _LIBCPP_ASSERT(__libcpp_is_constant_evaluated(), "__copy_constexpr() should always be constant evaluated");
+ _VSTD::copy_n(__source, __n, __dest);
+ return __dest;
+}
+
+template <class _CharT>
+static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+_CharT* __move_constexpr(_CharT* __dest, const _CharT* __source, size_t __n) _NOEXCEPT
+{
+ _LIBCPP_ASSERT(__libcpp_is_constant_evaluated(), "__move_constexpr() should always be constant evaluated");
+ if (__n == 0)
+ return __dest;
+ _CharT* __allocation = new _CharT[__n];
+ _VSTD::__copy_constexpr(__allocation, __source, __n);
+ _VSTD::__copy_constexpr(__dest, static_cast<const _CharT*>(__allocation), __n);
+ delete[] __allocation;
+ return __dest;
+}
+
+template <class _CharT>
+static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+_CharT* __assign_constexpr(_CharT* __s, size_t __n, _CharT __a) _NOEXCEPT
+{
+ _LIBCPP_ASSERT(__libcpp_is_constant_evaluated(), "__assign_constexpr() should always be constant evaluated");
+ _VSTD::fill_n(__s, __n, __a);
+ return __s;
+}
+
+// char_traits<char>
+
+template <>
+struct _LIBCPP_TEMPLATE_VIS char_traits<char>
+{
+ typedef char char_type;
+ typedef int int_type;
+ typedef streamoff off_type;
+ typedef streampos pos_type;
+ typedef mbstate_t state_type;
+
+ static inline _LIBCPP_CONSTEXPR_AFTER_CXX14
+ void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
+ static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
+ {return __c1 == __c2;}
+ static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
+ {return (unsigned char)__c1 < (unsigned char)__c2;}
+
+ static _LIBCPP_CONSTEXPR_AFTER_CXX14
+ int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
+ static inline size_t _LIBCPP_CONSTEXPR_AFTER_CXX14 length(const char_type* __s) _NOEXCEPT {
+ // GCC currently does not support __builtin_strlen during constant evaluation.
+ // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70816
+#if defined(_LIBCPP_COMPILER_GCC) || defined(_LIBCPP_COMPILER_MSVC)
+ if (__libcpp_is_constant_evaluated()) {
+ size_t __i = 0;
+ for (; __s[__i] != char_type('\0'); ++__i)
+ ;
+ return __i;
+ }
+#endif
+ return __builtin_strlen(__s);
+ }
+
+ static _LIBCPP_CONSTEXPR_AFTER_CXX14
+ const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
+ static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+ char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
+ {
+ return __libcpp_is_constant_evaluated()
+ ? _VSTD::__move_constexpr(__s1, __s2, __n)
+ : __n == 0 ? __s1 : (char_type*)_VSTD::memmove(__s1, __s2, __n);
+ }
+ static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+ char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
+ {
+ if (!__libcpp_is_constant_evaluated()) {
+ _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
+ }
+ return __libcpp_is_constant_evaluated()
+ ? _VSTD::__copy_constexpr(__s1, __s2, __n)
+ : __n == 0 ? __s1 : (char_type*)_VSTD::memcpy(__s1, __s2, __n);
+ }
+ static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+ char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
+ {
+ return __libcpp_is_constant_evaluated()
+ ? _VSTD::__assign_constexpr(__s, __n, __a)
+ : __n == 0 ? __s : (char_type*)_VSTD::memset(__s, to_int_type(__a), __n);
+ }
+
+ static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
+ {return eq_int_type(__c, eof()) ? ~eof() : __c;}
+ static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
+ {return char_type(__c);}
+ static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
+ {return int_type((unsigned char)__c);}
+ static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
+ {return __c1 == __c2;}
+ static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
+ {return int_type(EOF);}
+};
+
+inline _LIBCPP_CONSTEXPR_AFTER_CXX14
+int
+char_traits<char>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
+{
+ if (__n == 0)
+ return 0;
+#if __has_feature(cxx_constexpr_string_builtins)
+ return __builtin_memcmp(__s1, __s2, __n);
+#elif _LIBCPP_STD_VER <= 14
+ return _VSTD::memcmp(__s1, __s2, __n);
+#else
+ for (; __n; --__n, ++__s1, ++__s2)
+ {
+ if (lt(*__s1, *__s2))
+ return -1;
+ if (lt(*__s2, *__s1))
+ return 1;
+ }
+ return 0;
+#endif
+}
+
+inline _LIBCPP_CONSTEXPR_AFTER_CXX14
+const char*
+char_traits<char>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
+{
+ if (__n == 0)
+ return nullptr;
+#if __has_feature(cxx_constexpr_string_builtins) && !defined(__CUDACC__)
+ return __builtin_char_memchr(__s, to_int_type(__a), __n);
+#elif _LIBCPP_STD_VER <= 14
+ return (const char_type*) _VSTD::memchr(__s, to_int_type(__a), __n);
+#else
+ for (; __n; --__n)
+ {
+ if (eq(*__s, __a))
+ return __s;
+ ++__s;
+ }
+ return nullptr;
+#endif
+}
+
+
+// char_traits<wchar_t>
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t>
+{
+ typedef wchar_t char_type;
+ typedef wint_t int_type;
+ typedef streamoff off_type;
+ typedef streampos pos_type;
+ typedef mbstate_t state_type;
+
+ static inline _LIBCPP_CONSTEXPR_AFTER_CXX14
+ void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
+ static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
+ {return __c1 == __c2;}
+ static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
+ {return __c1 < __c2;}
+
+ static _LIBCPP_CONSTEXPR_AFTER_CXX14
+ int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
+ static _LIBCPP_CONSTEXPR_AFTER_CXX14
+ size_t length(const char_type* __s) _NOEXCEPT;
+ static _LIBCPP_CONSTEXPR_AFTER_CXX14
+ const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
+ static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+ char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
+ {
+ return __libcpp_is_constant_evaluated()
+ ? _VSTD::__move_constexpr(__s1, __s2, __n)
+ : __n == 0 ? __s1 : _VSTD::wmemmove(__s1, __s2, __n);
+ }
+ static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+ char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
+ {
+ if (!__libcpp_is_constant_evaluated()) {
+ _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
+ }
+ return __libcpp_is_constant_evaluated()
+ ? _VSTD::__copy_constexpr(__s1, __s2, __n)
+ : __n == 0 ? __s1 : _VSTD::wmemcpy(__s1, __s2, __n);
+ }
+ static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+ char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
+ {
+ return __libcpp_is_constant_evaluated()
+ ? _VSTD::__assign_constexpr(__s, __n, __a)
+ : __n == 0 ? __s : _VSTD::wmemset(__s, __a, __n);
+ }
+ static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
+ {return eq_int_type(__c, eof()) ? ~eof() : __c;}
+ static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
+ {return char_type(__c);}
+ static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
+ {return int_type(__c);}
+ static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
+ {return __c1 == __c2;}
+ static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
+ {return int_type(WEOF);}
+};
+
+inline _LIBCPP_CONSTEXPR_AFTER_CXX14
+int
+char_traits<wchar_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
+{
+ if (__n == 0)
+ return 0;
+#if __has_feature(cxx_constexpr_string_builtins) && !defined(__CUDACC__)
+ return __builtin_wmemcmp(__s1, __s2, __n);
+#elif _LIBCPP_STD_VER <= 14
+ return _VSTD::wmemcmp(__s1, __s2, __n);
+#else
+ for (; __n; --__n, ++__s1, ++__s2)
+ {
+ if (lt(*__s1, *__s2))
+ return -1;
+ if (lt(*__s2, *__s1))
+ return 1;
+ }
+ return 0;
+#endif
+}
+
+inline _LIBCPP_CONSTEXPR_AFTER_CXX14
+size_t
+char_traits<wchar_t>::length(const char_type* __s) _NOEXCEPT
+{
+#if __has_feature(cxx_constexpr_string_builtins) && !defined(__CUDACC__)
+ return __builtin_wcslen(__s);
+#elif _LIBCPP_STD_VER <= 14
+ return _VSTD::wcslen(__s);
+#else
+ size_t __len = 0;
+ for (; !eq(*__s, char_type(0)); ++__s)
+ ++__len;
+ return __len;
+#endif
+}
+
+inline _LIBCPP_CONSTEXPR_AFTER_CXX14
+const wchar_t*
+char_traits<wchar_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
+{
+ if (__n == 0)
+ return nullptr;
+#if __has_feature(cxx_constexpr_string_builtins) && !defined(__CUDACC__)
+ return __builtin_wmemchr(__s, __a, __n);
+#elif _LIBCPP_STD_VER <= 14
+ return _VSTD::wmemchr(__s, __a, __n);
+#else
+ for (; __n; --__n)
+ {
+ if (eq(*__s, __a))
+ return __s;
+ ++__s;
+ }
+ return nullptr;
+#endif
+}
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+// Disable double inline warning.
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( push )
+#pragma warning ( disable : 4141 )
+#endif
+template <class _Traits>
+_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+inline size_t __char_traits_length_checked(const typename _Traits::char_type* __s) _NOEXCEPT {
+#if _LIBCPP_DEBUG_LEVEL >= 1
+ return __s ? _Traits::length(__s) : (_VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, "p == nullptr", "null pointer pass to non-null argument of char_traits<...>::length")), 0);
+#else
+ return _Traits::length(__s);
+#endif
+}
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( pop )
+#endif
+
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
+
+template <>
+struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>
+{
+ typedef char8_t char_type;
+ typedef unsigned int int_type;
+ typedef streamoff off_type;
+ typedef u8streampos pos_type;
+ typedef mbstate_t state_type;
+
+ static inline constexpr void assign(char_type& __c1, const char_type& __c2) noexcept
+ {__c1 = __c2;}
+ static inline constexpr bool eq(char_type __c1, char_type __c2) noexcept
+ {return __c1 == __c2;}
+ static inline constexpr bool lt(char_type __c1, char_type __c2) noexcept
+ {return __c1 < __c2;}
+
+ static constexpr
+ int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
+
+ static constexpr
+ size_t length(const char_type* __s) _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY static constexpr
+ const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
+
+ static _LIBCPP_CONSTEXPR_AFTER_CXX17
+ char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
+ {
+ return __libcpp_is_constant_evaluated()
+ ? _VSTD::__move_constexpr(__s1, __s2, __n)
+ : __n == 0 ? __s1 : (char_type*)_VSTD::memmove(__s1, __s2, __n);
+ }
+
+ static _LIBCPP_CONSTEXPR_AFTER_CXX17
+ char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
+ {
+ if (!__libcpp_is_constant_evaluated()) {
+ _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
+ }
+ return __libcpp_is_constant_evaluated()
+ ? _VSTD::__copy_constexpr(__s1, __s2, __n)
+ : __n == 0 ? __s1 : (char_type*)_VSTD::memcpy(__s1, __s2, __n);
+ }
+
+ static _LIBCPP_CONSTEXPR_AFTER_CXX17
+ char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
+ {
+ return __libcpp_is_constant_evaluated()
+ ? _VSTD::__assign_constexpr(__s, __n, __a)
+ : __n == 0 ? __s : (char_type*)_VSTD::memset(__s, to_int_type(__a), __n);
+ }
+
+ static inline constexpr int_type not_eof(int_type __c) noexcept
+ {return eq_int_type(__c, eof()) ? ~eof() : __c;}
+ static inline constexpr char_type to_char_type(int_type __c) noexcept
+ {return char_type(__c);}
+ static inline constexpr int_type to_int_type(char_type __c) noexcept
+ {return int_type(__c);}
+ static inline constexpr bool eq_int_type(int_type __c1, int_type __c2) noexcept
+ {return __c1 == __c2;}
+ static inline constexpr int_type eof() noexcept
+ {return int_type(EOF);}
+};
+
+// TODO use '__builtin_strlen' if it ever supports char8_t ??
+inline constexpr
+size_t
+char_traits<char8_t>::length(const char_type* __s) _NOEXCEPT
+{
+ size_t __len = 0;
+ for (; !eq(*__s, char_type(0)); ++__s)
+ ++__len;
+ return __len;
+}
+
+inline constexpr
+int
+char_traits<char8_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
+{
+#if __has_feature(cxx_constexpr_string_builtins)
+ return __builtin_memcmp(__s1, __s2, __n);
+#else
+ for (; __n; --__n, ++__s1, ++__s2)
+ {
+ if (lt(*__s1, *__s2))
+ return -1;
+ if (lt(*__s2, *__s1))
+ return 1;
+ }
+ return 0;
+#endif
+}
+
+// TODO use '__builtin_char_memchr' if it ever supports char8_t ??
+inline constexpr
+const char8_t*
+char_traits<char8_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
+{
+ for (; __n; --__n)
+ {
+ if (eq(*__s, __a))
+ return __s;
+ ++__s;
+ }
+ return nullptr;
+}
+
+#endif // #_LIBCPP_HAS_NO_CHAR8_T
+
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+
+template <>
+struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t>
+{
+ typedef char16_t char_type;
+ typedef uint_least16_t int_type;
+ typedef streamoff off_type;
+ typedef u16streampos pos_type;
+ typedef mbstate_t state_type;
+
+ static inline _LIBCPP_CONSTEXPR_AFTER_CXX14
+ void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
+ static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
+ {return __c1 == __c2;}
+ static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
+ {return __c1 < __c2;}
+
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
+ int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
+ size_t length(const char_type* __s) _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
+ const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT;
+
+ static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
+ {return eq_int_type(__c, eof()) ? ~eof() : __c;}
+ static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
+ {return char_type(__c);}
+ static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
+ {return int_type(__c);}
+ static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
+ {return __c1 == __c2;}
+ static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
+ {return int_type(0xFFFF);}
+};
+
+inline _LIBCPP_CONSTEXPR_AFTER_CXX14
+int
+char_traits<char16_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
+{
+ for (; __n; --__n, ++__s1, ++__s2)
+ {
+ if (lt(*__s1, *__s2))
+ return -1;
+ if (lt(*__s2, *__s1))
+ return 1;
+ }
+ return 0;
+}
+
+inline _LIBCPP_CONSTEXPR_AFTER_CXX14
+size_t
+char_traits<char16_t>::length(const char_type* __s) _NOEXCEPT
+{
+ size_t __len = 0;
+ for (; !eq(*__s, char_type(0)); ++__s)
+ ++__len;
+ return __len;
+}
+
+inline _LIBCPP_CONSTEXPR_AFTER_CXX14
+const char16_t*
+char_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
+{
+ for (; __n; --__n)
+ {
+ if (eq(*__s, __a))
+ return __s;
+ ++__s;
+ }
+ return nullptr;
+}
+
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+char16_t*
+char_traits<char16_t>::move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
+{
+ if (__n == 0) return __s1;
+ char_type* __r = __s1;
+ if (__s1 < __s2)
+ {
+ for (; __n; --__n, ++__s1, ++__s2)
+ assign(*__s1, *__s2);
+ }
+ else if (__s2 < __s1)
+ {
+ __s1 += __n;
+ __s2 += __n;
+ for (; __n; --__n)
+ assign(*--__s1, *--__s2);
+ }
+ return __r;
+}
+
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+char16_t*
+char_traits<char16_t>::copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
+{
+ if (!__libcpp_is_constant_evaluated()) {
+ _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
+ }
+ char_type* __r = __s1;
+ for (; __n; --__n, ++__s1, ++__s2)
+ assign(*__s1, *__s2);
+ return __r;
+}
+
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+char16_t*
+char_traits<char16_t>::assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
+{
+ char_type* __r = __s;
+ for (; __n; --__n, ++__s)
+ assign(*__s, __a);
+ return __r;
+}
+
+template <>
+struct _LIBCPP_TEMPLATE_VIS char_traits<char32_t>
+{
+ typedef char32_t char_type;
+ typedef uint_least32_t int_type;
+ typedef streamoff off_type;
+ typedef u32streampos pos_type;
+ typedef mbstate_t state_type;
+
+ static inline _LIBCPP_CONSTEXPR_AFTER_CXX14
+ void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
+ static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
+ {return __c1 == __c2;}
+ static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
+ {return __c1 < __c2;}
+
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
+ int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
+ size_t length(const char_type* __s) _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
+ const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT;
+
+ static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
+ {return eq_int_type(__c, eof()) ? ~eof() : __c;}
+ static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
+ {return char_type(__c);}
+ static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
+ {return int_type(__c);}
+ static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
+ {return __c1 == __c2;}
+ static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
+ {return int_type(0xFFFFFFFF);}
+};
+
+inline _LIBCPP_CONSTEXPR_AFTER_CXX14
+int
+char_traits<char32_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
+{
+ for (; __n; --__n, ++__s1, ++__s2)
+ {
+ if (lt(*__s1, *__s2))
+ return -1;
+ if (lt(*__s2, *__s1))
+ return 1;
+ }
+ return 0;
+}
+
+inline _LIBCPP_CONSTEXPR_AFTER_CXX14
+size_t
+char_traits<char32_t>::length(const char_type* __s) _NOEXCEPT
+{
+ size_t __len = 0;
+ for (; !eq(*__s, char_type(0)); ++__s)
+ ++__len;
+ return __len;
+}
+
+inline _LIBCPP_CONSTEXPR_AFTER_CXX14
+const char32_t*
+char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
+{
+ for (; __n; --__n)
+ {
+ if (eq(*__s, __a))
+ return __s;
+ ++__s;
+ }
+ return nullptr;
+}
+
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+char32_t*
+char_traits<char32_t>::move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
+{
+ if (__n == 0) return __s1;
+ char_type* __r = __s1;
+ if (__s1 < __s2)
+ {
+ for (; __n; --__n, ++__s1, ++__s2)
+ assign(*__s1, *__s2);
+ }
+ else if (__s2 < __s1)
+ {
+ __s1 += __n;
+ __s2 += __n;
+ for (; __n; --__n)
+ assign(*--__s1, *--__s2);
+ }
+ return __r;
+}
+
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+char32_t*
+char_traits<char32_t>::copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
+{
+ if (!__libcpp_is_constant_evaluated()) {
+ _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
+ }
+ char_type* __r = __s1;
+ for (; __n; --__n, ++__s1, ++__s2)
+ assign(*__s1, *__s2);
+ return __r;
+}
+
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+char32_t*
+char_traits<char32_t>::assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
+{
+ char_type* __r = __s;
+ for (; __n; --__n, ++__s)
+ assign(*__s, __a);
+ return __r;
+}
+
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+
+// helper fns for basic_string and string_view
+
+// __str_find
+template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
+inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+__str_find(const _CharT *__p, _SizeT __sz,
+ _CharT __c, _SizeT __pos) _NOEXCEPT
+{
+ if (__pos >= __sz)
+ return __npos;
+ const _CharT* __r = _Traits::find(__p + __pos, __sz - __pos, __c);
+ if (__r == nullptr)
+ return __npos;
+ return static_cast<_SizeT>(__r - __p);
+}
+
+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) _NOEXCEPT {
+ // Take advantage of knowing source and pattern lengths.
+ // Stop short when source is smaller than pattern.
+ const ptrdiff_t __len2 = __last2 - __first2;
+ if (__len2 == 0)
+ return __first1;
+
+ ptrdiff_t __len1 = __last1 - __first1;
+ if (__len1 < __len2)
+ return __last1;
+
+ // First element of __first2 is loop invariant.
+ _CharT __f2 = *__first2;
+ while (true) {
+ __len1 = __last1 - __first1;
+ // Check whether __first1 still has at least __len2 bytes.
+ if (__len1 < __len2)
+ return __last1;
+
+ // Find __f2 the first byte matching in __first1.
+ __first1 = _Traits::find(__first1, __len1 - __len2 + 1, __f2);
+ if (__first1 == nullptr)
+ return __last1;
+
+ // It is faster to compare from the first byte of __first1 even if we
+ // already know that it matches the first byte of __first2: this is because
+ // __first2 is most likely aligned, as it is user's "pattern" string, and
+ // __first1 + 1 is most likely not aligned, as the match is in the middle of
+ // the string.
+ if (_Traits::compare(__first1, __first2, __len2) == 0)
+ return __first1;
+
+ ++__first1;
+ }
+}
+
+template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
+inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+__str_find(const _CharT *__p, _SizeT __sz,
+ const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
+{
+ if (__pos > __sz)
+ return __npos;
+
+ if (__n == 0) // There is nothing to search, just return __pos.
+ return __pos;
+
+ const _CharT *__r = __search_substring<_CharT, _Traits>(
+ __p + __pos, __p + __sz, __s, __s + __n);
+
+ if (__r == __p + __sz)
+ return __npos;
+ return static_cast<_SizeT>(__r - __p);
+}
+
+
+// __str_rfind
+
+template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
+inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+__str_rfind(const _CharT *__p, _SizeT __sz,
+ _CharT __c, _SizeT __pos) _NOEXCEPT
+{
+ if (__sz < 1)
+ return __npos;
+ if (__pos < __sz)
+ ++__pos;
+ else
+ __pos = __sz;
+ for (const _CharT* __ps = __p + __pos; __ps != __p;)
+ {
+ if (_Traits::eq(*--__ps, __c))
+ return static_cast<_SizeT>(__ps - __p);
+ }
+ return __npos;
+}
+
+template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
+inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+__str_rfind(const _CharT *__p, _SizeT __sz,
+ const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
+{
+ __pos = _VSTD::min(__pos, __sz);
+ if (__n < __sz - __pos)
+ __pos += __n;
+ else
+ __pos = __sz;
+ const _CharT* __r = _VSTD::__find_end(
+ __p, __p + __pos, __s, __s + __n, _Traits::eq,
+ random_access_iterator_tag(), random_access_iterator_tag());
+ if (__n > 0 && __r == __p + __pos)
+ return __npos;
+ return static_cast<_SizeT>(__r - __p);
+}
+
+// __str_find_first_of
+template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
+inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+__str_find_first_of(const _CharT *__p, _SizeT __sz,
+ const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
+{
+ if (__pos >= __sz || __n == 0)
+ return __npos;
+ const _CharT* __r = _VSTD::__find_first_of_ce
+ (__p + __pos, __p + __sz, __s, __s + __n, _Traits::eq );
+ if (__r == __p + __sz)
+ return __npos;
+ return static_cast<_SizeT>(__r - __p);
+}
+
+
+// __str_find_last_of
+template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
+inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+__str_find_last_of(const _CharT *__p, _SizeT __sz,
+ const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
+ {
+ if (__n != 0)
+ {
+ if (__pos < __sz)
+ ++__pos;
+ else
+ __pos = __sz;
+ for (const _CharT* __ps = __p + __pos; __ps != __p;)
+ {
+ const _CharT* __r = _Traits::find(__s, __n, *--__ps);
+ if (__r)
+ return static_cast<_SizeT>(__ps - __p);
+ }
+ }
+ return __npos;
+}
+
+
+// __str_find_first_not_of
+template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
+inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+__str_find_first_not_of(const _CharT *__p, _SizeT __sz,
+ const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
+{
+ if (__pos < __sz)
+ {
+ const _CharT* __pe = __p + __sz;
+ for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps)
+ if (_Traits::find(__s, __n, *__ps) == nullptr)
+ return static_cast<_SizeT>(__ps - __p);
+ }
+ return __npos;
+}
+
+
+template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
+inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+__str_find_first_not_of(const _CharT *__p, _SizeT __sz,
+ _CharT __c, _SizeT __pos) _NOEXCEPT
+{
+ if (__pos < __sz)
+ {
+ const _CharT* __pe = __p + __sz;
+ for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps)
+ if (!_Traits::eq(*__ps, __c))
+ return static_cast<_SizeT>(__ps - __p);
+ }
+ return __npos;
+}
+
+
+// __str_find_last_not_of
+template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
+inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+__str_find_last_not_of(const _CharT *__p, _SizeT __sz,
+ const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
+{
+ if (__pos < __sz)
+ ++__pos;
+ else
+ __pos = __sz;
+ for (const _CharT* __ps = __p + __pos; __ps != __p;)
+ if (_Traits::find(__s, __n, *--__ps) == nullptr)
+ return static_cast<_SizeT>(__ps - __p);
+ return __npos;
+}
+
+
+template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
+inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+__str_find_last_not_of(const _CharT *__p, _SizeT __sz,
+ _CharT __c, _SizeT __pos) _NOEXCEPT
+{
+ if (__pos < __sz)
+ ++__pos;
+ else
+ __pos = __sz;
+ for (const _CharT* __ps = __p + __pos; __ps != __p;)
+ if (!_Traits::eq(*--__ps, __c))
+ return static_cast<_SizeT>(__ps - __p);
+ return __npos;
+}
+
+template<class _Ptr>
+inline _LIBCPP_INLINE_VISIBILITY
+size_t __do_string_hash(_Ptr __p, _Ptr __e)
+{
+ typedef typename iterator_traits<_Ptr>::value_type value_type;
+ return __murmur2_or_cityhash<size_t>()(__p, (__e-__p)*sizeof(value_type));
+}
+
+template <class _CharT, class _Iter, class _Traits=char_traits<_CharT> >
+struct __quoted_output_proxy
+{
+ _Iter __first;
+ _Iter __last;
+ _CharT __delim;
+ _CharT __escape;
+
+ __quoted_output_proxy(_Iter __f, _Iter __l, _CharT __d, _CharT __e)
+ : __first(__f), __last(__l), __delim(__d), __escape(__e) {}
+ // This would be a nice place for a string_ref
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___STRING
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__support/android/locale_bionic.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/android/locale_bionic.h
new file mode 100644
index 0000000000..733eb83642
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/android/locale_bionic.h
@@ -0,0 +1,71 @@
+// -*- 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_SUPPORT_ANDROID_LOCALE_BIONIC_H
+#define _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H
+
+#if defined(__BIONIC__)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdlib.h>
+#include <xlocale.h>
+
+#ifdef __cplusplus
+}
+#endif
+
+#if defined(__ANDROID__)
+
+#include <android/api-level.h>
+#if defined(__has_include) && __has_include(<android/ndk-version.h>)
+# include <android/ndk-version.h>
+#endif
+#if __ANDROID_API__ < 21
+#include <__support/xlocale/__posix_l_fallback.h>
+#endif
+// In NDK versions later than 16, locale-aware functions are provided by
+// legacy_stdlib_inlines.h
+#if __NDK_MAJOR__ <= 16
+#if __ANDROID_API__ < 21
+#include <__support/xlocale/__strtonum_fallback.h>
+#elif __ANDROID_API__ < 26
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+inline _LIBCPP_INLINE_VISIBILITY float strtof_l(const char* __nptr, char** __endptr,
+ locale_t) {
+ return ::strtof(__nptr, __endptr);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY double strtod_l(const char* __nptr,
+ char** __endptr, locale_t) {
+ return ::strtod(__nptr, __endptr);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY long strtol_l(const char* __nptr, char** __endptr,
+ int __base, locale_t) {
+ return ::strtol(__nptr, __endptr, __base);
+}
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif // __ANDROID_API__ < 26
+
+#endif // __NDK_MAJOR__ <= 16
+#endif // defined(__ANDROID__)
+
+#endif // defined(__BIONIC__)
+#endif // _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__support/fuchsia/xlocale.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/fuchsia/xlocale.h
new file mode 100644
index 0000000000..e8def81480
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/fuchsia/xlocale.h
@@ -0,0 +1,22 @@
+// -*- 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_SUPPORT_FUCHSIA_XLOCALE_H
+#define _LIBCPP_SUPPORT_FUCHSIA_XLOCALE_H
+
+#if defined(__Fuchsia__)
+
+#include <cstdlib>
+#include <cwchar>
+#include <__support/xlocale/__posix_l_fallback.h>
+#include <__support/xlocale/__strtonum_fallback.h>
+
+#endif // defined(__Fuchsia__)
+
+#endif // _LIBCPP_SUPPORT_FUCHSIA_XLOCALE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__support/ibm/gettod_zos.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/ibm/gettod_zos.h
new file mode 100644
index 0000000000..46e02a6c8b
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/ibm/gettod_zos.h
@@ -0,0 +1,53 @@
+// -*- 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_SUPPORT_IBM_GETTOD_ZOS_H
+#define _LIBCPP_SUPPORT_IBM_GETTOD_ZOS_H
+
+#include <time.h>
+
+static inline int gettimeofdayMonotonic(struct timespec64* Output) {
+
+ // The POSIX gettimeofday() function is not available on z/OS. Therefore,
+ // we will call stcke and other hardware instructions in implement equivalent.
+ // Note that nanoseconds alone will overflow when reaching new epoch in 2042.
+
+ struct _t {
+ uint64_t Hi;
+ uint64_t Lo;
+ };
+ struct _t Value = {0, 0};
+ uint64_t CC = 0;
+ asm(" stcke %0\n"
+ " ipm %1\n"
+ " srlg %1,%1,28\n"
+ : "=m"(Value), "+r"(CC)::);
+
+ if (CC != 0) {
+ errno = EMVSTODNOTSET;
+ return CC;
+ }
+ uint64_t us = (Value.Hi >> 4);
+ uint64_t ns = ((Value.Hi & 0x0F) << 8) + (Value.Lo >> 56);
+ ns = (ns * 1000) >> 12;
+ us = us - 2208988800000000;
+
+ register uint64_t DivPair0 asm("r0"); // dividend (upper half), remainder
+ DivPair0 = 0;
+ register uint64_t DivPair1 asm("r1"); // dividend (lower half), quotient
+ DivPair1 = us;
+ uint64_t Divisor = 1000000;
+ asm(" dlgr %0,%2" : "+r"(DivPair0), "+r"(DivPair1) : "r"(Divisor) :);
+
+ Output->tv_sec = DivPair1;
+ Output->tv_nsec = DivPair0 * 1000 + ns;
+ return 0;
+}
+
+#endif // _LIBCPP_SUPPORT_IBM_GETTOD_ZOS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__support/ibm/limits.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/ibm/limits.h
new file mode 100644
index 0000000000..45f1f1e368
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/ibm/limits.h
@@ -0,0 +1,98 @@
+// -*- 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_SUPPORT_IBM_LIMITS_H
+#define _LIBCPP_SUPPORT_IBM_LIMITS_H
+
+#if !defined(_AIX) // Linux
+#include <math.h> // for HUGE_VAL, HUGE_VALF, HUGE_VALL, and NAN
+
+static const unsigned int _QNAN_F = 0x7fc00000;
+#define NANF (*((float *)(&_QNAN_F)))
+static const unsigned int _QNAN_LDBL128[4] = {0x7ff80000, 0x0, 0x0, 0x0};
+#define NANL (*((long double *)(&_QNAN_LDBL128)))
+static const unsigned int _SNAN_F= 0x7f855555;
+#define NANSF (*((float *)(&_SNAN_F)))
+static const unsigned int _SNAN_D[2] = {0x7ff55555, 0x55555555};
+#define NANS (*((double *)(&_SNAN_D)))
+static const unsigned int _SNAN_LDBL128[4] = {0x7ff55555, 0x55555555, 0x0, 0x0};
+#define NANSL (*((long double *)(&_SNAN_LDBL128)))
+
+#define __builtin_huge_val() HUGE_VAL
+#define __builtin_huge_valf() HUGE_VALF
+#define __builtin_huge_vall() HUGE_VALL
+#define __builtin_nan(__dummy) NAN
+#define __builtin_nanf(__dummy) NANF
+#define __builtin_nanl(__dummy) NANL
+#define __builtin_nans(__dummy) NANS
+#define __builtin_nansf(__dummy) NANSF
+#define __builtin_nansl(__dummy) NANSL
+
+#else
+
+#include <math.h>
+#include <float.h> // limit constants
+
+#define __builtin_huge_val() HUGE_VAL //0x7ff0000000000000
+#define __builtin_huge_valf() HUGE_VALF //0x7f800000
+#define __builtin_huge_vall() HUGE_VALL //0x7ff0000000000000
+#define __builtin_nan(__dummy) nan(__dummy) //0x7ff8000000000000
+#define __builtin_nanf(__dummy) nanf(__dummy) // 0x7ff80000
+#define __builtin_nanl(__dummy) nanl(__dummy) //0x7ff8000000000000
+#define __builtin_nans(__dummy) DBL_SNAN //0x7ff5555555555555
+#define __builtin_nansf(__dummy) FLT_SNAN //0x7f855555
+#define __builtin_nansl(__dummy) DBL_SNAN //0x7ff5555555555555
+
+#define __FLT_MANT_DIG__ FLT_MANT_DIG
+#define __FLT_DIG__ FLT_DIG
+#define __FLT_RADIX__ FLT_RADIX
+#define __FLT_MIN_EXP__ FLT_MIN_EXP
+#define __FLT_MIN_10_EXP__ FLT_MIN_10_EXP
+#define __FLT_MAX_EXP__ FLT_MAX_EXP
+#define __FLT_MAX_10_EXP__ FLT_MAX_10_EXP
+#define __FLT_MIN__ FLT_MIN
+#define __FLT_MAX__ FLT_MAX
+#define __FLT_EPSILON__ FLT_EPSILON
+// predefined by XLC on LoP
+#define __FLT_DENORM_MIN__ 1.40129846e-45F
+
+#define __DBL_MANT_DIG__ DBL_MANT_DIG
+#define __DBL_DIG__ DBL_DIG
+#define __DBL_MIN_EXP__ DBL_MIN_EXP
+#define __DBL_MIN_10_EXP__ DBL_MIN_10_EXP
+#define __DBL_MAX_EXP__ DBL_MAX_EXP
+#define __DBL_MAX_10_EXP__ DBL_MAX_10_EXP
+#define __DBL_MIN__ DBL_MIN
+#define __DBL_MAX__ DBL_MAX
+#define __DBL_EPSILON__ DBL_EPSILON
+// predefined by XLC on LoP
+#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+
+#define __LDBL_MANT_DIG__ LDBL_MANT_DIG
+#define __LDBL_DIG__ LDBL_DIG
+#define __LDBL_MIN_EXP__ LDBL_MIN_EXP
+#define __LDBL_MIN_10_EXP__ LDBL_MIN_10_EXP
+#define __LDBL_MAX_EXP__ LDBL_MAX_EXP
+#define __LDBL_MAX_10_EXP__ LDBL_MAX_10_EXP
+#define __LDBL_MIN__ LDBL_MIN
+#define __LDBL_MAX__ LDBL_MAX
+#define __LDBL_EPSILON__ LDBL_EPSILON
+// predefined by XLC on LoP
+#if __LONGDOUBLE128
+#define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L
+#else
+#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
+#endif
+
+// predefined by XLC on LoP
+#define __CHAR_BIT__ 8
+
+#endif // _AIX
+
+#endif // _LIBCPP_SUPPORT_IBM_LIMITS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__support/ibm/locale_mgmt_zos.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/ibm/locale_mgmt_zos.h
new file mode 100644
index 0000000000..90ad2c2c86
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/ibm/locale_mgmt_zos.h
@@ -0,0 +1,53 @@
+// -*- 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_SUPPORT_IBM_LOCALE_MGMT_ZOS_H
+#define _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_ZOS_H
+
+#if defined(__MVS__)
+#include <locale.h>
+#include <string>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define _LC_MAX LC_MESSAGES /* highest real category */
+#define _NCAT (_LC_MAX + 1) /* maximum + 1 */
+
+#define _CATMASK(n) (1 << (n))
+#define LC_COLLATE_MASK _CATMASK(LC_COLLATE)
+#define LC_CTYPE_MASK _CATMASK(LC_CTYPE)
+#define LC_MONETARY_MASK _CATMASK(LC_MONETARY)
+#define LC_NUMERIC_MASK _CATMASK(LC_NUMERIC)
+#define LC_TIME_MASK _CATMASK(LC_TIME)
+#define LC_MESSAGES_MASK _CATMASK(LC_MESSAGES)
+#define LC_ALL_MASK (_CATMASK(_NCAT) - 1)
+
+typedef struct locale_struct {
+ int category_mask;
+ std::string lc_collate;
+ std::string lc_ctype;
+ std::string lc_monetary;
+ std::string lc_numeric;
+ std::string lc_time;
+ std::string lc_messages;
+} * locale_t;
+
+// z/OS does not have newlocale, freelocale and uselocale.
+// The functions below are workarounds in single thread mode.
+locale_t newlocale(int category_mask, const char* locale, locale_t base);
+void freelocale(locale_t locobj);
+locale_t uselocale(locale_t newloc);
+
+#ifdef __cplusplus
+}
+#endif
+#endif // defined(__MVS__)
+#endif // _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_ZOS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__support/ibm/nanosleep.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/ibm/nanosleep.h
new file mode 100644
index 0000000000..9c6b976c00
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/ibm/nanosleep.h
@@ -0,0 +1,55 @@
+// -*- 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_SUPPORT_IBM_NANOSLEEP_H
+#define _LIBCPP_SUPPORT_IBM_NANOSLEEP_H
+
+#include <unistd.h>
+
+inline int nanosleep(const struct timespec* __req, struct timespec* __rem) {
+ // The nanosleep() function is not available on z/OS. Therefore, we will call
+ // sleep() to sleep for whole seconds and usleep() to sleep for any remaining
+ // fraction of a second. Any remaining nanoseconds will round up to the next
+ // microsecond.
+ if (__req->tv_sec < 0 || __req->tv_nsec < 0 || __req->tv_nsec > 999999999) {
+ errno = EINVAL;
+ return -1;
+ }
+ long __micro_sec = (__req->tv_nsec + 999) / 1000;
+ time_t __sec = __req->tv_sec;
+ if (__micro_sec > 999999) {
+ ++__sec;
+ __micro_sec -= 1000000;
+ }
+ __sec = static_cast<time_t>(sleep(static_cast<unsigned int>(__sec)));
+ if (__sec) {
+ if (__rem) {
+ // Updating the remaining time to sleep in case of unsuccessful call to sleep().
+ __rem->tv_sec = __sec;
+ __rem->tv_nsec = __micro_sec * 1000;
+ }
+ errno = EINTR;
+ return -1;
+ }
+ if (__micro_sec) {
+ int __rt = usleep(static_cast<unsigned int>(__micro_sec));
+ if (__rt != 0 && __rem) {
+ // The usleep() does not provide the amount of remaining time upon its failure,
+ // so the time slept will be ignored.
+ __rem->tv_sec = 0;
+ __rem->tv_nsec = __micro_sec * 1000;
+ // The errno is already set.
+ return -1;
+ }
+ return __rt;
+ }
+ return 0;
+}
+
+#endif // _LIBCPP_SUPPORT_IBM_NANOSLEEP_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__support/ibm/support.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/ibm/support.h
new file mode 100644
index 0000000000..a7751b0176
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/ibm/support.h
@@ -0,0 +1,53 @@
+// -*- 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_SUPPORT_IBM_SUPPORT_H
+#define _LIBCPP_SUPPORT_IBM_SUPPORT_H
+
+extern "builtin" int __popcnt4(unsigned int);
+extern "builtin" int __popcnt8(unsigned long long);
+extern "builtin" unsigned int __cnttz4(unsigned int);
+extern "builtin" unsigned int __cnttz8(unsigned long long);
+extern "builtin" unsigned int __cntlz4(unsigned int);
+extern "builtin" unsigned int __cntlz8(unsigned long long);
+
+// Builtin functions for counting population
+#define __builtin_popcount(x) __popcnt4(x)
+#define __builtin_popcountll(x) __popcnt8(x)
+#if defined(__64BIT__)
+#define __builtin_popcountl(x) __builtin_popcountll(x)
+#else
+#define __builtin_popcountl(x) __builtin_popcount(x)
+#endif
+
+// Builtin functions for counting trailing zeros
+#define __builtin_ctz(x) __cnttz4(x)
+#define __builtin_ctzll(x) __cnttz8(x)
+#if defined(__64BIT__)
+#define __builtin_ctzl(x) __builtin_ctzll(x)
+#else
+#define __builtin_ctzl(x) __builtin_ctz(x)
+#endif
+
+// Builtin functions for counting leading zeros
+#define __builtin_clz(x) __cntlz4(x)
+#define __builtin_clzll(x) __cntlz8(x)
+#if defined(__64BIT__)
+#define __builtin_clzl(x) __builtin_clzll(x)
+#else
+#define __builtin_clzl(x) __builtin_clz(x)
+#endif
+
+#if defined(__64BIT__)
+#define __SIZE_WIDTH__ 64
+#else
+#define __SIZE_WIDTH__ 32
+#endif
+
+#endif // _LIBCPP_SUPPORT_IBM_SUPPORT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__support/ibm/xlocale.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/ibm/xlocale.h
new file mode 100644
index 0000000000..15b8386dd3
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/ibm/xlocale.h
@@ -0,0 +1,133 @@
+// -*- 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_SUPPORT_IBM_XLOCALE_H
+#define _LIBCPP_SUPPORT_IBM_XLOCALE_H
+
+#include <__support/ibm/locale_mgmt_zos.h>
+#include <stdarg.h>
+
+#include "cstdlib"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(__MVS__)
+#include <wctype.h>
+// POSIX routines
+#include <__support/xlocale/__posix_l_fallback.h>
+#endif // defined(__MVS__)
+
+namespace {
+
+struct __setAndRestore {
+ explicit __setAndRestore(locale_t locale) {
+ if (locale == (locale_t)0) {
+ __cloc = newlocale(LC_ALL_MASK, "C", /* base */ (locale_t)0);
+ __stored = uselocale(__cloc);
+ } else {
+ __stored = uselocale(locale);
+ }
+ }
+
+ ~__setAndRestore() {
+ uselocale(__stored);
+ if (__cloc)
+ freelocale(__cloc);
+ }
+
+private:
+ locale_t __stored = (locale_t)0;
+ locale_t __cloc = (locale_t)0;
+};
+
+} // namespace
+
+// The following are not POSIX routines. These are quick-and-dirty hacks
+// to make things pretend to work
+static inline
+long long strtoll_l(const char *__nptr, char **__endptr,
+ int __base, locale_t locale) {
+ __setAndRestore __newloc(locale);
+ return strtoll(__nptr, __endptr, __base);
+}
+
+static inline
+long strtol_l(const char *__nptr, char **__endptr,
+ int __base, locale_t locale) {
+ __setAndRestore __newloc(locale);
+ return strtol(__nptr, __endptr, __base);
+}
+
+static inline
+double strtod_l(const char *__nptr, char **__endptr,
+ locale_t locale) {
+ __setAndRestore __newloc(locale);
+ return strtod(__nptr, __endptr);
+}
+
+static inline
+float strtof_l(const char *__nptr, char **__endptr,
+ locale_t locale) {
+ __setAndRestore __newloc(locale);
+ return strtof(__nptr, __endptr);
+}
+
+static inline
+long double strtold_l(const char *__nptr, char **__endptr,
+ locale_t locale) {
+ __setAndRestore __newloc(locale);
+ return strtold(__nptr, __endptr);
+}
+
+static inline
+unsigned long long strtoull_l(const char *__nptr, char **__endptr,
+ int __base, locale_t locale) {
+ __setAndRestore __newloc(locale);
+ return strtoull(__nptr, __endptr, __base);
+}
+
+static inline
+unsigned long strtoul_l(const char *__nptr, char **__endptr,
+ int __base, locale_t locale) {
+ __setAndRestore __newloc(locale);
+ return strtoul(__nptr, __endptr, __base);
+}
+
+static inline
+int vasprintf(char **strp, const char *fmt, va_list ap) {
+ const size_t buff_size = 256;
+ if ((*strp = (char *)malloc(buff_size)) == NULL) {
+ return -1;
+ }
+
+ va_list ap_copy;
+ // va_copy may not be provided by the C library in C++ 03 mode.
+#if defined(_LIBCPP_CXX03_LANG) && __has_builtin(__builtin_va_copy)
+ __builtin_va_copy(ap_copy, ap);
+#else
+ va_copy(ap_copy, ap);
+#endif
+ int str_size = vsnprintf(*strp, buff_size, fmt, ap_copy);
+ va_end(ap_copy);
+
+ if ((size_t) str_size >= buff_size) {
+ if ((*strp = (char *)realloc(*strp, str_size + 1)) == NULL) {
+ return -1;
+ }
+ str_size = vsnprintf(*strp, str_size + 1, fmt, ap);
+ }
+ return str_size;
+}
+
+#ifdef __cplusplus
+}
+#endif
+#endif // _LIBCPP_SUPPORT_IBM_XLOCALE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__support/musl/xlocale.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/musl/xlocale.h
new file mode 100644
index 0000000000..2508a8e8e0
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/musl/xlocale.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
+//
+//===----------------------------------------------------------------------===//
+// This adds support for the extended locale functions that are currently
+// missing from the Musl C library.
+//
+// This only works when the specified locale is "C" or "POSIX", but that's
+// about as good as we can do without implementing full xlocale support
+// in Musl.
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_SUPPORT_MUSL_XLOCALE_H
+#define _LIBCPP_SUPPORT_MUSL_XLOCALE_H
+
+#include <cstdlib>
+#include <cwchar>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static inline long long strtoll_l(const char *nptr, char **endptr, int base,
+ locale_t) {
+ return strtoll(nptr, endptr, base);
+}
+
+static inline unsigned long long strtoull_l(const char *nptr, char **endptr,
+ int base, locale_t) {
+ return strtoull(nptr, endptr, base);
+}
+
+static inline long long wcstoll_l(const wchar_t *nptr, wchar_t **endptr,
+ int base, locale_t) {
+ return wcstoll(nptr, endptr, base);
+}
+
+static inline unsigned long long wcstoull_l(const wchar_t *nptr,
+ wchar_t **endptr, int base,
+ locale_t) {
+ return wcstoull(nptr, endptr, base);
+}
+
+static inline long double wcstold_l(const wchar_t *nptr, wchar_t **endptr,
+ locale_t) {
+ return wcstold(nptr, endptr);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _LIBCPP_SUPPORT_MUSL_XLOCALE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__support/newlib/xlocale.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/newlib/xlocale.h
new file mode 100644
index 0000000000..b75f9263a4
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/newlib/xlocale.h
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_SUPPORT_NEWLIB_XLOCALE_H
+#define _LIBCPP_SUPPORT_NEWLIB_XLOCALE_H
+
+#if defined(_NEWLIB_VERSION)
+
+#include <cstdlib>
+#include <clocale>
+#include <cwctype>
+#include <ctype.h>
+#if !defined(__NEWLIB__) || __NEWLIB__ < 2 || \
+ __NEWLIB__ == 2 && __NEWLIB_MINOR__ < 5
+#include <__support/xlocale/__nop_locale_mgmt.h>
+#include <__support/xlocale/__posix_l_fallback.h>
+#include <__support/xlocale/__strtonum_fallback.h>
+#endif
+
+#endif // _NEWLIB_VERSION
+
+#endif
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__support/openbsd/xlocale.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/openbsd/xlocale.h
new file mode 100644
index 0000000000..49d66fde1e
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/openbsd/xlocale.h
@@ -0,0 +1,19 @@
+// -*- 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_SUPPORT_OPENBSD_XLOCALE_H
+#define _LIBCPP_SUPPORT_OPENBSD_XLOCALE_H
+
+#include <__support/xlocale/__strtonum_fallback.h>
+#include <clocale>
+#include <cstdlib>
+#include <ctype.h>
+#include <cwctype>
+
+#endif
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__support/solaris/xlocale.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/solaris/xlocale.h
new file mode 100644
index 0000000000..05131f0272
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/solaris/xlocale.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
+//
+//===----------------------------------------------------------------------===//
+
+////////////////////////////////////////////////////////////////////////////////
+// Minimal xlocale implementation for Solaris. This implements the subset of
+// the xlocale APIs that libc++ depends on.
+////////////////////////////////////////////////////////////////////////////////
+#ifndef __XLOCALE_H_INCLUDED
+#define __XLOCALE_H_INCLUDED
+
+#include <stdlib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+int snprintf_l(char *__s, size_t __n, locale_t __l, const char *__format, ...);
+int asprintf_l(char **__s, locale_t __l, const char *__format, ...);
+
+int sscanf_l(const char *__s, locale_t __l, const char *__format, ...);
+
+int toupper_l(int __c, locale_t __l);
+int tolower_l(int __c, locale_t __l);
+
+struct lconv *localeconv(void);
+struct lconv *localeconv_l(locale_t __l);
+
+// FIXME: These are quick-and-dirty hacks to make things pretend to work
+static inline
+long long strtoll_l(const char *__nptr, char **__endptr,
+ int __base, locale_t __loc) {
+ return strtoll(__nptr, __endptr, __base);
+}
+static inline
+long strtol_l(const char *__nptr, char **__endptr,
+ int __base, locale_t __loc) {
+ return strtol(__nptr, __endptr, __base);
+}
+static inline
+unsigned long long strtoull_l(const char *__nptr, char **__endptr,
+ int __base, locale_t __loc) {
+ return strtoull(__nptr, __endptr, __base);
+}
+static inline
+unsigned long strtoul_l(const char *__nptr, char **__endptr,
+ int __base, locale_t __loc) {
+ return strtoul(__nptr, __endptr, __base);
+}
+static inline
+float strtof_l(const char *__nptr, char **__endptr,
+ locale_t __loc) {
+ return strtof(__nptr, __endptr);
+}
+static inline
+double strtod_l(const char *__nptr, char **__endptr,
+ locale_t __loc) {
+ return strtod(__nptr, __endptr);
+}
+static inline
+long double strtold_l(const char *__nptr, char **__endptr,
+ locale_t __loc) {
+ return strtold(__nptr, __endptr);
+}
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__support/win32/atomic_win32.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/win32/atomic_win32.h
new file mode 100644
index 0000000000..e32bcf9073
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/win32/atomic_win32.h
@@ -0,0 +1,1164 @@
+#ifndef _LIBCPP_ATOMIC_WIN32
+#define _LIBCPP_ATOMIC_WIN32
+
+#include <__config>
+#include <type_traits>
+#include <intrin.h>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#define _Atomic(x) x
+
+#ifdef _M_ARM
+#define _MemoryBarrier __dmb(_ARM_BARRIER_ISH)
+#endif
+
+#ifdef _M_ARM64
+#define _MemoryBarrier __dmb(_ARM64_BARRIER_ISH)
+#endif
+
+#ifdef _M_X64
+#define _MemoryBarrier __faststorefence()
+#endif
+
+#ifdef _M_IX86
+#define _MemoryBarrier _mm_mfence()
+#endif
+
+namespace __atomic {
+template <typename _Tp> _Tp __create();
+
+template <typename _Tp, typename _Td>
+enable_if_t<sizeof(__create<_Tp>() = __create<_Td>()), char>
+ __test_atomic_assignable(int);
+template <typename _Tp, typename _Up>
+__two __test_atomic_assignable(...);
+
+template <typename _Tp, typename _Td>
+struct __can_assign {
+ static const bool value =
+ sizeof(__test_atomic_assignable<_Tp, _Td>(1)) == sizeof(char);
+};
+} // namespace __atomic
+
+template <typename _Tp>
+static inline enable_if_t<is_assignable<volatile _Tp, _Tp>::value>
+__c11_atomic_init(volatile _Atomic(_Tp)* __a, _Tp __val) {
+ *__a = __val;
+}
+
+template <typename _Tp>
+static inline enable_if_t<!is_assignable<volatile _Tp, _Tp>::value>
+__c11_atomic_init(volatile _Atomic(_Tp)* __a, _Tp __val) {
+ volatile char* to = reinterpret_cast<volatile char*>(__a);
+ volatile char* end = to + sizeof(_Tp);
+ char* from = reinterpret_cast<char*>(&__val);
+ while (to != end) {
+ *to++ = *from++;
+ }
+}
+
+template <typename _Tp>
+static inline void __c11_atomic_init(_Atomic(_Tp)* __a, _Tp __val) {
+ *__a = __val;
+}
+
+static inline void __c11_atomic_thread_fence(int __order) {
+ if (__order != static_cast<int>(memory_order_relaxed)) {
+#if defined(_M_IX86) || defined(_M_X64)
+ if (__order == static_cast<int>(memory_order_seq_cst)) {
+ _MemoryBarrier;
+ } else {
+ _ReadWriteBarrier();
+ }
+#else // ARM
+ _MemoryBarrier;
+#endif
+ }
+}
+
+static inline void __c11_atomic_signal_fence(int /*__order*/) {
+ _ReadWriteBarrier();
+}
+
+void __msvc_lock(void* p);
+void __msvc_unlock(void* p);
+
+template<class _Out, class _Tp>
+static inline _Out __msvc_cast(_Tp __val) {
+ _Out __result;
+ volatile char* to = reinterpret_cast<volatile char*>(&__result);
+ volatile char* end = to + sizeof(_Tp);
+ char* from = reinterpret_cast<char*>(&__val);
+ while (to != end) {
+ *to++ = *from++;
+ }
+ return __result;
+}
+
+
+
+static inline void __msvc_atomic_store8(volatile char* __a, char __val,
+ memory_order __order) {
+ if (__order == memory_order_relaxed) {
+#if defined(_M_ARM) || defined(_M_ARM64)
+ __iso_volatile_store8(__a, __val);
+#else
+ *__a = __val;
+#endif
+ } else if (__order == memory_order_release) {
+#if defined(_M_ARM) || defined(_M_ARM64)
+ _MemoryBarrier;
+ __iso_volatile_store8(__a, __val);
+#else
+ _ReadWriteBarrier();
+ *__a = __val;
+#endif
+ } else { // __order == memory_order_seq_cst)
+#if defined(_M_ARM) || defined(_M_ARM64)
+ _MemoryBarrier;
+ __iso_volatile_store8(__a, __val);
+ _MemoryBarrier;
+#else
+ _InterlockedExchange8(__a, __val);
+#endif
+ }
+}
+
+static inline void __msvc_atomic_store16(volatile short* __a, short __val,
+ memory_order __order) {
+ if (__order == memory_order_relaxed) {
+#if defined(_M_ARM) || defined(_M_ARM64)
+ __iso_volatile_store16(__a, __val);
+#else
+ *__a = __val;
+#endif
+ } else if (__order == memory_order_release) {
+#if defined(_M_ARM) || defined(_M_ARM64)
+ _MemoryBarrier;
+ __iso_volatile_store16(__a, __val);
+#else
+ _ReadWriteBarrier();
+ *__a = __val;
+#endif
+ } else { // __order == memory_order_seq_cst)
+#if defined(_M_ARM) || defined(_M_ARM64)
+ _MemoryBarrier;
+ __iso_volatile_store16(__a, __val);
+ _MemoryBarrier;
+#else
+ _InterlockedExchange16(__a, __val);
+#endif
+ }
+}
+
+static inline void __msvc_atomic_store32(volatile long* __a, long __val,
+ memory_order __order) {
+ if (__order == memory_order_relaxed) {
+#if defined(_M_ARM) || defined(_M_ARM64)
+ __iso_volatile_store32(__a, __val);
+#else
+ *__a = __val;
+#endif
+ } else if (__order == memory_order_release) {
+#if defined(_M_ARM) || defined(_M_ARM64)
+ _MemoryBarrier;
+ __iso_volatile_store32(__a, __val);
+#else
+ _ReadWriteBarrier();
+ *__a = __val;
+#endif
+ } else { // __order == memory_order_seq_cst)
+#if defined(_M_ARM) || defined(_M_ARM64)
+ _MemoryBarrier;
+ __iso_volatile_store32(__a, __val);
+ _MemoryBarrier;
+#else
+ _InterlockedExchange(__a, __val);
+#endif
+ }
+}
+
+static inline void __msvc_atomic_store64(volatile __int64* __a, __int64 __val,
+ memory_order __order) {
+#if defined(_M_IX86)
+ __int64 __tmp;
+ do {
+ __tmp = *__a;
+ } while (__tmp != _InterlockedCompareExchange64(__a, __val, __tmp));
+#else
+ if (__order == memory_order_relaxed) {
+#if defined(_M_ARM) || defined(_M_ARM64)
+ __iso_volatile_store64(__a, __val);
+#else
+ *__a = __val;
+#endif
+ } else if (__order == memory_order_release) {
+#if defined(_M_ARM) || defined(_M_ARM64)
+ _MemoryBarrier;
+ __iso_volatile_store64(__a, __val);
+#else
+ _ReadWriteBarrier();
+ *__a = __val;
+#endif
+ } else { // __order == memory_order_seq_cst)
+#if defined(_M_ARM) || defined(_M_ARM64)
+ _MemoryBarrier;
+ __iso_volatile_store64(__a, __val);
+ _MemoryBarrier;
+#else
+ _InterlockedExchange64(__a, __val);
+#endif
+ }
+#endif
+}
+
+template <typename _Tp>
+static inline void __c11_atomic_store(volatile _Atomic(_Tp)* __a, _Tp __val,
+ int __order) {
+ if (sizeof(_Tp) == 1) {
+ __msvc_atomic_store8((volatile char*)__a, __msvc_cast<char>(__val), (memory_order)__order);
+ } else if (sizeof(_Tp) == 2 && alignof(_Tp) % 2 == 0) {
+ __msvc_atomic_store16((volatile short*)__a, __msvc_cast<short>(__val), (memory_order)__order);
+ } else if (sizeof(_Tp) == 4 && alignof(_Tp) % 4 == 0) {
+ __msvc_atomic_store32((volatile long*)__a, __msvc_cast<long>(__val), (memory_order)__order);
+ } else if (sizeof(_Tp) == 8 && alignof(_Tp) % 8 == 0) {
+ __msvc_atomic_store64((volatile __int64*)__a, __msvc_cast<__int64>(__val), (memory_order)__order);
+ } else {
+ __msvc_lock((void*)__a);
+ *(_Atomic(_Tp)*)__a = __val;
+ __msvc_unlock((void*)__a);
+ }
+}
+
+template<typename _Tp>
+static inline void __c11_atomic_store(_Atomic(_Tp)* __a, _Tp __val, int __order) {
+ __c11_atomic_store((volatile _Atomic(_Tp)*)__a, __val, __order);
+}
+
+static inline char __msvc_atomic_load8(volatile char* __a, memory_order __order) {
+ char __result;
+ if (__order == memory_order_relaxed) {
+#if defined(_M_ARM) || defined(_M_ARM64)
+ __result = __iso_volatile_load8(__a);
+#else
+ __result = *__a;
+#endif
+ } else if (__order == memory_order_acquire ||
+ __order == memory_order_consume) {
+#if defined(_M_ARM) || defined(_M_ARM64)
+ __result = __iso_volatile_load8(__a);
+ _MemoryBarrier;
+#else
+ __result = *__a;
+ _ReadWriteBarrier();
+#endif
+ } else { // __order == memory_order_seq_cst
+#if defined(_M_ARM) || defined(_M_ARM64)
+ _MemoryBarrier;
+ __result = __iso_volatile_load8(__a);
+ _MemoryBarrier;
+#else
+ _ReadWriteBarrier();
+ __result = *__a;
+ _ReadWriteBarrier();
+#endif
+ }
+ return __result;
+}
+
+static inline short __msvc_atomic_load16(volatile short* __a, memory_order __order) {
+ short __result;
+ if (__order == memory_order_relaxed) {
+#if defined(_M_ARM) || defined(_M_ARM64)
+ __result = __iso_volatile_load16(__a);
+#else
+ __result = *__a;
+#endif
+ } else if (__order == memory_order_acquire ||
+ __order == memory_order_consume) {
+#if defined(_M_ARM) || defined(_M_ARM64)
+ __result = __iso_volatile_load16(__a);
+ _MemoryBarrier;
+#else
+ __result = *__a;
+ _ReadWriteBarrier();
+#endif
+ } else { // __order == memory_order_seq_cst
+#if defined(_M_ARM) || defined(_M_ARM64)
+ _MemoryBarrier;
+ __result = __iso_volatile_load16(__a);
+ _MemoryBarrier;
+#else
+ _ReadWriteBarrier();
+ __result = *__a;
+ _ReadWriteBarrier();
+#endif
+ }
+ return __result;
+}
+
+static inline long __msvc_atomic_load32(volatile long* __a, memory_order __order) {
+ long __result;
+ if (__order == memory_order_relaxed) {
+#if defined(_M_ARM) || defined(_M_ARM64)
+ __result = __iso_volatile_load32(__a);
+#else
+ __result = *__a;
+#endif
+ } else if (__order == memory_order_acquire ||
+ __order == memory_order_consume) {
+#if defined(_M_ARM) || defined(_M_ARM64)
+ __result = __iso_volatile_load32(__a);
+ _MemoryBarrier;
+#else
+ __result = *__a;
+ _ReadWriteBarrier();
+#endif
+ } else { // __order == memory_order_seq_cst
+#if defined(_M_ARM) || defined(_M_ARM64)
+ _MemoryBarrier;
+ __result = __iso_volatile_load32(__a);
+ _MemoryBarrier;
+#else
+ _ReadWriteBarrier();
+ __result = *__a;
+ _ReadWriteBarrier();
+#endif
+ }
+ return __result;
+}
+
+static inline __int64 __msvc_atomic_load64(volatile __int64* __a, memory_order __order) {
+ __int64 __result;
+#if defined(_M_X86)
+ do {
+ __result = *__a;
+ } while (__result != _InterlockedCompareExchange64(__a, __result, __result));
+#else
+ if (__order == memory_order_relaxed) {
+#if defined(_M_ARM) || defined(_M_ARM64)
+ __result = __iso_volatile_load64(__a);
+#else
+ __result = *__a;
+#endif
+ } else if (__order == memory_order_acquire ||
+ __order == memory_order_consume) {
+#if defined(_M_ARM) || defined(_M_ARM64)
+ __result = __iso_volatile_load64(__a);
+ _MemoryBarrier;
+#else
+ __result = *__a;
+ _ReadWriteBarrier();
+#endif
+ } else { // __order == memory_order_seq_cst
+#if defined(_M_ARM) || defined(_M_ARM64)
+ _MemoryBarrier;
+ __result = __iso_volatile_load64(__a);
+ _MemoryBarrier;
+#else
+ _ReadWriteBarrier();
+ __result = *__a;
+ _ReadWriteBarrier();
+#endif
+ }
+#endif
+ return __result;
+}
+
+template<typename _Tp>
+static inline _Tp __c11_atomic_load(volatile _Atomic(_Tp)* __a, int __order) {
+ _Tp __result;
+ if (sizeof(_Tp) == 1) {
+ __result = __msvc_cast<_Tp>(__msvc_atomic_load8((volatile char*)__a, (memory_order)__order));
+ } else if (sizeof(_Tp) == 2 && alignof(_Tp) % 2 == 0) {
+ __result = __msvc_cast<_Tp>(__msvc_atomic_load16((volatile short*)__a, (memory_order)__order));
+ } else if (sizeof(_Tp) == 4 && alignof(_Tp) % 4 == 0) {
+ __result = __msvc_cast<_Tp>(__msvc_atomic_load32((volatile long*)__a, (memory_order)__order));
+ } else if (sizeof(_Tp) == 8 && alignof(_Tp) % 8 == 0) {
+ __result = __msvc_cast<_Tp>(__msvc_atomic_load64((volatile __int64*)__a, (memory_order)__order));
+ } else {
+ __msvc_lock((void*)__a);
+ __result = *(_Atomic(_Tp)*)__a;
+ __msvc_unlock((void*)__a);
+ }
+ return __result;
+}
+
+template<typename _Tp>
+static inline _Tp __c11_atomic_load(_Atomic(_Tp)* __a, int __order) {
+ return __c11_atomic_load((volatile _Atomic(_Tp)*)__a, __order);
+}
+
+static inline char __msvc_atomic_exchange8(volatile char* __a, char __val,
+ memory_order __order) {
+ char __result;
+#if defined(_M_ARM) || defined(_M_ARM64)
+ if (__order == memory_order_relaxed) {
+ __result = _InterlockedExchange8_nf(__a, __val);
+ } else if (__order == memory_order_acquire ||
+ __order == memory_order_consume) {
+ __result = _InterlockedExchange8_acq(__a, __val);
+ } else if (__order == memory_order_release) {
+ __result = _InterlockedExchange8_rel(__a, __val);
+ } else {
+ __result = _InterlockedExchange8(__a, __val);
+ }
+#else
+ (void)__order;
+ __result = _InterlockedExchange8(__a, __val);
+#endif
+ return __result;
+}
+
+static inline short __msvc_atomic_exchange16(volatile short* __a, short __val,
+ memory_order __order) {
+ short __result;
+#if defined(_M_ARM) || defined(_M_ARM64)
+ if (__order == memory_order_relaxed) {
+ __result = _InterlockedExchange16_nf(__a, __val);
+ } else if (__order == memory_order_acquire ||
+ __order == memory_order_consume) {
+ __result = _InterlockedExchange16_acq(__a, __val);
+ } else if (__order == memory_order_release) {
+ __result = _InterlockedExchange16_rel(__a, __val);
+ } else {
+ __result = _InterlockedExchange16(__a, __val);
+ }
+#else
+ (void)__order;
+ __result = _InterlockedExchange16(__a, __val);
+#endif
+ return __result;
+}
+
+static inline long __msvc_atomic_exchange32(volatile long* __a, long __val,
+ memory_order __order) {
+ long __result;
+#if defined(_M_ARM) || defined(_M_ARM64)
+ if (__order == memory_order_relaxed) {
+ __result = _InterlockedExchange_nf(__a, __val);
+ } else if (__order == memory_order_acquire ||
+ __order == memory_order_consume) {
+ __result = _InterlockedExchange_acq(__a, __val);
+ } else if (__order == memory_order_release) {
+ __result = _InterlockedExchange_rel(__a, __val);
+ } else {
+ __result = _InterlockedExchange(__a, __val);
+ }
+#else
+ (void)__order;
+ __result = _InterlockedExchange(__a, __val);
+#endif
+ return __result;
+}
+
+static inline __int64 __msvc_atomic_exchange64(volatile __int64* __a, __int64 __val,
+ memory_order __order) {
+ __int64 __result;
+#if defined(_M_IX86)
+ do {
+ __result = *__a;
+ } while (__result != _InterlockedCompareExchange64(__a, __val, __result));
+#elif defined(_M_ARM) || defined(_M_ARM64)
+ if (__order == memory_order_relaxed) {
+ __result = _InterlockedExchange64_nf(__a, __val);
+ } else if (__order == memory_order_acquire ||
+ __order == memory_order_consume) {
+ __result = _InterlockedExchange64_acq(__a, __val);
+ } else if (__order == memory_order_release) {
+ __result = _InterlockedExchange64_rel(__a, __val);
+ } else {
+ __result = _InterlockedExchange64(__a, __val);
+ }
+#else
+ (void)__order;
+ __result = _InterlockedExchange64(__a, __val);
+#endif
+ return __result;
+}
+
+template<typename _Tp>
+static inline _Tp __c11_atomic_exchange(volatile _Atomic(_Tp)* __a, _Tp __val,
+ int __order) {
+ _Tp __result;
+ if (sizeof(_Tp) == 1) {
+ __result = __msvc_cast<_Tp>(
+ __msvc_atomic_exchange8((volatile char*)__a, __msvc_cast<char>(__val), (memory_order)__order));
+ } else if (sizeof(_Tp) == 2 && alignof(_Tp) % 2 == 0) {
+ __result = __msvc_cast<_Tp>(
+ __msvc_atomic_exchange16((volatile short*)__a, __msvc_cast<short>(__val), (memory_order)__order));
+ } else if (sizeof(_Tp) == 4 && alignof(_Tp) % 4 == 0) {
+ __result = __msvc_cast<_Tp>(
+ __msvc_atomic_exchange32((volatile long*)__a, __msvc_cast<long>(__val), (memory_order)__order));
+ } else if (sizeof(_Tp) == 8 && alignof(_Tp) % 8 == 0) {
+ __result = __msvc_cast<_Tp>(
+ __msvc_atomic_exchange64((volatile __int64*)__a, __msvc_cast<__int64>(__val), (memory_order)__order));
+ } else {
+ __msvc_lock((void*)__a);
+ __result = *(_Atomic(_Tp)*)__a;
+ *(_Atomic(_Tp)*)__a = __val;
+ __msvc_unlock((void*)__a);
+ }
+ return __result;
+}
+
+template<typename _Tp>
+static inline _Tp __c11_atomic_exchange(_Atomic(_Tp)* __a, _Tp __val,
+ int __order) {
+ return __c11_atomic_exchange((volatile _Atomic(_Tp)*)__a, __val, __order);
+}
+
+static inline bool __msvc_atomic_compare_exchange8(volatile char* __a, char __value, char* __expected,
+ memory_order __order) {
+ char __compare = *__expected;
+ char __before;
+#if defined(_M_ARM) || defined(_M_ARM64)
+ if (__order == memory_order_relaxed) {
+ __before = _InterlockedCompareExchange8_nf(__a, __value, __compare);
+ } else if (__order == memory_order_acquire) {
+ __before = _InterlockedCompareExchange8_acq(__a, __value, __compare);
+ } else if (__order == memory_order_release) {
+ __before = _InterlockedCompareExchange8_rel(__a, __value, __compare);
+ } else {
+ __before = _InterlockedCompareExchange8(__a, __value, __compare);
+ }
+#else
+ (void)__order;
+ __before = _InterlockedCompareExchange8(__a, __value, __compare);
+#endif
+ if (__before == __compare) {
+ return true;
+ }
+ *__expected = __before;
+ return false;
+}
+
+static inline bool __msvc_atomic_compare_exchange16(volatile short* __a, short __value, short* __expected,
+ memory_order __order) {
+ short __compare = *__expected;
+ short __before;
+#if defined(_M_ARM) || defined(_M_ARM64)
+ if (__order == memory_order_relaxed) {
+ __before = _InterlockedCompareExchange16_nf(__a, __value, __compare);
+ } else if (__order == memory_order_acquire) {
+ __before = _InterlockedCompareExchange16_acq(__a, __value, __compare);
+ } else if (__order == memory_order_release) {
+ __before = _InterlockedCompareExchange16_rel(__a, __value, __compare);
+ } else {
+ __before = _InterlockedCompareExchange16(__a, __value, __compare);
+ }
+#else
+ (void)__order;
+ __before = _InterlockedCompareExchange16(__a, __value, __compare);
+#endif
+ if (__before == __compare) {
+ return true;
+ }
+ *__expected = __before;
+ return false;
+}
+
+static inline bool __msvc_atomic_compare_exchange32(volatile long* __a, long __value, long* __expected,
+ memory_order __order) {
+ long __compare = *__expected;
+ long __before;
+#if defined(_M_ARM) || defined(_M_ARM64)
+ if (__order == memory_order_relaxed) {
+ __before = _InterlockedCompareExchange_nf(__a, __value, __compare);
+ } else if (__order == memory_order_acquire) {
+ __before = _InterlockedCompareExchange_acq(__a, __value, __compare);
+ } else if (__order == memory_order_release) {
+ __before = _InterlockedCompareExchange_rel(__a, __value, __compare);
+ } else {
+ __before = _InterlockedCompareExchange(__a, __value, __compare);
+ }
+#else
+ (void)__order;
+ __before = _InterlockedCompareExchange(__a, __value, __compare);
+#endif
+ if (__before == __compare) {
+ return true;
+ }
+ *__expected = __before;
+ return false;
+}
+
+static inline bool __msvc_atomic_compare_exchange64(volatile __int64* __a, __int64 __value, __int64* __expected,
+ memory_order __order) {
+ __int64 __compare = *__expected;
+ __int64 __before;
+#if defined(_M_ARM) || defined(_M_ARM64)
+ if (__order == memory_order_relaxed) {
+ __before = _InterlockedCompareExchange64_nf(__a, __value, __compare);
+ } else if (__order == memory_order_acquire) {
+ __before = _InterlockedCompareExchange64_acq(__a, __value, __compare);
+ } else if (__order == memory_order_release) {
+ __before = _InterlockedCompareExchange64_rel(__a, __value, __compare);
+ } else {
+ __before = _InterlockedCompareExchange64(__a, __value, __compare);
+ }
+#else
+ (void)__order;
+ __before = _InterlockedCompareExchange64(__a, __value, __compare);
+#endif
+ if (__before == __compare) {
+ return true;
+ }
+ *__expected = __before;
+ return false;
+}
+
+
+static inline memory_order constexpr __msvc_top_memory_order(memory_order __order1, memory_order __order2) {
+ return
+ (__order1 == memory_order_relaxed && __order2 == memory_order_relaxed) ? memory_order_relaxed :
+ ((__order1 == memory_order_relaxed || __order1 == memory_order_acquire || __order1 == memory_order_consume) &&
+ (__order2 == memory_order_relaxed || __order2 == memory_order_relaxed || __order2 == memory_order_consume)) ? memory_order_acquire :
+ ((__order1 == memory_order_relaxed || __order1 == memory_order_release) &&
+ (__order2 == memory_order_relaxed || __order2 == memory_order_release)) ? memory_order_release :
+ (__order1 != memory_order_seq_cst && __order2 != memory_order_seq_cst) ? memory_order_acq_rel :
+ memory_order_seq_cst;
+}
+
+template<typename _Tp>
+static inline bool __c11_atomic_compare_exchange_strong(
+ volatile _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value,
+ int __order_success, int __order_failure) {
+ memory_order __order = __msvc_top_memory_order((memory_order)__order_success, (memory_order)__order_failure);
+ if (sizeof(_Tp) == 1) {
+ return __msvc_atomic_compare_exchange8((volatile char*)__a, __msvc_cast<char>(__value), (char*)__expected, __order);
+ } else if (sizeof(_Tp) == 2 && alignof(_Tp) % 2 == 0) {
+ return __msvc_atomic_compare_exchange16((volatile short*)__a, __msvc_cast<short>(__value), (short*)__expected, __order);
+ } else if (sizeof(_Tp) == 4 && alignof(_Tp) % 4 == 0) {
+ return __msvc_atomic_compare_exchange32((volatile long*)__a, __msvc_cast<long>(__value), (long*)__expected, __order);
+ } else if (sizeof(_Tp) == 8 && alignof(_Tp) % 8 == 0) {
+ return __msvc_atomic_compare_exchange64((volatile __int64*)__a, __msvc_cast<__int64>(__value), (__int64*)__expected, __order);
+ } else {
+ bool __result;
+ __msvc_lock((void*)__a);
+ volatile char* __p_a = reinterpret_cast<volatile char*>(__a);
+ volatile char* __p_a_end = __p_a + sizeof(_Atomic(_Tp));
+ volatile char* __p_expected = reinterpret_cast<volatile char*>(__expected);
+ bool __equal = true;
+ while (__p_a != __p_a_end) {
+ if (*__p_a++ != *__p_expected++) {
+ __equal = false;
+ break;
+ }
+ }
+ if (__equal) {
+ *(_Atomic(_Tp)*)__a = __value;
+ __result = true;
+ } else {
+ *__expected = *(_Atomic(_Tp)*)__a;
+ __result = false;
+ }
+ __msvc_unlock((void*)__a);
+ return __result;
+ }
+}
+
+template<typename _Tp>
+static inline bool __c11_atomic_compare_exchange_strong(
+ _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value,
+ int __order_success, int __order_failure) {
+ return __c11_atomic_compare_exchange_strong(
+ (volatile _Atomic(_Tp)*)__a, __expected, __value, __order_success, __order_failure);
+}
+
+template<typename _Tp>
+static inline bool __c11_atomic_compare_exchange_weak(
+ volatile _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value,
+ int __order_success, int __order_failure) {
+ return __c11_atomic_compare_exchange_strong(__a, __expected, __value, __order_success, __order_failure);
+}
+
+template<typename _Tp>
+static inline bool __c11_atomic_compare_exchange_weak(
+ _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value,
+ int __order_success, int __order_failure) {
+ return __c11_atomic_compare_exchange_strong(__a, __expected, __value, __order_success, __order_failure);
+}
+
+template <typename _Tp>
+struct __msvc_skip { enum {value = 1}; };
+
+template <typename _Tp>
+struct __msvc_skip<_Tp*> { enum {value = sizeof(_Tp)}; };
+
+// FIXME: Haven't figured out what the spec says about using arrays with
+// atomic_fetch_add. Force a failure rather than creating bad behavior.
+template <typename _Tp>
+struct __msvc_skip<_Tp[]> { };
+template <typename _Tp, int n>
+struct __msvc_skip<_Tp[n]> { };
+
+static inline char __msvc_atomic_fetch_add8(volatile char* __a, char __delta,
+ memory_order __order) {
+#if defined(_M_ARM) || defined(_M_ARM64)
+ if (__order == memory_order_relaxed) {
+ return _InterlockedExchangeAdd8_nf(__a, __delta);
+ } else if (__order == memory_order_acquire) {
+ return _InterlockedExchangeAdd8_acq(__a, __delta);
+ } else if (__order == memory_order_release) {
+ return _InterlockedExchangeAdd8_rel(__a, __delta);
+ } else {
+ return _InterlockedExchangeAdd8(__a, __delta);
+ }
+#else
+ (void)__order;
+ return _InterlockedExchangeAdd8(__a, __delta);
+#endif
+}
+
+static inline short __msvc_atomic_fetch_add16(volatile short* __a, short __delta,
+ memory_order __order) {
+#if defined(_M_ARM) || defined(_M_ARM64)
+ if (__order == memory_order_relaxed) {
+ return _InterlockedExchangeAdd16_nf(__a, __delta);
+ } else if (__order == memory_order_acquire) {
+ return _InterlockedExchangeAdd16_acq(__a, __delta);
+ } else if (__order == memory_order_release) {
+ return _InterlockedExchangeAdd16_rel(__a, __delta);
+ } else {
+ return _InterlockedExchangeAdd16(__a, __delta);
+ }
+#else
+ (void)__order;
+ return _InterlockedExchangeAdd16(__a, __delta);
+#endif
+}
+
+static inline long __msvc_atomic_fetch_add32(volatile long* __a, long __delta,
+ memory_order __order) {
+#if defined(_M_ARM) || defined(_M_ARM64)
+ if (__order == memory_order_relaxed) {
+ return _InterlockedExchangeAdd_nf(__a, __delta);
+ } else if (__order == memory_order_acquire) {
+ return _InterlockedExchangeAdd_acq(__a, __delta);
+ } else if (__order == memory_order_release) {
+ return _InterlockedExchangeAdd_rel(__a, __delta);
+ } else {
+ return _InterlockedExchangeAdd(__a, __delta);
+ }
+#else
+ (void)__order;
+ return _InterlockedExchangeAdd(__a, __delta);
+#endif
+}
+
+static inline __int64 __msvc_atomic_fetch_add64(volatile __int64* __a, __int64 __delta,
+ memory_order __order) {
+#if defined(_M_IX86)
+ __int64 __tmp;
+ do {
+ __tmp = *__a;
+ } while (__tmp != _InterlockedCompareExchange64(__a, __tmp + __delta, __tmp));
+ return __tmp;
+#elif defined(_M_ARM) || defined(_M_ARM64)
+ if (__order == memory_order_relaxed) {
+ return _InterlockedExchangeAdd64_nf(__a, __delta);
+ } else if (__order == memory_order_acquire) {
+ return _InterlockedExchangeAdd64_acq(__a, __delta);
+ } else if (__order == memory_order_release) {
+ return _InterlockedExchangeAdd64_rel(__a, __delta);
+ } else {
+ return _InterlockedExchangeAdd64(__a, __delta);
+ }
+#else
+ (void)__order;
+ return _InterlockedExchangeAdd64(__a, __delta);
+#endif
+}
+
+template <typename _Tp, typename _Td>
+static inline _Tp __c11_atomic_fetch_add(volatile _Atomic(_Tp)* __a,
+ _Td __delta, int __order) {
+ _Td __real_delta = __delta * __msvc_skip<_Tp>::value;
+ if (sizeof(_Tp) == 1 && std::is_integral<_Tp>::value) {
+ return __msvc_cast<_Tp>(__msvc_atomic_fetch_add8((volatile char*)__a, (char)__real_delta, (memory_order)__order));
+ } else if (sizeof(_Tp) == 2 && std::is_integral<_Tp>::value) {
+ return __msvc_cast<_Tp>(__msvc_atomic_fetch_add16((volatile short*)__a, (short)__real_delta, (memory_order)__order));
+ } else if (sizeof(_Tp) == 4 && (std::is_integral<_Tp>::value || std::is_pointer<_Tp>::value)) {
+ return __msvc_cast<_Tp>(__msvc_atomic_fetch_add32((volatile long*)__a, (long)__real_delta, (memory_order)__order));
+ } else if (sizeof(_Tp) == 8 && (std::is_integral<_Tp>::value || std::is_pointer<_Tp>::value)) {
+ return __msvc_cast<_Tp>(__msvc_atomic_fetch_add64((volatile __int64*)__a, (__int64)__real_delta, (memory_order)__order));
+ } else {
+ __msvc_lock((void*)__a);
+ _Tp __result = *(_Atomic(_Tp)*)__a;
+ *(_Atomic(_Tp)*)__a += __delta;
+ __msvc_unlock((void*)__a);
+ return __result;
+ }
+}
+
+template <typename _Tp, typename _Td>
+static inline _Tp __c11_atomic_fetch_add(_Atomic(_Tp)* __a,
+ _Td __delta, int __order) {
+ return __c11_atomic_fetch_add((volatile _Atomic(_Tp)*) __a, __delta, __order);
+}
+
+template <typename _Tp, typename _Td>
+static inline _Tp __c11_atomic_fetch_sub(volatile _Atomic(_Tp)* __a,
+ _Td __delta, int __order) {
+ _Td __real_delta = __delta * __msvc_skip<_Tp>::value;
+ // Cast __real_delta to unsigned types to avoid integer overflow on negation.
+ if (sizeof(_Tp) == 1 && std::is_integral<_Tp>::value) {
+ return __msvc_cast<_Tp>(__msvc_atomic_fetch_add8((volatile char*)__a, -(unsigned char)__real_delta, (memory_order)__order));
+ } else if (sizeof(_Tp) == 2 && std::is_integral<_Tp>::value) {
+ return __msvc_cast<_Tp>(__msvc_atomic_fetch_add16((volatile short*)__a, -(unsigned short)__real_delta, (memory_order)__order));
+ } else if (sizeof(_Tp) == 4 && (std::is_integral<_Tp>::value || std::is_pointer<_Tp>::value)) {
+ return __msvc_cast<_Tp>(__msvc_atomic_fetch_add32((volatile long*)__a, -(unsigned long)__real_delta, (memory_order)__order));
+ } else if (sizeof(_Tp) == 8 && (std::is_integral<_Tp>::value || std::is_pointer<_Tp>::value)) {
+ return __msvc_cast<_Tp>(__msvc_atomic_fetch_add64((volatile __int64*)__a, -(unsigned __int64)__real_delta, (memory_order)__order));
+ } else {
+ __msvc_lock((void*)__a);
+ _Tp __result = *(_Atomic(_Tp)*)__a;
+ *(_Atomic(_Tp)*)__a -= __delta;
+ __msvc_unlock((void*)__a);
+ return __result;
+ }
+}
+
+template <typename _Tp, typename _Td>
+static inline _Tp __c11_atomic_fetch_sub(_Atomic(_Tp)* __a,
+ _Td __delta, int __order) {
+ return __c11_atomic_fetch_sub((volatile _Atomic(_Tp)*) __a, __delta, __order);
+}
+
+static inline char __msvc_atomic_fetch_and8(volatile char* __a, char __value,
+ memory_order __order) {
+#if defined(_M_ARM) || defined(_M_ARM64)
+ if (__order == memory_order_relaxed) {
+ return _InterlockedAnd8_nf(__a, __value);
+ } else if (__order == memory_order_acquire) {
+ return _InterlockedAnd8_acq(__a, __value);
+ } else if (__order == memory_order_release) {
+ return _InterlockedAnd8_rel(__a, __value);
+ } else {
+ return _InterlockedAnd8(__a, __value);
+ }
+#else
+ (void)__order;
+ return _InterlockedAnd8(__a, __value);
+#endif
+}
+
+static inline short __msvc_atomic_fetch_and16(volatile short* __a, short __value,
+ memory_order __order) {
+#if defined(_M_ARM) || defined(_M_ARM64)
+ if (__order == memory_order_relaxed) {
+ return _InterlockedAnd16_nf(__a, __value);
+ } else if (__order == memory_order_acquire) {
+ return _InterlockedAnd16_acq(__a, __value);
+ } else if (__order == memory_order_release) {
+ return _InterlockedAnd16_rel(__a, __value);
+ } else {
+ return _InterlockedAnd16(__a, __value);
+ }
+#else
+ (void)__order;
+ return _InterlockedAnd16(__a, __value);
+#endif
+}
+
+static inline long __msvc_atomic_fetch_and32(volatile long* __a, long __value,
+ memory_order __order) {
+#if defined(_M_ARM) || defined(_M_ARM64)
+ if (__order == memory_order_relaxed) {
+ return _InterlockedAnd_nf(__a, __value);
+ } else if (__order == memory_order_acquire) {
+ return _InterlockedAnd_acq(__a, __value);
+ } else if (__order == memory_order_release) {
+ return _InterlockedAnd_rel(__a, __value);
+ } else {
+ return _InterlockedAnd(__a, __value);
+ }
+#else
+ (void)__order;
+ return _InterlockedAnd(__a, __value);
+#endif
+}
+
+static inline __int64 __msvc_atomic_fetch_and64(volatile __int64* __a, __int64 __value,
+ memory_order __order) {
+#if defined(_M_IX86)
+ __int64 __tmp;
+ do {
+ __tmp = *__a;
+ } while (__tmp != _InterlockedCompareExchange64(__a, __tmp & __value, __tmp));
+ return __tmp;
+#elif defined(_M_ARM) || defined(_M_ARM64)
+ if (__order == memory_order_relaxed) {
+ return _InterlockedAnd64_nf(__a, __value);
+ } else if (__order == memory_order_acquire) {
+ return _InterlockedAnd64_acq(__a, __value);
+ } else if (__order == memory_order_release) {
+ return _InterlockedAnd64_rel(__a, __value);
+ } else {
+ return _InterlockedAnd64(__a, __value);
+ }
+#else
+ (void)__order;
+ return _InterlockedAnd64(__a, __value);
+#endif
+}
+
+template <typename _Tp>
+static inline _Tp __c11_atomic_fetch_and(volatile _Atomic(_Tp)* __a,
+ _Tp __value, int __order) {
+ if (sizeof(_Tp) == 1 && (std::is_integral<_Tp>::value || std::is_same<std::remove_cv_t<_Tp>, bool>::value)) {
+ return __msvc_cast<_Tp>(__msvc_atomic_fetch_and8((volatile char*)__a, __msvc_cast<char>(__value), (memory_order)__order));
+ } else if (sizeof(_Tp) == 2 && std::is_integral<_Tp>::value) {
+ return (_Tp)__msvc_atomic_fetch_and16((volatile short*)__a, (short)__value, (memory_order)__order);
+ } else if (sizeof(_Tp) == 4 && std::is_integral<_Tp>::value) {
+ return (_Tp) __msvc_atomic_fetch_and32((volatile long*)__a, (long)__value, (memory_order)__order);
+ } else if (sizeof(_Tp) == 8 && std::is_integral<_Tp>::value) {
+ return (_Tp) __msvc_atomic_fetch_and64((volatile __int64*)__a, (__int64)__value, (memory_order)__order);
+ } else {
+ __msvc_lock((void*)__a);
+ _Tp __result = *(_Atomic(_Tp)*)__a;
+ *(_Atomic(_Tp)*)__a &= __value;
+ __msvc_unlock((void*)__a);
+ return __result;
+ }
+}
+
+template <typename _Tp>
+static inline _Tp __c11_atomic_fetch_and(_Atomic(_Tp)* __a,
+ _Tp __value, int __order) {
+ return __c11_atomic_fetch_and((volatile _Atomic(_Tp)*)__a, __value, __order);
+}
+
+static inline char __msvc_atomic_fetch_or8(volatile char* __a, char __value,
+ memory_order __order) {
+#if defined(_M_ARM) || defined(_M_ARM64)
+ if (__order == memory_order_relaxed) {
+ return _InterlockedOr8_nf(__a, __value);
+ } else if (__order == memory_order_acquire) {
+ return _InterlockedOr8_acq(__a, __value);
+ } else if (__order == memory_order_release) {
+ return _InterlockedOr8_rel(__a, __value);
+ } else {
+ return _InterlockedOr8(__a, __value);
+ }
+#else
+ (void)__order;
+ return _InterlockedOr8(__a, __value);
+#endif
+}
+
+static inline short __msvc_atomic_fetch_or16(volatile short* __a, short __value,
+ memory_order __order) {
+#if defined(_M_ARM) || defined(_M_ARM64)
+ if (__order == memory_order_relaxed) {
+ return _InterlockedOr16_nf(__a, __value);
+ } else if (__order == memory_order_acquire) {
+ return _InterlockedOr16_acq(__a, __value);
+ } else if (__order == memory_order_release) {
+ return _InterlockedOr16_rel(__a, __value);
+ } else {
+ return _InterlockedOr16(__a, __value);
+ }
+#else
+ (void)__order;
+ return _InterlockedOr16(__a, __value);
+#endif
+}
+
+static inline long __msvc_atomic_fetch_or32(volatile long* __a, long __value,
+ memory_order __order) {
+#if defined(_M_ARM) || defined(_M_ARM64)
+ if (__order == memory_order_relaxed) {
+ return _InterlockedOr_nf(__a, __value);
+ } else if (__order == memory_order_acquire) {
+ return _InterlockedOr_acq(__a, __value);
+ } else if (__order == memory_order_release) {
+ return _InterlockedOr_rel(__a, __value);
+ } else {
+ return _InterlockedOr(__a, __value);
+ }
+#else
+ (void)__order;
+ return _InterlockedOr(__a, __value);
+#endif
+}
+
+static inline __int64 __msvc_atomic_fetch_or64(volatile __int64* __a, __int64 __value,
+ memory_order __order) {
+#if defined(_M_IX86)
+ __int64 __tmp;
+ do {
+ __tmp = *__a;
+ } while (__tmp != _InterlockedCompareExchange64(__a, __tmp | __value, __tmp));
+ return __tmp;
+#elif defined(_M_ARM) || defined(_M_ARM64)
+ if (__order == memory_order_relaxed) {
+ return _InterlockedOr64_nf(__a, __value);
+ } else if (__order == memory_order_acquire) {
+ return _InterlockedOr64_acq(__a, __value);
+ } else if (__order == memory_order_release) {
+ return _InterlockedOr64_rel(__a, __value);
+ } else {
+ return _InterlockedOr64(__a, __value);
+ }
+#else
+ (void)__order;
+ return _InterlockedOr64(__a, __value);
+#endif
+}
+
+template <typename _Tp>
+static inline _Tp __c11_atomic_fetch_or(volatile _Atomic(_Tp)* __a,
+ _Tp __value, int __order) {
+ if (sizeof(_Tp) == 1 && (std::is_integral<_Tp>::value || std::is_same<std::remove_cv_t<_Tp>, bool>::value)) {
+ return __msvc_cast<_Tp>(__msvc_atomic_fetch_or8((volatile char*)__a, __msvc_cast<char>(__value), (memory_order)__order));
+ } else if (sizeof(_Tp) == 2 && std::is_integral<_Tp>::value) {
+ return (_Tp)__msvc_atomic_fetch_or16((volatile short*)__a, (short)__value, (memory_order)__order);
+ } else if (sizeof(_Tp) == 4 && std::is_integral<_Tp>::value) {
+ return (_Tp) __msvc_atomic_fetch_or32((volatile long*)__a, (long)__value, (memory_order)__order);
+ } else if (sizeof(_Tp) == 8 && std::is_integral<_Tp>::value) {
+ return (_Tp) __msvc_atomic_fetch_or64((volatile __int64*)__a, (__int64)__value, (memory_order)__order);
+ } else {
+ __msvc_lock((void*)__a);
+ _Tp __result = *(_Atomic(_Tp)*)__a;
+ *(_Atomic(_Tp)*)__a |= __value;
+ __msvc_unlock((void*)__a);
+ return __result;
+ }
+}
+
+template <typename _Tp>
+static inline _Tp __c11_atomic_fetch_or(_Atomic(_Tp)* __a,
+ _Tp __value, int __order) {
+ return __c11_atomic_fetch_or((volatile _Atomic(_Tp)*)__a, __value, __order);
+}
+
+static inline char __msvc_atomic_fetch_xor8(volatile char* __a, char __value,
+ memory_order __order) {
+#if defined(_M_ARM) || defined(_M_ARM64)
+ if (__order == memory_order_relaxed) {
+ return _InterlockedXor8_nf(__a, __value);
+ } else if (__order == memory_order_acquire) {
+ return _InterlockedXor8_acq(__a, __value);
+ } else if (__order == memory_order_release) {
+ return _InterlockedXor8_rel(__a, __value);
+ } else {
+ return _InterlockedXor8(__a, __value);
+ }
+#else
+ (void)__order;
+ return _InterlockedXor8(__a, __value);
+#endif
+}
+
+static inline short __msvc_atomic_fetch_xor16(volatile short* __a, short __value,
+ memory_order __order) {
+#if defined(_M_ARM) || defined(_M_ARM64)
+ if (__order == memory_order_relaxed) {
+ return _InterlockedXor16_nf(__a, __value);
+ } else if (__order == memory_order_acquire) {
+ return _InterlockedXor16_acq(__a, __value);
+ } else if (__order == memory_order_release) {
+ return _InterlockedXor16_rel(__a, __value);
+ } else {
+ return _InterlockedXor16(__a, __value);
+ }
+#else
+ (void)__order;
+ return _InterlockedXor16(__a, __value);
+#endif
+}
+
+static inline long __msvc_atomic_fetch_xor32(volatile long* __a, long __value,
+ memory_order __order) {
+#if defined(_M_ARM) || defined(_M_ARM64)
+ if (__order == memory_order_relaxed) {
+ return _InterlockedXor_nf(__a, __value);
+ } else if (__order == memory_order_acquire) {
+ return _InterlockedXor_acq(__a, __value);
+ } else if (__order == memory_order_release) {
+ return _InterlockedXor_rel(__a, __value);
+ } else {
+ return _InterlockedXor(__a, __value);
+ }
+#else
+ (void)__order;
+ return _InterlockedXor(__a, __value);
+#endif
+}
+
+static inline __int64 __msvc_atomic_fetch_xor64(volatile __int64* __a, __int64 __value,
+ memory_order __order) {
+#if defined(_M_IX86)
+ __int64 __tmp;
+ do {
+ __tmp = *__a;
+ } while (__tmp != _InterlockedCompareExchange64(__a, __tmp ^ __value, __tmp));
+ return __tmp;
+#elif defined(_M_ARM) || defined(_M_ARM64)
+ if (__order == memory_order_relaxed) {
+ return _InterlockedXor64_nf(__a, __value);
+ } else if (__order == memory_order_acquire) {
+ return _InterlockedXor64_acq(__a, __value);
+ } else if (__order == memory_order_release) {
+ return _InterlockedXor64_rel(__a, __value);
+ } else {
+ return _InterlockedXor64(__a, __value);
+ }
+#else
+ (void)__order;
+ return _InterlockedXor64(__a, __value);
+#endif
+}
+
+template <typename _Tp>
+static inline _Tp __c11_atomic_fetch_xor(volatile _Atomic(_Tp)* __a,
+ _Tp __value, int __order) {
+ if (sizeof(_Tp) == 1 && (std::is_integral<_Tp>::value || std::is_same<std::remove_cv_t<_Tp>, bool>::value)) {
+ return __msvc_cast<_Tp>(__msvc_atomic_fetch_xor8((volatile char*)__a, __msvc_cast<char>(__value), (memory_order)__order));
+ } else if (sizeof(_Tp) == 2 && std::is_integral<_Tp>::value) {
+ return (_Tp)__msvc_atomic_fetch_xor16((volatile short*)__a, (short)__value, (memory_order)__order);
+ } else if (sizeof(_Tp) == 4 && std::is_integral<_Tp>::value) {
+ return (_Tp) __msvc_atomic_fetch_xor32((volatile long*)__a, (long)__value, (memory_order)__order);
+ } else if (sizeof(_Tp) == 8 && std::is_integral<_Tp>::value) {
+ return (_Tp) __msvc_atomic_fetch_xor64((volatile __int64*)__a, (__int64)__value, (memory_order)__order);
+ } else {
+ __msvc_lock((void*)__a);
+ _Tp __result = *(_Atomic(_Tp)*)__a;
+ *(_Atomic(_Tp)*)__a ^= __value;
+ __msvc_unlock((void*)__a);
+ return __result;
+ }
+}
+
+template <typename _Tp>
+static inline _Tp __c11_atomic_fetch_xor(_Atomic(_Tp)* __a,
+ _Tp __value, int __order) {
+ return __c11_atomic_fetch_xor((volatile _Atomic(_Tp)*)__a, __value, __order);
+}
+
+static constexpr bool __atomic_is_lock_free(size_t __size, void*) {
+ return __size <= 8;
+}
+
+static constexpr bool __atomic_always_lock_free(size_t __size, void*) {
+ return __size <= 8;
+}
+
+#define __CLANG_ATOMIC_BOOL_LOCK_FREE 2
+#define __CLANG_ATOMIC_CHAR_LOCK_FREE 2
+#define __CLANG_ATOMIC_CHAR8_T_LOCK_FREE 2
+#define __CLANG_ATOMIC_CHAR16_T_LOCK_FREE 2
+#define __CLANG_ATOMIC_CHAR32_T_LOCK_FREE 2
+#define __CLANG_ATOMIC_WCHAR_T_LOCK_FREE 2
+#define __CLANG_ATOMIC_SHORT_LOCK_FREE 2
+#define __CLANG_ATOMIC_INT_LOCK_FREE 2
+#define __CLANG_ATOMIC_LONG_LOCK_FREE 2
+#define __CLANG_ATOMIC_LLONG_LOCK_FREE 2
+#define __CLANG_ATOMIC_POINTER_LOCK_FREE 2
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__support/win32/limits_msvc_win32.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/win32/limits_msvc_win32.h
new file mode 100644
index 0000000000..9f693d9fa4
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/win32/limits_msvc_win32.h
@@ -0,0 +1,70 @@
+// -*- 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_SUPPORT_WIN32_LIMITS_MSVC_WIN32_H
+#define _LIBCPP_SUPPORT_WIN32_LIMITS_MSVC_WIN32_H
+
+#if !defined(_LIBCPP_MSVCRT)
+#error "This header complements the Microsoft C Runtime library, and should not be included otherwise."
+#endif
+#if defined(__clang__)
+#error "This header should only be included when using Microsoft's C1XX frontend"
+#endif
+
+#include <float.h> // limit constants
+#include <limits.h> // CHAR_BIT
+#include <math.h> // HUGE_VAL
+
+#define __CHAR_BIT__ CHAR_BIT
+
+#define __FLT_MANT_DIG__ FLT_MANT_DIG
+#define __FLT_DIG__ FLT_DIG
+#define __FLT_RADIX__ FLT_RADIX
+#define __FLT_MIN_EXP__ FLT_MIN_EXP
+#define __FLT_MIN_10_EXP__ FLT_MIN_10_EXP
+#define __FLT_MAX_EXP__ FLT_MAX_EXP
+#define __FLT_MAX_10_EXP__ FLT_MAX_10_EXP
+#define __FLT_MIN__ FLT_MIN
+#define __FLT_MAX__ FLT_MAX
+#define __FLT_EPSILON__ FLT_EPSILON
+// predefined by MinGW GCC
+#define __FLT_DENORM_MIN__ 1.40129846432481707092e-45F
+
+#define __DBL_MANT_DIG__ DBL_MANT_DIG
+#define __DBL_DIG__ DBL_DIG
+#define __DBL_RADIX__ DBL_RADIX
+#define __DBL_MIN_EXP__ DBL_MIN_EXP
+#define __DBL_MIN_10_EXP__ DBL_MIN_10_EXP
+#define __DBL_MAX_EXP__ DBL_MAX_EXP
+#define __DBL_MAX_10_EXP__ DBL_MAX_10_EXP
+#define __DBL_MIN__ DBL_MIN
+#define __DBL_MAX__ DBL_MAX
+#define __DBL_EPSILON__ DBL_EPSILON
+// predefined by MinGW GCC
+#define __DBL_DENORM_MIN__ double(4.94065645841246544177e-324L)
+
+#define __LDBL_MANT_DIG__ LDBL_MANT_DIG
+#define __LDBL_DIG__ LDBL_DIG
+#define __LDBL_RADIX__ LDBL_RADIX
+#define __LDBL_MIN_EXP__ LDBL_MIN_EXP
+#define __LDBL_MIN_10_EXP__ LDBL_MIN_10_EXP
+#define __LDBL_MAX_EXP__ LDBL_MAX_EXP
+#define __LDBL_MAX_10_EXP__ LDBL_MAX_10_EXP
+#define __LDBL_MIN__ LDBL_MIN
+#define __LDBL_MAX__ LDBL_MAX
+#define __LDBL_EPSILON__ LDBL_EPSILON
+// predefined by MinGW GCC
+#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L
+
+// __builtin replacements/workarounds
+#define __builtin_huge_vall() ((long double)__builtin_huge_val())
+#define __builtin_nanl(__dummy) ((long double)__builtin_nan(__dummy))
+#define __builtin_nansl(__dummy) ((long double)__builtin_nans(__dummy))
+
+#endif // _LIBCPP_SUPPORT_WIN32_LIMITS_MSVC_WIN32_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__support/win32/locale_win32.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/win32/locale_win32.h
new file mode 100644
index 0000000000..8456b0564d
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/win32/locale_win32.h
@@ -0,0 +1,259 @@
+// -*- 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_SUPPORT_WIN32_LOCALE_WIN32_H
+#define _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H
+
+#include <__config>
+#include <cstddef>
+#include <locale.h> // _locale_t
+#include <stdio.h>
+
+#define _X_ALL LC_ALL
+#define _X_COLLATE LC_COLLATE
+#define _X_CTYPE LC_CTYPE
+#define _X_MONETARY LC_MONETARY
+#define _X_NUMERIC LC_NUMERIC
+#define _X_TIME LC_TIME
+#define _X_MAX LC_MAX
+#define _X_MESSAGES 6
+#define _NCAT (_X_MESSAGES + 1)
+
+#define _CATMASK(n) ((1 << (n)) >> 1)
+#define _M_COLLATE _CATMASK(_X_COLLATE)
+#define _M_CTYPE _CATMASK(_X_CTYPE)
+#define _M_MONETARY _CATMASK(_X_MONETARY)
+#define _M_NUMERIC _CATMASK(_X_NUMERIC)
+#define _M_TIME _CATMASK(_X_TIME)
+#define _M_MESSAGES _CATMASK(_X_MESSAGES)
+#define _M_ALL (_CATMASK(_NCAT) - 1)
+
+#define LC_COLLATE_MASK _M_COLLATE
+#define LC_CTYPE_MASK _M_CTYPE
+#define LC_MONETARY_MASK _M_MONETARY
+#define LC_NUMERIC_MASK _M_NUMERIC
+#define LC_TIME_MASK _M_TIME
+#define LC_MESSAGES_MASK _M_MESSAGES
+#define LC_MESSAGES _X_MESSAGES
+#define LC_ALL_MASK _M_ALL
+
+class __lconv_storage {
+public:
+ __lconv_storage(const lconv *__lc_input) {
+ __lc = *__lc_input;
+
+ __decimal_point = __lc_input->decimal_point;
+ __thousands_sep = __lc_input->thousands_sep;
+ __grouping = __lc_input->grouping;
+ __int_curr_symbol = __lc_input->int_curr_symbol;
+ __currency_symbol = __lc_input->currency_symbol;
+ __mon_decimal_point = __lc_input->mon_decimal_point;
+ __mon_thousands_sep = __lc_input->mon_thousands_sep;
+ __mon_grouping = __lc_input->mon_grouping;
+ __positive_sign = __lc_input->positive_sign;
+ __negative_sign = __lc_input->negative_sign;
+
+ __lc.decimal_point = const_cast<char *>(__decimal_point.c_str());
+ __lc.thousands_sep = const_cast<char *>(__thousands_sep.c_str());
+ __lc.grouping = const_cast<char *>(__grouping.c_str());
+ __lc.int_curr_symbol = const_cast<char *>(__int_curr_symbol.c_str());
+ __lc.currency_symbol = const_cast<char *>(__currency_symbol.c_str());
+ __lc.mon_decimal_point = const_cast<char *>(__mon_decimal_point.c_str());
+ __lc.mon_thousands_sep = const_cast<char *>(__mon_thousands_sep.c_str());
+ __lc.mon_grouping = const_cast<char *>(__mon_grouping.c_str());
+ __lc.positive_sign = const_cast<char *>(__positive_sign.c_str());
+ __lc.negative_sign = const_cast<char *>(__negative_sign.c_str());
+ }
+
+ lconv *__get() {
+ return &__lc;
+ }
+private:
+ lconv __lc;
+ std::string __decimal_point;
+ std::string __thousands_sep;
+ std::string __grouping;
+ std::string __int_curr_symbol;
+ std::string __currency_symbol;
+ std::string __mon_decimal_point;
+ std::string __mon_thousands_sep;
+ std::string __mon_grouping;
+ std::string __positive_sign;
+ std::string __negative_sign;
+};
+
+class locale_t {
+public:
+ locale_t()
+ : __locale(nullptr), __locale_str(nullptr), __lc(nullptr) {}
+ locale_t(std::nullptr_t)
+ : __locale(nullptr), __locale_str(nullptr), __lc(nullptr) {}
+ locale_t(_locale_t __xlocale, const char* __xlocale_str)
+ : __locale(__xlocale), __locale_str(__xlocale_str), __lc(nullptr) {}
+ locale_t(const locale_t &__l)
+ : __locale(__l.__locale), __locale_str(__l.__locale_str), __lc(nullptr) {}
+
+ ~locale_t() {
+ delete __lc;
+ }
+
+ locale_t &operator =(const locale_t &__l) {
+ __locale = __l.__locale;
+ __locale_str = __l.__locale_str;
+ // __lc not copied
+ return *this;
+ }
+
+ friend bool operator==(const locale_t& __left, const locale_t& __right) {
+ return __left.__locale == __right.__locale;
+ }
+
+ friend bool operator==(const locale_t& __left, int __right) {
+ return __left.__locale == nullptr && __right == 0;
+ }
+
+ friend bool operator==(const locale_t& __left, long long __right) {
+ return __left.__locale == nullptr && __right == 0;
+ }
+
+ friend bool operator==(const locale_t& __left, std::nullptr_t) {
+ return __left.__locale == nullptr;
+ }
+
+ friend bool operator==(int __left, const locale_t& __right) {
+ return __left == 0 && nullptr == __right.__locale;
+ }
+
+ friend bool operator==(std::nullptr_t, const locale_t& __right) {
+ return nullptr == __right.__locale;
+ }
+
+ friend bool operator!=(const locale_t& __left, const locale_t& __right) {
+ return !(__left == __right);
+ }
+
+ friend bool operator!=(const locale_t& __left, int __right) {
+ return !(__left == __right);
+ }
+
+ friend bool operator!=(const locale_t& __left, long long __right) {
+ return !(__left == __right);
+ }
+
+ friend bool operator!=(const locale_t& __left, std::nullptr_t __right) {
+ return !(__left == __right);
+ }
+
+ friend bool operator!=(int __left, const locale_t& __right) {
+ return !(__left == __right);
+ }
+
+ friend bool operator!=(std::nullptr_t __left, const locale_t& __right) {
+ return !(__left == __right);
+ }
+
+ operator bool() const {
+ return __locale != nullptr;
+ }
+
+ const char* __get_locale() const { return __locale_str; }
+
+ operator _locale_t() const {
+ return __locale;
+ }
+
+ lconv *__store_lconv(const lconv *__input_lc) {
+ delete __lc;
+ __lc = new __lconv_storage(__input_lc);
+ return __lc->__get();
+ }
+private:
+ _locale_t __locale;
+ const char* __locale_str;
+ __lconv_storage *__lc = nullptr;
+};
+
+// Locale management functions
+#define freelocale _free_locale
+// FIXME: base currently unused. Needs manual work to construct the new locale
+locale_t newlocale( int mask, const char * locale, locale_t base );
+// uselocale can't be implemented on Windows because Windows allows partial modification
+// of thread-local locale and so _get_current_locale() returns a copy while uselocale does
+// not create any copies.
+// We can still implement raii even without uselocale though.
+
+
+lconv *localeconv_l( locale_t &__loc );
+size_t mbrlen_l( const char *__restrict __s, size_t __n,
+ mbstate_t *__restrict __ps, locale_t __loc);
+size_t mbsrtowcs_l( wchar_t *__restrict __dst, const char **__restrict __src,
+ size_t __len, mbstate_t *__restrict __ps, locale_t __loc );
+size_t wcrtomb_l( char *__restrict s, wchar_t __wc, mbstate_t *__restrict __ps,
+ locale_t __loc);
+size_t mbrtowc_l( wchar_t *__restrict __pwc, const char *__restrict __s,
+ size_t __n, mbstate_t *__restrict __ps, locale_t __loc);
+size_t mbsnrtowcs_l( wchar_t *__restrict __dst, const char **__restrict __src,
+ size_t __nms, size_t __len, mbstate_t *__restrict __ps, locale_t __loc);
+size_t wcsnrtombs_l( char *__restrict __dst, const wchar_t **__restrict __src,
+ size_t __nwc, size_t __len, mbstate_t *__restrict __ps, locale_t __loc);
+wint_t btowc_l( int __c, locale_t __loc );
+int wctob_l( wint_t __c, locale_t __loc );
+
+decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l );
+
+// the *_l functions are prefixed on Windows, only available for msvcr80+, VS2005+
+#define mbtowc_l _mbtowc_l
+#define strtoll_l _strtoi64_l
+#define strtoull_l _strtoui64_l
+#define strtod_l _strtod_l
+#if defined(_LIBCPP_MSVCRT)
+#define strtof_l _strtof_l
+#define strtold_l _strtod_l
+#else
+_LIBCPP_FUNC_VIS float strtof_l(const char*, char**, locale_t);
+_LIBCPP_FUNC_VIS long double strtold_l(const char*, char**, locale_t);
+#endif
+#define isupper_l _isupper_l
+#define islower_l _islower_l
+#define isblank_l _isblank_l
+#define isdigit_l _isdigit_l
+#define isxdigit_l _isxdigit_l
+#define strcoll_l _strcoll_l
+#define strxfrm_l _strxfrm_l
+#define wcscoll_l _wcscoll_l
+#define wcsxfrm_l _wcsxfrm_l
+#define toupper_l _toupper_l
+#define tolower_l _tolower_l
+#define iswspace_l _iswspace_l
+#define iswprint_l _iswprint_l
+#define iswcntrl_l _iswcntrl_l
+#define iswupper_l _iswupper_l
+#define iswlower_l _iswlower_l
+#define iswblank_l _iswblank_l
+#define iswalpha_l _iswalpha_l
+#define iswdigit_l _iswdigit_l
+#define iswpunct_l _iswpunct_l
+#define iswxdigit_l _iswxdigit_l
+#define towupper_l _towupper_l
+#define towlower_l _towlower_l
+#if defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x0800
+_LIBCPP_FUNC_VIS size_t strftime_l(char *ret, size_t n, const char *format,
+ const struct tm *tm, locale_t loc);
+#else
+#define strftime_l _strftime_l
+#endif
+#define sscanf_l( __s, __l, __f, ...) _sscanf_l( __s, __f, __l, ##__VA_ARGS__ )
+#define sprintf_l( __s, __l, __f, ... ) _sprintf_l( __s, __f, __l, ##__VA_ARGS__ )
+#define vsprintf_l( __s, __l, __f, ... ) _vsprintf_l( __s, __f, __l, ##__VA_ARGS__ )
+#define vsnprintf_l( __s, __n, __l, __f, ... ) _vsnprintf_l( __s, __n, __f, __l, ##__VA_ARGS__ )
+#define snprintf_l(__s, __n, __l, __f, ...) _snprintf_l( __s, __n, __f, __l, ##__VA_ARGS__ )
+_LIBCPP_FUNC_VIS int asprintf_l( char **__ret, locale_t __loc, const char *__format, ... );
+_LIBCPP_FUNC_VIS int vasprintf_l( char **__ret, locale_t __loc, const char *__format, va_list __ap );
+
+#endif // _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__support/xlocale/__nop_locale_mgmt.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/xlocale/__nop_locale_mgmt.h
new file mode 100644
index 0000000000..57b18842ff
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/xlocale/__nop_locale_mgmt.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_SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H
+#define _LIBCPP_SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Patch over lack of extended locale support
+typedef void *locale_t;
+static inline locale_t duplocale(locale_t) {
+ return NULL;
+}
+
+static inline void freelocale(locale_t) {
+}
+
+static inline locale_t newlocale(int, const char *, locale_t) {
+ return NULL;
+}
+
+static inline locale_t uselocale(locale_t) {
+ return NULL;
+}
+
+#define LC_COLLATE_MASK (1 << LC_COLLATE)
+#define LC_CTYPE_MASK (1 << LC_CTYPE)
+#define LC_MESSAGES_MASK (1 << LC_MESSAGES)
+#define LC_MONETARY_MASK (1 << LC_MONETARY)
+#define LC_NUMERIC_MASK (1 << LC_NUMERIC)
+#define LC_TIME_MASK (1 << LC_TIME)
+#define LC_ALL_MASK (LC_COLLATE_MASK|\
+ LC_CTYPE_MASK|\
+ LC_MONETARY_MASK|\
+ LC_NUMERIC_MASK|\
+ LC_TIME_MASK|\
+ LC_MESSAGES_MASK)
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _LIBCPP_SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__support/xlocale/__posix_l_fallback.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/xlocale/__posix_l_fallback.h
new file mode 100644
index 0000000000..00d69d19e8
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/xlocale/__posix_l_fallback.h
@@ -0,0 +1,164 @@
+// -*- 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
+//
+//===----------------------------------------------------------------------===//
+// These are reimplementations of some extended locale functions ( *_l ) that
+// are normally part of POSIX. This shared implementation provides parts of the
+// extended locale support for libc's that normally don't have any (like
+// Android's bionic and Newlib).
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_SUPPORT_XLOCALE_POSIX_L_FALLBACK_H
+#define _LIBCPP_SUPPORT_XLOCALE_POSIX_L_FALLBACK_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+inline _LIBCPP_INLINE_VISIBILITY int isalnum_l(int c, locale_t) {
+ return ::isalnum(c);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int isalpha_l(int c, locale_t) {
+ return ::isalpha(c);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int isblank_l(int c, locale_t) {
+ return ::isblank(c);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int iscntrl_l(int c, locale_t) {
+ return ::iscntrl(c);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int isdigit_l(int c, locale_t) {
+ return ::isdigit(c);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int isgraph_l(int c, locale_t) {
+ return ::isgraph(c);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int islower_l(int c, locale_t) {
+ return ::islower(c);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int isprint_l(int c, locale_t) {
+ return ::isprint(c);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int ispunct_l(int c, locale_t) {
+ return ::ispunct(c);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int isspace_l(int c, locale_t) {
+ return ::isspace(c);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int isupper_l(int c, locale_t) {
+ return ::isupper(c);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int isxdigit_l(int c, locale_t) {
+ return ::isxdigit(c);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int iswalnum_l(wint_t c, locale_t) {
+ return ::iswalnum(c);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int iswalpha_l(wint_t c, locale_t) {
+ return ::iswalpha(c);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int iswblank_l(wint_t c, locale_t) {
+ return ::iswblank(c);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int iswcntrl_l(wint_t c, locale_t) {
+ return ::iswcntrl(c);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int iswdigit_l(wint_t c, locale_t) {
+ return ::iswdigit(c);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int iswgraph_l(wint_t c, locale_t) {
+ return ::iswgraph(c);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int iswlower_l(wint_t c, locale_t) {
+ return ::iswlower(c);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int iswprint_l(wint_t c, locale_t) {
+ return ::iswprint(c);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int iswpunct_l(wint_t c, locale_t) {
+ return ::iswpunct(c);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int iswspace_l(wint_t c, locale_t) {
+ return ::iswspace(c);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int iswupper_l(wint_t c, locale_t) {
+ return ::iswupper(c);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int iswxdigit_l(wint_t c, locale_t) {
+ return ::iswxdigit(c);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int toupper_l(int c, locale_t) {
+ return ::toupper(c);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int tolower_l(int c, locale_t) {
+ return ::tolower(c);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY wint_t towupper_l(wint_t c, locale_t) {
+ return ::towupper(c);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY wint_t towlower_l(wint_t c, locale_t) {
+ return ::towlower(c);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int strcoll_l(const char *s1, const char *s2,
+ locale_t) {
+ return ::strcoll(s1, s2);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY size_t strxfrm_l(char *dest, const char *src,
+ size_t n, locale_t) {
+ return ::strxfrm(dest, src, n);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY size_t strftime_l(char *s, size_t max,
+ const char *format,
+ const struct tm *tm, locale_t) {
+ return ::strftime(s, max, format, tm);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int wcscoll_l(const wchar_t *ws1,
+ const wchar_t *ws2, locale_t) {
+ return ::wcscoll(ws1, ws2);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY size_t wcsxfrm_l(wchar_t *dest, const wchar_t *src,
+ size_t n, locale_t) {
+ return ::wcsxfrm(dest, src, n);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _LIBCPP_SUPPORT_XLOCALE_POSIX_L_FALLBACK_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__support/xlocale/__strtonum_fallback.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/xlocale/__strtonum_fallback.h
new file mode 100644
index 0000000000..1172a5d572
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/xlocale/__strtonum_fallback.h
@@ -0,0 +1,66 @@
+// -*- 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
+//
+//===----------------------------------------------------------------------===//
+// These are reimplementations of some extended locale functions ( *_l ) that
+// aren't part of POSIX. They are widely available though (GLIBC, BSD, maybe
+// others). The unifying aspect in this case is that all of these functions
+// convert strings to some numeric type.
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_SUPPORT_XLOCALE_STRTONUM_FALLBACK_H
+#define _LIBCPP_SUPPORT_XLOCALE_STRTONUM_FALLBACK_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+inline _LIBCPP_INLINE_VISIBILITY float strtof_l(const char *nptr,
+ char **endptr, locale_t) {
+ return ::strtof(nptr, endptr);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY double strtod_l(const char *nptr,
+ char **endptr, locale_t) {
+ return ::strtod(nptr, endptr);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY long double strtold_l(const char *nptr,
+ char **endptr, locale_t) {
+ return ::strtold(nptr, endptr);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY long long
+strtoll_l(const char *nptr, char **endptr, int base, locale_t) {
+ return ::strtoll(nptr, endptr, base);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY unsigned long long
+strtoull_l(const char *nptr, char **endptr, int base, locale_t) {
+ return ::strtoull(nptr, endptr, base);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY long long
+wcstoll_l(const wchar_t *nptr, wchar_t **endptr, int base, locale_t) {
+ return ::wcstoll(nptr, endptr, base);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY unsigned long long
+wcstoull_l(const wchar_t *nptr, wchar_t **endptr, int base, locale_t) {
+ return ::wcstoull(nptr, endptr, base);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY long double wcstold_l(const wchar_t *nptr,
+ wchar_t **endptr, locale_t) {
+ return ::wcstold(nptr, endptr);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _LIBCPP_SUPPORT_XLOCALE_STRTONUM_FALLBACK_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__thread/poll_with_backoff.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__thread/poll_with_backoff.h
new file mode 100644
index 0000000000..9b084b3302
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__thread/poll_with_backoff.h
@@ -0,0 +1,69 @@
+// -*- 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___THREAD_POLL_WITH_BACKOFF_H
+#define _LIBCPP___THREAD_POLL_WITH_BACKOFF_H
+
+#include <__availability>
+#include <__config>
+#include <chrono>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+static _LIBCPP_CONSTEXPR const int __libcpp_polling_count = 64;
+
+// Polls a thread for a condition given by a predicate, and backs off based on a backoff policy
+// before polling again.
+//
+// - __f is the "test function" that should return true if polling succeeded, and false if it failed.
+//
+// - __bf is the "backoff policy", which is called with the duration since we started polling. It should
+// return false in order to resume polling, and true if polling should stop entirely for some reason.
+// In general, backoff policies sleep for some time before returning control to the polling loop.
+//
+// - __max_elapsed is the maximum duration to try polling for. If the maximum duration is exceeded,
+// the polling loop will return false to report a timeout.
+template<class _Fn, class _BFn>
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI
+bool __libcpp_thread_poll_with_backoff(_Fn&& __f, _BFn&& __bf, chrono::nanoseconds __max_elapsed = chrono::nanoseconds::zero()) {
+ auto const __start = chrono::high_resolution_clock::now();
+ for (int __count = 0;;) {
+ if (__f())
+ return true; // _Fn completion means success
+ if (__count < __libcpp_polling_count) {
+ __count += 1;
+ continue;
+ }
+ chrono::nanoseconds const __elapsed = chrono::high_resolution_clock::now() - __start;
+ if (__max_elapsed != chrono::nanoseconds::zero() && __max_elapsed < __elapsed)
+ return false; // timeout failure
+ if (__bf(__elapsed))
+ return false; // _BFn completion means failure
+ }
+}
+
+// A trivial backoff policy that always immediately returns the control to
+// the polling loop.
+//
+// This is not very well-behaved since it will cause the polling loop to spin,
+// so this should most likely only be used on single-threaded systems where there
+// are no other threads to compete with.
+struct __spinning_backoff_policy {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
+ bool operator()(chrono::nanoseconds const&) const {
+ return false;
+ }
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___THREAD_POLL_WITH_BACKOFF_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__thread/timed_backoff_policy.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__thread/timed_backoff_policy.h
new file mode 100644
index 0000000000..58c2390baf
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__thread/timed_backoff_policy.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___THREAD_TIMED_BACKOFF_POLICY_H
+#define _LIBCPP___THREAD_TIMED_BACKOFF_POLICY_H
+
+#include <__config>
+
+#ifndef _LIBCPP_HAS_NO_THREADS
+
+#include <__threading_support>
+#include <chrono>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+struct __libcpp_timed_backoff_policy {
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(chrono::nanoseconds __elapsed) const
+ {
+ if(__elapsed > chrono::milliseconds(128))
+ __libcpp_thread_sleep_for(chrono::milliseconds(8));
+ else if(__elapsed > chrono::microseconds(64))
+ __libcpp_thread_sleep_for(__elapsed / 2);
+ else if(__elapsed > chrono::microseconds(4))
+ __libcpp_thread_yield();
+ else
+ {} // poll
+ return false;
+ }
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_HAS_NO_THREADS
+
+#endif // _LIBCPP___THREAD_TIMED_BACKOFF_POLICY_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__threading_support b/contrib/libs/cxxsupp/libcxxmsvc/include/__threading_support
new file mode 100644
index 0000000000..8320557b1c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__threading_support
@@ -0,0 +1,676 @@
+// -*- 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_THREADING_SUPPORT
+#define _LIBCPP_THREADING_SUPPORT
+
+#include <__availability>
+#include <__config>
+#include <__thread/poll_with_backoff.h>
+#include <chrono>
+#include <errno.h>
+#include <iosfwd>
+#include <limits>
+
+#ifdef __MVS__
+# include <__support/ibm/nanosleep.h>
+#endif
+
+#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
+# pragma GCC system_header
+#endif
+
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+#error #include <__external_threading>
+#elif !defined(_LIBCPP_HAS_NO_THREADS)
+
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
+# include <pthread.h>
+# include <sched.h>
+#elif defined(_LIBCPP_HAS_THREAD_API_C11)
+# include <threads.h>
+#endif
+
+#if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
+ defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL) || \
+ defined(_LIBCPP_HAS_THREAD_API_WIN32)
+#define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS
+#else
+#define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
+#endif
+
+#if defined(__FreeBSD__) && defined(__clang__) && __has_attribute(no_thread_safety_analysis)
+#define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS __attribute__((no_thread_safety_analysis))
+#else
+#define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
+#endif
+
+typedef ::timespec __libcpp_timespec_t;
+#endif // !defined(_LIBCPP_HAS_NO_THREADS)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
+// Mutex
+typedef pthread_mutex_t __libcpp_mutex_t;
+#define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
+
+typedef pthread_mutex_t __libcpp_recursive_mutex_t;
+
+// Condition Variable
+typedef pthread_cond_t __libcpp_condvar_t;
+#define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER
+
+// Execute once
+typedef pthread_once_t __libcpp_exec_once_flag;
+#define _LIBCPP_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT
+
+// Thread id
+#if defined(__MVS__)
+ typedef unsigned long long __libcpp_thread_id;
+#else
+ typedef pthread_t __libcpp_thread_id;
+#endif
+
+// Thread
+#define _LIBCPP_NULL_THREAD ((__libcpp_thread_t()))
+typedef pthread_t __libcpp_thread_t;
+
+// Thread Local Storage
+typedef pthread_key_t __libcpp_tls_key;
+
+#define _LIBCPP_TLS_DESTRUCTOR_CC
+#elif defined(_LIBCPP_HAS_THREAD_API_C11)
+// Mutex
+typedef mtx_t __libcpp_mutex_t;
+// mtx_t is a struct so using {} for initialization is valid.
+#define _LIBCPP_MUTEX_INITIALIZER {}
+
+typedef mtx_t __libcpp_recursive_mutex_t;
+
+// Condition Variable
+typedef cnd_t __libcpp_condvar_t;
+// cnd_t is a struct so using {} for initialization is valid.
+#define _LIBCPP_CONDVAR_INITIALIZER {}
+
+// Execute once
+typedef once_flag __libcpp_exec_once_flag;
+#define _LIBCPP_EXEC_ONCE_INITIALIZER ONCE_FLAG_INIT
+
+// Thread id
+typedef thrd_t __libcpp_thread_id;
+
+// Thread
+#define _LIBCPP_NULL_THREAD 0U
+
+typedef thrd_t __libcpp_thread_t;
+
+// Thread Local Storage
+typedef tss_t __libcpp_tls_key;
+
+#define _LIBCPP_TLS_DESTRUCTOR_CC
+#elif !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+// Mutex
+typedef void* __libcpp_mutex_t;
+#define _LIBCPP_MUTEX_INITIALIZER 0
+
+#if defined(_M_IX86) || defined(__i386__) || defined(_M_ARM) || defined(__arm__)
+typedef void* __libcpp_recursive_mutex_t[6];
+#elif defined(_M_AMD64) || defined(__x86_64__) || defined(_M_ARM64) || defined(__aarch64__)
+typedef void* __libcpp_recursive_mutex_t[5];
+#else
+# error Unsupported architecture
+#endif
+
+// Condition Variable
+typedef void* __libcpp_condvar_t;
+#define _LIBCPP_CONDVAR_INITIALIZER 0
+
+// Execute Once
+typedef void* __libcpp_exec_once_flag;
+#define _LIBCPP_EXEC_ONCE_INITIALIZER 0
+
+// Thread ID
+typedef long __libcpp_thread_id;
+
+// Thread
+#define _LIBCPP_NULL_THREAD 0U
+
+typedef void* __libcpp_thread_t;
+
+// Thread Local Storage
+typedef long __libcpp_tls_key;
+
+#define _LIBCPP_TLS_DESTRUCTOR_CC __stdcall
+#endif // !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+
+#if !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+// Mutex
+_LIBCPP_THREAD_ABI_VISIBILITY
+int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m);
+
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
+int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m);
+
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
+bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m);
+
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
+int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m);
+
+_LIBCPP_THREAD_ABI_VISIBILITY
+int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m);
+
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
+int __libcpp_mutex_lock(__libcpp_mutex_t *__m);
+
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
+bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m);
+
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
+int __libcpp_mutex_unlock(__libcpp_mutex_t *__m);
+
+_LIBCPP_THREAD_ABI_VISIBILITY
+int __libcpp_mutex_destroy(__libcpp_mutex_t *__m);
+
+// Condition variable
+_LIBCPP_THREAD_ABI_VISIBILITY
+int __libcpp_condvar_signal(__libcpp_condvar_t* __cv);
+
+_LIBCPP_THREAD_ABI_VISIBILITY
+int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv);
+
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
+int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m);
+
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
+int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
+ __libcpp_timespec_t *__ts);
+
+_LIBCPP_THREAD_ABI_VISIBILITY
+int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv);
+
+// Execute once
+_LIBCPP_THREAD_ABI_VISIBILITY
+int __libcpp_execute_once(__libcpp_exec_once_flag *flag,
+ void (*init_routine)());
+
+// Thread id
+_LIBCPP_THREAD_ABI_VISIBILITY
+bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2);
+
+_LIBCPP_THREAD_ABI_VISIBILITY
+bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2);
+
+// Thread
+_LIBCPP_THREAD_ABI_VISIBILITY
+bool __libcpp_thread_isnull(const __libcpp_thread_t *__t);
+
+_LIBCPP_THREAD_ABI_VISIBILITY
+int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
+ void *__arg);
+
+_LIBCPP_THREAD_ABI_VISIBILITY
+__libcpp_thread_id __libcpp_thread_get_current_id();
+
+_LIBCPP_THREAD_ABI_VISIBILITY
+__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t);
+
+_LIBCPP_THREAD_ABI_VISIBILITY
+int __libcpp_thread_join(__libcpp_thread_t *__t);
+
+_LIBCPP_THREAD_ABI_VISIBILITY
+int __libcpp_thread_detach(__libcpp_thread_t *__t);
+
+_LIBCPP_THREAD_ABI_VISIBILITY
+void __libcpp_thread_yield();
+
+_LIBCPP_THREAD_ABI_VISIBILITY
+void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns);
+
+// Thread local storage
+_LIBCPP_THREAD_ABI_VISIBILITY
+int __libcpp_tls_create(__libcpp_tls_key* __key,
+ void(_LIBCPP_TLS_DESTRUCTOR_CC* __at_exit)(void*));
+
+_LIBCPP_THREAD_ABI_VISIBILITY
+void *__libcpp_tls_get(__libcpp_tls_key __key);
+
+_LIBCPP_THREAD_ABI_VISIBILITY
+int __libcpp_tls_set(__libcpp_tls_key __key, void *__p);
+
+#endif // !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+
+#if (!defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
+ defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL))
+
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
+
+int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m)
+{
+ pthread_mutexattr_t attr;
+ int __ec = pthread_mutexattr_init(&attr);
+ if (__ec)
+ return __ec;
+ __ec = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+ if (__ec) {
+ pthread_mutexattr_destroy(&attr);
+ return __ec;
+ }
+ __ec = pthread_mutex_init(__m, &attr);
+ if (__ec) {
+ pthread_mutexattr_destroy(&attr);
+ return __ec;
+ }
+ __ec = pthread_mutexattr_destroy(&attr);
+ if (__ec) {
+ pthread_mutex_destroy(__m);
+ return __ec;
+ }
+ return 0;
+}
+
+int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m)
+{
+ return pthread_mutex_lock(__m);
+}
+
+bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m)
+{
+ return pthread_mutex_trylock(__m) == 0;
+}
+
+int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m)
+{
+ return pthread_mutex_unlock(__m);
+}
+
+int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m)
+{
+ return pthread_mutex_destroy(__m);
+}
+
+int __libcpp_mutex_lock(__libcpp_mutex_t *__m)
+{
+ return pthread_mutex_lock(__m);
+}
+
+bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m)
+{
+ return pthread_mutex_trylock(__m) == 0;
+}
+
+int __libcpp_mutex_unlock(__libcpp_mutex_t *__m)
+{
+ return pthread_mutex_unlock(__m);
+}
+
+int __libcpp_mutex_destroy(__libcpp_mutex_t *__m)
+{
+ return pthread_mutex_destroy(__m);
+}
+
+// Condition Variable
+int __libcpp_condvar_signal(__libcpp_condvar_t *__cv)
+{
+ return pthread_cond_signal(__cv);
+}
+
+int __libcpp_condvar_broadcast(__libcpp_condvar_t *__cv)
+{
+ return pthread_cond_broadcast(__cv);
+}
+
+int __libcpp_condvar_wait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m)
+{
+ return pthread_cond_wait(__cv, __m);
+}
+
+int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
+ __libcpp_timespec_t *__ts)
+{
+ return pthread_cond_timedwait(__cv, __m, __ts);
+}
+
+int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv)
+{
+ return pthread_cond_destroy(__cv);
+}
+
+// Execute once
+int __libcpp_execute_once(__libcpp_exec_once_flag *flag,
+ void (*init_routine)()) {
+ return pthread_once(flag, init_routine);
+}
+
+// Thread id
+// Returns non-zero if the thread ids are equal, otherwise 0
+bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2)
+{
+ return t1 == t2;
+}
+
+// Returns non-zero if t1 < t2, otherwise 0
+bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2)
+{
+ return t1 < t2;
+}
+
+// Thread
+bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {
+ return __libcpp_thread_get_id(__t) == 0;
+}
+
+int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
+ void *__arg)
+{
+ return pthread_create(__t, nullptr, __func, __arg);
+}
+
+__libcpp_thread_id __libcpp_thread_get_current_id()
+{
+ const __libcpp_thread_t thread = pthread_self();
+ return __libcpp_thread_get_id(&thread);
+}
+
+__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t)
+{
+#if defined(__MVS__)
+ return __t->__;
+#else
+ return *__t;
+#endif
+}
+
+int __libcpp_thread_join(__libcpp_thread_t *__t)
+{
+ return pthread_join(*__t, nullptr);
+}
+
+int __libcpp_thread_detach(__libcpp_thread_t *__t)
+{
+ return pthread_detach(*__t);
+}
+
+void __libcpp_thread_yield()
+{
+ sched_yield();
+}
+
+void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns)
+{
+ __libcpp_timespec_t __ts = _VSTD::__convert_to_timespec<__libcpp_timespec_t>(__ns);
+ while (nanosleep(&__ts, &__ts) == -1 && errno == EINTR);
+}
+
+// Thread local storage
+int __libcpp_tls_create(__libcpp_tls_key *__key, void (*__at_exit)(void *))
+{
+ return pthread_key_create(__key, __at_exit);
+}
+
+void *__libcpp_tls_get(__libcpp_tls_key __key)
+{
+ return pthread_getspecific(__key);
+}
+
+int __libcpp_tls_set(__libcpp_tls_key __key, void *__p)
+{
+ return pthread_setspecific(__key, __p);
+}
+
+#elif defined(_LIBCPP_HAS_THREAD_API_C11)
+
+int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m)
+{
+ return mtx_init(__m, mtx_plain | mtx_recursive) == thrd_success ? 0 : EINVAL;
+}
+
+int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m)
+{
+ return mtx_lock(__m) == thrd_success ? 0 : EINVAL;
+}
+
+bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m)
+{
+ return mtx_trylock(__m) == thrd_success;
+}
+
+int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m)
+{
+ return mtx_unlock(__m) == thrd_success ? 0 : EINVAL;
+}
+
+int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m)
+{
+ mtx_destroy(__m);
+ return 0;
+}
+
+int __libcpp_mutex_lock(__libcpp_mutex_t *__m)
+{
+ return mtx_lock(__m) == thrd_success ? 0 : EINVAL;
+}
+
+bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m)
+{
+ return mtx_trylock(__m) == thrd_success;
+}
+
+int __libcpp_mutex_unlock(__libcpp_mutex_t *__m)
+{
+ return mtx_unlock(__m) == thrd_success ? 0 : EINVAL;
+}
+
+int __libcpp_mutex_destroy(__libcpp_mutex_t *__m)
+{
+ mtx_destroy(__m);
+ return 0;
+}
+
+// Condition Variable
+int __libcpp_condvar_signal(__libcpp_condvar_t *__cv)
+{
+ return cnd_signal(__cv) == thrd_success ? 0 : EINVAL;
+}
+
+int __libcpp_condvar_broadcast(__libcpp_condvar_t *__cv)
+{
+ return cnd_broadcast(__cv) == thrd_success ? 0 : EINVAL;
+}
+
+int __libcpp_condvar_wait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m)
+{
+ return cnd_wait(__cv, __m) == thrd_success ? 0 : EINVAL;
+}
+
+int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
+ timespec *__ts)
+{
+ int __ec = cnd_timedwait(__cv, __m, __ts);
+ return __ec == thrd_timedout ? ETIMEDOUT : __ec;
+}
+
+int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv)
+{
+ cnd_destroy(__cv);
+ return 0;
+}
+
+// Execute once
+int __libcpp_execute_once(__libcpp_exec_once_flag *flag,
+ void (*init_routine)(void)) {
+ ::call_once(flag, init_routine);
+ return 0;
+}
+
+// Thread id
+// Returns non-zero if the thread ids are equal, otherwise 0
+bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2)
+{
+ return thrd_equal(t1, t2) != 0;
+}
+
+// Returns non-zero if t1 < t2, otherwise 0
+bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2)
+{
+ return t1 < t2;
+}
+
+// Thread
+bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {
+ return __libcpp_thread_get_id(__t) == 0;
+}
+
+int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
+ void *__arg)
+{
+ int __ec = thrd_create(__t, reinterpret_cast<thrd_start_t>(__func), __arg);
+ return __ec == thrd_nomem ? ENOMEM : __ec;
+}
+
+__libcpp_thread_id __libcpp_thread_get_current_id()
+{
+ return thrd_current();
+}
+
+__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t)
+{
+ return *__t;
+}
+
+int __libcpp_thread_join(__libcpp_thread_t *__t)
+{
+ return thrd_join(*__t, nullptr) == thrd_success ? 0 : EINVAL;
+}
+
+int __libcpp_thread_detach(__libcpp_thread_t *__t)
+{
+ return thrd_detach(*__t) == thrd_success ? 0 : EINVAL;
+}
+
+void __libcpp_thread_yield()
+{
+ thrd_yield();
+}
+
+void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns)
+{
+ __libcpp_timespec_t __ts = _VSTD::__convert_to_timespec<__libcpp_timespec_t>(__ns);
+ thrd_sleep(&__ts, nullptr);
+}
+
+// Thread local storage
+int __libcpp_tls_create(__libcpp_tls_key *__key, void (*__at_exit)(void *))
+{
+ return tss_create(__key, __at_exit) == thrd_success ? 0 : EINVAL;
+}
+
+void *__libcpp_tls_get(__libcpp_tls_key __key)
+{
+ return tss_get(__key);
+}
+
+int __libcpp_tls_set(__libcpp_tls_key __key, void *__p)
+{
+ return tss_set(__key, __p) == thrd_success ? 0 : EINVAL;
+}
+
+#endif
+
+
+#endif // !_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL || _LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL
+
+class _LIBCPP_TYPE_VIS thread;
+class _LIBCPP_TYPE_VIS __thread_id;
+
+namespace this_thread
+{
+
+_LIBCPP_INLINE_VISIBILITY __thread_id get_id() _NOEXCEPT;
+
+} // namespace this_thread
+
+template<> struct hash<__thread_id>;
+
+class _LIBCPP_TEMPLATE_VIS __thread_id
+{
+ // FIXME: pthread_t is a pointer on Darwin but a long on Linux.
+ // NULL is the no-thread value on Darwin. Someone needs to check
+ // on other platforms. We assume 0 works everywhere for now.
+ __libcpp_thread_id __id_;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ __thread_id() _NOEXCEPT : __id_(0) {}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(__thread_id __x, __thread_id __y) _NOEXCEPT
+ { // don't pass id==0 to underlying routines
+ if (__x.__id_ == 0) return __y.__id_ == 0;
+ if (__y.__id_ == 0) return false;
+ return __libcpp_thread_id_equal(__x.__id_, __y.__id_);
+ }
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(__thread_id __x, __thread_id __y) _NOEXCEPT
+ {return !(__x == __y);}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator< (__thread_id __x, __thread_id __y) _NOEXCEPT
+ { // id==0 is always less than any other thread_id
+ if (__x.__id_ == 0) return __y.__id_ != 0;
+ if (__y.__id_ == 0) return false;
+ return __libcpp_thread_id_less(__x.__id_, __y.__id_);
+ }
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator<=(__thread_id __x, __thread_id __y) _NOEXCEPT
+ {return !(__y < __x);}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator> (__thread_id __x, __thread_id __y) _NOEXCEPT
+ {return __y < __x ;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator>=(__thread_id __x, __thread_id __y) _NOEXCEPT
+ {return !(__x < __y);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __reset() { __id_ = 0; }
+
+ template<class _CharT, class _Traits>
+ friend
+ _LIBCPP_INLINE_VISIBILITY
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os, __thread_id __id);
+
+private:
+ _LIBCPP_INLINE_VISIBILITY
+ __thread_id(__libcpp_thread_id __id) : __id_(__id) {}
+
+ friend __thread_id this_thread::get_id() _NOEXCEPT;
+ friend class _LIBCPP_TYPE_VIS thread;
+ friend struct _LIBCPP_TEMPLATE_VIS hash<__thread_id>;
+};
+
+namespace this_thread
+{
+
+inline _LIBCPP_INLINE_VISIBILITY
+__thread_id
+get_id() _NOEXCEPT
+{
+ return __libcpp_thread_get_current_id();
+}
+
+} // namespace this_thread
+
+#endif // !_LIBCPP_HAS_NO_THREADS
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_THREADING_SUPPORT
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__tree b/contrib/libs/cxxsupp/libcxxmsvc/include/__tree
new file mode 100644
index 0000000000..384d383504
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__tree
@@ -0,0 +1,2748 @@
+// -*- 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___TREE
+#define _LIBCPP___TREE
+
+#include <__algorithm/min.h>
+#include <__config>
+#include <__utility/forward.h>
+#include <iterator>
+#include <limits>
+#include <memory>
+#include <stdexcept>
+
+#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(__GNUC__) && !defined(__clang__) // gcc.gnu.org/PR37804
+template <class, class, class, class> class _LIBCPP_TEMPLATE_VIS map;
+template <class, class, class, class> class _LIBCPP_TEMPLATE_VIS multimap;
+template <class, class, class> class _LIBCPP_TEMPLATE_VIS set;
+template <class, class, class> class _LIBCPP_TEMPLATE_VIS multiset;
+#endif
+
+template <class _Tp, class _Compare, class _Allocator> class __tree;
+template <class _Tp, class _NodePtr, class _DiffType>
+ class _LIBCPP_TEMPLATE_VIS __tree_iterator;
+template <class _Tp, class _ConstNodePtr, class _DiffType>
+ class _LIBCPP_TEMPLATE_VIS __tree_const_iterator;
+
+template <class _Pointer> class __tree_end_node;
+template <class _VoidPtr> class __tree_node_base;
+template <class _Tp, class _VoidPtr> class __tree_node;
+
+template <class _Key, class _Value>
+struct __value_type;
+
+template <class _Allocator> class __map_node_destructor;
+template <class _TreeIterator> class _LIBCPP_TEMPLATE_VIS __map_iterator;
+template <class _TreeIterator> class _LIBCPP_TEMPLATE_VIS __map_const_iterator;
+
+/*
+
+_NodePtr algorithms
+
+The algorithms taking _NodePtr are red black tree algorithms. Those
+algorithms taking a parameter named __root should assume that __root
+points to a proper red black tree (unless otherwise specified).
+
+Each algorithm herein assumes that __root->__parent_ points to a non-null
+structure which has a member __left_ which points back to __root. No other
+member is read or written to at __root->__parent_.
+
+__root->__parent_ will be referred to below (in comments only) as end_node.
+end_node->__left_ is an externably accessible lvalue for __root, and can be
+changed by node insertion and removal (without explicit reference to end_node).
+
+All nodes (with the exception of end_node), even the node referred to as
+__root, have a non-null __parent_ field.
+
+*/
+
+// Returns: true if __x is a left child of its parent, else false
+// Precondition: __x != nullptr.
+template <class _NodePtr>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__tree_is_left_child(_NodePtr __x) _NOEXCEPT
+{
+ return __x == __x->__parent_->__left_;
+}
+
+// Determines if the subtree rooted at __x is a proper red black subtree. If
+// __x is a proper subtree, returns the black height (null counts as 1). If
+// __x is an improper subtree, returns 0.
+template <class _NodePtr>
+unsigned
+__tree_sub_invariant(_NodePtr __x)
+{
+ if (__x == nullptr)
+ return 1;
+ // parent consistency checked by caller
+ // check __x->__left_ consistency
+ if (__x->__left_ != nullptr && __x->__left_->__parent_ != __x)
+ return 0;
+ // check __x->__right_ consistency
+ if (__x->__right_ != nullptr && __x->__right_->__parent_ != __x)
+ return 0;
+ // check __x->__left_ != __x->__right_ unless both are nullptr
+ if (__x->__left_ == __x->__right_ && __x->__left_ != nullptr)
+ return 0;
+ // If this is red, neither child can be red
+ if (!__x->__is_black_)
+ {
+ if (__x->__left_ && !__x->__left_->__is_black_)
+ return 0;
+ if (__x->__right_ && !__x->__right_->__is_black_)
+ return 0;
+ }
+ unsigned __h = _VSTD::__tree_sub_invariant(__x->__left_);
+ if (__h == 0)
+ return 0; // invalid left subtree
+ if (__h != _VSTD::__tree_sub_invariant(__x->__right_))
+ return 0; // invalid or different height right subtree
+ return __h + __x->__is_black_; // return black height of this node
+}
+
+// Determines if the red black tree rooted at __root is a proper red black tree.
+// __root == nullptr is a proper tree. Returns true is __root is a proper
+// red black tree, else returns false.
+template <class _NodePtr>
+bool
+__tree_invariant(_NodePtr __root)
+{
+ if (__root == nullptr)
+ return true;
+ // check __x->__parent_ consistency
+ if (__root->__parent_ == nullptr)
+ return false;
+ if (!_VSTD::__tree_is_left_child(__root))
+ return false;
+ // root must be black
+ if (!__root->__is_black_)
+ return false;
+ // do normal node checks
+ return _VSTD::__tree_sub_invariant(__root) != 0;
+}
+
+// Returns: pointer to the left-most node under __x.
+// Precondition: __x != nullptr.
+template <class _NodePtr>
+inline _LIBCPP_INLINE_VISIBILITY
+_NodePtr
+__tree_min(_NodePtr __x) _NOEXCEPT
+{
+ while (__x->__left_ != nullptr)
+ __x = __x->__left_;
+ return __x;
+}
+
+// Returns: pointer to the right-most node under __x.
+// Precondition: __x != nullptr.
+template <class _NodePtr>
+inline _LIBCPP_INLINE_VISIBILITY
+_NodePtr
+__tree_max(_NodePtr __x) _NOEXCEPT
+{
+ while (__x->__right_ != nullptr)
+ __x = __x->__right_;
+ return __x;
+}
+
+// Returns: pointer to the next in-order node after __x.
+// Precondition: __x != nullptr.
+template <class _NodePtr>
+_NodePtr
+__tree_next(_NodePtr __x) _NOEXCEPT
+{
+ if (__x->__right_ != nullptr)
+ return _VSTD::__tree_min(__x->__right_);
+ while (!_VSTD::__tree_is_left_child(__x))
+ __x = __x->__parent_unsafe();
+ return __x->__parent_unsafe();
+}
+
+template <class _EndNodePtr, class _NodePtr>
+inline _LIBCPP_INLINE_VISIBILITY
+_EndNodePtr
+__tree_next_iter(_NodePtr __x) _NOEXCEPT
+{
+ if (__x->__right_ != nullptr)
+ return static_cast<_EndNodePtr>(_VSTD::__tree_min(__x->__right_));
+ while (!_VSTD::__tree_is_left_child(__x))
+ __x = __x->__parent_unsafe();
+ return static_cast<_EndNodePtr>(__x->__parent_);
+}
+
+// Returns: pointer to the previous in-order node before __x.
+// Precondition: __x != nullptr.
+// Note: __x may be the end node.
+template <class _NodePtr, class _EndNodePtr>
+inline _LIBCPP_INLINE_VISIBILITY
+_NodePtr
+__tree_prev_iter(_EndNodePtr __x) _NOEXCEPT
+{
+ if (__x->__left_ != nullptr)
+ return _VSTD::__tree_max(__x->__left_);
+ _NodePtr __xx = static_cast<_NodePtr>(__x);
+ while (_VSTD::__tree_is_left_child(__xx))
+ __xx = __xx->__parent_unsafe();
+ return __xx->__parent_unsafe();
+}
+
+// Returns: pointer to a node which has no children
+// Precondition: __x != nullptr.
+template <class _NodePtr>
+_NodePtr
+__tree_leaf(_NodePtr __x) _NOEXCEPT
+{
+ while (true)
+ {
+ if (__x->__left_ != nullptr)
+ {
+ __x = __x->__left_;
+ continue;
+ }
+ if (__x->__right_ != nullptr)
+ {
+ __x = __x->__right_;
+ continue;
+ }
+ break;
+ }
+ return __x;
+}
+
+// Effects: Makes __x->__right_ the subtree root with __x as its left child
+// while preserving in-order order.
+// Precondition: __x->__right_ != nullptr
+template <class _NodePtr>
+void
+__tree_left_rotate(_NodePtr __x) _NOEXCEPT
+{
+ _NodePtr __y = __x->__right_;
+ __x->__right_ = __y->__left_;
+ if (__x->__right_ != nullptr)
+ __x->__right_->__set_parent(__x);
+ __y->__parent_ = __x->__parent_;
+ if (_VSTD::__tree_is_left_child(__x))
+ __x->__parent_->__left_ = __y;
+ else
+ __x->__parent_unsafe()->__right_ = __y;
+ __y->__left_ = __x;
+ __x->__set_parent(__y);
+}
+
+// Effects: Makes __x->__left_ the subtree root with __x as its right child
+// while preserving in-order order.
+// Precondition: __x->__left_ != nullptr
+template <class _NodePtr>
+void
+__tree_right_rotate(_NodePtr __x) _NOEXCEPT
+{
+ _NodePtr __y = __x->__left_;
+ __x->__left_ = __y->__right_;
+ if (__x->__left_ != nullptr)
+ __x->__left_->__set_parent(__x);
+ __y->__parent_ = __x->__parent_;
+ if (_VSTD::__tree_is_left_child(__x))
+ __x->__parent_->__left_ = __y;
+ else
+ __x->__parent_unsafe()->__right_ = __y;
+ __y->__right_ = __x;
+ __x->__set_parent(__y);
+}
+
+// Effects: Rebalances __root after attaching __x to a leaf.
+// Precondition: __root != nulptr && __x != nullptr.
+// __x has no children.
+// __x == __root or == a direct or indirect child of __root.
+// If __x were to be unlinked from __root (setting __root to
+// nullptr if __root == __x), __tree_invariant(__root) == true.
+// Postcondition: __tree_invariant(end_node->__left_) == true. end_node->__left_
+// may be different than the value passed in as __root.
+template <class _NodePtr>
+void
+__tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT
+{
+ __x->__is_black_ = __x == __root;
+ while (__x != __root && !__x->__parent_unsafe()->__is_black_)
+ {
+ // __x->__parent_ != __root because __x->__parent_->__is_black == false
+ if (_VSTD::__tree_is_left_child(__x->__parent_unsafe()))
+ {
+ _NodePtr __y = __x->__parent_unsafe()->__parent_unsafe()->__right_;
+ if (__y != nullptr && !__y->__is_black_)
+ {
+ __x = __x->__parent_unsafe();
+ __x->__is_black_ = true;
+ __x = __x->__parent_unsafe();
+ __x->__is_black_ = __x == __root;
+ __y->__is_black_ = true;
+ }
+ else
+ {
+ if (!_VSTD::__tree_is_left_child(__x))
+ {
+ __x = __x->__parent_unsafe();
+ _VSTD::__tree_left_rotate(__x);
+ }
+ __x = __x->__parent_unsafe();
+ __x->__is_black_ = true;
+ __x = __x->__parent_unsafe();
+ __x->__is_black_ = false;
+ _VSTD::__tree_right_rotate(__x);
+ break;
+ }
+ }
+ else
+ {
+ _NodePtr __y = __x->__parent_unsafe()->__parent_->__left_;
+ if (__y != nullptr && !__y->__is_black_)
+ {
+ __x = __x->__parent_unsafe();
+ __x->__is_black_ = true;
+ __x = __x->__parent_unsafe();
+ __x->__is_black_ = __x == __root;
+ __y->__is_black_ = true;
+ }
+ else
+ {
+ if (_VSTD::__tree_is_left_child(__x))
+ {
+ __x = __x->__parent_unsafe();
+ _VSTD::__tree_right_rotate(__x);
+ }
+ __x = __x->__parent_unsafe();
+ __x->__is_black_ = true;
+ __x = __x->__parent_unsafe();
+ __x->__is_black_ = false;
+ _VSTD::__tree_left_rotate(__x);
+ break;
+ }
+ }
+ }
+}
+
+// Precondition: __root != nullptr && __z != nullptr.
+// __tree_invariant(__root) == true.
+// __z == __root or == a direct or indirect child of __root.
+// Effects: unlinks __z from the tree rooted at __root, rebalancing as needed.
+// Postcondition: __tree_invariant(end_node->__left_) == true && end_node->__left_
+// nor any of its children refer to __z. end_node->__left_
+// may be different than the value passed in as __root.
+template <class _NodePtr>
+void
+__tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT
+{
+ // __z will be removed from the tree. Client still needs to destruct/deallocate it
+ // __y is either __z, or if __z has two children, __tree_next(__z).
+ // __y will have at most one child.
+ // __y will be the initial hole in the tree (make the hole at a leaf)
+ _NodePtr __y = (__z->__left_ == nullptr || __z->__right_ == nullptr) ?
+ __z : _VSTD::__tree_next(__z);
+ // __x is __y's possibly null single child
+ _NodePtr __x = __y->__left_ != nullptr ? __y->__left_ : __y->__right_;
+ // __w is __x's possibly null uncle (will become __x's sibling)
+ _NodePtr __w = nullptr;
+ // link __x to __y's parent, and find __w
+ if (__x != nullptr)
+ __x->__parent_ = __y->__parent_;
+ if (_VSTD::__tree_is_left_child(__y))
+ {
+ __y->__parent_->__left_ = __x;
+ if (__y != __root)
+ __w = __y->__parent_unsafe()->__right_;
+ else
+ __root = __x; // __w == nullptr
+ }
+ else
+ {
+ __y->__parent_unsafe()->__right_ = __x;
+ // __y can't be root if it is a right child
+ __w = __y->__parent_->__left_;
+ }
+ bool __removed_black = __y->__is_black_;
+ // If we didn't remove __z, do so now by splicing in __y for __z,
+ // but copy __z's color. This does not impact __x or __w.
+ if (__y != __z)
+ {
+ // __z->__left_ != nulptr but __z->__right_ might == __x == nullptr
+ __y->__parent_ = __z->__parent_;
+ if (_VSTD::__tree_is_left_child(__z))
+ __y->__parent_->__left_ = __y;
+ else
+ __y->__parent_unsafe()->__right_ = __y;
+ __y->__left_ = __z->__left_;
+ __y->__left_->__set_parent(__y);
+ __y->__right_ = __z->__right_;
+ if (__y->__right_ != nullptr)
+ __y->__right_->__set_parent(__y);
+ __y->__is_black_ = __z->__is_black_;
+ if (__root == __z)
+ __root = __y;
+ }
+ // There is no need to rebalance if we removed a red, or if we removed
+ // the last node.
+ if (__removed_black && __root != nullptr)
+ {
+ // Rebalance:
+ // __x has an implicit black color (transferred from the removed __y)
+ // associated with it, no matter what its color is.
+ // If __x is __root (in which case it can't be null), it is supposed
+ // to be black anyway, and if it is doubly black, then the double
+ // can just be ignored.
+ // If __x is red (in which case it can't be null), then it can absorb
+ // the implicit black just by setting its color to black.
+ // Since __y was black and only had one child (which __x points to), __x
+ // is either red with no children, else null, otherwise __y would have
+ // different black heights under left and right pointers.
+ // if (__x == __root || __x != nullptr && !__x->__is_black_)
+ if (__x != nullptr)
+ __x->__is_black_ = true;
+ else
+ {
+ // Else __x isn't root, and is "doubly black", even though it may
+ // be null. __w can not be null here, else the parent would
+ // see a black height >= 2 on the __x side and a black height
+ // of 1 on the __w side (__w must be a non-null black or a red
+ // with a non-null black child).
+ while (true)
+ {
+ if (!_VSTD::__tree_is_left_child(__w)) // if x is left child
+ {
+ if (!__w->__is_black_)
+ {
+ __w->__is_black_ = true;
+ __w->__parent_unsafe()->__is_black_ = false;
+ _VSTD::__tree_left_rotate(__w->__parent_unsafe());
+ // __x is still valid
+ // reset __root only if necessary
+ if (__root == __w->__left_)
+ __root = __w;
+ // reset sibling, and it still can't be null
+ __w = __w->__left_->__right_;
+ }
+ // __w->__is_black_ is now true, __w may have null children
+ if ((__w->__left_ == nullptr || __w->__left_->__is_black_) &&
+ (__w->__right_ == nullptr || __w->__right_->__is_black_))
+ {
+ __w->__is_black_ = false;
+ __x = __w->__parent_unsafe();
+ // __x can no longer be null
+ if (__x == __root || !__x->__is_black_)
+ {
+ __x->__is_black_ = true;
+ break;
+ }
+ // reset sibling, and it still can't be null
+ __w = _VSTD::__tree_is_left_child(__x) ?
+ __x->__parent_unsafe()->__right_ :
+ __x->__parent_->__left_;
+ // continue;
+ }
+ else // __w has a red child
+ {
+ if (__w->__right_ == nullptr || __w->__right_->__is_black_)
+ {
+ // __w left child is non-null and red
+ __w->__left_->__is_black_ = true;
+ __w->__is_black_ = false;
+ _VSTD::__tree_right_rotate(__w);
+ // __w is known not to be root, so root hasn't changed
+ // reset sibling, and it still can't be null
+ __w = __w->__parent_unsafe();
+ }
+ // __w has a right red child, left child may be null
+ __w->__is_black_ = __w->__parent_unsafe()->__is_black_;
+ __w->__parent_unsafe()->__is_black_ = true;
+ __w->__right_->__is_black_ = true;
+ _VSTD::__tree_left_rotate(__w->__parent_unsafe());
+ break;
+ }
+ }
+ else
+ {
+ if (!__w->__is_black_)
+ {
+ __w->__is_black_ = true;
+ __w->__parent_unsafe()->__is_black_ = false;
+ _VSTD::__tree_right_rotate(__w->__parent_unsafe());
+ // __x is still valid
+ // reset __root only if necessary
+ if (__root == __w->__right_)
+ __root = __w;
+ // reset sibling, and it still can't be null
+ __w = __w->__right_->__left_;
+ }
+ // __w->__is_black_ is now true, __w may have null children
+ if ((__w->__left_ == nullptr || __w->__left_->__is_black_) &&
+ (__w->__right_ == nullptr || __w->__right_->__is_black_))
+ {
+ __w->__is_black_ = false;
+ __x = __w->__parent_unsafe();
+ // __x can no longer be null
+ if (!__x->__is_black_ || __x == __root)
+ {
+ __x->__is_black_ = true;
+ break;
+ }
+ // reset sibling, and it still can't be null
+ __w = _VSTD::__tree_is_left_child(__x) ?
+ __x->__parent_unsafe()->__right_ :
+ __x->__parent_->__left_;
+ // continue;
+ }
+ else // __w has a red child
+ {
+ if (__w->__left_ == nullptr || __w->__left_->__is_black_)
+ {
+ // __w right child is non-null and red
+ __w->__right_->__is_black_ = true;
+ __w->__is_black_ = false;
+ _VSTD::__tree_left_rotate(__w);
+ // __w is known not to be root, so root hasn't changed
+ // reset sibling, and it still can't be null
+ __w = __w->__parent_unsafe();
+ }
+ // __w has a left red child, right child may be null
+ __w->__is_black_ = __w->__parent_unsafe()->__is_black_;
+ __w->__parent_unsafe()->__is_black_ = true;
+ __w->__left_->__is_black_ = true;
+ _VSTD::__tree_right_rotate(__w->__parent_unsafe());
+ break;
+ }
+ }
+ }
+ }
+ }
+}
+
+// node traits
+
+
+template <class _Tp>
+struct __is_tree_value_type_imp : false_type {};
+
+template <class _Key, class _Value>
+struct __is_tree_value_type_imp<__value_type<_Key, _Value> > : true_type {};
+
+template <class ..._Args>
+struct __is_tree_value_type : false_type {};
+
+template <class _One>
+struct __is_tree_value_type<_One> : __is_tree_value_type_imp<__uncvref_t<_One> > {};
+
+template <class _Tp>
+struct __tree_key_value_types {
+ typedef _Tp key_type;
+ typedef _Tp __node_value_type;
+ typedef _Tp __container_value_type;
+ static const bool __is_map = false;
+
+ _LIBCPP_INLINE_VISIBILITY
+ static key_type const& __get_key(_Tp const& __v) {
+ return __v;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ static __container_value_type const& __get_value(__node_value_type const& __v) {
+ return __v;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ static __container_value_type* __get_ptr(__node_value_type& __n) {
+ return _VSTD::addressof(__n);
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ static __container_value_type&& __move(__node_value_type& __v) {
+ return _VSTD::move(__v);
+ }
+};
+
+template <class _Key, class _Tp>
+struct __tree_key_value_types<__value_type<_Key, _Tp> > {
+ typedef _Key key_type;
+ typedef _Tp mapped_type;
+ typedef __value_type<_Key, _Tp> __node_value_type;
+ typedef pair<const _Key, _Tp> __container_value_type;
+ typedef __container_value_type __map_value_type;
+ static const bool __is_map = true;
+
+ _LIBCPP_INLINE_VISIBILITY
+ static key_type const&
+ __get_key(__node_value_type const& __t) {
+ return __t.__get_value().first;
+ }
+
+ template <class _Up>
+ _LIBCPP_INLINE_VISIBILITY
+ static typename enable_if<__is_same_uncvref<_Up, __container_value_type>::value,
+ key_type const&>::type
+ __get_key(_Up& __t) {
+ return __t.first;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ static __container_value_type const&
+ __get_value(__node_value_type const& __t) {
+ return __t.__get_value();
+ }
+
+ template <class _Up>
+ _LIBCPP_INLINE_VISIBILITY
+ static typename enable_if<__is_same_uncvref<_Up, __container_value_type>::value,
+ __container_value_type const&>::type
+ __get_value(_Up& __t) {
+ return __t;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ static __container_value_type* __get_ptr(__node_value_type& __n) {
+ return _VSTD::addressof(__n.__get_value());
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ static pair<key_type&&, mapped_type&&> __move(__node_value_type& __v) {
+ return __v.__move();
+ }
+};
+
+template <class _VoidPtr>
+struct __tree_node_base_types {
+ typedef _VoidPtr __void_pointer;
+
+ typedef __tree_node_base<__void_pointer> __node_base_type;
+ typedef typename __rebind_pointer<_VoidPtr, __node_base_type>::type
+ __node_base_pointer;
+
+ typedef __tree_end_node<__node_base_pointer> __end_node_type;
+ typedef typename __rebind_pointer<_VoidPtr, __end_node_type>::type
+ __end_node_pointer;
+#if defined(_LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB)
+ typedef __end_node_pointer __parent_pointer;
+#else
+ typedef typename conditional<
+ is_pointer<__end_node_pointer>::value,
+ __end_node_pointer,
+ __node_base_pointer>::type __parent_pointer;
+#endif
+
+private:
+ static_assert((is_same<typename pointer_traits<_VoidPtr>::element_type, void>::value),
+ "_VoidPtr does not point to unqualified void type");
+};
+
+template <class _Tp, class _AllocPtr, class _KVTypes = __tree_key_value_types<_Tp>,
+ bool = _KVTypes::__is_map>
+struct __tree_map_pointer_types {};
+
+template <class _Tp, class _AllocPtr, class _KVTypes>
+struct __tree_map_pointer_types<_Tp, _AllocPtr, _KVTypes, true> {
+ typedef typename _KVTypes::__map_value_type _Mv;
+ typedef typename __rebind_pointer<_AllocPtr, _Mv>::type
+ __map_value_type_pointer;
+ typedef typename __rebind_pointer<_AllocPtr, const _Mv>::type
+ __const_map_value_type_pointer;
+};
+
+template <class _NodePtr, class _NodeT = typename pointer_traits<_NodePtr>::element_type>
+struct __tree_node_types;
+
+template <class _NodePtr, class _Tp, class _VoidPtr>
+struct __tree_node_types<_NodePtr, __tree_node<_Tp, _VoidPtr> >
+ : public __tree_node_base_types<_VoidPtr>,
+ __tree_key_value_types<_Tp>,
+ __tree_map_pointer_types<_Tp, _VoidPtr>
+{
+ typedef __tree_node_base_types<_VoidPtr> __base;
+ typedef __tree_key_value_types<_Tp> __key_base;
+ typedef __tree_map_pointer_types<_Tp, _VoidPtr> __map_pointer_base;
+public:
+
+ typedef typename pointer_traits<_NodePtr>::element_type __node_type;
+ typedef _NodePtr __node_pointer;
+
+ typedef _Tp __node_value_type;
+ typedef typename __rebind_pointer<_VoidPtr, __node_value_type>::type
+ __node_value_type_pointer;
+ typedef typename __rebind_pointer<_VoidPtr, const __node_value_type>::type
+ __const_node_value_type_pointer;
+#if defined(_LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB)
+ typedef typename __base::__end_node_pointer __iter_pointer;
+#else
+ typedef typename conditional<
+ is_pointer<__node_pointer>::value,
+ typename __base::__end_node_pointer,
+ __node_pointer>::type __iter_pointer;
+#endif
+private:
+ static_assert(!is_const<__node_type>::value,
+ "_NodePtr should never be a pointer to const");
+ static_assert((is_same<typename __rebind_pointer<_VoidPtr, __node_type>::type,
+ _NodePtr>::value), "_VoidPtr does not rebind to _NodePtr.");
+};
+
+template <class _ValueTp, class _VoidPtr>
+struct __make_tree_node_types {
+ typedef typename __rebind_pointer<_VoidPtr, __tree_node<_ValueTp, _VoidPtr> >::type
+ _NodePtr;
+ typedef __tree_node_types<_NodePtr> type;
+};
+
+// node
+
+template <class _Pointer>
+class __tree_end_node
+{
+public:
+ typedef _Pointer pointer;
+ pointer __left_;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __tree_end_node() _NOEXCEPT : __left_() {}
+};
+
+template <class _VoidPtr>
+class _LIBCPP_STANDALONE_DEBUG __tree_node_base
+ : public __tree_node_base_types<_VoidPtr>::__end_node_type
+{
+ typedef __tree_node_base_types<_VoidPtr> _NodeBaseTypes;
+
+public:
+ typedef typename _NodeBaseTypes::__node_base_pointer pointer;
+ typedef typename _NodeBaseTypes::__parent_pointer __parent_pointer;
+
+ pointer __right_;
+ __parent_pointer __parent_;
+ bool __is_black_;
+
+ _LIBCPP_INLINE_VISIBILITY
+ pointer __parent_unsafe() const { return static_cast<pointer>(__parent_);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __set_parent(pointer __p) {
+ __parent_ = static_cast<__parent_pointer>(__p);
+ }
+
+private:
+ ~__tree_node_base() = delete;
+ __tree_node_base(__tree_node_base const&) = delete;
+ __tree_node_base& operator=(__tree_node_base const&) = delete;
+};
+
+template <class _Tp, class _VoidPtr>
+class _LIBCPP_STANDALONE_DEBUG __tree_node
+ : public __tree_node_base<_VoidPtr>
+{
+public:
+ typedef _Tp __node_value_type;
+
+ __node_value_type __value_;
+
+private:
+ ~__tree_node() = delete;
+ __tree_node(__tree_node const&) = delete;
+ __tree_node& operator=(__tree_node const&) = delete;
+};
+
+
+template <class _Allocator>
+class __tree_node_destructor
+{
+ typedef _Allocator allocator_type;
+ typedef allocator_traits<allocator_type> __alloc_traits;
+
+public:
+ typedef typename __alloc_traits::pointer pointer;
+private:
+ typedef __tree_node_types<pointer> _NodeTypes;
+ allocator_type& __na_;
+
+
+public:
+ bool __value_constructed;
+
+
+ __tree_node_destructor(const __tree_node_destructor &) = default;
+ __tree_node_destructor& operator=(const __tree_node_destructor&) = delete;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __tree_node_destructor(allocator_type& __na, bool __val = false) _NOEXCEPT
+ : __na_(__na),
+ __value_constructed(__val)
+ {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void operator()(pointer __p) _NOEXCEPT
+ {
+ if (__value_constructed)
+ __alloc_traits::destroy(__na_, _NodeTypes::__get_ptr(__p->__value_));
+ if (__p)
+ __alloc_traits::deallocate(__na_, __p, 1);
+ }
+
+ template <class> friend class __map_node_destructor;
+};
+
+#if _LIBCPP_STD_VER > 14
+template <class _NodeType, class _Alloc>
+struct __generic_container_node_destructor;
+template <class _Tp, class _VoidPtr, class _Alloc>
+struct __generic_container_node_destructor<__tree_node<_Tp, _VoidPtr>, _Alloc>
+ : __tree_node_destructor<_Alloc>
+{
+ using __tree_node_destructor<_Alloc>::__tree_node_destructor;
+};
+#endif
+
+template <class _Tp, class _NodePtr, class _DiffType>
+class _LIBCPP_TEMPLATE_VIS __tree_iterator
+{
+ typedef __tree_node_types<_NodePtr> _NodeTypes;
+ typedef _NodePtr __node_pointer;
+ typedef typename _NodeTypes::__node_base_pointer __node_base_pointer;
+ typedef typename _NodeTypes::__end_node_pointer __end_node_pointer;
+ typedef typename _NodeTypes::__iter_pointer __iter_pointer;
+ typedef pointer_traits<__node_pointer> __pointer_traits;
+
+ __iter_pointer __ptr_;
+
+public:
+ typedef bidirectional_iterator_tag iterator_category;
+ typedef _Tp value_type;
+ typedef _DiffType difference_type;
+ typedef value_type& reference;
+ typedef typename _NodeTypes::__node_value_type_pointer pointer;
+
+ _LIBCPP_INLINE_VISIBILITY __tree_iterator() _NOEXCEPT
+#if _LIBCPP_STD_VER > 11
+ : __ptr_(nullptr)
+#endif
+ {}
+
+ _LIBCPP_INLINE_VISIBILITY reference operator*() const
+ {return __get_np()->__value_;}
+ _LIBCPP_INLINE_VISIBILITY pointer operator->() const
+ {return pointer_traits<pointer>::pointer_to(__get_np()->__value_);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __tree_iterator& operator++() {
+ __ptr_ = static_cast<__iter_pointer>(
+ _VSTD::__tree_next_iter<__end_node_pointer>(static_cast<__node_base_pointer>(__ptr_)));
+ return *this;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ __tree_iterator operator++(int)
+ {__tree_iterator __t(*this); ++(*this); return __t;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __tree_iterator& operator--() {
+ __ptr_ = static_cast<__iter_pointer>(_VSTD::__tree_prev_iter<__node_base_pointer>(
+ static_cast<__end_node_pointer>(__ptr_)));
+ return *this;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ __tree_iterator operator--(int)
+ {__tree_iterator __t(*this); --(*this); return __t;}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const __tree_iterator& __x, const __tree_iterator& __y)
+ {return __x.__ptr_ == __y.__ptr_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const __tree_iterator& __x, const __tree_iterator& __y)
+ {return !(__x == __y);}
+
+private:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __tree_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __tree_iterator(__end_node_pointer __p) _NOEXCEPT : __ptr_(__p) {}
+ _LIBCPP_INLINE_VISIBILITY
+ __node_pointer __get_np() const { return static_cast<__node_pointer>(__ptr_); }
+ template <class, class, class> friend class __tree;
+ template <class, class, class> friend class _LIBCPP_TEMPLATE_VIS __tree_const_iterator;
+ template <class> friend class _LIBCPP_TEMPLATE_VIS __map_iterator;
+ template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS map;
+ template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS multimap;
+ template <class, class, class> friend class _LIBCPP_TEMPLATE_VIS set;
+ template <class, class, class> friend class _LIBCPP_TEMPLATE_VIS multiset;
+};
+
+template <class _Tp, class _NodePtr, class _DiffType>
+class _LIBCPP_TEMPLATE_VIS __tree_const_iterator
+{
+ typedef __tree_node_types<_NodePtr> _NodeTypes;
+ typedef typename _NodeTypes::__node_pointer __node_pointer;
+ typedef typename _NodeTypes::__node_base_pointer __node_base_pointer;
+ typedef typename _NodeTypes::__end_node_pointer __end_node_pointer;
+ typedef typename _NodeTypes::__iter_pointer __iter_pointer;
+ typedef pointer_traits<__node_pointer> __pointer_traits;
+
+ __iter_pointer __ptr_;
+
+public:
+ typedef bidirectional_iterator_tag iterator_category;
+ typedef _Tp value_type;
+ typedef _DiffType difference_type;
+ typedef const value_type& reference;
+ typedef typename _NodeTypes::__const_node_value_type_pointer pointer;
+
+ _LIBCPP_INLINE_VISIBILITY __tree_const_iterator() _NOEXCEPT
+#if _LIBCPP_STD_VER > 11
+ : __ptr_(nullptr)
+#endif
+ {}
+
+private:
+ typedef __tree_iterator<value_type, __node_pointer, difference_type>
+ __non_const_iterator;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ __tree_const_iterator(__non_const_iterator __p) _NOEXCEPT
+ : __ptr_(__p.__ptr_) {}
+
+ _LIBCPP_INLINE_VISIBILITY reference operator*() const
+ {return __get_np()->__value_;}
+ _LIBCPP_INLINE_VISIBILITY pointer operator->() const
+ {return pointer_traits<pointer>::pointer_to(__get_np()->__value_);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __tree_const_iterator& operator++() {
+ __ptr_ = static_cast<__iter_pointer>(
+ _VSTD::__tree_next_iter<__end_node_pointer>(static_cast<__node_base_pointer>(__ptr_)));
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __tree_const_iterator operator++(int)
+ {__tree_const_iterator __t(*this); ++(*this); return __t;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __tree_const_iterator& operator--() {
+ __ptr_ = static_cast<__iter_pointer>(_VSTD::__tree_prev_iter<__node_base_pointer>(
+ static_cast<__end_node_pointer>(__ptr_)));
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __tree_const_iterator operator--(int)
+ {__tree_const_iterator __t(*this); --(*this); return __t;}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const __tree_const_iterator& __x, const __tree_const_iterator& __y)
+ {return __x.__ptr_ == __y.__ptr_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const __tree_const_iterator& __x, const __tree_const_iterator& __y)
+ {return !(__x == __y);}
+
+private:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __tree_const_iterator(__node_pointer __p) _NOEXCEPT
+ : __ptr_(__p) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __tree_const_iterator(__end_node_pointer __p) _NOEXCEPT
+ : __ptr_(__p) {}
+ _LIBCPP_INLINE_VISIBILITY
+ __node_pointer __get_np() const { return static_cast<__node_pointer>(__ptr_); }
+
+ template <class, class, class> friend class __tree;
+ template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS map;
+ template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS multimap;
+ template <class, class, class> friend class _LIBCPP_TEMPLATE_VIS set;
+ template <class, class, class> friend class _LIBCPP_TEMPLATE_VIS multiset;
+ template <class> friend class _LIBCPP_TEMPLATE_VIS __map_const_iterator;
+
+};
+
+template<class _Tp, class _Compare>
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_DIAGNOSE_WARNING(!__invokable<_Compare const&, _Tp const&, _Tp const&>::value,
+ "the specified comparator type does not provide a viable const call operator")
+#endif
+int __diagnose_non_const_comparator();
+
+template <class _Tp, class _Compare, class _Allocator>
+class __tree
+{
+public:
+ typedef _Tp value_type;
+ typedef _Compare value_compare;
+ typedef _Allocator allocator_type;
+
+private:
+ typedef allocator_traits<allocator_type> __alloc_traits;
+ typedef typename __make_tree_node_types<value_type,
+ typename __alloc_traits::void_pointer>::type
+ _NodeTypes;
+ typedef typename _NodeTypes::key_type key_type;
+public:
+ typedef typename _NodeTypes::__node_value_type __node_value_type;
+ typedef typename _NodeTypes::__container_value_type __container_value_type;
+
+ typedef typename __alloc_traits::pointer pointer;
+ typedef typename __alloc_traits::const_pointer const_pointer;
+ typedef typename __alloc_traits::size_type size_type;
+ typedef typename __alloc_traits::difference_type difference_type;
+
+public:
+ typedef typename _NodeTypes::__void_pointer __void_pointer;
+
+ typedef typename _NodeTypes::__node_type __node;
+ typedef typename _NodeTypes::__node_pointer __node_pointer;
+
+ typedef typename _NodeTypes::__node_base_type __node_base;
+ typedef typename _NodeTypes::__node_base_pointer __node_base_pointer;
+
+ typedef typename _NodeTypes::__end_node_type __end_node_t;
+ typedef typename _NodeTypes::__end_node_pointer __end_node_ptr;
+
+ typedef typename _NodeTypes::__parent_pointer __parent_pointer;
+ typedef typename _NodeTypes::__iter_pointer __iter_pointer;
+
+ typedef typename __rebind_alloc_helper<__alloc_traits, __node>::type __node_allocator;
+ typedef allocator_traits<__node_allocator> __node_traits;
+
+private:
+ // check for sane allocator pointer rebinding semantics. Rebinding the
+ // allocator for a new pointer type should be exactly the same as rebinding
+ // the pointer using 'pointer_traits'.
+ static_assert((is_same<__node_pointer, typename __node_traits::pointer>::value),
+ "Allocator does not rebind pointers in a sane manner.");
+ typedef typename __rebind_alloc_helper<__node_traits, __node_base>::type
+ __node_base_allocator;
+ typedef allocator_traits<__node_base_allocator> __node_base_traits;
+ static_assert((is_same<__node_base_pointer, typename __node_base_traits::pointer>::value),
+ "Allocator does not rebind pointers in a sane manner.");
+
+private:
+ __iter_pointer __begin_node_;
+ __compressed_pair<__end_node_t, __node_allocator> __pair1_;
+ __compressed_pair<size_type, value_compare> __pair3_;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ __iter_pointer __end_node() _NOEXCEPT
+ {
+ return static_cast<__iter_pointer>(
+ pointer_traits<__end_node_ptr>::pointer_to(__pair1_.first())
+ );
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ __iter_pointer __end_node() const _NOEXCEPT
+ {
+ return static_cast<__iter_pointer>(
+ pointer_traits<__end_node_ptr>::pointer_to(
+ const_cast<__end_node_t&>(__pair1_.first())
+ )
+ );
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ __node_allocator& __node_alloc() _NOEXCEPT {return __pair1_.second();}
+private:
+ _LIBCPP_INLINE_VISIBILITY
+ const __node_allocator& __node_alloc() const _NOEXCEPT
+ {return __pair1_.second();}
+ _LIBCPP_INLINE_VISIBILITY
+ __iter_pointer& __begin_node() _NOEXCEPT {return __begin_node_;}
+ _LIBCPP_INLINE_VISIBILITY
+ const __iter_pointer& __begin_node() const _NOEXCEPT {return __begin_node_;}
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ allocator_type __alloc() const _NOEXCEPT
+ {return allocator_type(__node_alloc());}
+private:
+ _LIBCPP_INLINE_VISIBILITY
+ size_type& size() _NOEXCEPT {return __pair3_.first();}
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ const size_type& size() const _NOEXCEPT {return __pair3_.first();}
+ _LIBCPP_INLINE_VISIBILITY
+ value_compare& value_comp() _NOEXCEPT {return __pair3_.second();}
+ _LIBCPP_INLINE_VISIBILITY
+ const value_compare& value_comp() const _NOEXCEPT
+ {return __pair3_.second();}
+public:
+
+ _LIBCPP_INLINE_VISIBILITY
+ __node_pointer __root() const _NOEXCEPT
+ {return static_cast<__node_pointer>(__end_node()->__left_);}
+
+ __node_base_pointer* __root_ptr() const _NOEXCEPT {
+ return _VSTD::addressof(__end_node()->__left_);
+ }
+
+ typedef __tree_iterator<value_type, __node_pointer, difference_type> iterator;
+ typedef __tree_const_iterator<value_type, __node_pointer, difference_type> const_iterator;
+
+ explicit __tree(const value_compare& __comp)
+ _NOEXCEPT_(
+ is_nothrow_default_constructible<__node_allocator>::value &&
+ is_nothrow_copy_constructible<value_compare>::value);
+ explicit __tree(const allocator_type& __a);
+ __tree(const value_compare& __comp, const allocator_type& __a);
+ __tree(const __tree& __t);
+ __tree& operator=(const __tree& __t);
+ template <class _ForwardIterator>
+ void __assign_unique(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _InputIterator>
+ void __assign_multi(_InputIterator __first, _InputIterator __last);
+ __tree(__tree&& __t)
+ _NOEXCEPT_(
+ is_nothrow_move_constructible<__node_allocator>::value &&
+ is_nothrow_move_constructible<value_compare>::value);
+ __tree(__tree&& __t, const allocator_type& __a);
+ __tree& operator=(__tree&& __t)
+ _NOEXCEPT_(
+ __node_traits::propagate_on_container_move_assignment::value &&
+ is_nothrow_move_assignable<value_compare>::value &&
+ is_nothrow_move_assignable<__node_allocator>::value);
+ ~__tree();
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator begin() _NOEXCEPT {return iterator(__begin_node());}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator begin() const _NOEXCEPT {return const_iterator(__begin_node());}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator end() _NOEXCEPT {return iterator(__end_node());}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator end() const _NOEXCEPT {return const_iterator(__end_node());}
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type max_size() const _NOEXCEPT
+ {return _VSTD::min<size_type>(
+ __node_traits::max_size(__node_alloc()),
+ numeric_limits<difference_type >::max());}
+
+ void clear() _NOEXCEPT;
+
+ void swap(__tree& __t)
+#if _LIBCPP_STD_VER <= 11
+ _NOEXCEPT_(
+ __is_nothrow_swappable<value_compare>::value
+ && (!__node_traits::propagate_on_container_swap::value ||
+ __is_nothrow_swappable<__node_allocator>::value)
+ );
+#else
+ _NOEXCEPT_(__is_nothrow_swappable<value_compare>::value);
+#endif
+
+ template <class _Key, class ..._Args>
+ pair<iterator, bool>
+ __emplace_unique_key_args(_Key const&, _Args&&... __args);
+ template <class _Key, class ..._Args>
+ pair<iterator, bool>
+ __emplace_hint_unique_key_args(const_iterator, _Key const&, _Args&&...);
+
+ template <class... _Args>
+ pair<iterator, bool> __emplace_unique_impl(_Args&&... __args);
+
+ template <class... _Args>
+ iterator __emplace_hint_unique_impl(const_iterator __p, _Args&&... __args);
+
+ template <class... _Args>
+ iterator __emplace_multi(_Args&&... __args);
+
+ template <class... _Args>
+ iterator __emplace_hint_multi(const_iterator __p, _Args&&... __args);
+
+ template <class _Pp>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool> __emplace_unique(_Pp&& __x) {
+ return __emplace_unique_extract_key(_VSTD::forward<_Pp>(__x),
+ __can_extract_key<_Pp, key_type>());
+ }
+
+ template <class _First, class _Second>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if<
+ __can_extract_map_key<_First, key_type, __container_value_type>::value,
+ pair<iterator, bool>
+ >::type __emplace_unique(_First&& __f, _Second&& __s) {
+ return __emplace_unique_key_args(__f, _VSTD::forward<_First>(__f),
+ _VSTD::forward<_Second>(__s));
+ }
+
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool> __emplace_unique(_Args&&... __args) {
+ return __emplace_unique_impl(_VSTD::forward<_Args>(__args)...);
+ }
+
+ template <class _Pp>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool>
+ __emplace_unique_extract_key(_Pp&& __x, __extract_key_fail_tag) {
+ return __emplace_unique_impl(_VSTD::forward<_Pp>(__x));
+ }
+
+ template <class _Pp>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool>
+ __emplace_unique_extract_key(_Pp&& __x, __extract_key_self_tag) {
+ return __emplace_unique_key_args(__x, _VSTD::forward<_Pp>(__x));
+ }
+
+ template <class _Pp>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool>
+ __emplace_unique_extract_key(_Pp&& __x, __extract_key_first_tag) {
+ return __emplace_unique_key_args(__x.first, _VSTD::forward<_Pp>(__x));
+ }
+
+ template <class _Pp>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator __emplace_hint_unique(const_iterator __p, _Pp&& __x) {
+ return __emplace_hint_unique_extract_key(__p, _VSTD::forward<_Pp>(__x),
+ __can_extract_key<_Pp, key_type>());
+ }
+
+ template <class _First, class _Second>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if<
+ __can_extract_map_key<_First, key_type, __container_value_type>::value,
+ iterator
+ >::type __emplace_hint_unique(const_iterator __p, _First&& __f, _Second&& __s) {
+ return __emplace_hint_unique_key_args(__p, __f,
+ _VSTD::forward<_First>(__f),
+ _VSTD::forward<_Second>(__s)).first;
+ }
+
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator __emplace_hint_unique(const_iterator __p, _Args&&... __args) {
+ return __emplace_hint_unique_impl(__p, _VSTD::forward<_Args>(__args)...);
+ }
+
+ template <class _Pp>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator
+ __emplace_hint_unique_extract_key(const_iterator __p, _Pp&& __x, __extract_key_fail_tag) {
+ return __emplace_hint_unique_impl(__p, _VSTD::forward<_Pp>(__x));
+ }
+
+ template <class _Pp>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator
+ __emplace_hint_unique_extract_key(const_iterator __p, _Pp&& __x, __extract_key_self_tag) {
+ return __emplace_hint_unique_key_args(__p, __x, _VSTD::forward<_Pp>(__x)).first;
+ }
+
+ template <class _Pp>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator
+ __emplace_hint_unique_extract_key(const_iterator __p, _Pp&& __x, __extract_key_first_tag) {
+ return __emplace_hint_unique_key_args(__p, __x.first, _VSTD::forward<_Pp>(__x)).first;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool> __insert_unique(const __container_value_type& __v) {
+ return __emplace_unique_key_args(_NodeTypes::__get_key(__v), __v);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator __insert_unique(const_iterator __p, const __container_value_type& __v) {
+ return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), __v).first;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool> __insert_unique(__container_value_type&& __v) {
+ return __emplace_unique_key_args(_NodeTypes::__get_key(__v), _VSTD::move(__v));
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator __insert_unique(const_iterator __p, __container_value_type&& __v) {
+ return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), _VSTD::move(__v)).first;
+ }
+
+ template <class _Vp, class = typename enable_if<
+ !is_same<typename __unconstref<_Vp>::type,
+ __container_value_type
+ >::value
+ >::type>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool> __insert_unique(_Vp&& __v) {
+ return __emplace_unique(_VSTD::forward<_Vp>(__v));
+ }
+
+ template <class _Vp, class = typename enable_if<
+ !is_same<typename __unconstref<_Vp>::type,
+ __container_value_type
+ >::value
+ >::type>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator __insert_unique(const_iterator __p, _Vp&& __v) {
+ return __emplace_hint_unique(__p, _VSTD::forward<_Vp>(__v));
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator __insert_multi(__container_value_type&& __v) {
+ return __emplace_multi(_VSTD::move(__v));
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator __insert_multi(const_iterator __p, __container_value_type&& __v) {
+ return __emplace_hint_multi(__p, _VSTD::move(__v));
+ }
+
+ template <class _Vp>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator __insert_multi(_Vp&& __v) {
+ return __emplace_multi(_VSTD::forward<_Vp>(__v));
+ }
+
+ template <class _Vp>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator __insert_multi(const_iterator __p, _Vp&& __v) {
+ return __emplace_hint_multi(__p, _VSTD::forward<_Vp>(__v));
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool> __node_assign_unique(const __container_value_type& __v, __node_pointer __dest);
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator __node_insert_multi(__node_pointer __nd);
+ _LIBCPP_INLINE_VISIBILITY
+ iterator __node_insert_multi(const_iterator __p, __node_pointer __nd);
+
+
+ _LIBCPP_INLINE_VISIBILITY iterator
+ __remove_node_pointer(__node_pointer) _NOEXCEPT;
+
+#if _LIBCPP_STD_VER > 14
+ template <class _NodeHandle, class _InsertReturnType>
+ _LIBCPP_INLINE_VISIBILITY
+ _InsertReturnType __node_handle_insert_unique(_NodeHandle&&);
+ template <class _NodeHandle>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator __node_handle_insert_unique(const_iterator, _NodeHandle&&);
+ template <class _Tree>
+ _LIBCPP_INLINE_VISIBILITY
+ void __node_handle_merge_unique(_Tree& __source);
+
+ template <class _NodeHandle>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator __node_handle_insert_multi(_NodeHandle&&);
+ template <class _NodeHandle>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator __node_handle_insert_multi(const_iterator, _NodeHandle&&);
+ template <class _Tree>
+ _LIBCPP_INLINE_VISIBILITY
+ void __node_handle_merge_multi(_Tree& __source);
+
+
+ template <class _NodeHandle>
+ _LIBCPP_INLINE_VISIBILITY
+ _NodeHandle __node_handle_extract(key_type const&);
+ template <class _NodeHandle>
+ _LIBCPP_INLINE_VISIBILITY
+ _NodeHandle __node_handle_extract(const_iterator);
+#endif
+
+ iterator erase(const_iterator __p);
+ iterator erase(const_iterator __f, const_iterator __l);
+ template <class _Key>
+ size_type __erase_unique(const _Key& __k);
+ template <class _Key>
+ size_type __erase_multi(const _Key& __k);
+
+ void __insert_node_at(__parent_pointer __parent,
+ __node_base_pointer& __child,
+ __node_base_pointer __new_node) _NOEXCEPT;
+
+ template <class _Key>
+ iterator find(const _Key& __v);
+ template <class _Key>
+ const_iterator find(const _Key& __v) const;
+
+ template <class _Key>
+ size_type __count_unique(const _Key& __k) const;
+ template <class _Key>
+ size_type __count_multi(const _Key& __k) const;
+
+ template <class _Key>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator lower_bound(const _Key& __v)
+ {return __lower_bound(__v, __root(), __end_node());}
+ template <class _Key>
+ iterator __lower_bound(const _Key& __v,
+ __node_pointer __root,
+ __iter_pointer __result);
+ template <class _Key>
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator lower_bound(const _Key& __v) const
+ {return __lower_bound(__v, __root(), __end_node());}
+ template <class _Key>
+ const_iterator __lower_bound(const _Key& __v,
+ __node_pointer __root,
+ __iter_pointer __result) const;
+ template <class _Key>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator upper_bound(const _Key& __v)
+ {return __upper_bound(__v, __root(), __end_node());}
+ template <class _Key>
+ iterator __upper_bound(const _Key& __v,
+ __node_pointer __root,
+ __iter_pointer __result);
+ template <class _Key>
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator upper_bound(const _Key& __v) const
+ {return __upper_bound(__v, __root(), __end_node());}
+ template <class _Key>
+ const_iterator __upper_bound(const _Key& __v,
+ __node_pointer __root,
+ __iter_pointer __result) const;
+ template <class _Key>
+ pair<iterator, iterator>
+ __equal_range_unique(const _Key& __k);
+ template <class _Key>
+ pair<const_iterator, const_iterator>
+ __equal_range_unique(const _Key& __k) const;
+
+ template <class _Key>
+ pair<iterator, iterator>
+ __equal_range_multi(const _Key& __k);
+ template <class _Key>
+ pair<const_iterator, const_iterator>
+ __equal_range_multi(const _Key& __k) const;
+
+ typedef __tree_node_destructor<__node_allocator> _Dp;
+ typedef unique_ptr<__node, _Dp> __node_holder;
+
+ __node_holder remove(const_iterator __p) _NOEXCEPT;
+private:
+ __node_base_pointer&
+ __find_leaf_low(__parent_pointer& __parent, const key_type& __v);
+ __node_base_pointer&
+ __find_leaf_high(__parent_pointer& __parent, const key_type& __v);
+ __node_base_pointer&
+ __find_leaf(const_iterator __hint,
+ __parent_pointer& __parent, const key_type& __v);
+ // FIXME: Make this function const qualified. Unfortunately doing so
+ // breaks existing code which uses non-const callable comparators.
+ template <class _Key>
+ __node_base_pointer&
+ __find_equal(__parent_pointer& __parent, const _Key& __v);
+ template <class _Key>
+ _LIBCPP_INLINE_VISIBILITY __node_base_pointer&
+ __find_equal(__parent_pointer& __parent, const _Key& __v) const {
+ return const_cast<__tree*>(this)->__find_equal(__parent, __v);
+ }
+ template <class _Key>
+ __node_base_pointer&
+ __find_equal(const_iterator __hint, __parent_pointer& __parent,
+ __node_base_pointer& __dummy,
+ const _Key& __v);
+
+ template <class ..._Args>
+ __node_holder __construct_node(_Args&& ...__args);
+
+ void destroy(__node_pointer __nd) _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __copy_assign_alloc(const __tree& __t)
+ {__copy_assign_alloc(__t, integral_constant<bool,
+ __node_traits::propagate_on_container_copy_assignment::value>());}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __copy_assign_alloc(const __tree& __t, true_type)
+ {
+ if (__node_alloc() != __t.__node_alloc())
+ clear();
+ __node_alloc() = __t.__node_alloc();
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ void __copy_assign_alloc(const __tree&, false_type) {}
+
+ void __move_assign(__tree& __t, false_type);
+ void __move_assign(__tree& __t, true_type)
+ _NOEXCEPT_(is_nothrow_move_assignable<value_compare>::value &&
+ is_nothrow_move_assignable<__node_allocator>::value);
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __move_assign_alloc(__tree& __t)
+ _NOEXCEPT_(
+ !__node_traits::propagate_on_container_move_assignment::value ||
+ is_nothrow_move_assignable<__node_allocator>::value)
+ {__move_assign_alloc(__t, integral_constant<bool,
+ __node_traits::propagate_on_container_move_assignment::value>());}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __move_assign_alloc(__tree& __t, true_type)
+ _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value)
+ {__node_alloc() = _VSTD::move(__t.__node_alloc());}
+ _LIBCPP_INLINE_VISIBILITY
+ void __move_assign_alloc(__tree&, false_type) _NOEXCEPT {}
+
+ struct _DetachedTreeCache {
+ _LIBCPP_INLINE_VISIBILITY
+ explicit _DetachedTreeCache(__tree *__t) _NOEXCEPT : __t_(__t),
+ __cache_root_(__detach_from_tree(__t)) {
+ __advance();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __node_pointer __get() const _NOEXCEPT {
+ return __cache_elem_;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __advance() _NOEXCEPT {
+ __cache_elem_ = __cache_root_;
+ if (__cache_root_) {
+ __cache_root_ = __detach_next(__cache_root_);
+ }
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ ~_DetachedTreeCache() {
+ __t_->destroy(__cache_elem_);
+ if (__cache_root_) {
+ while (__cache_root_->__parent_ != nullptr)
+ __cache_root_ = static_cast<__node_pointer>(__cache_root_->__parent_);
+ __t_->destroy(__cache_root_);
+ }
+ }
+
+ _DetachedTreeCache(_DetachedTreeCache const&) = delete;
+ _DetachedTreeCache& operator=(_DetachedTreeCache const&) = delete;
+
+ private:
+ _LIBCPP_INLINE_VISIBILITY
+ static __node_pointer __detach_from_tree(__tree *__t) _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ static __node_pointer __detach_next(__node_pointer) _NOEXCEPT;
+
+ __tree *__t_;
+ __node_pointer __cache_root_;
+ __node_pointer __cache_elem_;
+ };
+
+
+ template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS map;
+ template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS multimap;
+};
+
+template <class _Tp, class _Compare, class _Allocator>
+__tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp)
+ _NOEXCEPT_(
+ is_nothrow_default_constructible<__node_allocator>::value &&
+ is_nothrow_copy_constructible<value_compare>::value)
+ : __pair3_(0, __comp)
+{
+ __begin_node() = __end_node();
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+__tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a)
+ : __begin_node_(__iter_pointer()),
+ __pair1_(__default_init_tag(), __node_allocator(__a)),
+ __pair3_(0, __default_init_tag())
+{
+ __begin_node() = __end_node();
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+__tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp,
+ const allocator_type& __a)
+ : __begin_node_(__iter_pointer()),
+ __pair1_(__default_init_tag(), __node_allocator(__a)),
+ __pair3_(0, __comp)
+{
+ __begin_node() = __end_node();
+}
+
+// Precondition: size() != 0
+template <class _Tp, class _Compare, class _Allocator>
+typename __tree<_Tp, _Compare, _Allocator>::__node_pointer
+__tree<_Tp, _Compare, _Allocator>::_DetachedTreeCache::__detach_from_tree(__tree *__t) _NOEXCEPT
+{
+ __node_pointer __cache = static_cast<__node_pointer>(__t->__begin_node());
+ __t->__begin_node() = __t->__end_node();
+ __t->__end_node()->__left_->__parent_ = nullptr;
+ __t->__end_node()->__left_ = nullptr;
+ __t->size() = 0;
+ // __cache->__left_ == nullptr
+ if (__cache->__right_ != nullptr)
+ __cache = static_cast<__node_pointer>(__cache->__right_);
+ // __cache->__left_ == nullptr
+ // __cache->__right_ == nullptr
+ return __cache;
+}
+
+// Precondition: __cache != nullptr
+// __cache->left_ == nullptr
+// __cache->right_ == nullptr
+// This is no longer a red-black tree
+template <class _Tp, class _Compare, class _Allocator>
+typename __tree<_Tp, _Compare, _Allocator>::__node_pointer
+__tree<_Tp, _Compare, _Allocator>::_DetachedTreeCache::__detach_next(__node_pointer __cache) _NOEXCEPT
+{
+ if (__cache->__parent_ == nullptr)
+ return nullptr;
+ if (_VSTD::__tree_is_left_child(static_cast<__node_base_pointer>(__cache)))
+ {
+ __cache->__parent_->__left_ = nullptr;
+ __cache = static_cast<__node_pointer>(__cache->__parent_);
+ if (__cache->__right_ == nullptr)
+ return __cache;
+ return static_cast<__node_pointer>(_VSTD::__tree_leaf(__cache->__right_));
+ }
+ // __cache is right child
+ __cache->__parent_unsafe()->__right_ = nullptr;
+ __cache = static_cast<__node_pointer>(__cache->__parent_);
+ if (__cache->__left_ == nullptr)
+ return __cache;
+ return static_cast<__node_pointer>(_VSTD::__tree_leaf(__cache->__left_));
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+__tree<_Tp, _Compare, _Allocator>&
+__tree<_Tp, _Compare, _Allocator>::operator=(const __tree& __t)
+{
+ if (this != _VSTD::addressof(__t))
+ {
+ value_comp() = __t.value_comp();
+ __copy_assign_alloc(__t);
+ __assign_multi(__t.begin(), __t.end());
+ }
+ return *this;
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _ForwardIterator>
+void
+__tree<_Tp, _Compare, _Allocator>::__assign_unique(_ForwardIterator __first, _ForwardIterator __last)
+{
+ typedef iterator_traits<_ForwardIterator> _ITraits;
+ typedef typename _ITraits::value_type _ItValueType;
+ static_assert((is_same<_ItValueType, __container_value_type>::value),
+ "__assign_unique may only be called with the containers value type");
+ static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
+ "__assign_unique requires a forward iterator");
+ if (size() != 0)
+ {
+ _DetachedTreeCache __cache(this);
+ for (; __cache.__get() != nullptr && __first != __last; ++__first) {
+ if (__node_assign_unique(*__first, __cache.__get()).second)
+ __cache.__advance();
+ }
+ }
+ for (; __first != __last; ++__first)
+ __insert_unique(*__first);
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _InputIterator>
+void
+__tree<_Tp, _Compare, _Allocator>::__assign_multi(_InputIterator __first, _InputIterator __last)
+{
+ typedef iterator_traits<_InputIterator> _ITraits;
+ typedef typename _ITraits::value_type _ItValueType;
+ static_assert((is_same<_ItValueType, __container_value_type>::value ||
+ is_same<_ItValueType, __node_value_type>::value),
+ "__assign_multi may only be called with the containers value type"
+ " or the nodes value type");
+ if (size() != 0)
+ {
+ _DetachedTreeCache __cache(this);
+ for (; __cache.__get() && __first != __last; ++__first) {
+ __cache.__get()->__value_ = *__first;
+ __node_insert_multi(__cache.__get());
+ __cache.__advance();
+ }
+ }
+ for (; __first != __last; ++__first)
+ __insert_multi(_NodeTypes::__get_value(*__first));
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+__tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t)
+ : __begin_node_(__iter_pointer()),
+ __pair1_(__default_init_tag(), __node_traits::select_on_container_copy_construction(__t.__node_alloc())),
+ __pair3_(0, __t.value_comp())
+{
+ __begin_node() = __end_node();
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+__tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t)
+ _NOEXCEPT_(
+ is_nothrow_move_constructible<__node_allocator>::value &&
+ is_nothrow_move_constructible<value_compare>::value)
+ : __begin_node_(_VSTD::move(__t.__begin_node_)),
+ __pair1_(_VSTD::move(__t.__pair1_)),
+ __pair3_(_VSTD::move(__t.__pair3_))
+{
+ if (size() == 0)
+ __begin_node() = __end_node();
+ else
+ {
+ __end_node()->__left_->__parent_ = static_cast<__parent_pointer>(__end_node());
+ __t.__begin_node() = __t.__end_node();
+ __t.__end_node()->__left_ = nullptr;
+ __t.size() = 0;
+ }
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+__tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t, const allocator_type& __a)
+ : __pair1_(__default_init_tag(), __node_allocator(__a)),
+ __pair3_(0, _VSTD::move(__t.value_comp()))
+{
+ if (__a == __t.__alloc())
+ {
+ if (__t.size() == 0)
+ __begin_node() = __end_node();
+ else
+ {
+ __begin_node() = __t.__begin_node();
+ __end_node()->__left_ = __t.__end_node()->__left_;
+ __end_node()->__left_->__parent_ = static_cast<__parent_pointer>(__end_node());
+ size() = __t.size();
+ __t.__begin_node() = __t.__end_node();
+ __t.__end_node()->__left_ = nullptr;
+ __t.size() = 0;
+ }
+ }
+ else
+ {
+ __begin_node() = __end_node();
+ }
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+void
+__tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, true_type)
+ _NOEXCEPT_(is_nothrow_move_assignable<value_compare>::value &&
+ is_nothrow_move_assignable<__node_allocator>::value)
+{
+ destroy(static_cast<__node_pointer>(__end_node()->__left_));
+ __begin_node_ = __t.__begin_node_;
+ __pair1_.first() = __t.__pair1_.first();
+ __move_assign_alloc(__t);
+ __pair3_ = _VSTD::move(__t.__pair3_);
+ if (size() == 0)
+ __begin_node() = __end_node();
+ else
+ {
+ __end_node()->__left_->__parent_ = static_cast<__parent_pointer>(__end_node());
+ __t.__begin_node() = __t.__end_node();
+ __t.__end_node()->__left_ = nullptr;
+ __t.size() = 0;
+ }
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+void
+__tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, false_type)
+{
+ if (__node_alloc() == __t.__node_alloc())
+ __move_assign(__t, true_type());
+ else
+ {
+ value_comp() = _VSTD::move(__t.value_comp());
+ const_iterator __e = end();
+ if (size() != 0)
+ {
+ _DetachedTreeCache __cache(this);
+ while (__cache.__get() != nullptr && __t.size() != 0) {
+ __cache.__get()->__value_ = _VSTD::move(__t.remove(__t.begin())->__value_);
+ __node_insert_multi(__cache.__get());
+ __cache.__advance();
+ }
+ }
+ while (__t.size() != 0)
+ __insert_multi(__e, _NodeTypes::__move(__t.remove(__t.begin())->__value_));
+ }
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+__tree<_Tp, _Compare, _Allocator>&
+__tree<_Tp, _Compare, _Allocator>::operator=(__tree&& __t)
+ _NOEXCEPT_(
+ __node_traits::propagate_on_container_move_assignment::value &&
+ is_nothrow_move_assignable<value_compare>::value &&
+ is_nothrow_move_assignable<__node_allocator>::value)
+
+{
+ __move_assign(__t, integral_constant<bool,
+ __node_traits::propagate_on_container_move_assignment::value>());
+ return *this;
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+__tree<_Tp, _Compare, _Allocator>::~__tree()
+{
+ static_assert((is_copy_constructible<value_compare>::value),
+ "Comparator must be copy-constructible.");
+ destroy(__root());
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+void
+__tree<_Tp, _Compare, _Allocator>::destroy(__node_pointer __nd) _NOEXCEPT
+{
+ if (__nd != nullptr)
+ {
+ destroy(static_cast<__node_pointer>(__nd->__left_));
+ destroy(static_cast<__node_pointer>(__nd->__right_));
+ __node_allocator& __na = __node_alloc();
+ __node_traits::destroy(__na, _NodeTypes::__get_ptr(__nd->__value_));
+ __node_traits::deallocate(__na, __nd, 1);
+ }
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+void
+__tree<_Tp, _Compare, _Allocator>::swap(__tree& __t)
+#if _LIBCPP_STD_VER <= 11
+ _NOEXCEPT_(
+ __is_nothrow_swappable<value_compare>::value
+ && (!__node_traits::propagate_on_container_swap::value ||
+ __is_nothrow_swappable<__node_allocator>::value)
+ )
+#else
+ _NOEXCEPT_(__is_nothrow_swappable<value_compare>::value)
+#endif
+{
+ using _VSTD::swap;
+ swap(__begin_node_, __t.__begin_node_);
+ swap(__pair1_.first(), __t.__pair1_.first());
+ _VSTD::__swap_allocator(__node_alloc(), __t.__node_alloc());
+ __pair3_.swap(__t.__pair3_);
+ if (size() == 0)
+ __begin_node() = __end_node();
+ else
+ __end_node()->__left_->__parent_ = static_cast<__parent_pointer>(__end_node());
+ if (__t.size() == 0)
+ __t.__begin_node() = __t.__end_node();
+ else
+ __t.__end_node()->__left_->__parent_ = static_cast<__parent_pointer>(__t.__end_node());
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+void
+__tree<_Tp, _Compare, _Allocator>::clear() _NOEXCEPT
+{
+ destroy(__root());
+ size() = 0;
+ __begin_node() = __end_node();
+ __end_node()->__left_ = nullptr;
+}
+
+// Find lower_bound place to insert
+// Set __parent to parent of null leaf
+// Return reference to null leaf
+template <class _Tp, class _Compare, class _Allocator>
+typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&
+__tree<_Tp, _Compare, _Allocator>::__find_leaf_low(__parent_pointer& __parent,
+ const key_type& __v)
+{
+ __node_pointer __nd = __root();
+ if (__nd != nullptr)
+ {
+ while (true)
+ {
+ if (value_comp()(__nd->__value_, __v))
+ {
+ if (__nd->__right_ != nullptr)
+ __nd = static_cast<__node_pointer>(__nd->__right_);
+ else
+ {
+ __parent = static_cast<__parent_pointer>(__nd);
+ return __nd->__right_;
+ }
+ }
+ else
+ {
+ if (__nd->__left_ != nullptr)
+ __nd = static_cast<__node_pointer>(__nd->__left_);
+ else
+ {
+ __parent = static_cast<__parent_pointer>(__nd);
+ return __parent->__left_;
+ }
+ }
+ }
+ }
+ __parent = static_cast<__parent_pointer>(__end_node());
+ return __parent->__left_;
+}
+
+// Find upper_bound place to insert
+// Set __parent to parent of null leaf
+// Return reference to null leaf
+template <class _Tp, class _Compare, class _Allocator>
+typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&
+__tree<_Tp, _Compare, _Allocator>::__find_leaf_high(__parent_pointer& __parent,
+ const key_type& __v)
+{
+ __node_pointer __nd = __root();
+ if (__nd != nullptr)
+ {
+ while (true)
+ {
+ if (value_comp()(__v, __nd->__value_))
+ {
+ if (__nd->__left_ != nullptr)
+ __nd = static_cast<__node_pointer>(__nd->__left_);
+ else
+ {
+ __parent = static_cast<__parent_pointer>(__nd);
+ return __parent->__left_;
+ }
+ }
+ else
+ {
+ if (__nd->__right_ != nullptr)
+ __nd = static_cast<__node_pointer>(__nd->__right_);
+ else
+ {
+ __parent = static_cast<__parent_pointer>(__nd);
+ return __nd->__right_;
+ }
+ }
+ }
+ }
+ __parent = static_cast<__parent_pointer>(__end_node());
+ return __parent->__left_;
+}
+
+// Find leaf place to insert closest to __hint
+// First check prior to __hint.
+// Next check after __hint.
+// Next do O(log N) search.
+// Set __parent to parent of null leaf
+// Return reference to null leaf
+template <class _Tp, class _Compare, class _Allocator>
+typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&
+__tree<_Tp, _Compare, _Allocator>::__find_leaf(const_iterator __hint,
+ __parent_pointer& __parent,
+ const key_type& __v)
+{
+ if (__hint == end() || !value_comp()(*__hint, __v)) // check before
+ {
+ // __v <= *__hint
+ const_iterator __prior = __hint;
+ if (__prior == begin() || !value_comp()(__v, *--__prior))
+ {
+ // *prev(__hint) <= __v <= *__hint
+ if (__hint.__ptr_->__left_ == nullptr)
+ {
+ __parent = static_cast<__parent_pointer>(__hint.__ptr_);
+ return __parent->__left_;
+ }
+ else
+ {
+ __parent = static_cast<__parent_pointer>(__prior.__ptr_);
+ return static_cast<__node_base_pointer>(__prior.__ptr_)->__right_;
+ }
+ }
+ // __v < *prev(__hint)
+ return __find_leaf_high(__parent, __v);
+ }
+ // else __v > *__hint
+ return __find_leaf_low(__parent, __v);
+}
+
+// Find place to insert if __v doesn't exist
+// Set __parent to parent of null leaf
+// Return reference to null leaf
+// If __v exists, set parent to node of __v and return reference to node of __v
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key>
+typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&
+__tree<_Tp, _Compare, _Allocator>::__find_equal(__parent_pointer& __parent,
+ const _Key& __v)
+{
+ __node_pointer __nd = __root();
+ __node_base_pointer* __nd_ptr = __root_ptr();
+ if (__nd != nullptr)
+ {
+ while (true)
+ {
+ if (value_comp()(__v, __nd->__value_))
+ {
+ if (__nd->__left_ != nullptr) {
+ __nd_ptr = _VSTD::addressof(__nd->__left_);
+ __nd = static_cast<__node_pointer>(__nd->__left_);
+ } else {
+ __parent = static_cast<__parent_pointer>(__nd);
+ return __parent->__left_;
+ }
+ }
+ else if (value_comp()(__nd->__value_, __v))
+ {
+ if (__nd->__right_ != nullptr) {
+ __nd_ptr = _VSTD::addressof(__nd->__right_);
+ __nd = static_cast<__node_pointer>(__nd->__right_);
+ } else {
+ __parent = static_cast<__parent_pointer>(__nd);
+ return __nd->__right_;
+ }
+ }
+ else
+ {
+ __parent = static_cast<__parent_pointer>(__nd);
+ return *__nd_ptr;
+ }
+ }
+ }
+ __parent = static_cast<__parent_pointer>(__end_node());
+ return __parent->__left_;
+}
+
+// Find place to insert if __v doesn't exist
+// First check prior to __hint.
+// Next check after __hint.
+// Next do O(log N) search.
+// Set __parent to parent of null leaf
+// Return reference to null leaf
+// If __v exists, set parent to node of __v and return reference to node of __v
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key>
+typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&
+__tree<_Tp, _Compare, _Allocator>::__find_equal(const_iterator __hint,
+ __parent_pointer& __parent,
+ __node_base_pointer& __dummy,
+ const _Key& __v)
+{
+ if (__hint == end() || value_comp()(__v, *__hint)) // check before
+ {
+ // __v < *__hint
+ const_iterator __prior = __hint;
+ if (__prior == begin() || value_comp()(*--__prior, __v))
+ {
+ // *prev(__hint) < __v < *__hint
+ if (__hint.__ptr_->__left_ == nullptr)
+ {
+ __parent = static_cast<__parent_pointer>(__hint.__ptr_);
+ return __parent->__left_;
+ }
+ else
+ {
+ __parent = static_cast<__parent_pointer>(__prior.__ptr_);
+ return static_cast<__node_base_pointer>(__prior.__ptr_)->__right_;
+ }
+ }
+ // __v <= *prev(__hint)
+ return __find_equal(__parent, __v);
+ }
+ else if (value_comp()(*__hint, __v)) // check after
+ {
+ // *__hint < __v
+ const_iterator __next = _VSTD::next(__hint);
+ if (__next == end() || value_comp()(__v, *__next))
+ {
+ // *__hint < __v < *_VSTD::next(__hint)
+ if (__hint.__get_np()->__right_ == nullptr)
+ {
+ __parent = static_cast<__parent_pointer>(__hint.__ptr_);
+ return static_cast<__node_base_pointer>(__hint.__ptr_)->__right_;
+ }
+ else
+ {
+ __parent = static_cast<__parent_pointer>(__next.__ptr_);
+ return __parent->__left_;
+ }
+ }
+ // *next(__hint) <= __v
+ return __find_equal(__parent, __v);
+ }
+ // else __v == *__hint
+ __parent = static_cast<__parent_pointer>(__hint.__ptr_);
+ __dummy = static_cast<__node_base_pointer>(__hint.__ptr_);
+ return __dummy;
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+void __tree<_Tp, _Compare, _Allocator>::__insert_node_at(
+ __parent_pointer __parent, __node_base_pointer& __child,
+ __node_base_pointer __new_node) _NOEXCEPT
+{
+ __new_node->__left_ = nullptr;
+ __new_node->__right_ = nullptr;
+ __new_node->__parent_ = __parent;
+ // __new_node->__is_black_ is initialized in __tree_balance_after_insert
+ __child = __new_node;
+ if (__begin_node()->__left_ != nullptr)
+ __begin_node() = static_cast<__iter_pointer>(__begin_node()->__left_);
+ _VSTD::__tree_balance_after_insert(__end_node()->__left_, __child);
+ ++size();
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key, class... _Args>
+pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>
+__tree<_Tp, _Compare, _Allocator>::__emplace_unique_key_args(_Key const& __k, _Args&&... __args)
+{
+ __parent_pointer __parent;
+ __node_base_pointer& __child = __find_equal(__parent, __k);
+ __node_pointer __r = static_cast<__node_pointer>(__child);
+ bool __inserted = false;
+ if (__child == nullptr)
+ {
+ __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
+ __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
+ __r = __h.release();
+ __inserted = true;
+ }
+ return pair<iterator, bool>(iterator(__r), __inserted);
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key, class... _Args>
+pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>
+__tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_key_args(
+ const_iterator __p, _Key const& __k, _Args&&... __args)
+{
+ __parent_pointer __parent;
+ __node_base_pointer __dummy;
+ __node_base_pointer& __child = __find_equal(__p, __parent, __dummy, __k);
+ __node_pointer __r = static_cast<__node_pointer>(__child);
+ bool __inserted = false;
+ if (__child == nullptr)
+ {
+ __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
+ __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
+ __r = __h.release();
+ __inserted = true;
+ }
+ return pair<iterator, bool>(iterator(__r), __inserted);
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class ..._Args>
+typename __tree<_Tp, _Compare, _Allocator>::__node_holder
+__tree<_Tp, _Compare, _Allocator>::__construct_node(_Args&& ...__args)
+{
+ static_assert(!__is_tree_value_type<_Args...>::value,
+ "Cannot construct from __value_type");
+ __node_allocator& __na = __node_alloc();
+ __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
+ __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), _VSTD::forward<_Args>(__args)...);
+ __h.get_deleter().__value_constructed = true;
+ return __h;
+}
+
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class... _Args>
+pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>
+__tree<_Tp, _Compare, _Allocator>::__emplace_unique_impl(_Args&&... __args)
+{
+ __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
+ __parent_pointer __parent;
+ __node_base_pointer& __child = __find_equal(__parent, __h->__value_);
+ __node_pointer __r = static_cast<__node_pointer>(__child);
+ bool __inserted = false;
+ if (__child == nullptr)
+ {
+ __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
+ __r = __h.release();
+ __inserted = true;
+ }
+ return pair<iterator, bool>(iterator(__r), __inserted);
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class... _Args>
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_impl(const_iterator __p, _Args&&... __args)
+{
+ __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
+ __parent_pointer __parent;
+ __node_base_pointer __dummy;
+ __node_base_pointer& __child = __find_equal(__p, __parent, __dummy, __h->__value_);
+ __node_pointer __r = static_cast<__node_pointer>(__child);
+ if (__child == nullptr)
+ {
+ __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
+ __r = __h.release();
+ }
+ return iterator(__r);
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class... _Args>
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::__emplace_multi(_Args&&... __args)
+{
+ __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
+ __parent_pointer __parent;
+ __node_base_pointer& __child = __find_leaf_high(__parent, _NodeTypes::__get_key(__h->__value_));
+ __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
+ return iterator(static_cast<__node_pointer>(__h.release()));
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class... _Args>
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::__emplace_hint_multi(const_iterator __p,
+ _Args&&... __args)
+{
+ __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
+ __parent_pointer __parent;
+ __node_base_pointer& __child = __find_leaf(__p, __parent, _NodeTypes::__get_key(__h->__value_));
+ __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
+ return iterator(static_cast<__node_pointer>(__h.release()));
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>
+__tree<_Tp, _Compare, _Allocator>::__node_assign_unique(const __container_value_type& __v, __node_pointer __nd)
+{
+ __parent_pointer __parent;
+ __node_base_pointer& __child = __find_equal(__parent, _NodeTypes::__get_key(__v));
+ __node_pointer __r = static_cast<__node_pointer>(__child);
+ bool __inserted = false;
+ if (__child == nullptr)
+ {
+ __nd->__value_ = __v;
+ __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd));
+ __r = __nd;
+ __inserted = true;
+ }
+ return pair<iterator, bool>(iterator(__r), __inserted);
+}
+
+
+template <class _Tp, class _Compare, class _Allocator>
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::__node_insert_multi(__node_pointer __nd)
+{
+ __parent_pointer __parent;
+ __node_base_pointer& __child = __find_leaf_high(__parent, _NodeTypes::__get_key(__nd->__value_));
+ __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd));
+ return iterator(__nd);
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::__node_insert_multi(const_iterator __p,
+ __node_pointer __nd)
+{
+ __parent_pointer __parent;
+ __node_base_pointer& __child = __find_leaf(__p, __parent, _NodeTypes::__get_key(__nd->__value_));
+ __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd));
+ return iterator(__nd);
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::__remove_node_pointer(__node_pointer __ptr) _NOEXCEPT
+{
+ iterator __r(__ptr);
+ ++__r;
+ if (__begin_node() == __ptr)
+ __begin_node() = __r.__ptr_;
+ --size();
+ _VSTD::__tree_remove(__end_node()->__left_,
+ static_cast<__node_base_pointer>(__ptr));
+ return __r;
+}
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp, class _Compare, class _Allocator>
+template <class _NodeHandle, class _InsertReturnType>
+_LIBCPP_INLINE_VISIBILITY
+_InsertReturnType
+__tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(
+ _NodeHandle&& __nh)
+{
+ if (__nh.empty())
+ return _InsertReturnType{end(), false, _NodeHandle()};
+
+ __node_pointer __ptr = __nh.__ptr_;
+ __parent_pointer __parent;
+ __node_base_pointer& __child = __find_equal(__parent,
+ __ptr->__value_);
+ if (__child != nullptr)
+ return _InsertReturnType{
+ iterator(static_cast<__node_pointer>(__child)),
+ false, _VSTD::move(__nh)};
+
+ __insert_node_at(__parent, __child,
+ static_cast<__node_base_pointer>(__ptr));
+ __nh.__release_ptr();
+ return _InsertReturnType{iterator(__ptr), true, _NodeHandle()};
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _NodeHandle>
+_LIBCPP_INLINE_VISIBILITY
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(
+ const_iterator __hint, _NodeHandle&& __nh)
+{
+ if (__nh.empty())
+ return end();
+
+ __node_pointer __ptr = __nh.__ptr_;
+ __parent_pointer __parent;
+ __node_base_pointer __dummy;
+ __node_base_pointer& __child = __find_equal(__hint, __parent, __dummy,
+ __ptr->__value_);
+ __node_pointer __r = static_cast<__node_pointer>(__child);
+ if (__child == nullptr)
+ {
+ __insert_node_at(__parent, __child,
+ static_cast<__node_base_pointer>(__ptr));
+ __r = __ptr;
+ __nh.__release_ptr();
+ }
+ return iterator(__r);
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _NodeHandle>
+_LIBCPP_INLINE_VISIBILITY
+_NodeHandle
+__tree<_Tp, _Compare, _Allocator>::__node_handle_extract(key_type const& __key)
+{
+ iterator __it = find(__key);
+ if (__it == end())
+ return _NodeHandle();
+ return __node_handle_extract<_NodeHandle>(__it);
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _NodeHandle>
+_LIBCPP_INLINE_VISIBILITY
+_NodeHandle
+__tree<_Tp, _Compare, _Allocator>::__node_handle_extract(const_iterator __p)
+{
+ __node_pointer __np = __p.__get_np();
+ __remove_node_pointer(__np);
+ return _NodeHandle(__np, __alloc());
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Tree>
+_LIBCPP_INLINE_VISIBILITY
+void
+__tree<_Tp, _Compare, _Allocator>::__node_handle_merge_unique(_Tree& __source)
+{
+ static_assert(is_same<typename _Tree::__node_pointer, __node_pointer>::value, "");
+
+ for (typename _Tree::iterator __i = __source.begin();
+ __i != __source.end();)
+ {
+ __node_pointer __src_ptr = __i.__get_np();
+ __parent_pointer __parent;
+ __node_base_pointer& __child =
+ __find_equal(__parent, _NodeTypes::__get_key(__src_ptr->__value_));
+ ++__i;
+ if (__child != nullptr)
+ continue;
+ __source.__remove_node_pointer(__src_ptr);
+ __insert_node_at(__parent, __child,
+ static_cast<__node_base_pointer>(__src_ptr));
+ }
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _NodeHandle>
+_LIBCPP_INLINE_VISIBILITY
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi(_NodeHandle&& __nh)
+{
+ if (__nh.empty())
+ return end();
+ __node_pointer __ptr = __nh.__ptr_;
+ __parent_pointer __parent;
+ __node_base_pointer& __child = __find_leaf_high(
+ __parent, _NodeTypes::__get_key(__ptr->__value_));
+ __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr));
+ __nh.__release_ptr();
+ return iterator(__ptr);
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _NodeHandle>
+_LIBCPP_INLINE_VISIBILITY
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi(
+ const_iterator __hint, _NodeHandle&& __nh)
+{
+ if (__nh.empty())
+ return end();
+
+ __node_pointer __ptr = __nh.__ptr_;
+ __parent_pointer __parent;
+ __node_base_pointer& __child = __find_leaf(__hint, __parent,
+ _NodeTypes::__get_key(__ptr->__value_));
+ __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr));
+ __nh.__release_ptr();
+ return iterator(__ptr);
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Tree>
+_LIBCPP_INLINE_VISIBILITY
+void
+__tree<_Tp, _Compare, _Allocator>::__node_handle_merge_multi(_Tree& __source)
+{
+ static_assert(is_same<typename _Tree::__node_pointer, __node_pointer>::value, "");
+
+ for (typename _Tree::iterator __i = __source.begin();
+ __i != __source.end();)
+ {
+ __node_pointer __src_ptr = __i.__get_np();
+ __parent_pointer __parent;
+ __node_base_pointer& __child = __find_leaf_high(
+ __parent, _NodeTypes::__get_key(__src_ptr->__value_));
+ ++__i;
+ __source.__remove_node_pointer(__src_ptr);
+ __insert_node_at(__parent, __child,
+ static_cast<__node_base_pointer>(__src_ptr));
+ }
+}
+
+#endif // _LIBCPP_STD_VER > 14
+
+template <class _Tp, class _Compare, class _Allocator>
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::erase(const_iterator __p)
+{
+ __node_pointer __np = __p.__get_np();
+ iterator __r = __remove_node_pointer(__np);
+ __node_allocator& __na = __node_alloc();
+ __node_traits::destroy(__na, _NodeTypes::__get_ptr(
+ const_cast<__node_value_type&>(*__p)));
+ __node_traits::deallocate(__na, __np, 1);
+ return __r;
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::erase(const_iterator __f, const_iterator __l)
+{
+ while (__f != __l)
+ __f = erase(__f);
+ return iterator(__l.__ptr_);
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key>
+typename __tree<_Tp, _Compare, _Allocator>::size_type
+__tree<_Tp, _Compare, _Allocator>::__erase_unique(const _Key& __k)
+{
+ iterator __i = find(__k);
+ if (__i == end())
+ return 0;
+ erase(__i);
+ return 1;
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key>
+typename __tree<_Tp, _Compare, _Allocator>::size_type
+__tree<_Tp, _Compare, _Allocator>::__erase_multi(const _Key& __k)
+{
+ pair<iterator, iterator> __p = __equal_range_multi(__k);
+ size_type __r = 0;
+ for (; __p.first != __p.second; ++__r)
+ __p.first = erase(__p.first);
+ return __r;
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key>
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::find(const _Key& __v)
+{
+ iterator __p = __lower_bound(__v, __root(), __end_node());
+ if (__p != end() && !value_comp()(__v, *__p))
+ return __p;
+ return end();
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key>
+typename __tree<_Tp, _Compare, _Allocator>::const_iterator
+__tree<_Tp, _Compare, _Allocator>::find(const _Key& __v) const
+{
+ const_iterator __p = __lower_bound(__v, __root(), __end_node());
+ if (__p != end() && !value_comp()(__v, *__p))
+ return __p;
+ return end();
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key>
+typename __tree<_Tp, _Compare, _Allocator>::size_type
+__tree<_Tp, _Compare, _Allocator>::__count_unique(const _Key& __k) const
+{
+ __node_pointer __rt = __root();
+ while (__rt != nullptr)
+ {
+ if (value_comp()(__k, __rt->__value_))
+ {
+ __rt = static_cast<__node_pointer>(__rt->__left_);
+ }
+ else if (value_comp()(__rt->__value_, __k))
+ __rt = static_cast<__node_pointer>(__rt->__right_);
+ else
+ return 1;
+ }
+ return 0;
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key>
+typename __tree<_Tp, _Compare, _Allocator>::size_type
+__tree<_Tp, _Compare, _Allocator>::__count_multi(const _Key& __k) const
+{
+ __iter_pointer __result = __end_node();
+ __node_pointer __rt = __root();
+ while (__rt != nullptr)
+ {
+ if (value_comp()(__k, __rt->__value_))
+ {
+ __result = static_cast<__iter_pointer>(__rt);
+ __rt = static_cast<__node_pointer>(__rt->__left_);
+ }
+ else if (value_comp()(__rt->__value_, __k))
+ __rt = static_cast<__node_pointer>(__rt->__right_);
+ else
+ return _VSTD::distance(
+ __lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__iter_pointer>(__rt)),
+ __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result)
+ );
+ }
+ return 0;
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key>
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::__lower_bound(const _Key& __v,
+ __node_pointer __root,
+ __iter_pointer __result)
+{
+ while (__root != nullptr)
+ {
+ if (!value_comp()(__root->__value_, __v))
+ {
+ __result = static_cast<__iter_pointer>(__root);
+ __root = static_cast<__node_pointer>(__root->__left_);
+ }
+ else
+ __root = static_cast<__node_pointer>(__root->__right_);
+ }
+ return iterator(__result);
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key>
+typename __tree<_Tp, _Compare, _Allocator>::const_iterator
+__tree<_Tp, _Compare, _Allocator>::__lower_bound(const _Key& __v,
+ __node_pointer __root,
+ __iter_pointer __result) const
+{
+ while (__root != nullptr)
+ {
+ if (!value_comp()(__root->__value_, __v))
+ {
+ __result = static_cast<__iter_pointer>(__root);
+ __root = static_cast<__node_pointer>(__root->__left_);
+ }
+ else
+ __root = static_cast<__node_pointer>(__root->__right_);
+ }
+ return const_iterator(__result);
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key>
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::__upper_bound(const _Key& __v,
+ __node_pointer __root,
+ __iter_pointer __result)
+{
+ while (__root != nullptr)
+ {
+ if (value_comp()(__v, __root->__value_))
+ {
+ __result = static_cast<__iter_pointer>(__root);
+ __root = static_cast<__node_pointer>(__root->__left_);
+ }
+ else
+ __root = static_cast<__node_pointer>(__root->__right_);
+ }
+ return iterator(__result);
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key>
+typename __tree<_Tp, _Compare, _Allocator>::const_iterator
+__tree<_Tp, _Compare, _Allocator>::__upper_bound(const _Key& __v,
+ __node_pointer __root,
+ __iter_pointer __result) const
+{
+ while (__root != nullptr)
+ {
+ if (value_comp()(__v, __root->__value_))
+ {
+ __result = static_cast<__iter_pointer>(__root);
+ __root = static_cast<__node_pointer>(__root->__left_);
+ }
+ else
+ __root = static_cast<__node_pointer>(__root->__right_);
+ }
+ return const_iterator(__result);
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key>
+pair<typename __tree<_Tp, _Compare, _Allocator>::iterator,
+ typename __tree<_Tp, _Compare, _Allocator>::iterator>
+__tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k)
+{
+ typedef pair<iterator, iterator> _Pp;
+ __iter_pointer __result = __end_node();
+ __node_pointer __rt = __root();
+ while (__rt != nullptr)
+ {
+ if (value_comp()(__k, __rt->__value_))
+ {
+ __result = static_cast<__iter_pointer>(__rt);
+ __rt = static_cast<__node_pointer>(__rt->__left_);
+ }
+ else if (value_comp()(__rt->__value_, __k))
+ __rt = static_cast<__node_pointer>(__rt->__right_);
+ else
+ return _Pp(iterator(__rt),
+ iterator(
+ __rt->__right_ != nullptr ?
+ static_cast<__iter_pointer>(_VSTD::__tree_min(__rt->__right_))
+ : __result));
+ }
+ return _Pp(iterator(__result), iterator(__result));
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key>
+pair<typename __tree<_Tp, _Compare, _Allocator>::const_iterator,
+ typename __tree<_Tp, _Compare, _Allocator>::const_iterator>
+__tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) const
+{
+ typedef pair<const_iterator, const_iterator> _Pp;
+ __iter_pointer __result = __end_node();
+ __node_pointer __rt = __root();
+ while (__rt != nullptr)
+ {
+ if (value_comp()(__k, __rt->__value_))
+ {
+ __result = static_cast<__iter_pointer>(__rt);
+ __rt = static_cast<__node_pointer>(__rt->__left_);
+ }
+ else if (value_comp()(__rt->__value_, __k))
+ __rt = static_cast<__node_pointer>(__rt->__right_);
+ else
+ return _Pp(const_iterator(__rt),
+ const_iterator(
+ __rt->__right_ != nullptr ?
+ static_cast<__iter_pointer>(_VSTD::__tree_min(__rt->__right_))
+ : __result));
+ }
+ return _Pp(const_iterator(__result), const_iterator(__result));
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key>
+pair<typename __tree<_Tp, _Compare, _Allocator>::iterator,
+ typename __tree<_Tp, _Compare, _Allocator>::iterator>
+__tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k)
+{
+ typedef pair<iterator, iterator> _Pp;
+ __iter_pointer __result = __end_node();
+ __node_pointer __rt = __root();
+ while (__rt != nullptr)
+ {
+ if (value_comp()(__k, __rt->__value_))
+ {
+ __result = static_cast<__iter_pointer>(__rt);
+ __rt = static_cast<__node_pointer>(__rt->__left_);
+ }
+ else if (value_comp()(__rt->__value_, __k))
+ __rt = static_cast<__node_pointer>(__rt->__right_);
+ else
+ return _Pp(__lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__iter_pointer>(__rt)),
+ __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result));
+ }
+ return _Pp(iterator(__result), iterator(__result));
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key>
+pair<typename __tree<_Tp, _Compare, _Allocator>::const_iterator,
+ typename __tree<_Tp, _Compare, _Allocator>::const_iterator>
+__tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) const
+{
+ typedef pair<const_iterator, const_iterator> _Pp;
+ __iter_pointer __result = __end_node();
+ __node_pointer __rt = __root();
+ while (__rt != nullptr)
+ {
+ if (value_comp()(__k, __rt->__value_))
+ {
+ __result = static_cast<__iter_pointer>(__rt);
+ __rt = static_cast<__node_pointer>(__rt->__left_);
+ }
+ else if (value_comp()(__rt->__value_, __k))
+ __rt = static_cast<__node_pointer>(__rt->__right_);
+ else
+ return _Pp(__lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__iter_pointer>(__rt)),
+ __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result));
+ }
+ return _Pp(const_iterator(__result), const_iterator(__result));
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+typename __tree<_Tp, _Compare, _Allocator>::__node_holder
+__tree<_Tp, _Compare, _Allocator>::remove(const_iterator __p) _NOEXCEPT
+{
+ __node_pointer __np = __p.__get_np();
+ if (__begin_node() == __p.__ptr_)
+ {
+ if (__np->__right_ != nullptr)
+ __begin_node() = static_cast<__iter_pointer>(__np->__right_);
+ else
+ __begin_node() = static_cast<__iter_pointer>(__np->__parent_);
+ }
+ --size();
+ _VSTD::__tree_remove(__end_node()->__left_,
+ static_cast<__node_base_pointer>(__np));
+ return __node_holder(__np, _Dp(__node_alloc(), true));
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(__tree<_Tp, _Compare, _Allocator>& __x,
+ __tree<_Tp, _Compare, _Allocator>& __y)
+ _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+ __x.swap(__y);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___TREE
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__tuple b/contrib/libs/cxxsupp/libcxxmsvc/include/__tuple
new file mode 100644
index 0000000000..89448b0a43
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__tuple
@@ -0,0 +1,635 @@
+// -*- 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___TUPLE
+#define _LIBCPP___TUPLE
+
+#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> class _LIBCPP_TEMPLATE_VIS tuple_size;
+
+#if !defined(_LIBCPP_CXX03_LANG)
+template <class _Tp, class...>
+using __enable_if_tuple_size_imp = _Tp;
+
+template <class _Tp>
+class _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
+ const _Tp,
+ typename enable_if<!is_volatile<_Tp>::value>::type,
+ integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
+ : public integral_constant<size_t, tuple_size<_Tp>::value> {};
+
+template <class _Tp>
+class _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
+ volatile _Tp,
+ typename enable_if<!is_const<_Tp>::value>::type,
+ integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
+ : public integral_constant<size_t, tuple_size<_Tp>::value> {};
+
+template <class _Tp>
+class _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
+ const volatile _Tp,
+ integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
+ : public integral_constant<size_t, tuple_size<_Tp>::value> {};
+
+#else
+template <class _Tp> class _LIBCPP_TEMPLATE_VIS tuple_size<const _Tp> : public tuple_size<_Tp> {};
+template <class _Tp> class _LIBCPP_TEMPLATE_VIS tuple_size<volatile _Tp> : public tuple_size<_Tp> {};
+template <class _Tp> class _LIBCPP_TEMPLATE_VIS tuple_size<const volatile _Tp> : public tuple_size<_Tp> {};
+#endif
+
+template <size_t _Ip, class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_element;
+
+template <size_t _Ip, class _Tp>
+struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const _Tp>
+{
+ typedef _LIBCPP_NODEBUG typename add_const<typename tuple_element<_Ip, _Tp>::type>::type type;
+};
+
+template <size_t _Ip, class _Tp>
+struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, volatile _Tp>
+{
+ typedef _LIBCPP_NODEBUG typename add_volatile<typename tuple_element<_Ip, _Tp>::type>::type type;
+};
+
+template <size_t _Ip, class _Tp>
+struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp>
+{
+ typedef _LIBCPP_NODEBUG typename add_cv<typename tuple_element<_Ip, _Tp>::type>::type type;
+};
+
+template <class _Tp> struct __tuple_like : false_type {};
+
+template <class _Tp> struct __tuple_like<const _Tp> : public __tuple_like<_Tp> {};
+template <class _Tp> struct __tuple_like<volatile _Tp> : public __tuple_like<_Tp> {};
+template <class _Tp> struct __tuple_like<const volatile _Tp> : public __tuple_like<_Tp> {};
+
+// tuple specializations
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <size_t...> struct __tuple_indices {};
+
+template <class _IdxType, _IdxType... _Values>
+struct __integer_sequence {
+ template <size_t _Sp>
+ using __to_tuple_indices = __tuple_indices<(_Values + _Sp)...>;
+};
+
+#if defined(__CUDACC__) || !__has_builtin(__make_integer_seq) || defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE)
+namespace __detail {
+
+template<typename _Tp, size_t ..._Extra> struct __repeat;
+template<typename _Tp, _Tp ..._Np, size_t ..._Extra> struct __repeat<__integer_sequence<_Tp, _Np...>, _Extra...> {
+ typedef _LIBCPP_NODEBUG __integer_sequence<_Tp,
+ _Np...,
+ sizeof...(_Np) + _Np...,
+ 2 * sizeof...(_Np) + _Np...,
+ 3 * sizeof...(_Np) + _Np...,
+ 4 * sizeof...(_Np) + _Np...,
+ 5 * sizeof...(_Np) + _Np...,
+ 6 * sizeof...(_Np) + _Np...,
+ 7 * sizeof...(_Np) + _Np...,
+ _Extra...> type;
+};
+
+template<size_t _Np> struct __parity;
+template<size_t _Np> struct __make : __parity<_Np % 8>::template __pmake<_Np> {};
+
+template<> struct __make<0> { typedef __integer_sequence<size_t> type; };
+template<> struct __make<1> { typedef __integer_sequence<size_t, 0> type; };
+template<> struct __make<2> { typedef __integer_sequence<size_t, 0, 1> type; };
+template<> struct __make<3> { typedef __integer_sequence<size_t, 0, 1, 2> type; };
+template<> struct __make<4> { typedef __integer_sequence<size_t, 0, 1, 2, 3> type; };
+template<> struct __make<5> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4> type; };
+template<> struct __make<6> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4, 5> type; };
+template<> struct __make<7> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4, 5, 6> type; };
+
+template<> struct __parity<0> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type> {}; };
+template<> struct __parity<1> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 1> {}; };
+template<> struct __parity<2> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 2, _Np - 1> {}; };
+template<> struct __parity<3> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 3, _Np - 2, _Np - 1> {}; };
+template<> struct __parity<4> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
+template<> struct __parity<5> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
+template<> struct __parity<6> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
+template<> struct __parity<7> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 7, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
+
+} // namespace detail
+
+#endif // !__has_builtin(__make_integer_seq) || defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE)
+
+#if __has_builtin(__make_integer_seq) && !defined(__CUDACC__)
+template <size_t _Ep, size_t _Sp>
+using __make_indices_imp =
+ typename __make_integer_seq<__integer_sequence, size_t, _Ep - _Sp>::template
+ __to_tuple_indices<_Sp>;
+#else
+template <size_t _Ep, size_t _Sp>
+using __make_indices_imp =
+ typename __detail::__make<_Ep - _Sp>::type::template __to_tuple_indices<_Sp>;
+
+#endif
+
+template <size_t _Ep, size_t _Sp = 0>
+struct __make_tuple_indices
+{
+ static_assert(_Sp <= _Ep, "__make_tuple_indices input error");
+ typedef __make_indices_imp<_Ep, _Sp> type;
+};
+
+
+template <class ..._Tp> class _LIBCPP_TEMPLATE_VIS tuple;
+
+template <class... _Tp> struct __tuple_like<tuple<_Tp...> > : true_type {};
+
+template <class ..._Tp>
+class _LIBCPP_TEMPLATE_VIS tuple_size<tuple<_Tp...> >
+ : public integral_constant<size_t, sizeof...(_Tp)>
+{
+};
+
+template <size_t _Ip, class ..._Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+typename tuple_element<_Ip, tuple<_Tp...> >::type&
+get(tuple<_Tp...>&) _NOEXCEPT;
+
+template <size_t _Ip, class ..._Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+const typename tuple_element<_Ip, tuple<_Tp...> >::type&
+get(const tuple<_Tp...>&) _NOEXCEPT;
+
+template <size_t _Ip, class ..._Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+typename tuple_element<_Ip, tuple<_Tp...> >::type&&
+get(tuple<_Tp...>&&) _NOEXCEPT;
+
+template <size_t _Ip, class ..._Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
+get(const tuple<_Tp...>&&) _NOEXCEPT;
+
+#endif // !defined(_LIBCPP_CXX03_LANG)
+
+// pair specializations
+
+template <class _T1, class _T2> struct __tuple_like<pair<_T1, _T2> > : true_type {};
+
+template <size_t _Ip, class _T1, class _T2>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+typename tuple_element<_Ip, pair<_T1, _T2> >::type&
+get(pair<_T1, _T2>&) _NOEXCEPT;
+
+template <size_t _Ip, class _T1, class _T2>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+const typename tuple_element<_Ip, pair<_T1, _T2> >::type&
+get(const pair<_T1, _T2>&) _NOEXCEPT;
+
+#ifndef _LIBCPP_CXX03_LANG
+template <size_t _Ip, class _T1, class _T2>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
+get(pair<_T1, _T2>&&) _NOEXCEPT;
+
+template <size_t _Ip, class _T1, class _T2>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+const typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
+get(const pair<_T1, _T2>&&) _NOEXCEPT;
+#endif
+
+// array specializations
+
+template <class _Tp, size_t _Size> struct _LIBCPP_TEMPLATE_VIS array;
+
+template <class _Tp, size_t _Size> struct __tuple_like<array<_Tp, _Size> > : true_type {};
+
+template <size_t _Ip, class _Tp, size_t _Size>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_Tp&
+get(array<_Tp, _Size>&) _NOEXCEPT;
+
+template <size_t _Ip, class _Tp, size_t _Size>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+const _Tp&
+get(const array<_Tp, _Size>&) _NOEXCEPT;
+
+#ifndef _LIBCPP_CXX03_LANG
+template <size_t _Ip, class _Tp, size_t _Size>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_Tp&&
+get(array<_Tp, _Size>&&) _NOEXCEPT;
+
+template <size_t _Ip, class _Tp, size_t _Size>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+const _Tp&&
+get(const array<_Tp, _Size>&&) _NOEXCEPT;
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+
+// __tuple_types
+
+template <class ..._Tp> struct __tuple_types {};
+
+#if !__has_builtin(__type_pack_element)
+
+namespace __indexer_detail {
+
+template <size_t _Idx, class _Tp>
+struct __indexed { using type _LIBCPP_NODEBUG = _Tp; };
+
+template <class _Types, class _Indexes> struct __indexer;
+
+template <class ..._Types, size_t ..._Idx>
+struct __indexer<__tuple_types<_Types...>, __tuple_indices<_Idx...>>
+ : __indexed<_Idx, _Types>...
+{};
+
+template <size_t _Idx, class _Tp>
+__indexed<_Idx, _Tp> __at_index(__indexed<_Idx, _Tp> const&);
+
+} // namespace __indexer_detail
+
+#if !defined(__CUDACC__) || !defined(_MSC_VER)
+template <size_t _Idx, class ..._Types>
+using __type_pack_element _LIBCPP_NODEBUG = typename decltype(
+ __indexer_detail::__at_index<_Idx>(
+ __indexer_detail::__indexer<
+ __tuple_types<_Types...>,
+ typename __make_tuple_indices<sizeof...(_Types)>::type
+ >{})
+ )::type;
+
+#else // !defined(__CUDACC__) || !defined(_MSC_VER)
+template <size_t _Idx, class ..._Types>
+struct __y_type_pack_element {
+ using __t1 = typename __make_tuple_indices<sizeof...(_Types)>::type;
+ using __t2 = __indexer_detail::__indexer<__tuple_types<_Types...>, __t1>;
+ using __t3 = decltype(__indexer_detail::__at_index<_Idx>(__t2{}));
+ using __t4 = typename __t3::type;
+};
+
+template <size_t _Idx, class ..._Types>
+using __type_pack_element = typename __y_type_pack_element<_Idx, _Types...>::__t4;
+
+#endif // !defined(__CUDACC__) || !defined(_MSC_VER)
+
+#endif // __has_builtin(__type_pack_element)
+
+template <size_t _Ip, class ..._Types>
+struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...> >
+{
+ static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range");
+ typedef _LIBCPP_NODEBUG __type_pack_element<_Ip, _Types...> type;
+};
+
+
+template <class ..._Tp>
+class _LIBCPP_TEMPLATE_VIS tuple_size<__tuple_types<_Tp...> >
+ : public integral_constant<size_t, sizeof...(_Tp)>
+{
+};
+
+template <class... _Tp> struct __tuple_like<__tuple_types<_Tp...> > : true_type {};
+
+template <bool _ApplyLV, bool _ApplyConst, bool _ApplyVolatile>
+struct __apply_cv_mf;
+template <>
+struct __apply_cv_mf<false, false, false> {
+ template <class _Tp> using __apply = _Tp;
+};
+template <>
+struct __apply_cv_mf<false, true, false> {
+ template <class _Tp> using __apply _LIBCPP_NODEBUG = const _Tp;
+};
+template <>
+struct __apply_cv_mf<false, false, true> {
+ template <class _Tp> using __apply _LIBCPP_NODEBUG = volatile _Tp;
+};
+template <>
+struct __apply_cv_mf<false, true, true> {
+ template <class _Tp> using __apply _LIBCPP_NODEBUG = const volatile _Tp;
+};
+template <>
+struct __apply_cv_mf<true, false, false> {
+ template <class _Tp> using __apply _LIBCPP_NODEBUG = _Tp&;
+};
+template <>
+struct __apply_cv_mf<true, true, false> {
+ template <class _Tp> using __apply _LIBCPP_NODEBUG = const _Tp&;
+};
+template <>
+struct __apply_cv_mf<true, false, true> {
+ template <class _Tp> using __apply _LIBCPP_NODEBUG = volatile _Tp&;
+};
+template <>
+struct __apply_cv_mf<true, true, true> {
+ template <class _Tp> using __apply _LIBCPP_NODEBUG = const volatile _Tp&;
+};
+template <class _Tp, class _RawTp = typename remove_reference<_Tp>::type>
+using __apply_cv_t _LIBCPP_NODEBUG = __apply_cv_mf<
+ is_lvalue_reference<_Tp>::value,
+ is_const<_RawTp>::value,
+ is_volatile<_RawTp>::value>;
+
+// __make_tuple_types
+
+// __make_tuple_types<_Tuple<_Types...>, _Ep, _Sp>::type is a
+// __tuple_types<_Types...> using only those _Types in the range [_Sp, _Ep).
+// _Sp defaults to 0 and _Ep defaults to tuple_size<_Tuple>. If _Tuple is a
+// lvalue_reference type, then __tuple_types<_Types&...> is the result.
+
+#ifdef _LIBCPP_COMPILER_MSVC
+
+template<class _TupleTypes, class _Tp>
+struct __make_tuple_types_append_front;
+
+template<class ..._Types, class _Tp>
+struct __make_tuple_types_append_front<__tuple_types<_Types...>, _Tp> {
+ using type = __tuple_types<_Tp, _Types...>;
+};
+
+template<class _TupleTypes, class _Apply, size_t _Ep, size_t _Sp, class = void>
+struct __make_tuple_types_flat;
+
+template<class _Tuple, class _Apply>
+struct __make_tuple_types_flat<_Tuple, _Apply, 0, 0, void> {
+ using type = __tuple_types<>;
+};
+
+template<template<class...> class _Tuple, class _Tp, class ..._Types, class _Apply, size_t _Ep>
+struct __make_tuple_types_flat<_Tuple<_Tp, _Types...>, _Apply, _Ep, 0, enable_if_t<(_Ep > 0)>> {
+ using type = typename __make_tuple_types_append_front<
+ typename __make_tuple_types_flat<__tuple_types<_Types...>, _Apply, _Ep - 1, 0>::type,
+ typename _Apply::template __apply<_Tp>>::type;
+};
+
+template<template <class...> class _Tuple, class _Tp, class ..._Types, class _Apply, size_t _Ep, size_t _Sp>
+struct __make_tuple_types_flat<_Tuple<_Tp, _Types...>, _Apply, _Ep, _Sp, enable_if_t<(_Ep > 0 && _Sp > 0)>> {
+ using type = typename __make_tuple_types_flat<__tuple_types<_Types...>, _Apply, _Ep - 1, _Sp - 1>::type;
+};
+
+template<class _Tp, size_t _Np, class _Apply, size_t _Ep>
+struct __make_tuple_types_flat<array<_Tp, _Np>, _Apply, _Ep, 0, enable_if_t<(_Ep > 0)>> {
+ using type = typename __make_tuple_types_append_front<
+ typename __make_tuple_types_flat<array<_Tp, _Np>, _Apply, _Ep - 1, 0>::type,
+ typename _Apply::template __apply<_Tp>>::type;
+};
+
+template<class _Tp, size_t _Np, class _Apply, size_t _Ep, size_t _Sp>
+struct __make_tuple_types_flat<array<_Tp, _Np>, _Apply, _Ep, _Sp, enable_if_t<(_Sp > 0)>> {
+ using type = typename __make_tuple_types_flat<array<_Tp, _Np>, _Apply, _Ep - _Sp, 0>::type;
+};
+
+template<class _Tp,
+ size_t _Ep = tuple_size<remove_reference_t<_Tp>>::value,
+ size_t _Sp = 0,
+ bool _SameSize = (_Ep == tuple_size<typename remove_reference<_Tp>::type>::value)>
+struct __make_tuple_types {
+ static_assert(_Sp <= _Ep, "__make_tuple_types input error");
+ using _RawTp = typename remove_cv<typename remove_reference<_Tp>::type>::type;
+ using type = typename __make_tuple_types_flat<_RawTp, __apply_cv_t<_Tp>, _Ep, _Sp>::type;
+};
+
+template <class ..._Types, size_t _Ep>
+struct __make_tuple_types<tuple<_Types...>, _Ep, 0, true> {
+ typedef __tuple_types<_Types...> type;
+};
+
+template <class ..._Types, size_t _Ep>
+struct __make_tuple_types<__tuple_types<_Types...>, _Ep, 0, true> {
+ typedef __tuple_types<_Types...> type;
+};
+
+#else
+
+template <class _TupleTypes, class _TupleIndices>
+struct __make_tuple_types_flat;
+
+template <template <class...> class _Tuple, class ..._Types, size_t ..._Idx>
+struct __make_tuple_types_flat<_Tuple<_Types...>, __tuple_indices<_Idx...>> {
+ // Specialization for pair, tuple, and __tuple_types
+ template <class _Tp, class _ApplyFn = __apply_cv_t<_Tp>>
+ using __apply_quals _LIBCPP_NODEBUG = __tuple_types<
+ typename _ApplyFn::template __apply<__type_pack_element<_Idx, _Types...>>...
+ >;
+};
+
+template <class _Vt, size_t _Np, size_t ..._Idx>
+struct __make_tuple_types_flat<array<_Vt, _Np>, __tuple_indices<_Idx...>> {
+ template <size_t>
+ using __value_type = _Vt;
+ template <class _Tp, class _ApplyFn = __apply_cv_t<_Tp>>
+ using __apply_quals = __tuple_types<
+ typename _ApplyFn::template __apply<__value_type<_Idx>>...
+ >;
+};
+
+template <class _Tp, size_t _Ep = tuple_size<typename remove_reference<_Tp>::type>::value,
+ size_t _Sp = 0,
+ bool _SameSize = (_Ep == tuple_size<typename remove_reference<_Tp>::type>::value)>
+struct __make_tuple_types
+{
+ static_assert(_Sp <= _Ep, "__make_tuple_types input error");
+ using _RawTp = typename remove_cv<typename remove_reference<_Tp>::type>::type;
+ using _Maker = __make_tuple_types_flat<_RawTp, typename __make_tuple_indices<_Ep, _Sp>::type>;
+ using type = typename _Maker::template __apply_quals<_Tp>;
+};
+
+template <class ..._Types, size_t _Ep>
+struct __make_tuple_types<tuple<_Types...>, _Ep, 0, true> {
+ typedef _LIBCPP_NODEBUG __tuple_types<_Types...> type;
+};
+
+template <class ..._Types, size_t _Ep>
+struct __make_tuple_types<__tuple_types<_Types...>, _Ep, 0, true> {
+ typedef _LIBCPP_NODEBUG __tuple_types<_Types...> type;
+};
+
+#endif // _LIBCPP_COMPILER_MSVC
+
+template <bool ..._Preds>
+struct __all_dummy;
+
+template <bool ..._Pred>
+struct __all : _IsSame<__all_dummy<_Pred...>, __all_dummy<(_Pred | true)...>>{};
+
+struct __tuple_sfinae_base {
+ template <template <class, class...> class _Trait,
+ class ..._LArgs, class ..._RArgs>
+ static auto __do_test(__tuple_types<_LArgs...>, __tuple_types<_RArgs...>)
+ -> __all<_Trait<_LArgs, _RArgs>::value...>;
+ template <template <class...> class>
+ static auto __do_test(...) -> false_type;
+
+ template <class _FromArgs, class _ToArgs>
+ using __constructible = decltype(__do_test<is_constructible>(declval<_ToArgs>(), declval<_FromArgs>()));
+ template <class _FromArgs, class _ToArgs>
+ using __convertible = decltype(__do_test<is_convertible>(declval<_FromArgs>(), declval<_ToArgs>()));
+ template <class _FromArgs, class _ToArgs>
+ using __assignable = decltype(__do_test<is_assignable>(declval<_ToArgs>(), declval<_FromArgs>()));
+};
+
+// __tuple_convertible
+
+template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
+ bool = __tuple_like<_Up>::value,
+ class = void>
+struct __tuple_convertible
+ : public false_type {};
+
+template <class _Tp, class _Up>
+struct __tuple_convertible<_Tp, _Up, true, true,
+ typename enable_if<(tuple_size<typename remove_reference<_Tp>::type>::value == tuple_size<_Up>::value)>::type>
+ : public __tuple_sfinae_base::__convertible<
+ typename __make_tuple_types<_Tp>::type
+ , typename __make_tuple_types<_Up>::type
+ >
+{};
+
+// __tuple_constructible
+
+template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
+ bool = __tuple_like<_Up>::value,
+ class = void>
+struct __tuple_constructible
+ : public false_type {};
+
+template <class _Tp, class _Up>
+struct __tuple_constructible<_Tp, _Up, true, true,
+ typename enable_if<(tuple_size<typename remove_reference<_Tp>::type>::value == tuple_size<_Up>::value)>::type>
+ : public __tuple_sfinae_base::__constructible<
+ typename __make_tuple_types<_Tp>::type
+ , typename __make_tuple_types<_Up>::type
+ >
+{};
+
+// __tuple_assignable
+
+template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
+ bool = __tuple_like<_Up>::value,
+ class = void>
+struct __tuple_assignable
+ : public false_type {};
+
+template <class _Tp, class _Up>
+struct __tuple_assignable<_Tp, _Up, true, true,
+ typename enable_if<(tuple_size<typename remove_reference<_Tp>::type>::value == tuple_size<_Up>::value)>::type>
+ : public __tuple_sfinae_base::__assignable<
+ typename __make_tuple_types<_Tp>::type
+ , typename __make_tuple_types<_Up&>::type
+ >
+{};
+
+
+template <size_t _Ip, class ..._Tp>
+struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, tuple<_Tp...> >
+{
+ typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type;
+};
+
+#if _LIBCPP_STD_VER > 11
+template <size_t _Ip, class ..._Tp>
+using tuple_element_t _LIBCPP_NODEBUG = typename tuple_element <_Ip, _Tp...>::type;
+#endif
+
+template <bool _IsTuple, class _SizeTrait, size_t _Expected>
+struct __tuple_like_with_size_imp : false_type {};
+
+template <class _SizeTrait, size_t _Expected>
+struct __tuple_like_with_size_imp<true, _SizeTrait, _Expected>
+ : integral_constant<bool, _SizeTrait::value == _Expected> {};
+
+template <class _Tuple, size_t _ExpectedSize, class _RawTuple = __uncvref_t<_Tuple> >
+using __tuple_like_with_size _LIBCPP_NODEBUG = __tuple_like_with_size_imp<
+ __tuple_like<_RawTuple>::value,
+ tuple_size<_RawTuple>, _ExpectedSize
+ >;
+
+struct _LIBCPP_TYPE_VIS __check_tuple_constructor_fail {
+
+ static constexpr bool __enable_explicit_default() { return false; }
+ static constexpr bool __enable_implicit_default() { return false; }
+ template <class ...>
+ static constexpr bool __enable_explicit() { return false; }
+ template <class ...>
+ static constexpr bool __enable_implicit() { return false; }
+ template <class ...>
+ static constexpr bool __enable_assign() { return false; }
+};
+#endif // !defined(_LIBCPP_CXX03_LANG)
+
+#if _LIBCPP_STD_VER > 14
+
+template <bool _CanCopy, bool _CanMove>
+struct __sfinae_ctor_base {};
+template <>
+struct __sfinae_ctor_base<false, false> {
+ __sfinae_ctor_base() = default;
+ __sfinae_ctor_base(__sfinae_ctor_base const&) = delete;
+ __sfinae_ctor_base(__sfinae_ctor_base &&) = delete;
+ __sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default;
+ __sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default;
+};
+template <>
+struct __sfinae_ctor_base<true, false> {
+ __sfinae_ctor_base() = default;
+ __sfinae_ctor_base(__sfinae_ctor_base const&) = default;
+ __sfinae_ctor_base(__sfinae_ctor_base &&) = delete;
+ __sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default;
+ __sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default;
+};
+template <>
+struct __sfinae_ctor_base<false, true> {
+ __sfinae_ctor_base() = default;
+ __sfinae_ctor_base(__sfinae_ctor_base const&) = delete;
+ __sfinae_ctor_base(__sfinae_ctor_base &&) = default;
+ __sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default;
+ __sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default;
+};
+
+template <bool _CanCopy, bool _CanMove>
+struct __sfinae_assign_base {};
+template <>
+struct __sfinae_assign_base<false, false> {
+ __sfinae_assign_base() = default;
+ __sfinae_assign_base(__sfinae_assign_base const&) = default;
+ __sfinae_assign_base(__sfinae_assign_base &&) = default;
+ __sfinae_assign_base& operator=(__sfinae_assign_base const&) = delete;
+ __sfinae_assign_base& operator=(__sfinae_assign_base&&) = delete;
+};
+template <>
+struct __sfinae_assign_base<true, false> {
+ __sfinae_assign_base() = default;
+ __sfinae_assign_base(__sfinae_assign_base const&) = default;
+ __sfinae_assign_base(__sfinae_assign_base &&) = default;
+ __sfinae_assign_base& operator=(__sfinae_assign_base const&) = default;
+ __sfinae_assign_base& operator=(__sfinae_assign_base&&) = delete;
+};
+template <>
+struct __sfinae_assign_base<false, true> {
+ __sfinae_assign_base() = default;
+ __sfinae_assign_base(__sfinae_assign_base const&) = default;
+ __sfinae_assign_base(__sfinae_assign_base &&) = default;
+ __sfinae_assign_base& operator=(__sfinae_assign_base const&) = delete;
+ __sfinae_assign_base& operator=(__sfinae_assign_base&&) = default;
+};
+#endif // _LIBCPP_STD_VER > 14
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TUPLE
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__undef_macros b/contrib/libs/cxxsupp/libcxxmsvc/include/__undef_macros
new file mode 100644
index 0000000000..40b2b64d0a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__undef_macros
@@ -0,0 +1,33 @@
+// -*- 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
+//
+//===----------------------------------------------------------------------===//
+
+
+#ifdef min
+#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS)
+#if defined(_LIBCPP_WARNING)
+_LIBCPP_WARNING("macro min is incompatible with C++. Try #define NOMINMAX "
+ "before any Windows header. #undefing min")
+#else
+#warning: macro min is incompatible with C++. #undefing min
+#endif
+#endif
+#undef min
+#endif
+
+#ifdef max
+#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS)
+#if defined(_LIBCPP_WARNING)
+_LIBCPP_WARNING("macro max is incompatible with C++. Try #define NOMINMAX "
+ "before any Windows header. #undefing max")
+#else
+#warning: macro max is incompatible with C++. #undefing max
+#endif
+#endif
+#undef max
+#endif
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/as_const.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/as_const.h
new file mode 100644
index 0000000000..be7dd8c7cf
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/as_const.h
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_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
+
+#endif // _LIBCPP___UTILITY_AS_CONST_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/auto_cast.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/auto_cast.h
new file mode 100644
index 0000000000..e907944395
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/auto_cast.h
@@ -0,0 +1,22 @@
+// -*- 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_AUTO_CAST_H
+#define _LIBCPP___UTILITY_AUTO_CAST_H
+
+#include <__config>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#define _LIBCPP_AUTO_CAST(expr) static_cast<typename decay<decltype((expr))>::type>(expr)
+
+#endif // _LIBCPP___UTILITY_AUTO_CAST_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/cmp.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/cmp.h
new file mode 100644
index 0000000000..f36d53ad46
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/cmp.h
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 !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
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ , wchar_t
+#endif
+ >::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/libs/cxxsupp/libcxxmsvc/include/__utility/declval.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/declval.h
new file mode 100644
index 0000000000..e2fcf48d36
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/declval.h
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_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
+
+#ifdef _LIBCPP_COMPILER_MSVC
+template <class _Tp>
+using __declval_void = void;
+
+template <class _Tp, class = void>
+struct __declval_add_rvalue_reference {
+ using type = _Tp;
+};
+template <class _Tp>
+struct __declval_add_rvalue_reference<_Tp, __declval_void<_Tp&>> {
+ using type = _Tp&&;
+};
+#endif
+
+template <class _Tp>
+#ifdef _LIBCPP_COMPILER_MSVC
+typename __declval_add_rvalue_reference<_Tp>::type
+#else
+decltype(__declval<_Tp>(0))
+#endif
+declval() _NOEXCEPT;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___UTILITY_DECLVAL_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/exchange.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/exchange.h
new file mode 100644
index 0000000000..d9b3c15175
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/exchange.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___UTILITY_EXCHANGE_H
+#define _LIBCPP___UTILITY_EXCHANGE_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_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)
+ noexcept(is_nothrow_move_constructible<_T1>::value && is_nothrow_assignable<_T1&, _T2>::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
+
+#endif // _LIBCPP___UTILITY_EXCHANGE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/forward.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/forward.h
new file mode 100644
index 0000000000..6ee1f818ba
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/forward.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___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_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
+
+#endif // _LIBCPP___UTILITY_FORWARD_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/in_place.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/in_place.h
new file mode 100644
index 0000000000..7a4973fa04
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/in_place.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___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_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 14
+
+struct _LIBCPP_TYPE_VIS in_place_t {
+ explicit in_place_t() = default;
+};
+inline 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>
+inline 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>
+inline 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
+
+#endif // _LIBCPP___UTILITY_IN_PLACE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/integer_sequence.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/integer_sequence.h
new file mode 100644
index 0000000000..a74b1a0337
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/integer_sequence.h
@@ -0,0 +1,94 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_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 = __make_integer_seq<integer_sequence, _Tp, _Ep>;
+
+#else
+
+template <class _Tp, class _T> struct __integer_sequence_convert {
+ using type = integer_sequence<_Tp>;
+};
+
+template<class _Tp, class _Tp2, _Tp... _Values>
+struct __integer_sequence_convert<_Tp, __integer_sequence<_Tp2, _Values...>> {
+ using type = integer_sequence<_Tp, _Values...>;
+};
+
+template<typename _Tp, _Tp _Np> using __make_integer_sequence_unchecked _LIBCPP_NODEBUG =
+ typename __integer_sequence_convert<_Tp, typename __detail::__make<_Np>::type>::type;
+
+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");
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( push )
+#pragma warning ( disable : 4296 )
+#endif
+ // Workaround GCC bug by preventing bad installations when 0 <= _Ep
+ // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68929
+ typedef _LIBCPP_NODEBUG __make_integer_sequence_unchecked<_Tp, 0 <= _Ep ? _Ep : 0> type;
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( pop )
+#endif
+};
+
+template <class _Tp, _Tp _Ep>
+using __make_integer_sequence _LIBCPP_NODEBUG = 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
+
+#endif // _LIBCPP___UTILITY_INTEGER_SEQUENCE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/move.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/move.h
new file mode 100644
index 0000000000..7d1c8c2522
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/move.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___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_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 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
+
+#endif // _LIBCPP___UTILITY_MOVE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/pair.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/pair.h
new file mode 100644
index 0000000000..258e65379f
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/pair.h
@@ -0,0 +1,635 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <__compare/common_comparison_category.h>
+#include <__compare/synth_three_way.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_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 _Dummy = true, int&... _Args>
+ struct _EnableImplicitDefaultConstructor {
+ static constexpr bool value = __is_implicitly_default_constructible<_T1>::value
+ && __is_implicitly_default_constructible<_T2>::value;
+ };
+
+ template<bool _Dummy = true, int&... _Args>
+ struct _EnableExplicitDefaultConstructor {
+ static constexpr bool value = is_default_constructible<_T1>::value
+ && is_default_constructible<_T2>::value
+ && !_EnableImplicitDefaultConstructor<_Dummy, _Args...>::value;
+ };
+
+ template <class _U1, class _U2, bool _Dummy = true>
+ struct _EnableExplicitConstructor {
+ static constexpr bool value = 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, bool _Dummy = true>
+ struct _EnableImplicitConstructor {
+ static constexpr bool value = 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 _Tuple, bool _Enable = __tuple_like_with_size<_Tuple, 2>::value
+ && !is_same<typename decay<_Tuple>::type, pair>::value>
+ struct _EnableImplicitTupleLikeConstructor {
+ static constexpr bool value = false;
+ };
+
+ template <class _Tuple, bool _Enable = __tuple_like_with_size<_Tuple, 2>::value
+ && !is_same<typename decay<_Tuple>::type, pair>::value>
+ struct _EnableExplicitTupleLikeConstructor {
+ static constexpr bool value = false;
+ };
+
+ template <class _Tuple, bool _Enable = __tuple_like_with_size<_Tuple, 2>::value
+ && !is_same<typename decay<_Tuple>::type, pair>::value>
+ struct _EnableTupleLikeAssign {
+ static constexpr bool value = false;
+ };
+
+ template <class _Tuple>
+ struct _EnableImplicitTupleLikeConstructor<_Tuple, true> {
+ static constexpr bool value = __tuple_convertible<_Tuple, pair>::value;
+ };
+
+ template <class _Tuple>
+ struct _EnableExplicitTupleLikeConstructor<_Tuple, true> {
+ static constexpr bool value = __tuple_constructible<_Tuple, pair>::value
+ && !__tuple_convertible<_Tuple, pair>::value;
+ };
+
+ template <class _Tuple>
+ struct _EnableTupleLikeAssign<_Tuple, true> {
+ static constexpr bool value = __tuple_assignable<_Tuple, pair>::value;
+ };
+
+ template<bool _Dummy = true, typename enable_if<
+ _EnableExplicitDefaultConstructor<_Dummy>::value
+ >::type* = nullptr>
+ explicit _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ pair()
+// danlark@ if you remove this define, MSVC gets into ICE
+#if !defined(_LIBCPP_COMPILER_MSVC)
+ _NOEXCEPT_(is_nothrow_default_constructible<first_type>::value &&
+ is_nothrow_default_constructible<second_type>::value)
+#endif
+ : first(), second() {}
+
+ template<bool _Dummy = true, typename enable_if<
+ _EnableImplicitDefaultConstructor<_Dummy>::value
+ >::type* = nullptr>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ pair()
+// danlark@ if you remove this define, MSVC gets into ICE
+#if !defined(_LIBCPP_COMPILER_MSVC)
+ _NOEXCEPT_(is_nothrow_default_constructible<first_type>::value &&
+ is_nothrow_default_constructible<second_type>::value)
+#endif
+ : first(), second() {}
+
+ template <bool _Dummy = true, typename enable_if<
+ _EnableExplicitConstructor<_T1 const&, _T2 const&, _Dummy>::value
+ >::type* = nullptr>
+ _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, bool _Dummy2 = true, typename enable_if<
+ _EnableImplicitConstructor<_T1 const&, _T2 const&, _Dummy>::value
+ >::type* = nullptr>
+ _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 <
+#if _LIBCPP_STD_VER > 20 // http://wg21.link/P1951
+ class _U1 = _T1, class _U2 = _T2,
+#else
+ class _U1, class _U2,
+#endif
+ typename enable_if<_EnableExplicitConstructor<_U1, _U2>::value>::type* = nullptr
+ >
+ _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<
+#if _LIBCPP_STD_VER > 20 // http://wg21.link/P1951
+ class _U1 = _T1, class _U2 = _T2,
+#else
+ class _U1, class _U2,
+#endif
+ bool _Dummy = true, typename enable_if<_EnableImplicitConstructor<_U1, _U2, _Dummy>::value>::type* = nullptr
+ >
+ _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, typename enable_if<
+ _EnableExplicitConstructor<_U1 const&, _U2 const&>::value
+ >::type* = nullptr>
+ _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, bool _Dummy = true, typename enable_if<
+ _EnableImplicitConstructor<_U1 const&, _U2 const&, _Dummy>::value
+ >::type* = nullptr>
+ _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, typename enable_if<
+ _EnableExplicitConstructor<_U1, _U2>::value
+ >::type* = nullptr>
+ _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, bool _Dummy = true, typename enable_if<
+ _EnableImplicitConstructor<_U1, _U2>::value
+ >::type* = nullptr>
+ _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, typename enable_if<
+ _EnableExplicitTupleLikeConstructor<_Tuple>::value
+ >::type* = nullptr>
+ _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, bool _Dummy = true, typename enable_if<
+ _EnableImplicitTupleLikeConstructor<_Tuple>::value
+ >::type* = nullptr>
+ _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, bool _Dummy = true, typename enable_if<
+ _EnableTupleLikeAssign<_Tuple>::value
+ >::type* = nullptr>
+ _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
+};
+
+#if _LIBCPP_STD_VER > 14
+template<class _T1, class _T2>
+pair(_T1, _T2) -> pair<_T1, _T2>;
+#endif
+
+// [pairs.spec], specialized algorithms
+
+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;
+}
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+template <class _T1, class _T2>
+_LIBCPP_HIDE_FROM_ABI constexpr
+common_comparison_category_t<
+ __synth_three_way_result<_T1>,
+ __synth_three_way_result<_T2> >
+operator<=>(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
+{
+ if (auto __c = _VSTD::__synth_three_way(__x.first, __y.first); __c != 0) {
+ return __c;
+ }
+ return _VSTD::__synth_three_way(__x.second, __y.second);
+}
+
+#else // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+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);
+}
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+#if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_CONCEPTS)
+template <class _T1, class _T2, class _U1, class _U2, template<class> class _TQual, template<class> class _UQual>
+ requires requires { typename pair<common_reference_t<_TQual<_T1>, _UQual<_U1>>,
+ common_reference_t<_TQual<_T2>, _UQual<_U2>>>; }
+struct basic_common_reference<pair<_T1, _T2>, pair<_U1, _U2>, _TQual, _UQual> {
+ using type = pair<common_reference_t<_TQual<_T1>, _UQual<_U1>>,
+ common_reference_t<_TQual<_T2>, _UQual<_U2>>>;
+};
+
+template <class _T1, class _T2, class _U1, class _U2>
+ requires requires { typename pair<common_type_t<_T1, _U1>, common_type_t<_T2, _U2>>; }
+struct common_type<pair<_T1, _T2>, pair<_U1, _U2>> {
+ using type = pair<common_type_t<_T1, _U1>, common_type_t<_T2, _U2>>;
+};
+#endif // _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+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 _T1 type;
+};
+
+template <class _T1, class _T2>
+struct _LIBCPP_TEMPLATE_VIS tuple_element<1, pair<_T1, _T2> >
+{
+ typedef _LIBCPP_NODEBUG _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
+
+#endif // _LIBCPP___UTILITY_PAIR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/piecewise_construct.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/piecewise_construct.h
new file mode 100644
index 0000000000..3cc86fef2a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/piecewise_construct.h
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_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
+/* inline */ constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___UTILITY_PIECEWISE_CONSTRUCT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/priority_tag.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/priority_tag.h
new file mode 100644
index 0000000000..e51ba6bfcc
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/priority_tag.h
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_PRIORITY_TAG_H
+#define _LIBCPP___UTILITY_PRIORITY_TAG_H
+
+#include <__config>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template<size_t _Ip> struct __priority_tag : __priority_tag<_Ip - 1> {};
+template<> struct __priority_tag<0> {};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___UTILITY_PRIORITY_TAG_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/rel_ops.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/rel_ops.h
new file mode 100644
index 0000000000..2577e94e91
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/rel_ops.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___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_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);
+}
+
+} // namespace rel_ops
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___UTILITY_REL_OPS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/swap.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/swap.h
new file mode 100644
index 0000000000..f9e7f36678
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/swap.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___UTILITY_SWAP_H
+#define _LIBCPP___UTILITY_SWAP_H
+
+#include <__config>
+#include <__utility/declval.h>
+#include <__utility/move.h>
+#include <cstddef>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+#endif // _LIBCPP___UTILITY_SWAP_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/to_underlying.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/to_underlying.h
new file mode 100644
index 0000000000..3428406e8d
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/to_underlying.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___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_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
+
+#endif // _LIBCPP___UTILITY_TO_UNDERLYING_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/transaction.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/transaction.h
new file mode 100644
index 0000000000..79e6c3fb42
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/transaction.h
@@ -0,0 +1,94 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_TRANSACTION_H
+#define _LIBCPP___UTILITY_TRANSACTION_H
+
+#include <__config>
+#include <__utility/exchange.h>
+#include <__utility/move.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// __transaction is a helper class for writing code with the strong exception guarantee.
+//
+// When writing code that can throw an exception, one can store rollback instructions in a
+// transaction so that if an exception is thrown at any point during the lifetime of the
+// transaction, it will be rolled back automatically. When the transaction is done, one
+// must mark it as being complete so it isn't rolled back when the transaction is destroyed.
+//
+// Transactions are not default constructible, they can't be copied or assigned to, but
+// they can be moved around for convenience.
+//
+// __transaction can help greatly simplify code that would normally be cluttered by
+// `#if _LIBCPP_NO_EXCEPTIONS`. For example:
+//
+// template <class Iterator, class Size, class OutputIterator>
+// Iterator uninitialized_copy_n(Iterator iter, Size n, OutputIterator out) {
+// typedef typename iterator_traits<Iterator>::value_type value_type;
+// __transaction transaction([start=out, &out] {
+// std::destroy(start, out);
+// });
+//
+// for (; n > 0; ++iter, ++out, --n) {
+// ::new ((void*)std::addressof(*out)) value_type(*iter);
+// }
+// transaction.__complete();
+// return out;
+// }
+//
+template <class _Rollback>
+struct __transaction {
+ __transaction() = delete;
+
+ _LIBCPP_HIDE_FROM_ABI
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit __transaction(_Rollback __rollback)
+ : __rollback_(_VSTD::move(__rollback))
+ , __completed_(false)
+ { }
+
+ _LIBCPP_HIDE_FROM_ABI
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 __transaction(__transaction&& __other)
+ _NOEXCEPT_(is_nothrow_move_constructible<_Rollback>::value)
+ : __rollback_(_VSTD::move(__other.__rollback_))
+ , __completed_(__other.__completed_)
+ {
+ __other.__completed_ = true;
+ }
+
+ __transaction(__transaction const&) = delete;
+ __transaction& operator=(__transaction const&) = delete;
+ __transaction& operator=(__transaction&&) = delete;
+
+ _LIBCPP_HIDE_FROM_ABI
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __complete() _NOEXCEPT {
+ __completed_ = true;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+#if !defined(_LIBCPP_COMPILER_MSVC)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+#endif
+ ~__transaction() {
+ if (!__completed_)
+ __rollback_();
+ }
+
+private:
+ _Rollback __rollback_;
+ bool __completed_;
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___UTILITY_TRANSACTION_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/unreachable.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/unreachable.h
new file mode 100644
index 0000000000..485edb227c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__utility/unreachable.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_UNREACHABLE_H
+#define _LIBCPP___UTILITY_UNREACHABLE_H
+
+#include <__config>
+#include <cstdlib>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI inline void __libcpp_unreachable()
+{
+#if __has_builtin(__builtin_unreachable)
+ __builtin_unreachable();
+#else
+ std::abort();
+#endif
+}
+
+#if _LIBCPP_STD_VER > 20
+
+[[noreturn]] _LIBCPP_HIDE_FROM_ABI inline void unreachable() { __libcpp_unreachable(); }
+
+#endif // _LIBCPP_STD_VER > 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__variant/monostate.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__variant/monostate.h
new file mode 100644
index 0000000000..b389c3b56b
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__variant/monostate.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___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_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
+
+#endif // _LIBCPP___VARIANT_MONOSTATE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__wrappers_config b/contrib/libs/cxxsupp/libcxxmsvc/include/__wrappers_config
new file mode 100644
index 0000000000..40a56485fb
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__wrappers_config
@@ -0,0 +1,50 @@
+#pragma once
+
+#define _LIBCPP_ABI_VERSION 1
+#define _LIBCPP_ABI_NAMESPACE __y1
+
+#if !defined(NDEBUG) && !defined(_LIBCPP_DEBUG)
+# define _LIBCPP_DEBUG 0
+#endif
+
+#ifndef _YNDX_LIBCPP_ENABLE_EXTENSIONS
+# define _YNDX_LIBCPP_ENABLE_EXTENSIONS 1
+#endif
+
+#if _YNDX_LIBCPP_ENABLE_EXTENSIONS == 1
+# define _YNDX_LIBCXX_ENABLE_STRING_RESIZE_UNINITIALIZED 1
+# define _YNDX_LIBCXX_ENABLE_VECTOR_BOOL_COMPRESSION 0
+# define _YNDX_LIBCXX_ENABLE_VECTOR_POD_RESIZE_UNINITIALIZED 1
+#else
+# define _YNDX_LIBCXX_ENABLE_STRING_RESIZE_UNINITIALIZED 0
+# define _YNDX_LIBCXX_ENABLE_VECTOR_BOOL_COMPRESSION 1
+# define _YNDX_LIBCXX_ENABLE_VECTOR_POD_RESIZE_UNINITIALIZED 0
+#endif
+
+#if _YNDX_LIBCPP_ENABLE_EXTENSIONS == 1 && (!defined(_LIBCPP_DEBUG) || _LIBCPP_DEBUG == 0)
+# define _YNDX_LIBCPP_MAKE_VECTOR_ITERATOR_POINTERS 1
+# define _YNDX_LIBCPP_MAKE_STRING_ITERATOR_POINTERS 1
+#else
+# define _YNDX_LIBCPP_MAKE_VECTOR_ITERATOR_POINTERS 0
+# define _YNDX_LIBCPP_MAKE_STRING_ITERATOR_POINTERS 0
+#endif
+
+#define _YNDX_WIN32_NOFILESYSTEM_RUNTIME
+
+#define _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
+#define _LIBCPP_NO_AUTO_LINK
+#define _LIBCPP_DISABLE_DEPRECATION_WARNINGS
+
+// should be removed in https://st.yandex-team.ru/IGNIETFERRO-1957
+#define _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
+
+// should be removed in https://st.yandex-team.ru/IGNIETFERRO-1955
+#define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
+
+// should be removed in https://st.yandex-team.ru/IGNIETFERRO-1956
+#define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS
+#define _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+
+#ifdef _musl_
+# define _LIBCPP_HAS_MUSL_LIBC
+#endif
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/algorithm b/contrib/libs/cxxsupp/libcxxmsvc/include/algorithm
new file mode 100644
index 0000000000..e4aba31567
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/algorithm
@@ -0,0 +1,801 @@
+// -*- 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
+#define _LIBCPP_ALGORITHM
+
+/*
+ algorithm synopsis
+
+#include <initializer_list>
+
+namespace std
+{
+
+namespace ranges {
+ template <class I, class F>
+ struct in_fun_result; // since C++20
+
+ template <class I1, class I2>
+ struct in_in_result; // since C++20
+
+ template <class I1, class I2, class O>
+ struct in_in_out_result; // since C++20
+
+ template <class I, class O1, class O2>
+ struct in_out_out_result; // since C++20
+
+ template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
+ indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less> // since C++20
+ constexpr I min_element(I first, S last, Comp comp = {}, Proj proj = {});
+
+ template<forward_range R, class Proj = identity,
+ indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> // since C++20
+ constexpr borrowed_iterator_t<R> min_element(R&& r, Comp comp = {}, Proj proj = {});
+}
+
+template <class InputIterator, class Predicate>
+ constexpr bool // constexpr in C++20
+ all_of(InputIterator first, InputIterator last, Predicate pred);
+
+template <class InputIterator, class Predicate>
+ constexpr bool // constexpr in C++20
+ any_of(InputIterator first, InputIterator last, Predicate pred);
+
+template <class InputIterator, class Predicate>
+ constexpr bool // constexpr in C++20
+ none_of(InputIterator first, InputIterator last, Predicate pred);
+
+template <class InputIterator, class Function>
+ constexpr Function // constexpr in C++20
+ for_each(InputIterator first, InputIterator last, Function f);
+
+template<class InputIterator, class Size, class Function>
+ constexpr InputIterator // constexpr in C++20
+ for_each_n(InputIterator first, Size n, Function f); // C++17
+
+template <class InputIterator, class T>
+ constexpr InputIterator // constexpr in C++20
+ find(InputIterator first, InputIterator last, const T& value);
+
+template <class InputIterator, class Predicate>
+ constexpr InputIterator // constexpr in C++20
+ find_if(InputIterator first, InputIterator last, Predicate pred);
+
+template<class InputIterator, class Predicate>
+ constexpr InputIterator // constexpr in C++20
+ find_if_not(InputIterator first, InputIterator last, Predicate pred);
+
+template <class ForwardIterator1, class ForwardIterator2>
+ constexpr ForwardIterator1 // constexpr in C++20
+ find_end(ForwardIterator1 first1, ForwardIterator1 last1,
+ ForwardIterator2 first2, ForwardIterator2 last2);
+
+template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
+ constexpr ForwardIterator1 // constexpr in C++20
+ find_end(ForwardIterator1 first1, ForwardIterator1 last1,
+ ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
+
+template <class ForwardIterator1, class ForwardIterator2>
+ constexpr ForwardIterator1 // constexpr in C++20
+ find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
+ ForwardIterator2 first2, ForwardIterator2 last2);
+
+template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
+ constexpr ForwardIterator1 // constexpr in C++20
+ find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
+ ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
+
+template <class ForwardIterator>
+ constexpr ForwardIterator // constexpr in C++20
+ adjacent_find(ForwardIterator first, ForwardIterator last);
+
+template <class ForwardIterator, class BinaryPredicate>
+ constexpr ForwardIterator // constexpr in C++20
+ adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
+
+template <class InputIterator, class T>
+ constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
+ count(InputIterator first, InputIterator last, const T& value);
+
+template <class InputIterator, class Predicate>
+ constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
+ count_if(InputIterator first, InputIterator last, Predicate pred);
+
+template <class InputIterator1, class InputIterator2>
+ constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
+ mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
+
+template <class InputIterator1, class InputIterator2>
+ constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
+ mismatch(InputIterator1 first1, InputIterator1 last1,
+ InputIterator2 first2, InputIterator2 last2); // **C++14**
+
+template <class InputIterator1, class InputIterator2, class BinaryPredicate>
+ constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
+ mismatch(InputIterator1 first1, InputIterator1 last1,
+ InputIterator2 first2, BinaryPredicate pred);
+
+template <class InputIterator1, class InputIterator2, class BinaryPredicate>
+ constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
+ mismatch(InputIterator1 first1, InputIterator1 last1,
+ InputIterator2 first2, InputIterator2 last2,
+ BinaryPredicate pred); // **C++14**
+
+template <class InputIterator1, class InputIterator2>
+ constexpr bool // constexpr in C++20
+ equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
+
+template <class InputIterator1, class InputIterator2>
+ constexpr bool // constexpr in C++20
+ equal(InputIterator1 first1, InputIterator1 last1,
+ InputIterator2 first2, InputIterator2 last2); // **C++14**
+
+template <class InputIterator1, class InputIterator2, class BinaryPredicate>
+ constexpr bool // constexpr in C++20
+ equal(InputIterator1 first1, InputIterator1 last1,
+ InputIterator2 first2, BinaryPredicate pred);
+
+template <class InputIterator1, class InputIterator2, class BinaryPredicate>
+ constexpr bool // constexpr in C++20
+ equal(InputIterator1 first1, InputIterator1 last1,
+ InputIterator2 first2, InputIterator2 last2,
+ BinaryPredicate pred); // **C++14**
+
+template<class ForwardIterator1, class ForwardIterator2>
+ constexpr bool // constexpr in C++20
+ is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
+ ForwardIterator2 first2);
+
+template<class ForwardIterator1, class ForwardIterator2>
+ constexpr bool // constexpr in C++20
+ is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
+ ForwardIterator2 first2, ForwardIterator2 last2); // **C++14**
+
+template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
+ constexpr bool // constexpr in C++20
+ is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
+ ForwardIterator2 first2, BinaryPredicate pred);
+
+template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
+ constexpr bool // constexpr in C++20
+ is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
+ ForwardIterator2 first2, ForwardIterator2 last2,
+ BinaryPredicate pred); // **C++14**
+
+template <class ForwardIterator1, class ForwardIterator2>
+ constexpr ForwardIterator1 // constexpr in C++20
+ search(ForwardIterator1 first1, ForwardIterator1 last1,
+ ForwardIterator2 first2, ForwardIterator2 last2);
+
+template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
+ constexpr ForwardIterator1 // constexpr in C++20
+ search(ForwardIterator1 first1, ForwardIterator1 last1,
+ ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
+
+template <class ForwardIterator, class Size, class T>
+ constexpr ForwardIterator // constexpr in C++20
+ search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value);
+
+template <class ForwardIterator, class Size, class T, class BinaryPredicate>
+ constexpr ForwardIterator // constexpr in C++20
+ search_n(ForwardIterator first, ForwardIterator last,
+ Size count, const T& value, BinaryPredicate pred);
+
+template <class InputIterator, class OutputIterator>
+ constexpr OutputIterator // constexpr in C++20
+ copy(InputIterator first, InputIterator last, OutputIterator result);
+
+template<class InputIterator, class OutputIterator, class Predicate>
+ constexpr OutputIterator // constexpr in C++20
+ copy_if(InputIterator first, InputIterator last,
+ OutputIterator result, Predicate pred);
+
+template<class InputIterator, class Size, class OutputIterator>
+ constexpr OutputIterator // constexpr in C++20
+ copy_n(InputIterator first, Size n, OutputIterator result);
+
+template <class BidirectionalIterator1, class BidirectionalIterator2>
+ constexpr BidirectionalIterator2 // constexpr in C++20
+ copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
+ BidirectionalIterator2 result);
+
+template <class ForwardIterator1, class ForwardIterator2>
+ constexpr ForwardIterator2 // constexpr in C++20
+ swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2);
+
+template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2>
+ requires indirectly_swappable<I1, I2>
+ constexpr ranges::swap_ranges_result<I1, I2>
+ ranges::swap_ranges(I1 first1, S1 last1, I2 first2, S2 last2);
+
+template<input_range R1, input_range R2>
+ requires indirectly_swappable<iterator_t<R1>, iterator_t<R2>>
+ constexpr ranges::swap_ranges_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
+ ranges::swap_ranges(R1&& r1, R2&& r2);
+
+template <class ForwardIterator1, class ForwardIterator2>
+ constexpr void // constexpr in C++20
+ iter_swap(ForwardIterator1 a, ForwardIterator2 b);
+
+template <class InputIterator, class OutputIterator, class UnaryOperation>
+ constexpr OutputIterator // constexpr in C++20
+ transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op);
+
+template <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation>
+ constexpr OutputIterator // constexpr in C++20
+ transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
+ OutputIterator result, BinaryOperation binary_op);
+
+template <class ForwardIterator, class T>
+ constexpr void // constexpr in C++20
+ replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value);
+
+template <class ForwardIterator, class Predicate, class T>
+ constexpr void // constexpr in C++20
+ replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, const T& new_value);
+
+template <class InputIterator, class OutputIterator, class T>
+ constexpr OutputIterator // constexpr in C++20
+ replace_copy(InputIterator first, InputIterator last, OutputIterator result,
+ const T& old_value, const T& new_value);
+
+template <class InputIterator, class OutputIterator, class Predicate, class T>
+ constexpr OutputIterator // constexpr in C++20
+ replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T& new_value);
+
+template <class ForwardIterator, class T>
+ constexpr void // constexpr in C++20
+ fill(ForwardIterator first, ForwardIterator last, const T& value);
+
+template <class OutputIterator, class Size, class T>
+ constexpr OutputIterator // constexpr in C++20
+ fill_n(OutputIterator first, Size n, const T& value);
+
+template <class ForwardIterator, class Generator>
+ constexpr void // constexpr in C++20
+ generate(ForwardIterator first, ForwardIterator last, Generator gen);
+
+template <class OutputIterator, class Size, class Generator>
+ constexpr OutputIterator // constexpr in C++20
+ generate_n(OutputIterator first, Size n, Generator gen);
+
+template <class ForwardIterator, class T>
+ constexpr ForwardIterator // constexpr in C++20
+ remove(ForwardIterator first, ForwardIterator last, const T& value);
+
+template <class ForwardIterator, class Predicate>
+ constexpr ForwardIterator // constexpr in C++20
+ remove_if(ForwardIterator first, ForwardIterator last, Predicate pred);
+
+template <class InputIterator, class OutputIterator, class T>
+ constexpr OutputIterator // constexpr in C++20
+ remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value);
+
+template <class InputIterator, class OutputIterator, class Predicate>
+ constexpr OutputIterator // constexpr in C++20
+ remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred);
+
+template <class ForwardIterator>
+ constexpr ForwardIterator // constexpr in C++20
+ unique(ForwardIterator first, ForwardIterator last);
+
+template <class ForwardIterator, class BinaryPredicate>
+ constexpr ForwardIterator // constexpr in C++20
+ unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
+
+template <class InputIterator, class OutputIterator>
+ constexpr OutputIterator // constexpr in C++20
+ unique_copy(InputIterator first, InputIterator last, OutputIterator result);
+
+template <class InputIterator, class OutputIterator, class BinaryPredicate>
+ constexpr OutputIterator // constexpr in C++20
+ unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred);
+
+template <class BidirectionalIterator>
+ constexpr void // constexpr in C++20
+ reverse(BidirectionalIterator first, BidirectionalIterator last);
+
+template <class BidirectionalIterator, class OutputIterator>
+ constexpr OutputIterator // constexpr in C++20
+ reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result);
+
+template <class ForwardIterator>
+ constexpr ForwardIterator // constexpr in C++20
+ rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last);
+
+template <class ForwardIterator, class OutputIterator>
+ constexpr OutputIterator // constexpr in C++20
+ rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result);
+
+template <class RandomAccessIterator>
+ void
+ random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14, removed in C++17
+
+template <class RandomAccessIterator, class RandomNumberGenerator>
+ void
+ random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
+ RandomNumberGenerator& rand); // deprecated in C++14, removed in C++17
+
+template<class PopulationIterator, class SampleIterator,
+ class Distance, class UniformRandomBitGenerator>
+ SampleIterator sample(PopulationIterator first, PopulationIterator last,
+ SampleIterator out, Distance n,
+ UniformRandomBitGenerator&& g); // C++17
+
+template<class RandomAccessIterator, class UniformRandomNumberGenerator>
+ void shuffle(RandomAccessIterator first, RandomAccessIterator last,
+ UniformRandomNumberGenerator&& g);
+
+template<class ForwardIterator>
+ constexpr ForwardIterator
+ shift_left(ForwardIterator first, ForwardIterator last,
+ typename iterator_traits<ForwardIterator>::difference_type n); // C++20
+
+template<class ForwardIterator>
+ constexpr ForwardIterator
+ shift_right(ForwardIterator first, ForwardIterator last,
+ typename iterator_traits<ForwardIterator>::difference_type n); // C++20
+
+template <class InputIterator, class Predicate>
+ constexpr bool // constexpr in C++20
+ is_partitioned(InputIterator first, InputIterator last, Predicate pred);
+
+template <class ForwardIterator, class Predicate>
+ constexpr ForwardIterator // constexpr in C++20
+ partition(ForwardIterator first, ForwardIterator last, Predicate pred);
+
+template <class InputIterator, class OutputIterator1,
+ class OutputIterator2, class Predicate>
+ constexpr pair<OutputIterator1, OutputIterator2> // constexpr in C++20
+ partition_copy(InputIterator first, InputIterator last,
+ OutputIterator1 out_true, OutputIterator2 out_false,
+ Predicate pred);
+
+template <class ForwardIterator, class Predicate>
+ ForwardIterator
+ stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred);
+
+template<class ForwardIterator, class Predicate>
+ constexpr ForwardIterator // constexpr in C++20
+ partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
+
+template <class ForwardIterator>
+ constexpr bool // constexpr in C++20
+ is_sorted(ForwardIterator first, ForwardIterator last);
+
+template <class ForwardIterator, class Compare>
+ constexpr bool // constexpr in C++20
+ is_sorted(ForwardIterator first, ForwardIterator last, Compare comp);
+
+template<class ForwardIterator>
+ constexpr ForwardIterator // constexpr in C++20
+ is_sorted_until(ForwardIterator first, ForwardIterator last);
+
+template <class ForwardIterator, class Compare>
+ constexpr ForwardIterator // constexpr in C++20
+ is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp);
+
+template <class RandomAccessIterator>
+ constexpr void // constexpr in C++20
+ sort(RandomAccessIterator first, RandomAccessIterator last);
+
+template <class RandomAccessIterator, class Compare>
+ constexpr void // constexpr in C++20
+ sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
+
+template <class RandomAccessIterator>
+ void
+ stable_sort(RandomAccessIterator first, RandomAccessIterator last);
+
+template <class RandomAccessIterator, class Compare>
+ void
+ stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
+
+template <class RandomAccessIterator>
+ constexpr void // constexpr in C++20
+ partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last);
+
+template <class RandomAccessIterator, class Compare>
+ constexpr void // constexpr in C++20
+ partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp);
+
+template <class InputIterator, class 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>
+ constexpr RandomAccessIterator // constexpr in C++20
+ partial_sort_copy(InputIterator first, InputIterator last,
+ RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp);
+
+template <class RandomAccessIterator>
+ constexpr void // constexpr in C++20
+ nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last);
+
+template <class RandomAccessIterator, class Compare>
+ constexpr void // constexpr in C++20
+ nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp);
+
+template <class ForwardIterator, class T>
+ constexpr ForwardIterator // constexpr in C++20
+ lower_bound(ForwardIterator first, ForwardIterator last, const T& value);
+
+template <class ForwardIterator, class T, class Compare>
+ constexpr ForwardIterator // constexpr in C++20
+ lower_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
+
+template <class ForwardIterator, class T>
+ constexpr ForwardIterator // constexpr in C++20
+ upper_bound(ForwardIterator first, ForwardIterator last, const T& value);
+
+template <class ForwardIterator, class T, class Compare>
+ constexpr ForwardIterator // constexpr in C++20
+ upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
+
+template <class ForwardIterator, class T>
+ constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
+ equal_range(ForwardIterator first, ForwardIterator last, const T& value);
+
+template <class ForwardIterator, class T, class Compare>
+ constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
+ equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
+
+template <class ForwardIterator, class T>
+ constexpr bool // constexpr in C++20
+ binary_search(ForwardIterator first, ForwardIterator last, const T& value);
+
+template <class ForwardIterator, class T, class Compare>
+ constexpr bool // constexpr in C++20
+ binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
+
+template <class InputIterator1, class InputIterator2, class OutputIterator>
+ constexpr OutputIterator // constexpr in C++20
+ merge(InputIterator1 first1, InputIterator1 last1,
+ InputIterator2 first2, InputIterator2 last2, OutputIterator result);
+
+template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
+ constexpr OutputIterator // constexpr in C++20
+ merge(InputIterator1 first1, InputIterator1 last1,
+ InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
+
+template <class BidirectionalIterator>
+ void
+ inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last);
+
+template <class BidirectionalIterator, class Compare>
+ void
+ inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, Compare comp);
+
+template <class InputIterator1, class InputIterator2>
+ constexpr bool // constexpr in C++20
+ includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
+
+template <class InputIterator1, class InputIterator2, class Compare>
+ constexpr bool // constexpr in C++20
+ includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp);
+
+template <class InputIterator1, class InputIterator2, class OutputIterator>
+ constexpr OutputIterator // constexpr in C++20
+ set_union(InputIterator1 first1, InputIterator1 last1,
+ InputIterator2 first2, InputIterator2 last2, OutputIterator result);
+
+template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
+ constexpr OutputIterator // constexpr in C++20
+ set_union(InputIterator1 first1, InputIterator1 last1,
+ InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
+
+template <class InputIterator1, class InputIterator2, class OutputIterator>
+ constexpr OutputIterator // constexpr in C++20
+ set_intersection(InputIterator1 first1, InputIterator1 last1,
+ InputIterator2 first2, InputIterator2 last2, OutputIterator result);
+
+template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
+ constexpr OutputIterator // constexpr in C++20
+ set_intersection(InputIterator1 first1, InputIterator1 last1,
+ InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
+
+template <class InputIterator1, class InputIterator2, class OutputIterator>
+ constexpr OutputIterator // constexpr in C++20
+ set_difference(InputIterator1 first1, InputIterator1 last1,
+ InputIterator2 first2, InputIterator2 last2, OutputIterator result);
+
+template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
+ constexpr OutputIterator // constexpr in C++20
+ set_difference(InputIterator1 first1, InputIterator1 last1,
+ InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
+
+template <class InputIterator1, class InputIterator2, class OutputIterator>
+ constexpr OutputIterator // constexpr in C++20
+ set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
+ InputIterator2 first2, InputIterator2 last2, OutputIterator result);
+
+template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
+ constexpr OutputIterator // constexpr in C++20
+ set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
+ InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
+
+template <class RandomAccessIterator>
+ constexpr void // constexpr in C++20
+ push_heap(RandomAccessIterator first, RandomAccessIterator last);
+
+template <class RandomAccessIterator, class Compare>
+ constexpr void // constexpr in C++20
+ push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
+
+template <class RandomAccessIterator>
+ constexpr void // constexpr in C++20
+ pop_heap(RandomAccessIterator first, RandomAccessIterator last);
+
+template <class RandomAccessIterator, class Compare>
+ constexpr void // constexpr in C++20
+ pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
+
+template <class RandomAccessIterator>
+ constexpr void // constexpr in C++20
+ make_heap(RandomAccessIterator first, RandomAccessIterator last);
+
+template <class RandomAccessIterator, class Compare>
+ constexpr void // constexpr in C++20
+ make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
+
+template <class RandomAccessIterator>
+ constexpr void // constexpr in C++20
+ sort_heap(RandomAccessIterator first, RandomAccessIterator last);
+
+template <class RandomAccessIterator, class Compare>
+ constexpr void // constexpr in C++20
+ sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
+
+template <class RandomAccessIterator>
+ constexpr bool // constexpr in C++20
+ is_heap(RandomAccessIterator first, RandomAccessiterator last);
+
+template <class RandomAccessIterator, class Compare>
+ constexpr bool // constexpr in C++20
+ is_heap(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
+
+template <class RandomAccessIterator>
+ constexpr RandomAccessIterator // constexpr in C++20
+ is_heap_until(RandomAccessIterator first, RandomAccessiterator last);
+
+template <class RandomAccessIterator, class Compare>
+ constexpr RandomAccessIterator // constexpr in C++20
+ is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
+
+template <class ForwardIterator>
+ constexpr ForwardIterator // constexpr in C++14
+ min_element(ForwardIterator first, ForwardIterator last);
+
+template <class ForwardIterator, class Compare>
+ constexpr ForwardIterator // constexpr in C++14
+ min_element(ForwardIterator first, ForwardIterator last, Compare comp);
+
+template <class T>
+ constexpr const T& // constexpr in C++14
+ min(const T& a, const T& b);
+
+template <class T, class Compare>
+ constexpr const T& // constexpr in C++14
+ min(const T& a, const T& b, Compare comp);
+
+template<class T>
+ constexpr T // constexpr in C++14
+ min(initializer_list<T> t);
+
+template<class T, class Compare>
+ constexpr T // constexpr in C++14
+ min(initializer_list<T> t, Compare comp);
+
+template<class T>
+ constexpr const T& clamp(const T& v, const T& lo, const T& hi); // C++17
+
+template<class T, class Compare>
+ constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); // C++17
+
+template <class ForwardIterator>
+ constexpr ForwardIterator // constexpr in C++14
+ max_element(ForwardIterator first, ForwardIterator last);
+
+template <class ForwardIterator, class Compare>
+ constexpr ForwardIterator // constexpr in C++14
+ max_element(ForwardIterator first, ForwardIterator last, Compare comp);
+
+template <class T>
+ constexpr const T& // constexpr in C++14
+ max(const T& a, const T& b);
+
+template <class T, class Compare>
+ constexpr const T& // constexpr in C++14
+ max(const T& a, const T& b, Compare comp);
+
+template<class T>
+ constexpr T // constexpr in C++14
+ max(initializer_list<T> t);
+
+template<class T, class Compare>
+ constexpr T // constexpr in C++14
+ max(initializer_list<T> t, Compare comp);
+
+template<class ForwardIterator>
+ constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
+ minmax_element(ForwardIterator first, ForwardIterator last);
+
+template<class ForwardIterator, class Compare>
+ constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
+ minmax_element(ForwardIterator first, ForwardIterator last, Compare comp);
+
+template<class T>
+ constexpr pair<const T&, const T&> // constexpr in C++14
+ minmax(const T& a, const T& b);
+
+template<class T, class Compare>
+ constexpr pair<const T&, const T&> // constexpr in C++14
+ minmax(const T& a, const T& b, Compare comp);
+
+template<class T>
+ constexpr pair<T, T> // constexpr in C++14
+ minmax(initializer_list<T> t);
+
+template<class T, class Compare>
+ constexpr pair<T, T> // constexpr in C++14
+ minmax(initializer_list<T> t, Compare comp);
+
+template <class InputIterator1, class InputIterator2>
+ constexpr bool // constexpr in C++20
+ lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
+
+template <class InputIterator1, class InputIterator2, class Compare>
+ constexpr bool // constexpr in C++20
+ lexicographical_compare(InputIterator1 first1, InputIterator1 last1,
+ InputIterator2 first2, InputIterator2 last2, Compare comp);
+
+template <class BidirectionalIterator>
+ constexpr bool // constexpr in C++20
+ next_permutation(BidirectionalIterator first, BidirectionalIterator last);
+
+template <class BidirectionalIterator, class Compare>
+ constexpr bool // constexpr in C++20
+ next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
+
+template <class BidirectionalIterator>
+ constexpr bool // constexpr in C++20
+ prev_permutation(BidirectionalIterator first, BidirectionalIterator last);
+
+template <class BidirectionalIterator, class Compare>
+ constexpr bool // constexpr in C++20
+ prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
+} // std
+
+*/
+
+#include <__bits>
+#include <__config>
+#include <__debug>
+#include <cstddef>
+#include <cstring>
+#include <functional>
+#include <initializer_list>
+#include <iterator>
+#include <memory>
+#include <type_traits>
+#include <utility>
+#include <version>
+
+#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.h>
+#include <__algorithm/fill_n.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.h>
+#include <__algorithm/generate_n.h>
+#include <__algorithm/half_positive.h>
+#include <__algorithm/in_fun_result.h>
+#include <__algorithm/in_in_out_result.h>
+#include <__algorithm/in_in_result.h>
+#include <__algorithm/in_out_out_result.h>
+#include <__algorithm/in_out_result.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/ranges_min_element.h>
+#include <__algorithm/ranges_swap_ranges.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.h>
+#include <__algorithm/unique_copy.h>
+#include <__algorithm/unwrap_iter.h>
+#include <__algorithm/upper_bound.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
+//# include <__pstl_algorithm>
+#endif
+
+#endif // _LIBCPP_ALGORITHM
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/any b/contrib/libs/cxxsupp/libcxxmsvc/include/any
new file mode 100644
index 0000000000..2a85a66c29
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/any
@@ -0,0 +1,686 @@
+// -*- 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_ANY
+#define _LIBCPP_ANY
+
+/*
+ any synopsis
+
+namespace std {
+
+ class bad_any_cast : public bad_cast
+ {
+ public:
+ virtual const char* what() const noexcept;
+ };
+
+ class any
+ {
+ public:
+
+ // 6.3.1 any construct/destruct
+ any() noexcept;
+
+ any(const any& other);
+ any(any&& other) noexcept;
+
+ template <class ValueType>
+ any(ValueType&& value);
+
+ ~any();
+
+ // 6.3.2 any assignments
+ any& operator=(const any& rhs);
+ any& operator=(any&& rhs) noexcept;
+
+ template <class ValueType>
+ any& operator=(ValueType&& rhs);
+
+ // 6.3.3 any modifiers
+ template <class ValueType, class... Args>
+ decay_t<ValueType>& emplace(Args&&... args);
+ template <class ValueType, class U, class... Args>
+ decay_t<ValueType>& emplace(initializer_list<U>, Args&&...);
+ void reset() noexcept;
+ void swap(any& rhs) noexcept;
+
+ // 6.3.4 any observers
+ bool has_value() const noexcept;
+ const type_info& type() const noexcept;
+ };
+
+ // 6.4 Non-member functions
+ void swap(any& x, any& y) noexcept;
+
+ template <class T, class ...Args>
+ any make_any(Args&& ...args);
+ template <class T, class U, class ...Args>
+ any make_any(initializer_list<U>, Args&& ...args);
+
+ template<class ValueType>
+ ValueType any_cast(const any& operand);
+ template<class ValueType>
+ ValueType any_cast(any& operand);
+ template<class ValueType>
+ ValueType any_cast(any&& operand);
+
+ template<class ValueType>
+ const ValueType* any_cast(const any* operand) noexcept;
+ template<class ValueType>
+ ValueType* any_cast(any* operand) noexcept;
+
+} // namespace std
+
+*/
+
+#include <__availability>
+#include <__config>
+#include <__utility/forward.h>
+#include <cstdlib>
+#include <memory>
+#include <type_traits>
+#include <typeinfo>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+namespace std {
+class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : public bad_cast
+{
+public:
+ virtual const char* what() const _NOEXCEPT;
+};
+} // namespace std
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 14
+
+_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
+void __throw_bad_any_cast()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw bad_any_cast();
+#else
+ _VSTD::abort();
+#endif
+}
+
+// Forward declarations
+class _LIBCPP_TEMPLATE_VIS any;
+
+template <class _ValueType>
+_LIBCPP_INLINE_VISIBILITY
+add_pointer_t<add_const_t<_ValueType>>
+any_cast(any const *) _NOEXCEPT;
+
+template <class _ValueType>
+_LIBCPP_INLINE_VISIBILITY
+add_pointer_t<_ValueType> any_cast(any *) _NOEXCEPT;
+
+namespace __any_imp
+{
+ using _Buffer = aligned_storage_t<3*sizeof(void*), alignment_of<void*>::value>;
+
+ template <class _Tp>
+ using _IsSmallObject = integral_constant<bool
+ , sizeof(_Tp) <= sizeof(_Buffer)
+ && alignment_of<_Buffer>::value
+ % alignment_of<_Tp>::value == 0
+ && is_nothrow_move_constructible<_Tp>::value
+ >;
+
+ enum class _Action {
+ _Destroy,
+ _Copy,
+ _Move,
+ _Get,
+ _TypeInfo
+ };
+
+ template <class _Tp> struct _SmallHandler;
+ template <class _Tp> struct _LargeHandler;
+
+ template <class _Tp>
+ struct _LIBCPP_TEMPLATE_VIS __unique_typeinfo { static constexpr int __id = 0; };
+ template <class _Tp> constexpr int __unique_typeinfo<_Tp>::__id;
+
+ template <class _Tp>
+ inline _LIBCPP_INLINE_VISIBILITY
+ constexpr const void* __get_fallback_typeid() {
+ return &__unique_typeinfo<remove_cv_t<remove_reference_t<_Tp>>>::__id;
+ }
+
+ template <class _Tp>
+ inline _LIBCPP_INLINE_VISIBILITY
+ bool __compare_typeid(type_info const* __id, const void* __fallback_id)
+ {
+#if !defined(_LIBCPP_NO_RTTI)
+ if (__id && *__id == typeid(_Tp))
+ return true;
+#endif
+ if (!__id && __fallback_id == __any_imp::__get_fallback_typeid<_Tp>())
+ return true;
+ return false;
+ }
+
+ template <class _Tp>
+ using _Handler = conditional_t<
+ _IsSmallObject<_Tp>::value, _SmallHandler<_Tp>, _LargeHandler<_Tp>>;
+
+} // namespace __any_imp
+
+class _LIBCPP_TEMPLATE_VIS any
+{
+public:
+ // construct/destruct
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr any() _NOEXCEPT : __h(nullptr) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ any(any const & __other) : __h(nullptr)
+ {
+ if (__other.__h) __other.__call(_Action::_Copy, this);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ any(any && __other) _NOEXCEPT : __h(nullptr)
+ {
+ if (__other.__h) __other.__call(_Action::_Move, this);
+ }
+
+ template <
+ class _ValueType
+ , class _Tp = decay_t<_ValueType>
+ , class = enable_if_t<
+ !is_same<_Tp, any>::value &&
+ !__is_inplace_type<_ValueType>::value &&
+ is_copy_constructible<_Tp>::value>
+ >
+ _LIBCPP_INLINE_VISIBILITY
+ any(_ValueType && __value);
+
+ template <class _ValueType, class ..._Args,
+ class _Tp = decay_t<_ValueType>,
+ class = enable_if_t<
+ is_constructible<_Tp, _Args...>::value &&
+ is_copy_constructible<_Tp>::value
+ >
+ >
+ _LIBCPP_INLINE_VISIBILITY
+ explicit any(in_place_type_t<_ValueType>, _Args&&... __args);
+
+ template <class _ValueType, class _Up, class ..._Args,
+ class _Tp = decay_t<_ValueType>,
+ class = enable_if_t<
+ is_constructible<_Tp, initializer_list<_Up>&, _Args...>::value &&
+ is_copy_constructible<_Tp>::value>
+ >
+ _LIBCPP_INLINE_VISIBILITY
+ explicit any(in_place_type_t<_ValueType>, initializer_list<_Up>, _Args&&... __args);
+
+ _LIBCPP_INLINE_VISIBILITY
+ ~any() { this->reset(); }
+
+ // assignments
+ _LIBCPP_INLINE_VISIBILITY
+ any & operator=(any const & __rhs) {
+ any(__rhs).swap(*this);
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ any & operator=(any && __rhs) _NOEXCEPT {
+ any(_VSTD::move(__rhs)).swap(*this);
+ return *this;
+ }
+
+ template <
+ class _ValueType
+ , class _Tp = decay_t<_ValueType>
+ , class = enable_if_t<
+ !is_same<_Tp, any>::value
+ && is_copy_constructible<_Tp>::value>
+ >
+ _LIBCPP_INLINE_VISIBILITY
+ any & operator=(_ValueType && __rhs);
+
+ template <class _ValueType, class ..._Args,
+ class _Tp = decay_t<_ValueType>,
+ class = enable_if_t<
+ is_constructible<_Tp, _Args...>::value &&
+ is_copy_constructible<_Tp>::value>
+ >
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp& emplace(_Args&&... args);
+
+ template <class _ValueType, class _Up, class ..._Args,
+ class _Tp = decay_t<_ValueType>,
+ class = enable_if_t<
+ is_constructible<_Tp, initializer_list<_Up>&, _Args...>::value &&
+ is_copy_constructible<_Tp>::value>
+ >
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp& emplace(initializer_list<_Up>, _Args&&...);
+
+ // 6.3.3 any modifiers
+ _LIBCPP_INLINE_VISIBILITY
+ void reset() _NOEXCEPT { if (__h) this->__call(_Action::_Destroy); }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(any & __rhs) _NOEXCEPT;
+
+ // 6.3.4 any observers
+ _LIBCPP_INLINE_VISIBILITY
+ bool has_value() const _NOEXCEPT { return __h != nullptr; }
+
+#if !defined(_LIBCPP_NO_RTTI)
+ _LIBCPP_INLINE_VISIBILITY
+ const type_info & type() const _NOEXCEPT {
+ if (__h) {
+ return *static_cast<type_info const *>(this->__call(_Action::_TypeInfo));
+ } else {
+ return typeid(void);
+ }
+ }
+#endif
+
+private:
+ typedef __any_imp::_Action _Action;
+ using _HandleFuncPtr = void* (*)(_Action, any const *, any *, const type_info *,
+ const void* __fallback_info);
+
+ union _Storage {
+ constexpr _Storage() : __ptr(nullptr) {}
+ void * __ptr;
+ __any_imp::_Buffer __buf;
+ };
+
+ _LIBCPP_INLINE_VISIBILITY
+ void * __call(_Action __a, any * __other = nullptr,
+ type_info const * __info = nullptr,
+ const void* __fallback_info = nullptr) const
+ {
+ return __h(__a, this, __other, __info, __fallback_info);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void * __call(_Action __a, any * __other = nullptr,
+ type_info const * __info = nullptr,
+ const void* __fallback_info = nullptr)
+ {
+ return __h(__a, this, __other, __info, __fallback_info);
+ }
+
+ template <class>
+ friend struct __any_imp::_SmallHandler;
+ template <class>
+ friend struct __any_imp::_LargeHandler;
+
+ template <class _ValueType>
+ friend add_pointer_t<add_const_t<_ValueType>>
+ any_cast(any const *) _NOEXCEPT;
+
+ template <class _ValueType>
+ friend add_pointer_t<_ValueType>
+ any_cast(any *) _NOEXCEPT;
+
+ _HandleFuncPtr __h = nullptr;
+ _Storage __s;
+};
+
+namespace __any_imp
+{
+ template <class _Tp>
+ struct _LIBCPP_TEMPLATE_VIS _SmallHandler
+ {
+ _LIBCPP_INLINE_VISIBILITY
+ static void* __handle(_Action __act, any const * __this, any * __other,
+ type_info const * __info, const void* __fallback_info)
+ {
+ switch (__act)
+ {
+ case _Action::_Destroy:
+ __destroy(const_cast<any &>(*__this));
+ return nullptr;
+ case _Action::_Copy:
+ __copy(*__this, *__other);
+ return nullptr;
+ case _Action::_Move:
+ __move(const_cast<any &>(*__this), *__other);
+ return nullptr;
+ case _Action::_Get:
+ return __get(const_cast<any &>(*__this), __info, __fallback_info);
+ case _Action::_TypeInfo:
+ return __type_info();
+ }
+ }
+
+ template <class ..._Args>
+ _LIBCPP_INLINE_VISIBILITY
+ static _Tp& __create(any & __dest, _Args&&... __args) {
+ typedef allocator<_Tp> _Alloc;
+ typedef allocator_traits<_Alloc> _ATraits;
+ _Alloc __a;
+ _Tp * __ret = static_cast<_Tp*>(static_cast<void*>(&__dest.__s.__buf));
+ _ATraits::construct(__a, __ret, _VSTD::forward<_Args>(__args)...);
+ __dest.__h = &_SmallHandler::__handle;
+ return *__ret;
+ }
+
+ private:
+ _LIBCPP_INLINE_VISIBILITY
+ static void __destroy(any & __this) {
+ typedef allocator<_Tp> _Alloc;
+ typedef allocator_traits<_Alloc> _ATraits;
+ _Alloc __a;
+ _Tp * __p = static_cast<_Tp *>(static_cast<void*>(&__this.__s.__buf));
+ _ATraits::destroy(__a, __p);
+ __this.__h = nullptr;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ static void __copy(any const & __this, any & __dest) {
+ _SmallHandler::__create(__dest, *static_cast<_Tp const *>(
+ static_cast<void const *>(&__this.__s.__buf)));
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ static void __move(any & __this, any & __dest) {
+ _SmallHandler::__create(__dest, _VSTD::move(
+ *static_cast<_Tp*>(static_cast<void*>(&__this.__s.__buf))));
+ __destroy(__this);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ static void* __get(any & __this,
+ type_info const * __info,
+ const void* __fallback_id)
+ {
+ if (__any_imp::__compare_typeid<_Tp>(__info, __fallback_id))
+ return static_cast<void*>(&__this.__s.__buf);
+ return nullptr;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ static void* __type_info()
+ {
+#if !defined(_LIBCPP_NO_RTTI)
+ return const_cast<void*>(static_cast<void const *>(&typeid(_Tp)));
+#else
+ return nullptr;
+#endif
+ }
+ };
+
+ template <class _Tp>
+ struct _LIBCPP_TEMPLATE_VIS _LargeHandler
+ {
+ _LIBCPP_INLINE_VISIBILITY
+ static void* __handle(_Action __act, any const * __this,
+ any * __other, type_info const * __info,
+ void const* __fallback_info)
+ {
+ switch (__act)
+ {
+ case _Action::_Destroy:
+ __destroy(const_cast<any &>(*__this));
+ return nullptr;
+ case _Action::_Copy:
+ __copy(*__this, *__other);
+ return nullptr;
+ case _Action::_Move:
+ __move(const_cast<any &>(*__this), *__other);
+ return nullptr;
+ case _Action::_Get:
+ return __get(const_cast<any &>(*__this), __info, __fallback_info);
+ case _Action::_TypeInfo:
+ return __type_info();
+ }
+ }
+
+ template <class ..._Args>
+ _LIBCPP_INLINE_VISIBILITY
+ static _Tp& __create(any & __dest, _Args&&... __args) {
+ typedef allocator<_Tp> _Alloc;
+ typedef allocator_traits<_Alloc> _ATraits;
+ typedef __allocator_destructor<_Alloc> _Dp;
+ _Alloc __a;
+ unique_ptr<_Tp, _Dp> __hold(_ATraits::allocate(__a, 1), _Dp(__a, 1));
+ _Tp * __ret = __hold.get();
+ _ATraits::construct(__a, __ret, _VSTD::forward<_Args>(__args)...);
+ __dest.__s.__ptr = __hold.release();
+ __dest.__h = &_LargeHandler::__handle;
+ return *__ret;
+ }
+
+ private:
+
+ _LIBCPP_INLINE_VISIBILITY
+ static void __destroy(any & __this){
+ typedef allocator<_Tp> _Alloc;
+ typedef allocator_traits<_Alloc> _ATraits;
+ _Alloc __a;
+ _Tp * __p = static_cast<_Tp *>(__this.__s.__ptr);
+ _ATraits::destroy(__a, __p);
+ _ATraits::deallocate(__a, __p, 1);
+ __this.__h = nullptr;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ static void __copy(any const & __this, any & __dest) {
+ _LargeHandler::__create(__dest, *static_cast<_Tp const *>(__this.__s.__ptr));
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ static void __move(any & __this, any & __dest) {
+ __dest.__s.__ptr = __this.__s.__ptr;
+ __dest.__h = &_LargeHandler::__handle;
+ __this.__h = nullptr;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ static void* __get(any & __this, type_info const * __info,
+ void const* __fallback_info)
+ {
+ if (__any_imp::__compare_typeid<_Tp>(__info, __fallback_info))
+ return static_cast<void*>(__this.__s.__ptr);
+ return nullptr;
+
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ static void* __type_info()
+ {
+#if !defined(_LIBCPP_NO_RTTI)
+ return const_cast<void*>(static_cast<void const *>(&typeid(_Tp)));
+#else
+ return nullptr;
+#endif
+ }
+ };
+
+} // namespace __any_imp
+
+
+template <class _ValueType, class _Tp, class>
+any::any(_ValueType && __v) : __h(nullptr)
+{
+ __any_imp::_Handler<_Tp>::__create(*this, _VSTD::forward<_ValueType>(__v));
+}
+
+template <class _ValueType, class ..._Args, class _Tp, class>
+any::any(in_place_type_t<_ValueType>, _Args&&... __args) {
+ __any_imp::_Handler<_Tp>::__create(*this, _VSTD::forward<_Args>(__args)...);
+}
+
+template <class _ValueType, class _Up, class ..._Args, class _Tp, class>
+any::any(in_place_type_t<_ValueType>, initializer_list<_Up> __il, _Args&&... __args) {
+ __any_imp::_Handler<_Tp>::__create(*this, __il, _VSTD::forward<_Args>(__args)...);
+}
+
+template <class _ValueType, class, class>
+inline _LIBCPP_INLINE_VISIBILITY
+any & any::operator=(_ValueType && __v)
+{
+ any(_VSTD::forward<_ValueType>(__v)).swap(*this);
+ return *this;
+}
+
+template <class _ValueType, class ..._Args, class _Tp, class>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp& any::emplace(_Args&&... __args) {
+ reset();
+ return __any_imp::_Handler<_Tp>::__create(*this, _VSTD::forward<_Args>(__args)...);
+}
+
+template <class _ValueType, class _Up, class ..._Args, class _Tp, class>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp& any::emplace(initializer_list<_Up> __il, _Args&&... __args) {
+ reset();
+ return __any_imp::_Handler<_Tp>::__create(*this, __il, _VSTD::forward<_Args>(__args)...);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void any::swap(any & __rhs) _NOEXCEPT
+{
+ if (this == &__rhs)
+ return;
+ if (__h && __rhs.__h) {
+ any __tmp;
+ __rhs.__call(_Action::_Move, &__tmp);
+ this->__call(_Action::_Move, &__rhs);
+ __tmp.__call(_Action::_Move, this);
+ }
+ else if (__h) {
+ this->__call(_Action::_Move, &__rhs);
+ }
+ else if (__rhs.__h) {
+ __rhs.__call(_Action::_Move, this);
+ }
+}
+
+// 6.4 Non-member functions
+
+inline _LIBCPP_INLINE_VISIBILITY
+void swap(any & __lhs, any & __rhs) _NOEXCEPT
+{
+ __lhs.swap(__rhs);
+}
+
+template <class _Tp, class ..._Args>
+inline _LIBCPP_INLINE_VISIBILITY
+any make_any(_Args&&... __args) {
+ return any(in_place_type<_Tp>, _VSTD::forward<_Args>(__args)...);
+}
+
+template <class _Tp, class _Up, class ..._Args>
+inline _LIBCPP_INLINE_VISIBILITY
+any make_any(initializer_list<_Up> __il, _Args&&... __args) {
+ return any(in_place_type<_Tp>, __il, _VSTD::forward<_Args>(__args)...);
+}
+
+template <class _ValueType>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
+_ValueType any_cast(any const & __v)
+{
+ using _RawValueType = __uncvref_t<_ValueType>;
+ static_assert(is_constructible<_ValueType, _RawValueType const &>::value,
+ "ValueType is required to be a const lvalue reference "
+ "or a CopyConstructible type");
+ auto __tmp = _VSTD::any_cast<add_const_t<_RawValueType>>(&__v);
+ if (__tmp == nullptr)
+ __throw_bad_any_cast();
+ return static_cast<_ValueType>(*__tmp);
+}
+
+template <class _ValueType>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
+_ValueType any_cast(any & __v)
+{
+ using _RawValueType = __uncvref_t<_ValueType>;
+ static_assert(is_constructible<_ValueType, _RawValueType &>::value,
+ "ValueType is required to be an lvalue reference "
+ "or a CopyConstructible type");
+ auto __tmp = _VSTD::any_cast<_RawValueType>(&__v);
+ if (__tmp == nullptr)
+ __throw_bad_any_cast();
+ return static_cast<_ValueType>(*__tmp);
+}
+
+template <class _ValueType>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
+_ValueType any_cast(any && __v)
+{
+ using _RawValueType = __uncvref_t<_ValueType>;
+ static_assert(is_constructible<_ValueType, _RawValueType>::value,
+ "ValueType is required to be an rvalue reference "
+ "or a CopyConstructible type");
+ auto __tmp = _VSTD::any_cast<_RawValueType>(&__v);
+ if (__tmp == nullptr)
+ __throw_bad_any_cast();
+ return static_cast<_ValueType>(_VSTD::move(*__tmp));
+}
+
+template <class _ValueType>
+inline _LIBCPP_INLINE_VISIBILITY
+add_pointer_t<add_const_t<_ValueType>>
+any_cast(any const * __any) _NOEXCEPT
+{
+ static_assert(!is_reference<_ValueType>::value,
+ "_ValueType may not be a reference.");
+ return _VSTD::any_cast<_ValueType>(const_cast<any *>(__any));
+}
+
+template <class _RetType>
+inline _LIBCPP_INLINE_VISIBILITY
+_RetType __pointer_or_func_cast(void* __p, /*IsFunction*/false_type) noexcept {
+ return static_cast<_RetType>(__p);
+}
+
+template <class _RetType>
+inline _LIBCPP_INLINE_VISIBILITY
+_RetType __pointer_or_func_cast(void*, /*IsFunction*/true_type) noexcept {
+ return nullptr;
+}
+
+template <class _ValueType>
+add_pointer_t<_ValueType>
+any_cast(any * __any) _NOEXCEPT
+{
+ using __any_imp::_Action;
+ static_assert(!is_reference<_ValueType>::value,
+ "_ValueType may not be a reference.");
+ typedef typename add_pointer<_ValueType>::type _ReturnType;
+ if (__any && __any->__h) {
+ void *__p = __any->__call(_Action::_Get, nullptr,
+#if !defined(_LIBCPP_NO_RTTI)
+ &typeid(_ValueType),
+#else
+ nullptr,
+#endif
+ __any_imp::__get_fallback_typeid<_ValueType>());
+ return _VSTD::__pointer_or_func_cast<_ReturnType>(
+ __p, is_function<_ValueType>{});
+ }
+ return nullptr;
+}
+
+#endif // _LIBCPP_STD_VER > 14
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_ANY
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/array b/contrib/libs/cxxsupp/libcxxmsvc/include/array
new file mode 100644
index 0000000000..314d24935a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/array
@@ -0,0 +1,523 @@
+// -*- 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_ARRAY
+#define _LIBCPP_ARRAY
+
+/*
+ array synopsis
+
+namespace std
+{
+template <class T, size_t N >
+struct array
+{
+ // types:
+ typedef T & reference;
+ typedef const T & const_reference;
+ typedef implementation defined iterator;
+ typedef implementation defined const_iterator;
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef T value_type;
+ typedef T* pointer;
+ typedef const T* const_pointer;
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+
+ // No explicit construct/copy/destroy for aggregate type
+ void fill(const T& u); // constexpr in C++20
+ void swap(array& a) noexcept(is_nothrow_swappable_v<T>); // constexpr in C++20
+
+ // iterators:
+ iterator begin() noexcept; // constexpr in C++17
+ const_iterator begin() const noexcept; // constexpr in C++17
+ iterator end() noexcept; // constexpr in C++17
+ const_iterator end() const noexcept; // constexpr in C++17
+
+ reverse_iterator rbegin() noexcept; // constexpr in C++17
+ const_reverse_iterator rbegin() const noexcept; // constexpr in C++17
+ reverse_iterator rend() noexcept; // constexpr in C++17
+ const_reverse_iterator rend() const noexcept; // constexpr in C++17
+
+ const_iterator cbegin() const noexcept; // constexpr in C++17
+ const_iterator cend() const noexcept; // constexpr in C++17
+ const_reverse_iterator crbegin() const noexcept; // constexpr in C++17
+ const_reverse_iterator crend() const noexcept; // constexpr in C++17
+
+ // capacity:
+ constexpr size_type size() const noexcept;
+ constexpr size_type max_size() const noexcept;
+ constexpr bool empty() const noexcept;
+
+ // element access:
+ reference operator[](size_type n); // constexpr in C++17
+ const_reference operator[](size_type n) const; // constexpr in C++14
+ reference at(size_type n); // constexpr in C++17
+ const_reference at(size_type n) const; // constexpr in C++14
+
+ reference front(); // constexpr in C++17
+ const_reference front() const; // constexpr in C++14
+ reference back(); // constexpr in C++17
+ const_reference back() const; // constexpr in C++14
+
+ T* data() noexcept; // constexpr in C++17
+ const T* data() const noexcept; // constexpr in C++17
+};
+
+template <class T, class... U>
+ array(T, U...) -> array<T, 1 + sizeof...(U)>; // C++17
+
+template <class T, size_t N>
+ bool operator==(const array<T,N>& x, const array<T,N>& y); // constexpr in C++20
+template <class T, size_t N>
+ bool operator!=(const array<T,N>& x, const array<T,N>& y); // constexpr in C++20
+template <class T, size_t N>
+ bool operator<(const array<T,N>& x, const array<T,N>& y); // constexpr in C++20
+template <class T, size_t N>
+ bool operator>(const array<T,N>& x, const array<T,N>& y); // constexpr in C++20
+template <class T, size_t N>
+ bool operator<=(const array<T,N>& x, const array<T,N>& y); // constexpr in C++20
+template <class T, size_t N>
+ bool operator>=(const array<T,N>& x, const array<T,N>& y); // constexpr in C++20
+
+template <class T, size_t N >
+ void swap(array<T,N>& x, array<T,N>& y) noexcept(noexcept(x.swap(y))); // constexpr in C++20
+
+template <class T, size_t N>
+ constexpr array<remove_cv_t<T>, N> to_array(T (&a)[N]); // C++20
+template <class T, size_t N>
+ constexpr array<remove_cv_t<T>, N> to_array(T (&&a)[N]); // C++20
+
+template <class T> struct tuple_size;
+template <size_t I, class T> struct tuple_element;
+template <class T, size_t N> struct tuple_size<array<T, N>>;
+template <size_t I, class T, size_t N> struct tuple_element<I, array<T, N>>;
+template <size_t I, class T, size_t N> T& get(array<T, N>&) noexcept; // constexpr in C++14
+template <size_t I, class T, size_t N> const T& get(const array<T, N>&) noexcept; // constexpr in C++14
+template <size_t I, class T, size_t N> T&& get(array<T, N>&&) noexcept; // constexpr in C++14
+template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexcept; // constexpr in C++14
+
+} // std
+
+*/
+
+#include <__algorithm/equal.h>
+#include <__algorithm/fill_n.h>
+#include <__algorithm/lexicographical_compare.h>
+#include <__algorithm/swap_ranges.h>
+#include <__assert>
+#include <__config>
+#include <__tuple>
+#include <__utility/unreachable.h>
+#include <iterator>
+#include <stdexcept>
+#include <type_traits>
+#include <utility>
+#include <version>
+
+#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
+{
+ // types:
+ typedef array __self;
+ typedef _Tp value_type;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef value_type* iterator;
+ typedef const value_type* const_iterator;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
+ typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
+
+ _Tp __elems_[_Size];
+
+ // No explicit construct/copy/destroy for aggregate type
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ void fill(const value_type& __u) {
+ _VSTD::fill_n(data(), _Size, __u);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
+ _VSTD::swap_ranges(data(), data() + _Size, __a.data());
+ }
+
+ // iterators:
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ iterator begin() _NOEXCEPT {return iterator(data());}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ const_iterator begin() const _NOEXCEPT {return const_iterator(data());}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ iterator end() _NOEXCEPT {return iterator(data() + _Size);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ const_iterator end() const _NOEXCEPT {return const_iterator(data() + _Size);}
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());}
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ const_iterator cbegin() const _NOEXCEPT {return begin();}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ const_iterator cend() const _NOEXCEPT {return end();}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ const_reverse_iterator crend() const _NOEXCEPT {return rend();}
+
+ // capacity:
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT {return _Size;}
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT {return _Size;}
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return _Size == 0;}
+
+ // element access:
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ reference operator[](size_type __n) _NOEXCEPT {
+ _LIBCPP_ASSERT(__n < _Size, "out-of-bounds access in std::array<T, N>");
+ return __elems_[__n];
+ }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ const_reference operator[](size_type __n) const _NOEXCEPT {
+ _LIBCPP_ASSERT(__n < _Size, "out-of-bounds access in std::array<T, N>");
+ return __elems_[__n];
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX14 reference at(size_type __n)
+ {
+ if (__n >= _Size)
+ __throw_out_of_range("array::at");
+ return __elems_[__n];
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference at(size_type __n) const
+ {
+ if (__n >= _Size)
+ __throw_out_of_range("array::at");
+ return __elems_[__n];
+ }
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference front() _NOEXCEPT {return (*this)[0];}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference front() const _NOEXCEPT {return (*this)[0];}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference back() _NOEXCEPT {return (*this)[_Size - 1];}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference back() const _NOEXCEPT {return (*this)[_Size - 1];}
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ value_type* data() _NOEXCEPT {return __elems_;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ const value_type* data() const _NOEXCEPT {return __elems_;}
+};
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0>
+{
+ // types:
+ typedef array __self;
+ typedef _Tp value_type;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef value_type* iterator;
+ typedef const value_type* const_iterator;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
+ typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
+
+ typedef typename conditional<is_const<_Tp>::value, const char,
+ char>::type _CharType;
+
+ struct _ArrayInStructT { _Tp __data_[1]; };
+ _ALIGNAS_TYPE(_ArrayInStructT) _CharType __elems_[sizeof(_ArrayInStructT)];
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ value_type* data() _NOEXCEPT {return nullptr;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ const value_type* data() const _NOEXCEPT {return nullptr;}
+
+ // No explicit construct/copy/destroy for aggregate type
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ void fill(const value_type&) {
+ static_assert(!is_const<_Tp>::value,
+ "cannot fill zero-sized array of type 'const T'");
+ }
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ void swap(array&) _NOEXCEPT {
+ static_assert(!is_const<_Tp>::value,
+ "cannot swap zero-sized array of type 'const T'");
+ }
+
+ // iterators:
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ iterator begin() _NOEXCEPT {return iterator(data());}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ const_iterator begin() const _NOEXCEPT {return const_iterator(data());}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ iterator end() _NOEXCEPT {return iterator(data());}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ const_iterator end() const _NOEXCEPT {return const_iterator(data());}
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());}
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ const_iterator cbegin() const _NOEXCEPT {return begin();}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ const_iterator cend() const _NOEXCEPT {return end();}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ const_reverse_iterator crend() const _NOEXCEPT {return rend();}
+
+ // capacity:
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT {return 0; }
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT {return 0;}
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return true;}
+
+ // element access:
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ reference operator[](size_type) _NOEXCEPT {
+ _LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array");
+ __libcpp_unreachable();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ const_reference operator[](size_type) const _NOEXCEPT {
+ _LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array");
+ __libcpp_unreachable();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ reference at(size_type) {
+ __throw_out_of_range("array<T, 0>::at");
+ __libcpp_unreachable();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ const_reference at(size_type) const {
+ __throw_out_of_range("array<T, 0>::at");
+ __libcpp_unreachable();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ reference front() _NOEXCEPT {
+ _LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array");
+ __libcpp_unreachable();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ const_reference front() const _NOEXCEPT {
+ _LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array");
+ __libcpp_unreachable();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ reference back() _NOEXCEPT {
+ _LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array");
+ __libcpp_unreachable();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ const_reference back() const _NOEXCEPT {
+ _LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array");
+ __libcpp_unreachable();
+ }
+};
+
+
+#if _LIBCPP_STD_VER > 14
+template<class _Tp, class... _Args,
+ class = enable_if_t<__all<_IsSame<_Tp, _Args>::value...>::value>
+ >
+array(_Tp, _Args...)
+ -> array<_Tp, 1 + sizeof...(_Args)>;
+#endif
+
+template <class _Tp, size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
+{
+ return _VSTD::equal(__x.begin(), __x.end(), __y.begin());
+}
+
+template <class _Tp, size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+operator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
+{
+ return !(__x == __y);
+}
+
+template <class _Tp, size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+operator<(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
+{
+ return _VSTD::lexicographical_compare(__x.begin(), __x.end(),
+ __y.begin(), __y.end());
+}
+
+template <class _Tp, size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+operator>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
+{
+ return __y < __x;
+}
+
+template <class _Tp, size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+operator<=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
+{
+ return !(__y < __x);
+}
+
+template <class _Tp, size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+operator>=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
+{
+ return !(__x < __y);
+}
+
+template <class _Tp, size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+typename enable_if
+<
+ _Size == 0 ||
+ __is_swappable<_Tp>::value,
+ void
+>::type
+swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y)
+ _NOEXCEPT_(noexcept(__x.swap(__y)))
+{
+ __x.swap(__y);
+}
+
+template <class _Tp, size_t _Size>
+struct _LIBCPP_TEMPLATE_VIS tuple_size<array<_Tp, _Size> >
+ : public integral_constant<size_t, _Size> {};
+
+template <size_t _Ip, class _Tp, size_t _Size>
+struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, array<_Tp, _Size> >
+{
+ static_assert(_Ip < _Size, "Index out of bounds in std::tuple_element<> (std::array)");
+ typedef _Tp type;
+};
+
+template <size_t _Ip, class _Tp, size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_Tp&
+get(array<_Tp, _Size>& __a) _NOEXCEPT
+{
+ static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array)");
+ return __a.__elems_[_Ip];
+}
+
+template <size_t _Ip, class _Tp, size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+const _Tp&
+get(const array<_Tp, _Size>& __a) _NOEXCEPT
+{
+ static_assert(_Ip < _Size, "Index out of bounds in std::get<> (const std::array)");
+ return __a.__elems_[_Ip];
+}
+
+template <size_t _Ip, class _Tp, size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_Tp&&
+get(array<_Tp, _Size>&& __a) _NOEXCEPT
+{
+ static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array &&)");
+ return _VSTD::move(__a.__elems_[_Ip]);
+}
+
+template <size_t _Ip, class _Tp, size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+const _Tp&&
+get(const array<_Tp, _Size>&& __a) _NOEXCEPT
+{
+ static_assert(_Ip < _Size, "Index out of bounds in std::get<> (const std::array &&)");
+ return _VSTD::move(__a.__elems_[_Ip]);
+}
+
+#if _LIBCPP_STD_VER > 17
+
+template <typename _Tp, size_t _Size, size_t... _Index>
+_LIBCPP_INLINE_VISIBILITY constexpr array<remove_cv_t<_Tp>, _Size>
+__to_array_lvalue_impl(_Tp (&__arr)[_Size], index_sequence<_Index...>) {
+ return {{__arr[_Index]...}};
+}
+
+template <typename _Tp, size_t _Size, size_t... _Index>
+_LIBCPP_INLINE_VISIBILITY constexpr array<remove_cv_t<_Tp>, _Size>
+__to_array_rvalue_impl(_Tp(&&__arr)[_Size], index_sequence<_Index...>) {
+ return {{_VSTD::move(__arr[_Index])...}};
+}
+
+template <typename _Tp, size_t _Size>
+_LIBCPP_INLINE_VISIBILITY constexpr array<remove_cv_t<_Tp>, _Size>
+to_array(_Tp (&__arr)[_Size]) noexcept(is_nothrow_constructible_v<_Tp, _Tp&>) {
+ static_assert(
+ !is_array_v<_Tp>,
+ "[array.creation]/1: to_array does not accept multidimensional arrays.");
+ static_assert(
+ is_constructible_v<_Tp, _Tp&>,
+ "[array.creation]/1: to_array requires copy constructible elements.");
+ return _VSTD::__to_array_lvalue_impl(__arr, make_index_sequence<_Size>());
+}
+
+template <typename _Tp, size_t _Size>
+_LIBCPP_INLINE_VISIBILITY constexpr array<remove_cv_t<_Tp>, _Size>
+to_array(_Tp(&&__arr)[_Size]) noexcept(is_nothrow_move_constructible_v<_Tp>) {
+ static_assert(
+ !is_array_v<_Tp>,
+ "[array.creation]/4: to_array does not accept multidimensional arrays.");
+ static_assert(
+ is_move_constructible_v<_Tp>,
+ "[array.creation]/4: to_array requires move constructible elements.");
+ return _VSTD::__to_array_rvalue_impl(_VSTD::move(__arr),
+ make_index_sequence<_Size>());
+}
+
+#endif // _LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_ARRAY
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/atomic b/contrib/libs/cxxsupp/libcxxmsvc/include/atomic
new file mode 100644
index 0000000000..09e3dd3bb0
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/atomic
@@ -0,0 +1,2735 @@
+// -*- 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_ATOMIC
+#define _LIBCPP_ATOMIC
+
+/*
+ atomic synopsis
+
+namespace std
+{
+
+// feature test macro [version.syn]
+
+#define __cpp_lib_atomic_is_always_lock_free
+#define __cpp_lib_atomic_flag_test
+#define __cpp_lib_atomic_lock_free_type_aliases
+#define __cpp_lib_atomic_wait
+
+ // order and consistency
+
+ enum memory_order: unspecified // enum class in C++20
+ {
+ relaxed,
+ consume, // load-consume
+ acquire, // load-acquire
+ release, // store-release
+ acq_rel, // store-release load-acquire
+ seq_cst // store-release load-acquire
+ };
+
+ inline constexpr auto memory_order_relaxed = memory_order::relaxed;
+ inline constexpr auto memory_order_consume = memory_order::consume;
+ inline constexpr auto memory_order_acquire = memory_order::acquire;
+ inline constexpr auto memory_order_release = memory_order::release;
+ inline constexpr auto memory_order_acq_rel = memory_order::acq_rel;
+ inline constexpr auto memory_order_seq_cst = memory_order::seq_cst;
+
+template <class T> T kill_dependency(T y) noexcept;
+
+// lock-free property
+
+#define ATOMIC_BOOL_LOCK_FREE unspecified
+#define ATOMIC_CHAR_LOCK_FREE unspecified
+#define ATOMIC_CHAR8_T_LOCK_FREE unspecified // C++20
+#define ATOMIC_CHAR16_T_LOCK_FREE unspecified
+#define ATOMIC_CHAR32_T_LOCK_FREE unspecified
+#define ATOMIC_WCHAR_T_LOCK_FREE unspecified
+#define ATOMIC_SHORT_LOCK_FREE unspecified
+#define ATOMIC_INT_LOCK_FREE unspecified
+#define ATOMIC_LONG_LOCK_FREE unspecified
+#define ATOMIC_LLONG_LOCK_FREE unspecified
+#define ATOMIC_POINTER_LOCK_FREE unspecified
+
+template <class T>
+struct atomic
+{
+ using value_type = T;
+
+ static constexpr bool is_always_lock_free;
+ bool is_lock_free() const volatile noexcept;
+ bool is_lock_free() const noexcept;
+
+ 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;
+ atomic& operator=(const atomic&) volatile = delete;
+
+ T load(memory_order m = memory_order_seq_cst) const volatile noexcept;
+ T load(memory_order m = memory_order_seq_cst) const noexcept;
+ operator T() const volatile noexcept;
+ operator T() const noexcept;
+ void store(T desr, memory_order m = memory_order_seq_cst) volatile noexcept;
+ void store(T desr, memory_order m = memory_order_seq_cst) noexcept;
+ T operator=(T) volatile noexcept;
+ T operator=(T) noexcept;
+
+ T exchange(T desr, memory_order m = memory_order_seq_cst) volatile noexcept;
+ T exchange(T desr, memory_order m = memory_order_seq_cst) noexcept;
+ bool compare_exchange_weak(T& expc, T desr,
+ memory_order s, memory_order f) volatile noexcept;
+ bool compare_exchange_weak(T& expc, T desr, memory_order s, memory_order f) noexcept;
+ bool compare_exchange_strong(T& expc, T desr,
+ memory_order s, memory_order f) volatile noexcept;
+ bool compare_exchange_strong(T& expc, T desr,
+ memory_order s, memory_order f) noexcept;
+ bool compare_exchange_weak(T& expc, T desr,
+ memory_order m = memory_order_seq_cst) volatile noexcept;
+ bool compare_exchange_weak(T& expc, T desr,
+ memory_order m = memory_order_seq_cst) noexcept;
+ bool compare_exchange_strong(T& expc, T desr,
+ memory_order m = memory_order_seq_cst) volatile noexcept;
+ bool compare_exchange_strong(T& expc, T desr,
+ memory_order m = memory_order_seq_cst) noexcept;
+
+ void wait(T, memory_order = memory_order::seq_cst) const volatile noexcept;
+ void wait(T, memory_order = memory_order::seq_cst) const noexcept;
+ void notify_one() volatile noexcept;
+ void notify_one() noexcept;
+ void notify_all() volatile noexcept;
+ void notify_all() noexcept;
+};
+
+template <>
+struct atomic<integral>
+{
+ using value_type = integral;
+ using difference_type = value_type;
+
+ static constexpr bool is_always_lock_free;
+ bool is_lock_free() const volatile noexcept;
+ bool is_lock_free() const noexcept;
+
+ atomic() noexcept = default;
+ constexpr atomic(integral desr) noexcept;
+ atomic(const atomic&) = delete;
+ atomic& operator=(const atomic&) = delete;
+ atomic& operator=(const atomic&) volatile = delete;
+
+ integral load(memory_order m = memory_order_seq_cst) const volatile noexcept;
+ integral load(memory_order m = memory_order_seq_cst) const noexcept;
+ operator integral() const volatile noexcept;
+ operator integral() const noexcept;
+ void store(integral desr, memory_order m = memory_order_seq_cst) volatile noexcept;
+ void store(integral desr, memory_order m = memory_order_seq_cst) noexcept;
+ integral operator=(integral desr) volatile noexcept;
+ integral operator=(integral desr) noexcept;
+
+ integral exchange(integral desr,
+ memory_order m = memory_order_seq_cst) volatile noexcept;
+ integral exchange(integral desr, memory_order m = memory_order_seq_cst) noexcept;
+ bool compare_exchange_weak(integral& expc, integral desr,
+ memory_order s, memory_order f) volatile noexcept;
+ bool compare_exchange_weak(integral& expc, integral desr,
+ memory_order s, memory_order f) noexcept;
+ bool compare_exchange_strong(integral& expc, integral desr,
+ memory_order s, memory_order f) volatile noexcept;
+ bool compare_exchange_strong(integral& expc, integral desr,
+ memory_order s, memory_order f) noexcept;
+ bool compare_exchange_weak(integral& expc, integral desr,
+ memory_order m = memory_order_seq_cst) volatile noexcept;
+ bool compare_exchange_weak(integral& expc, integral desr,
+ memory_order m = memory_order_seq_cst) noexcept;
+ bool compare_exchange_strong(integral& expc, integral desr,
+ memory_order m = memory_order_seq_cst) volatile noexcept;
+ bool compare_exchange_strong(integral& expc, integral desr,
+ memory_order m = memory_order_seq_cst) noexcept;
+
+ integral fetch_add(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
+ integral fetch_add(integral op, memory_order m = memory_order_seq_cst) noexcept;
+ integral fetch_sub(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
+ integral fetch_sub(integral op, memory_order m = memory_order_seq_cst) noexcept;
+ integral fetch_and(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
+ integral fetch_and(integral op, memory_order m = memory_order_seq_cst) noexcept;
+ integral fetch_or(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
+ integral fetch_or(integral op, memory_order m = memory_order_seq_cst) noexcept;
+ integral fetch_xor(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
+ integral fetch_xor(integral op, memory_order m = memory_order_seq_cst) noexcept;
+
+ integral operator++(int) volatile noexcept;
+ integral operator++(int) noexcept;
+ integral operator--(int) volatile noexcept;
+ integral operator--(int) noexcept;
+ integral operator++() volatile noexcept;
+ integral operator++() noexcept;
+ integral operator--() volatile noexcept;
+ integral operator--() noexcept;
+ integral operator+=(integral op) volatile noexcept;
+ integral operator+=(integral op) noexcept;
+ integral operator-=(integral op) volatile noexcept;
+ integral operator-=(integral op) noexcept;
+ integral operator&=(integral op) volatile noexcept;
+ integral operator&=(integral op) noexcept;
+ integral operator|=(integral op) volatile noexcept;
+ integral operator|=(integral op) noexcept;
+ integral operator^=(integral op) volatile noexcept;
+ integral operator^=(integral op) noexcept;
+
+ void wait(integral, memory_order = memory_order::seq_cst) const volatile noexcept;
+ void wait(integral, memory_order = memory_order::seq_cst) const noexcept;
+ void notify_one() volatile noexcept;
+ void notify_one() noexcept;
+ void notify_all() volatile noexcept;
+ void notify_all() noexcept;
+};
+
+template <class T>
+struct atomic<T*>
+{
+ using value_type = T*;
+ using difference_type = ptrdiff_t;
+
+ static constexpr bool is_always_lock_free;
+ bool is_lock_free() const volatile noexcept;
+ bool is_lock_free() const noexcept;
+
+ 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;
+ atomic& operator=(const atomic&) volatile = delete;
+
+ T* load(memory_order m = memory_order_seq_cst) const volatile noexcept;
+ T* load(memory_order m = memory_order_seq_cst) const noexcept;
+ operator T*() const volatile noexcept;
+ operator T*() const noexcept;
+ void store(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept;
+ void store(T* desr, memory_order m = memory_order_seq_cst) noexcept;
+ T* operator=(T*) volatile noexcept;
+ T* operator=(T*) noexcept;
+
+ T* exchange(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept;
+ T* exchange(T* desr, memory_order m = memory_order_seq_cst) noexcept;
+ bool compare_exchange_weak(T*& expc, T* desr,
+ memory_order s, memory_order f) volatile noexcept;
+ bool compare_exchange_weak(T*& expc, T* desr,
+ memory_order s, memory_order f) noexcept;
+ bool compare_exchange_strong(T*& expc, T* desr,
+ memory_order s, memory_order f) volatile noexcept;
+ bool compare_exchange_strong(T*& expc, T* desr,
+ memory_order s, memory_order f) noexcept;
+ bool compare_exchange_weak(T*& expc, T* desr,
+ memory_order m = memory_order_seq_cst) volatile noexcept;
+ bool compare_exchange_weak(T*& expc, T* desr,
+ memory_order m = memory_order_seq_cst) noexcept;
+ bool compare_exchange_strong(T*& expc, T* desr,
+ memory_order m = memory_order_seq_cst) volatile noexcept;
+ bool compare_exchange_strong(T*& expc, T* desr,
+ memory_order m = memory_order_seq_cst) noexcept;
+ T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept;
+ T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept;
+ T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept;
+ T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept;
+
+ T* operator++(int) volatile noexcept;
+ T* operator++(int) noexcept;
+ T* operator--(int) volatile noexcept;
+ T* operator--(int) noexcept;
+ T* operator++() volatile noexcept;
+ T* operator++() noexcept;
+ T* operator--() volatile noexcept;
+ T* operator--() noexcept;
+ T* operator+=(ptrdiff_t op) volatile noexcept;
+ T* operator+=(ptrdiff_t op) noexcept;
+ T* operator-=(ptrdiff_t op) volatile noexcept;
+ T* operator-=(ptrdiff_t op) noexcept;
+
+ void wait(T*, memory_order = memory_order::seq_cst) const volatile noexcept;
+ void wait(T*, memory_order = memory_order::seq_cst) const noexcept;
+ void notify_one() volatile noexcept;
+ void notify_one() noexcept;
+ void notify_all() volatile noexcept;
+ void notify_all() noexcept;
+};
+
+
+// [atomics.nonmembers], non-member functions
+template<class T>
+ bool atomic_is_lock_free(const volatile atomic<T>*) noexcept;
+template<class T>
+ bool atomic_is_lock_free(const atomic<T>*) noexcept;
+template<class T>
+ void atomic_store(volatile atomic<T>*, atomic<T>::value_type) noexcept;
+template<class T>
+ void atomic_store(atomic<T>*, atomic<T>::value_type) noexcept;
+template<class T>
+ void atomic_store_explicit(volatile atomic<T>*, atomic<T>::value_type,
+ memory_order) noexcept;
+template<class T>
+ void atomic_store_explicit(atomic<T>*, atomic<T>::value_type,
+ memory_order) noexcept;
+template<class T>
+ T atomic_load(const volatile atomic<T>*) noexcept;
+template<class T>
+ T atomic_load(const atomic<T>*) noexcept;
+template<class T>
+ T atomic_load_explicit(const volatile atomic<T>*, memory_order) noexcept;
+template<class T>
+ T atomic_load_explicit(const atomic<T>*, memory_order) noexcept;
+template<class T>
+ T atomic_exchange(volatile atomic<T>*, atomic<T>::value_type) noexcept;
+template<class T>
+ T atomic_exchange(atomic<T>*, atomic<T>::value_type) noexcept;
+template<class T>
+ T atomic_exchange_explicit(volatile atomic<T>*, atomic<T>::value_type,
+ memory_order) noexcept;
+template<class T>
+ T atomic_exchange_explicit(atomic<T>*, atomic<T>::value_type,
+ memory_order) noexcept;
+template<class T>
+ bool atomic_compare_exchange_weak(volatile atomic<T>*, atomic<T>::value_type*,
+ atomic<T>::value_type) noexcept;
+template<class T>
+ bool atomic_compare_exchange_weak(atomic<T>*, atomic<T>::value_type*,
+ atomic<T>::value_type) noexcept;
+template<class T>
+ bool atomic_compare_exchange_strong(volatile atomic<T>*, atomic<T>::value_type*,
+ atomic<T>::value_type) noexcept;
+template<class T>
+ bool atomic_compare_exchange_strong(atomic<T>*, atomic<T>::value_type*,
+ atomic<T>::value_type) noexcept;
+template<class T>
+ bool atomic_compare_exchange_weak_explicit(volatile atomic<T>*, atomic<T>::value_type*,
+ atomic<T>::value_type,
+ memory_order, memory_order) noexcept;
+template<class T>
+ bool atomic_compare_exchange_weak_explicit(atomic<T>*, atomic<T>::value_type*,
+ atomic<T>::value_type,
+ memory_order, memory_order) noexcept;
+template<class T>
+ bool atomic_compare_exchange_strong_explicit(volatile atomic<T>*, atomic<T>::value_type*,
+ atomic<T>::value_type,
+ memory_order, memory_order) noexcept;
+template<class T>
+ bool atomic_compare_exchange_strong_explicit(atomic<T>*, atomic<T>::value_type*,
+ atomic<T>::value_type,
+ memory_order, memory_order) noexcept;
+
+template<class T>
+ T atomic_fetch_add(volatile atomic<T>*, atomic<T>::difference_type) noexcept;
+template<class T>
+ T atomic_fetch_add(atomic<T>*, atomic<T>::difference_type) noexcept;
+template<class T>
+ T atomic_fetch_add_explicit(volatile atomic<T>*, atomic<T>::difference_type,
+ memory_order) noexcept;
+template<class T>
+ T atomic_fetch_add_explicit(atomic<T>*, atomic<T>::difference_type,
+ memory_order) noexcept;
+template<class T>
+ T atomic_fetch_sub(volatile atomic<T>*, atomic<T>::difference_type) noexcept;
+template<class T>
+ T atomic_fetch_sub(atomic<T>*, atomic<T>::difference_type) noexcept;
+template<class T>
+ T atomic_fetch_sub_explicit(volatile atomic<T>*, atomic<T>::difference_type,
+ memory_order) noexcept;
+template<class T>
+ T atomic_fetch_sub_explicit(atomic<T>*, atomic<T>::difference_type,
+ memory_order) noexcept;
+template<class T>
+ T atomic_fetch_and(volatile atomic<T>*, atomic<T>::value_type) noexcept;
+template<class T>
+ T atomic_fetch_and(atomic<T>*, atomic<T>::value_type) noexcept;
+template<class T>
+ T atomic_fetch_and_explicit(volatile atomic<T>*, atomic<T>::value_type,
+ memory_order) noexcept;
+template<class T>
+ T atomic_fetch_and_explicit(atomic<T>*, atomic<T>::value_type,
+ memory_order) noexcept;
+template<class T>
+ T atomic_fetch_or(volatile atomic<T>*, atomic<T>::value_type) noexcept;
+template<class T>
+ T atomic_fetch_or(atomic<T>*, atomic<T>::value_type) noexcept;
+template<class T>
+ T atomic_fetch_or_explicit(volatile atomic<T>*, atomic<T>::value_type,
+ memory_order) noexcept;
+template<class T>
+ T atomic_fetch_or_explicit(atomic<T>*, atomic<T>::value_type,
+ memory_order) noexcept;
+template<class T>
+ T atomic_fetch_xor(volatile atomic<T>*, atomic<T>::value_type) noexcept;
+template<class T>
+ T atomic_fetch_xor(atomic<T>*, atomic<T>::value_type) noexcept;
+template<class T>
+ T atomic_fetch_xor_explicit(volatile atomic<T>*, atomic<T>::value_type,
+ memory_order) noexcept;
+template<class T>
+ T atomic_fetch_xor_explicit(atomic<T>*, atomic<T>::value_type,
+ memory_order) noexcept;
+
+template<class T>
+ void atomic_wait(const volatile atomic<T>*, atomic<T>::value_type);
+template<class T>
+ void atomic_wait(const atomic<T>*, atomic<T>::value_type);
+template<class T>
+ void atomic_wait_explicit(const volatile atomic<T>*, atomic<T>::value_type,
+ memory_order);
+template<class T>
+ void atomic_wait_explicit(const atomic<T>*, atomic<T>::value_type,
+ memory_order);
+template<class T>
+ void atomic_notify_one(volatile atomic<T>*);
+template<class T>
+ void atomic_notify_one(atomic<T>*);
+template<class T>
+ void atomic_notify_all(volatile atomic<T>*);
+template<class T>
+ void atomic_notify_all(atomic<T>*);
+
+// Atomics for standard typedef types
+
+typedef atomic<bool> atomic_bool;
+typedef atomic<char> atomic_char;
+typedef atomic<signed char> atomic_schar;
+typedef atomic<unsigned char> atomic_uchar;
+typedef atomic<short> atomic_short;
+typedef atomic<unsigned short> atomic_ushort;
+typedef atomic<int> atomic_int;
+typedef atomic<unsigned int> atomic_uint;
+typedef atomic<long> atomic_long;
+typedef atomic<unsigned long> atomic_ulong;
+typedef atomic<long long> atomic_llong;
+typedef atomic<unsigned long long> atomic_ullong;
+typedef atomic<char8_t> atomic_char8_t; // C++20
+typedef atomic<char16_t> atomic_char16_t;
+typedef atomic<char32_t> atomic_char32_t;
+typedef atomic<wchar_t> atomic_wchar_t;
+
+typedef atomic<int_least8_t> atomic_int_least8_t;
+typedef atomic<uint_least8_t> atomic_uint_least8_t;
+typedef atomic<int_least16_t> atomic_int_least16_t;
+typedef atomic<uint_least16_t> atomic_uint_least16_t;
+typedef atomic<int_least32_t> atomic_int_least32_t;
+typedef atomic<uint_least32_t> atomic_uint_least32_t;
+typedef atomic<int_least64_t> atomic_int_least64_t;
+typedef atomic<uint_least64_t> atomic_uint_least64_t;
+
+typedef atomic<int_fast8_t> atomic_int_fast8_t;
+typedef atomic<uint_fast8_t> atomic_uint_fast8_t;
+typedef atomic<int_fast16_t> atomic_int_fast16_t;
+typedef atomic<uint_fast16_t> atomic_uint_fast16_t;
+typedef atomic<int_fast32_t> atomic_int_fast32_t;
+typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
+typedef atomic<int_fast64_t> atomic_int_fast64_t;
+typedef atomic<uint_fast64_t> atomic_uint_fast64_t;
+
+typedef atomic<int8_t> atomic_int8_t;
+typedef atomic<uint8_t> atomic_uint8_t;
+typedef atomic<int16_t> atomic_int16_t;
+typedef atomic<uint16_t> atomic_uint16_t;
+typedef atomic<int32_t> atomic_int32_t;
+typedef atomic<uint32_t> atomic_uint32_t;
+typedef atomic<int64_t> atomic_int64_t;
+typedef atomic<uint64_t> atomic_uint64_t;
+
+typedef atomic<intptr_t> atomic_intptr_t;
+typedef atomic<uintptr_t> atomic_uintptr_t;
+typedef atomic<size_t> atomic_size_t;
+typedef atomic<ptrdiff_t> atomic_ptrdiff_t;
+typedef atomic<intmax_t> atomic_intmax_t;
+typedef atomic<uintmax_t> atomic_uintmax_t;
+
+// flag type and operations
+
+typedef struct atomic_flag
+{
+ 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;
+
+ bool test(memory_order m = memory_order_seq_cst) volatile noexcept;
+ bool test(memory_order m = memory_order_seq_cst) noexcept;
+ bool test_and_set(memory_order m = memory_order_seq_cst) volatile noexcept;
+ bool test_and_set(memory_order m = memory_order_seq_cst) noexcept;
+ void clear(memory_order m = memory_order_seq_cst) volatile noexcept;
+ void clear(memory_order m = memory_order_seq_cst) noexcept;
+
+ void wait(bool, memory_order = memory_order::seq_cst) const volatile noexcept;
+ void wait(bool, memory_order = memory_order::seq_cst) const noexcept;
+ void notify_one() volatile noexcept;
+ void notify_one() noexcept;
+ void notify_all() volatile noexcept;
+ void notify_all() noexcept;
+} atomic_flag;
+
+bool atomic_flag_test(volatile atomic_flag* obj) noexcept;
+bool atomic_flag_test(atomic_flag* obj) noexcept;
+bool atomic_flag_test_explicit(volatile atomic_flag* obj,
+ memory_order m) noexcept;
+bool atomic_flag_test_explicit(atomic_flag* obj, memory_order m) noexcept;
+bool atomic_flag_test_and_set(volatile atomic_flag* obj) noexcept;
+bool atomic_flag_test_and_set(atomic_flag* obj) noexcept;
+bool atomic_flag_test_and_set_explicit(volatile atomic_flag* obj,
+ memory_order m) noexcept;
+bool atomic_flag_test_and_set_explicit(atomic_flag* obj, memory_order m) noexcept;
+void atomic_flag_clear(volatile atomic_flag* obj) noexcept;
+void atomic_flag_clear(atomic_flag* obj) noexcept;
+void atomic_flag_clear_explicit(volatile atomic_flag* obj, memory_order m) noexcept;
+void atomic_flag_clear_explicit(atomic_flag* obj, memory_order m) noexcept;
+
+void atomic_wait(const volatile atomic_flag* obj, T old) noexcept;
+void atomic_wait(const atomic_flag* obj, T old) noexcept;
+void atomic_wait_explicit(const volatile atomic_flag* obj, T old, memory_order m) noexcept;
+void atomic_wait_explicit(const atomic_flag* obj, T old, memory_order m) noexcept;
+void atomic_one(volatile atomic_flag* obj) noexcept;
+void atomic_one(atomic_flag* obj) noexcept;
+void atomic_all(volatile atomic_flag* obj) noexcept;
+void atomic_all(atomic_flag* obj) noexcept;
+
+// fences
+
+void atomic_thread_fence(memory_order m) noexcept;
+void atomic_signal_fence(memory_order m) noexcept;
+
+// deprecated
+
+template <class T>
+ void atomic_init(volatile atomic<T>* obj, atomic<T>::value_type desr) noexcept;
+
+template <class T>
+ void atomic_init(atomic<T>* obj, atomic<T>::value_type desr) noexcept;
+
+#define ATOMIC_VAR_INIT(value) see below
+
+#define ATOMIC_FLAG_INIT see below
+
+} // std
+
+*/
+
+#include <__availability>
+#include <__config>
+#include <__thread/poll_with_backoff.h>
+#include <__thread/timed_backoff_policy.h>
+#include <cstddef>
+#include <cstdint>
+#include <cstring>
+#include <type_traits>
+#include <version>
+
+#ifndef _LIBCPP_HAS_NO_THREADS
+# include <__threading_support>
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifdef _LIBCPP_HAS_NO_ATOMIC_HEADER
+# error <atomic> is not implemented
+#endif
+#ifdef kill_dependency
+# error C++ standard library is incompatible with <stdatomic.h>
+#endif
+
+#define _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m) \
+ _LIBCPP_DIAGNOSE_WARNING(__m == memory_order_consume || \
+ __m == memory_order_acquire || \
+ __m == memory_order_acq_rel, \
+ "memory order argument to atomic operation is invalid")
+
+#define _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m) \
+ _LIBCPP_DIAGNOSE_WARNING(__m == memory_order_release || \
+ __m == memory_order_acq_rel, \
+ "memory order argument to atomic operation is invalid")
+
+#define _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__m, __f) \
+ _LIBCPP_DIAGNOSE_WARNING(__f == memory_order_release || \
+ __f == memory_order_acq_rel, \
+ "memory order argument to atomic operation is invalid")
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// Figure out what the underlying type for `memory_order` would be if it were
+// declared as an unscoped enum (accounting for -fshort-enums). Use this result
+// to pin the underlying type in C++20.
+enum __legacy_memory_order {
+ __mo_relaxed,
+ __mo_consume,
+ __mo_acquire,
+ __mo_release,
+ __mo_acq_rel,
+ __mo_seq_cst
+};
+
+typedef underlying_type<__legacy_memory_order>::type __memory_order_underlying_t;
+
+#if _LIBCPP_STD_VER > 17
+
+enum class memory_order : __memory_order_underlying_t {
+ relaxed = __mo_relaxed,
+ consume = __mo_consume,
+ acquire = __mo_acquire,
+ release = __mo_release,
+ acq_rel = __mo_acq_rel,
+ seq_cst = __mo_seq_cst
+};
+
+inline constexpr auto memory_order_relaxed = memory_order::relaxed;
+inline constexpr auto memory_order_consume = memory_order::consume;
+inline constexpr auto memory_order_acquire = memory_order::acquire;
+inline constexpr auto memory_order_release = memory_order::release;
+inline constexpr auto memory_order_acq_rel = memory_order::acq_rel;
+inline constexpr auto memory_order_seq_cst = memory_order::seq_cst;
+
+#else
+
+typedef enum memory_order {
+ memory_order_relaxed = __mo_relaxed,
+ memory_order_consume = __mo_consume,
+ memory_order_acquire = __mo_acquire,
+ memory_order_release = __mo_release,
+ memory_order_acq_rel = __mo_acq_rel,
+ memory_order_seq_cst = __mo_seq_cst,
+} memory_order;
+
+#endif // _LIBCPP_STD_VER > 17
+
+template <typename _Tp> _LIBCPP_INLINE_VISIBILITY
+bool __cxx_nonatomic_compare_equal(_Tp const& __lhs, _Tp const& __rhs) {
+ return _VSTD::memcmp(&__lhs, &__rhs, sizeof(_Tp)) == 0;
+}
+
+static_assert((is_same<underlying_type<memory_order>::type, __memory_order_underlying_t>::value),
+ "unexpected underlying type for std::memory_order");
+
+#if defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) || \
+ 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
+// is required.
+template <typename _Tp, typename _Tv> _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_assignable<_Tp&, _Tv>::value>::type
+__cxx_atomic_assign_volatile(_Tp& __a_value, _Tv const& __val) {
+ __a_value = __val;
+}
+template <typename _Tp, typename _Tv> _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_assignable<_Tp&, _Tv>::value>::type
+__cxx_atomic_assign_volatile(_Tp volatile& __a_value, _Tv volatile const& __val) {
+ volatile char* __to = reinterpret_cast<volatile char*>(&__a_value);
+ volatile char* __end = __to + sizeof(_Tp);
+ volatile const char* __from = reinterpret_cast<volatile const char*>(&__val);
+ while (__to != __end)
+ *__to++ = *__from++;
+}
+
+#endif
+
+#if defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)
+
+template <typename _Tp>
+struct __cxx_atomic_base_impl {
+
+ _LIBCPP_INLINE_VISIBILITY
+#ifndef _LIBCPP_CXX03_LANG
+ __cxx_atomic_base_impl() _NOEXCEPT = default;
+#else
+ __cxx_atomic_base_impl() _NOEXCEPT : __a_value() {}
+#endif // _LIBCPP_CXX03_LANG
+ _LIBCPP_CONSTEXPR explicit __cxx_atomic_base_impl(_Tp value) _NOEXCEPT
+ : __a_value(value) {}
+ _Tp __a_value;
+};
+
+_LIBCPP_INLINE_VISIBILITY inline _LIBCPP_CONSTEXPR int __to_gcc_order(memory_order __order) {
+ // Avoid switch statement to make this a constexpr.
+ return __order == memory_order_relaxed ? __ATOMIC_RELAXED:
+ (__order == memory_order_acquire ? __ATOMIC_ACQUIRE:
+ (__order == memory_order_release ? __ATOMIC_RELEASE:
+ (__order == memory_order_seq_cst ? __ATOMIC_SEQ_CST:
+ (__order == memory_order_acq_rel ? __ATOMIC_ACQ_REL:
+ __ATOMIC_CONSUME))));
+}
+
+_LIBCPP_INLINE_VISIBILITY inline _LIBCPP_CONSTEXPR int __to_gcc_failure_order(memory_order __order) {
+ // Avoid switch statement to make this a constexpr.
+ return __order == memory_order_relaxed ? __ATOMIC_RELAXED:
+ (__order == memory_order_acquire ? __ATOMIC_ACQUIRE:
+ (__order == memory_order_release ? __ATOMIC_RELAXED:
+ (__order == memory_order_seq_cst ? __ATOMIC_SEQ_CST:
+ (__order == memory_order_acq_rel ? __ATOMIC_ACQUIRE:
+ __ATOMIC_CONSUME))));
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+void __cxx_atomic_init(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __val) {
+ __cxx_atomic_assign_volatile(__a->__a_value, __val);
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+void __cxx_atomic_init(__cxx_atomic_base_impl<_Tp>* __a, _Tp __val) {
+ __a->__a_value = __val;
+}
+
+_LIBCPP_INLINE_VISIBILITY inline
+void __cxx_atomic_thread_fence(memory_order __order) {
+ __atomic_thread_fence(__to_gcc_order(__order));
+}
+
+_LIBCPP_INLINE_VISIBILITY inline
+void __cxx_atomic_signal_fence(memory_order __order) {
+ __atomic_signal_fence(__to_gcc_order(__order));
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+void __cxx_atomic_store(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __val,
+ memory_order __order) {
+ __atomic_store(&__a->__a_value, &__val,
+ __to_gcc_order(__order));
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+void __cxx_atomic_store(__cxx_atomic_base_impl<_Tp>* __a, _Tp __val,
+ memory_order __order) {
+ __atomic_store(&__a->__a_value, &__val,
+ __to_gcc_order(__order));
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_load(const volatile __cxx_atomic_base_impl<_Tp>* __a,
+ memory_order __order) {
+ _Tp __ret;
+ __atomic_load(&__a->__a_value, &__ret,
+ __to_gcc_order(__order));
+ return __ret;
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_load(const __cxx_atomic_base_impl<_Tp>* __a, memory_order __order) {
+ _Tp __ret;
+ __atomic_load(&__a->__a_value, &__ret,
+ __to_gcc_order(__order));
+ return __ret;
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_exchange(volatile __cxx_atomic_base_impl<_Tp>* __a,
+ _Tp __value, memory_order __order) {
+ _Tp __ret;
+ __atomic_exchange(&__a->__a_value, &__value, &__ret,
+ __to_gcc_order(__order));
+ return __ret;
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_exchange(__cxx_atomic_base_impl<_Tp>* __a, _Tp __value,
+ memory_order __order) {
+ _Tp __ret;
+ __atomic_exchange(&__a->__a_value, &__value, &__ret,
+ __to_gcc_order(__order));
+ return __ret;
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+bool __cxx_atomic_compare_exchange_strong(
+ volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp* __expected, _Tp __value,
+ memory_order __success, memory_order __failure) {
+ return __atomic_compare_exchange(&__a->__a_value, __expected, &__value,
+ false,
+ __to_gcc_order(__success),
+ __to_gcc_failure_order(__failure));
+}
+
+template <typename _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) {
+ return __atomic_compare_exchange(&__a->__a_value, __expected, &__value,
+ false,
+ __to_gcc_order(__success),
+ __to_gcc_failure_order(__failure));
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+bool __cxx_atomic_compare_exchange_weak(
+ volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp* __expected, _Tp __value,
+ memory_order __success, memory_order __failure) {
+ return __atomic_compare_exchange(&__a->__a_value, __expected, &__value,
+ true,
+ __to_gcc_order(__success),
+ __to_gcc_failure_order(__failure));
+}
+
+template <typename _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) {
+ return __atomic_compare_exchange(&__a->__a_value, __expected, &__value,
+ true,
+ __to_gcc_order(__success),
+ __to_gcc_failure_order(__failure));
+}
+
+template <typename _Tp>
+struct __skip_amt { enum {value = 1}; };
+
+template <typename _Tp>
+struct __skip_amt<_Tp*> { enum {value = sizeof(_Tp)}; };
+
+// FIXME: Haven't figured out what the spec says about using arrays with
+// atomic_fetch_add. Force a failure rather than creating bad behavior.
+template <typename _Tp>
+struct __skip_amt<_Tp[]> { };
+template <typename _Tp, int n>
+struct __skip_amt<_Tp[n]> { };
+
+template <typename _Tp, typename _Td>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_add(volatile __cxx_atomic_base_impl<_Tp>* __a,
+ _Td __delta, memory_order __order) {
+ return __atomic_fetch_add(&__a->__a_value, __delta * __skip_amt<_Tp>::value,
+ __to_gcc_order(__order));
+}
+
+template <typename _Tp, typename _Td>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp>* __a, _Td __delta,
+ memory_order __order) {
+ return __atomic_fetch_add(&__a->__a_value, __delta * __skip_amt<_Tp>::value,
+ __to_gcc_order(__order));
+}
+
+template <typename _Tp, typename _Td>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_sub(volatile __cxx_atomic_base_impl<_Tp>* __a,
+ _Td __delta, memory_order __order) {
+ return __atomic_fetch_sub(&__a->__a_value, __delta * __skip_amt<_Tp>::value,
+ __to_gcc_order(__order));
+}
+
+template <typename _Tp, typename _Td>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp>* __a, _Td __delta,
+ memory_order __order) {
+ return __atomic_fetch_sub(&__a->__a_value, __delta * __skip_amt<_Tp>::value,
+ __to_gcc_order(__order));
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_and(volatile __cxx_atomic_base_impl<_Tp>* __a,
+ _Tp __pattern, memory_order __order) {
+ return __atomic_fetch_and(&__a->__a_value, __pattern,
+ __to_gcc_order(__order));
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_and(__cxx_atomic_base_impl<_Tp>* __a,
+ _Tp __pattern, memory_order __order) {
+ return __atomic_fetch_and(&__a->__a_value, __pattern,
+ __to_gcc_order(__order));
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_or(volatile __cxx_atomic_base_impl<_Tp>* __a,
+ _Tp __pattern, memory_order __order) {
+ return __atomic_fetch_or(&__a->__a_value, __pattern,
+ __to_gcc_order(__order));
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_or(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern,
+ memory_order __order) {
+ return __atomic_fetch_or(&__a->__a_value, __pattern,
+ __to_gcc_order(__order));
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_xor(volatile __cxx_atomic_base_impl<_Tp>* __a,
+ _Tp __pattern, memory_order __order) {
+ return __atomic_fetch_xor(&__a->__a_value, __pattern,
+ __to_gcc_order(__order));
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_xor(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern,
+ memory_order __order) {
+ return __atomic_fetch_xor(&__a->__a_value, __pattern,
+ __to_gcc_order(__order));
+}
+
+#define __cxx_atomic_is_lock_free(__s) __atomic_is_lock_free(__s, 0)
+
+#elif defined(_LIBCPP_HAS_C_ATOMIC_IMP) || defined(_LIBCPP_COMPILER_MSVC)
+
+#if defined(_LIBCPP_COMPILER_MSVC)
+_LIBCPP_END_NAMESPACE_STD
+#include <__support/win32/atomic_win32.h>
+_LIBCPP_BEGIN_NAMESPACE_STD
+#endif
+
+template <typename _Tp>
+struct __cxx_atomic_base_impl {
+
+ _LIBCPP_INLINE_VISIBILITY
+#ifndef _LIBCPP_CXX03_LANG
+ __cxx_atomic_base_impl() _NOEXCEPT = default;
+#else
+ __cxx_atomic_base_impl() _NOEXCEPT : __a_value() {}
+#endif // _LIBCPP_CXX03_LANG
+ _LIBCPP_CONSTEXPR explicit __cxx_atomic_base_impl(_Tp value) _NOEXCEPT
+ : __a_value(value) {}
+ _LIBCPP_DISABLE_EXTENSION_WARNING _Atomic(_Tp) __a_value;
+};
+
+#define __cxx_atomic_is_lock_free(__s) __c11_atomic_is_lock_free(__s)
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( push )
+#pragma warning ( disable : 4141 )
+#endif
+_LIBCPP_INLINE_VISIBILITY inline
+void __cxx_atomic_thread_fence(memory_order __order) _NOEXCEPT {
+ __c11_atomic_thread_fence(static_cast<__memory_order_underlying_t>(__order));
+}
+
+_LIBCPP_INLINE_VISIBILITY inline
+void __cxx_atomic_signal_fence(memory_order __order) _NOEXCEPT {
+ __c11_atomic_signal_fence(static_cast<__memory_order_underlying_t>(__order));
+}
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( pop )
+#endif
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+void __cxx_atomic_init(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __val) _NOEXCEPT {
+ __c11_atomic_init(&__a->__a_value, __val);
+}
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+void __cxx_atomic_init(__cxx_atomic_base_impl<_Tp> * __a, _Tp __val) _NOEXCEPT {
+ __c11_atomic_init(&__a->__a_value, __val);
+}
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+void __cxx_atomic_store(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __val, memory_order __order) _NOEXCEPT {
+ __c11_atomic_store(&__a->__a_value, __val, static_cast<__memory_order_underlying_t>(__order));
+}
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+void __cxx_atomic_store(__cxx_atomic_base_impl<_Tp> * __a, _Tp __val, memory_order __order) _NOEXCEPT {
+ __c11_atomic_store(&__a->__a_value, __val, static_cast<__memory_order_underlying_t>(__order));
+}
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_load(__cxx_atomic_base_impl<_Tp> const volatile* __a, memory_order __order) _NOEXCEPT {
+ using __ptr_type = typename remove_const<decltype(__a->__a_value)>::type*;
+ return __c11_atomic_load(const_cast<__ptr_type>(&__a->__a_value), static_cast<__memory_order_underlying_t>(__order));
+}
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_load(__cxx_atomic_base_impl<_Tp> const* __a, memory_order __order) _NOEXCEPT {
+ using __ptr_type = typename remove_const<decltype(__a->__a_value)>::type*;
+ return __c11_atomic_load(const_cast<__ptr_type>(&__a->__a_value), static_cast<__memory_order_underlying_t>(__order));
+}
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_exchange(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __value, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_exchange(&__a->__a_value, __value, static_cast<__memory_order_underlying_t>(__order));
+}
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_exchange(__cxx_atomic_base_impl<_Tp> * __a, _Tp __value, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_exchange(&__a->__a_value, __value, static_cast<__memory_order_underlying_t>(__order));
+}
+
+// Disable double inline warning
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( push )
+#pragma warning ( disable : 4141 )
+#endif
+_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);
+}
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( pop )
+#endif
+
+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>(__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>(__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>(__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>(__to_failure_order(__failure)));
+}
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __delta, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_fetch_add(&__a->__a_value, __delta, static_cast<__memory_order_underlying_t>(__order));
+}
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp> * __a, _Tp __delta, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_fetch_add(&__a->__a_value, __delta, static_cast<__memory_order_underlying_t>(__order));
+}
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp* __cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp*> volatile* __a, ptrdiff_t __delta, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_fetch_add(&__a->__a_value, __delta, static_cast<__memory_order_underlying_t>(__order));
+}
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp* __cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp*> * __a, ptrdiff_t __delta, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_fetch_add(&__a->__a_value, __delta, static_cast<__memory_order_underlying_t>(__order));
+}
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __delta, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_fetch_sub(&__a->__a_value, __delta, static_cast<__memory_order_underlying_t>(__order));
+}
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp> * __a, _Tp __delta, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_fetch_sub(&__a->__a_value, __delta, static_cast<__memory_order_underlying_t>(__order));
+}
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp* __cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp*> volatile* __a, ptrdiff_t __delta, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_fetch_sub(&__a->__a_value, __delta, static_cast<__memory_order_underlying_t>(__order));
+}
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp* __cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp*> * __a, ptrdiff_t __delta, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_fetch_sub(&__a->__a_value, __delta, static_cast<__memory_order_underlying_t>(__order));
+}
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_and(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __pattern, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_fetch_and(&__a->__a_value, __pattern, static_cast<__memory_order_underlying_t>(__order));
+}
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_and(__cxx_atomic_base_impl<_Tp> * __a, _Tp __pattern, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_fetch_and(&__a->__a_value, __pattern, static_cast<__memory_order_underlying_t>(__order));
+}
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_or(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __pattern, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_fetch_or(&__a->__a_value, __pattern, static_cast<__memory_order_underlying_t>(__order));
+}
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_or(__cxx_atomic_base_impl<_Tp> * __a, _Tp __pattern, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_fetch_or(&__a->__a_value, __pattern, static_cast<__memory_order_underlying_t>(__order));
+}
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_xor(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __pattern, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_fetch_xor(&__a->__a_value, __pattern, static_cast<__memory_order_underlying_t>(__order));
+}
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_xor(__cxx_atomic_base_impl<_Tp> * __a, _Tp __pattern, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_fetch_xor(&__a->__a_value, __pattern, static_cast<__memory_order_underlying_t>(__order));
+}
+
+#endif // _LIBCPP_HAS_GCC_ATOMIC_IMP, _LIBCPP_HAS_C_ATOMIC_IMP
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp kill_dependency(_Tp __y) _NOEXCEPT
+{
+ return __y;
+}
+
+#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_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
+# define ATOMIC_CHAR32_T_LOCK_FREE __CLANG_ATOMIC_CHAR32_T_LOCK_FREE
+# define ATOMIC_WCHAR_T_LOCK_FREE __CLANG_ATOMIC_WCHAR_T_LOCK_FREE
+# define ATOMIC_SHORT_LOCK_FREE __CLANG_ATOMIC_SHORT_LOCK_FREE
+# define ATOMIC_INT_LOCK_FREE __CLANG_ATOMIC_INT_LOCK_FREE
+# define ATOMIC_LONG_LOCK_FREE __CLANG_ATOMIC_LONG_LOCK_FREE
+# define ATOMIC_LLONG_LOCK_FREE __CLANG_ATOMIC_LLONG_LOCK_FREE
+# define ATOMIC_POINTER_LOCK_FREE __CLANG_ATOMIC_POINTER_LOCK_FREE
+#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_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
+# define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE
+# define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE
+# define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE
+# define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE
+# define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE
+# define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE
+# define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE
+#endif
+
+#ifdef _LIBCPP_ATOMIC_ONLY_USE_BUILTINS
+
+template<typename _Tp>
+struct __cxx_atomic_lock_impl {
+
+ _LIBCPP_INLINE_VISIBILITY
+ __cxx_atomic_lock_impl() _NOEXCEPT
+ : __a_value(), __a_lock(0) {}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR explicit
+ __cxx_atomic_lock_impl(_Tp value) _NOEXCEPT
+ : __a_value(value), __a_lock(0) {}
+
+ _Tp __a_value;
+ mutable __cxx_atomic_base_impl<_LIBCPP_ATOMIC_FLAG_TYPE> __a_lock;
+
+ _LIBCPP_INLINE_VISIBILITY void __lock() const volatile {
+ while(1 == __cxx_atomic_exchange(&__a_lock, _LIBCPP_ATOMIC_FLAG_TYPE(true), memory_order_acquire))
+ /*spin*/;
+ }
+ _LIBCPP_INLINE_VISIBILITY void __lock() const {
+ while(1 == __cxx_atomic_exchange(&__a_lock, _LIBCPP_ATOMIC_FLAG_TYPE(true), memory_order_acquire))
+ /*spin*/;
+ }
+ _LIBCPP_INLINE_VISIBILITY void __unlock() const volatile {
+ __cxx_atomic_store(&__a_lock, _LIBCPP_ATOMIC_FLAG_TYPE(false), memory_order_release);
+ }
+ _LIBCPP_INLINE_VISIBILITY void __unlock() const {
+ __cxx_atomic_store(&__a_lock, _LIBCPP_ATOMIC_FLAG_TYPE(false), memory_order_release);
+ }
+ _LIBCPP_INLINE_VISIBILITY _Tp __read() const volatile {
+ __lock();
+ _Tp __old;
+ __cxx_atomic_assign_volatile(__old, __a_value);
+ __unlock();
+ return __old;
+ }
+ _LIBCPP_INLINE_VISIBILITY _Tp __read() const {
+ __lock();
+ _Tp __old = __a_value;
+ __unlock();
+ return __old;
+ }
+};
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+void __cxx_atomic_init(volatile __cxx_atomic_lock_impl<_Tp>* __a, _Tp __val) {
+ __cxx_atomic_assign_volatile(__a->__a_value, __val);
+}
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+void __cxx_atomic_init(__cxx_atomic_lock_impl<_Tp>* __a, _Tp __val) {
+ __a->__a_value = __val;
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+void __cxx_atomic_store(volatile __cxx_atomic_lock_impl<_Tp>* __a, _Tp __val, memory_order) {
+ __a->__lock();
+ __cxx_atomic_assign_volatile(__a->__a_value, __val);
+ __a->__unlock();
+}
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+void __cxx_atomic_store(__cxx_atomic_lock_impl<_Tp>* __a, _Tp __val, memory_order) {
+ __a->__lock();
+ __a->__a_value = __val;
+ __a->__unlock();
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_load(const volatile __cxx_atomic_lock_impl<_Tp>* __a, memory_order) {
+ return __a->__read();
+}
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_load(const __cxx_atomic_lock_impl<_Tp>* __a, memory_order) {
+ return __a->__read();
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_exchange(volatile __cxx_atomic_lock_impl<_Tp>* __a, _Tp __value, memory_order) {
+ __a->__lock();
+ _Tp __old;
+ __cxx_atomic_assign_volatile(__old, __a->__a_value);
+ __cxx_atomic_assign_volatile(__a->__a_value, __value);
+ __a->__unlock();
+ return __old;
+}
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_exchange(__cxx_atomic_lock_impl<_Tp>* __a, _Tp __value, memory_order) {
+ __a->__lock();
+ _Tp __old = __a->__a_value;
+ __a->__a_value = __value;
+ __a->__unlock();
+ return __old;
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+bool __cxx_atomic_compare_exchange_strong(volatile __cxx_atomic_lock_impl<_Tp>* __a,
+ _Tp* __expected, _Tp __value, memory_order, memory_order) {
+ _Tp __temp;
+ __a->__lock();
+ __cxx_atomic_assign_volatile(__temp, __a->__a_value);
+ bool __ret = (_VSTD::memcmp(&__temp, __expected, sizeof(_Tp)) == 0);
+ if(__ret)
+ __cxx_atomic_assign_volatile(__a->__a_value, __value);
+ else
+ __cxx_atomic_assign_volatile(*__expected, __a->__a_value);
+ __a->__unlock();
+ return __ret;
+}
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+bool __cxx_atomic_compare_exchange_strong(__cxx_atomic_lock_impl<_Tp>* __a,
+ _Tp* __expected, _Tp __value, memory_order, memory_order) {
+ __a->__lock();
+ bool __ret = (_VSTD::memcmp(&__a->__a_value, __expected, sizeof(_Tp)) == 0);
+ if(__ret)
+ _VSTD::memcpy(&__a->__a_value, &__value, sizeof(_Tp));
+ else
+ _VSTD::memcpy(__expected, &__a->__a_value, sizeof(_Tp));
+ __a->__unlock();
+ return __ret;
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+bool __cxx_atomic_compare_exchange_weak(volatile __cxx_atomic_lock_impl<_Tp>* __a,
+ _Tp* __expected, _Tp __value, memory_order, memory_order) {
+ _Tp __temp;
+ __a->__lock();
+ __cxx_atomic_assign_volatile(__temp, __a->__a_value);
+ bool __ret = (_VSTD::memcmp(&__temp, __expected, sizeof(_Tp)) == 0);
+ if(__ret)
+ __cxx_atomic_assign_volatile(__a->__a_value, __value);
+ else
+ __cxx_atomic_assign_volatile(*__expected, __a->__a_value);
+ __a->__unlock();
+ return __ret;
+}
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+bool __cxx_atomic_compare_exchange_weak(__cxx_atomic_lock_impl<_Tp>* __a,
+ _Tp* __expected, _Tp __value, memory_order, memory_order) {
+ __a->__lock();
+ bool __ret = (_VSTD::memcmp(&__a->__a_value, __expected, sizeof(_Tp)) == 0);
+ if(__ret)
+ _VSTD::memcpy(&__a->__a_value, &__value, sizeof(_Tp));
+ else
+ _VSTD::memcpy(__expected, &__a->__a_value, sizeof(_Tp));
+ __a->__unlock();
+ return __ret;
+}
+
+template <typename _Tp, typename _Td>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_add(volatile __cxx_atomic_lock_impl<_Tp>* __a,
+ _Td __delta, memory_order) {
+ __a->__lock();
+ _Tp __old;
+ __cxx_atomic_assign_volatile(__old, __a->__a_value);
+ __cxx_atomic_assign_volatile(__a->__a_value, _Tp(__old + __delta));
+ __a->__unlock();
+ return __old;
+}
+template <typename _Tp, typename _Td>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_add(__cxx_atomic_lock_impl<_Tp>* __a,
+ _Td __delta, memory_order) {
+ __a->__lock();
+ _Tp __old = __a->__a_value;
+ __a->__a_value += __delta;
+ __a->__unlock();
+ return __old;
+}
+
+template <typename _Tp, typename _Td>
+_LIBCPP_INLINE_VISIBILITY
+_Tp* __cxx_atomic_fetch_add(volatile __cxx_atomic_lock_impl<_Tp*>* __a,
+ ptrdiff_t __delta, memory_order) {
+ __a->__lock();
+ _Tp* __old;
+ __cxx_atomic_assign_volatile(__old, __a->__a_value);
+ __cxx_atomic_assign_volatile(__a->__a_value, __old + __delta);
+ __a->__unlock();
+ return __old;
+}
+template <typename _Tp, typename _Td>
+_LIBCPP_INLINE_VISIBILITY
+_Tp* __cxx_atomic_fetch_add(__cxx_atomic_lock_impl<_Tp*>* __a,
+ ptrdiff_t __delta, memory_order) {
+ __a->__lock();
+ _Tp* __old = __a->__a_value;
+ __a->__a_value += __delta;
+ __a->__unlock();
+ return __old;
+}
+
+template <typename _Tp, typename _Td>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_sub(volatile __cxx_atomic_lock_impl<_Tp>* __a,
+ _Td __delta, memory_order) {
+ __a->__lock();
+ _Tp __old;
+ __cxx_atomic_assign_volatile(__old, __a->__a_value);
+ __cxx_atomic_assign_volatile(__a->__a_value, _Tp(__old - __delta));
+ __a->__unlock();
+ return __old;
+}
+template <typename _Tp, typename _Td>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_sub(__cxx_atomic_lock_impl<_Tp>* __a,
+ _Td __delta, memory_order) {
+ __a->__lock();
+ _Tp __old = __a->__a_value;
+ __a->__a_value -= __delta;
+ __a->__unlock();
+ return __old;
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_and(volatile __cxx_atomic_lock_impl<_Tp>* __a,
+ _Tp __pattern, memory_order) {
+ __a->__lock();
+ _Tp __old;
+ __cxx_atomic_assign_volatile(__old, __a->__a_value);
+ __cxx_atomic_assign_volatile(__a->__a_value, _Tp(__old & __pattern));
+ __a->__unlock();
+ return __old;
+}
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_and(__cxx_atomic_lock_impl<_Tp>* __a,
+ _Tp __pattern, memory_order) {
+ __a->__lock();
+ _Tp __old = __a->__a_value;
+ __a->__a_value &= __pattern;
+ __a->__unlock();
+ return __old;
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_or(volatile __cxx_atomic_lock_impl<_Tp>* __a,
+ _Tp __pattern, memory_order) {
+ __a->__lock();
+ _Tp __old;
+ __cxx_atomic_assign_volatile(__old, __a->__a_value);
+ __cxx_atomic_assign_volatile(__a->__a_value, _Tp(__old | __pattern));
+ __a->__unlock();
+ return __old;
+}
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_or(__cxx_atomic_lock_impl<_Tp>* __a,
+ _Tp __pattern, memory_order) {
+ __a->__lock();
+ _Tp __old = __a->__a_value;
+ __a->__a_value |= __pattern;
+ __a->__unlock();
+ return __old;
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_xor(volatile __cxx_atomic_lock_impl<_Tp>* __a,
+ _Tp __pattern, memory_order) {
+ __a->__lock();
+ _Tp __old;
+ __cxx_atomic_assign_volatile(__old, __a->__a_value);
+ __cxx_atomic_assign_volatile(__a->__a_value, _Tp(__old ^ __pattern));
+ __a->__unlock();
+ return __old;
+}
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_xor(__cxx_atomic_lock_impl<_Tp>* __a,
+ _Tp __pattern, memory_order) {
+ __a->__lock();
+ _Tp __old = __a->__a_value;
+ __a->__a_value ^= __pattern;
+ __a->__unlock();
+ return __old;
+}
+
+#ifdef __cpp_lib_atomic_is_always_lock_free
+
+template<typename _Tp> struct __cxx_is_always_lock_free {
+ enum { __value = __atomic_always_lock_free(sizeof(_Tp), 0) }; };
+
+#else
+
+template<typename _Tp> struct __cxx_is_always_lock_free { enum { __value = false }; };
+// Implementations must match the C ATOMIC_*_LOCK_FREE macro values.
+template<> struct __cxx_is_always_lock_free<bool> { enum { __value = 2 == ATOMIC_BOOL_LOCK_FREE }; };
+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_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 }; };
+template<> struct __cxx_is_always_lock_free<char32_t> { enum { __value = 2 == ATOMIC_CHAR32_T_LOCK_FREE }; };
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template<> struct __cxx_is_always_lock_free<wchar_t> { enum { __value = 2 == ATOMIC_WCHAR_T_LOCK_FREE }; };
+#endif
+template<> struct __cxx_is_always_lock_free<short> { enum { __value = 2 == ATOMIC_SHORT_LOCK_FREE }; };
+template<> struct __cxx_is_always_lock_free<unsigned short> { enum { __value = 2 == ATOMIC_SHORT_LOCK_FREE }; };
+template<> struct __cxx_is_always_lock_free<int> { enum { __value = 2 == ATOMIC_INT_LOCK_FREE }; };
+template<> struct __cxx_is_always_lock_free<unsigned int> { enum { __value = 2 == ATOMIC_INT_LOCK_FREE }; };
+template<> struct __cxx_is_always_lock_free<long> { enum { __value = 2 == ATOMIC_LONG_LOCK_FREE }; };
+template<> struct __cxx_is_always_lock_free<unsigned long> { enum { __value = 2 == ATOMIC_LONG_LOCK_FREE }; };
+template<> struct __cxx_is_always_lock_free<long long> { enum { __value = 2 == ATOMIC_LLONG_LOCK_FREE }; };
+template<> struct __cxx_is_always_lock_free<unsigned long long> { enum { __value = 2 == ATOMIC_LLONG_LOCK_FREE }; };
+template<typename _Tp> struct __cxx_is_always_lock_free<_Tp*> { enum { __value = 2 == ATOMIC_POINTER_LOCK_FREE }; };
+template<> struct __cxx_is_always_lock_free<std::nullptr_t> { enum { __value = 2 == ATOMIC_POINTER_LOCK_FREE }; };
+
+#endif //__cpp_lib_atomic_is_always_lock_free
+
+template <typename _Tp,
+ typename _Base = typename conditional<__cxx_is_always_lock_free<_Tp>::__value,
+ __cxx_atomic_base_impl<_Tp>,
+ __cxx_atomic_lock_impl<_Tp> >::type>
+#else
+template <typename _Tp,
+ typename _Base = __cxx_atomic_base_impl<_Tp> >
+#endif //_LIBCPP_ATOMIC_ONLY_USE_BUILTINS
+struct __cxx_atomic_impl : public _Base {
+ static_assert(is_trivially_copyable<_Tp>::value,
+ "std::atomic<T> requires that 'T' be a trivially copyable type");
+
+ _LIBCPP_INLINE_VISIBILITY __cxx_atomic_impl() _NOEXCEPT = default;
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR explicit __cxx_atomic_impl(_Tp value) _NOEXCEPT
+ : _Base(value) {}
+};
+
+#ifdef __linux__
+ using __cxx_contention_t = int32_t;
+#else
+ using __cxx_contention_t = int64_t;
+#endif //__linux__
+
+using __cxx_atomic_contention_t = __cxx_atomic_impl<__cxx_contention_t>;
+
+#if defined(_LIBCPP_HAS_NO_THREADS)
+# define _LIBCPP_HAS_NO_PLATFORM_WAIT
+#endif
+
+// TODO:
+// _LIBCPP_HAS_NO_PLATFORM_WAIT is currently a "dead" macro, in the sense that
+// it is not tied anywhere into the build system or even documented. We should
+// clean it up because it is technically never defined except when threads are
+// disabled. We should clean it up in its own changeset in case we break "bad"
+// users.
+#ifndef _LIBCPP_HAS_NO_PLATFORM_WAIT
+
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(void const volatile*);
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(void const volatile*);
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t __libcpp_atomic_monitor(void const volatile*);
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __libcpp_atomic_wait(void const volatile*, __cxx_contention_t);
+
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(__cxx_atomic_contention_t const volatile*);
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(__cxx_atomic_contention_t const volatile*);
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t __libcpp_atomic_monitor(__cxx_atomic_contention_t const volatile*);
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __libcpp_atomic_wait(__cxx_atomic_contention_t const volatile*, __cxx_contention_t);
+
+template <class _Atp, class _Fn>
+struct __libcpp_atomic_wait_backoff_impl {
+ _Atp* __a;
+ _Fn __test_fn;
+ _LIBCPP_AVAILABILITY_SYNC
+ _LIBCPP_INLINE_VISIBILITY bool operator()(chrono::nanoseconds __elapsed) const
+ {
+ if(__elapsed > chrono::microseconds(64))
+ {
+ auto const __monitor = __libcpp_atomic_monitor(__a);
+ if(__test_fn())
+ return true;
+ __libcpp_atomic_wait(__a, __monitor);
+ }
+ else if(__elapsed > chrono::microseconds(4))
+ __libcpp_thread_yield();
+ else
+ {} // poll
+ return false;
+ }
+};
+
+template <class _Atp, class _Fn>
+_LIBCPP_AVAILABILITY_SYNC
+_LIBCPP_INLINE_VISIBILITY bool __cxx_atomic_wait(_Atp* __a, _Fn && __test_fn)
+{
+ __libcpp_atomic_wait_backoff_impl<_Atp, typename decay<_Fn>::type> __backoff_fn = {__a, __test_fn};
+ return __libcpp_thread_poll_with_backoff(__test_fn, __backoff_fn);
+}
+
+#else // _LIBCPP_HAS_NO_PLATFORM_WAIT
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY void __cxx_atomic_notify_all(__cxx_atomic_impl<_Tp> const volatile*) { }
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY void __cxx_atomic_notify_one(__cxx_atomic_impl<_Tp> const volatile*) { }
+template <class _Atp, class _Fn>
+_LIBCPP_INLINE_VISIBILITY bool __cxx_atomic_wait(_Atp*, _Fn && __test_fn)
+{
+#if defined(_LIBCPP_HAS_NO_THREADS)
+ using _Policy = __spinning_backoff_policy;
+#else
+ using _Policy = __libcpp_timed_backoff_policy;
+#endif
+ return __libcpp_thread_poll_with_backoff(__test_fn, _Policy());
+}
+
+#endif // _LIBCPP_HAS_NO_PLATFORM_WAIT
+
+template <class _Atp, class _Tp>
+struct __cxx_atomic_wait_test_fn_impl {
+ _Atp* __a;
+ _Tp __val;
+ memory_order __order;
+ _LIBCPP_INLINE_VISIBILITY bool operator()() const
+ {
+ return !__cxx_nonatomic_compare_equal(__cxx_atomic_load(__a, __order), __val);
+ }
+};
+
+template <class _Atp, class _Tp>
+_LIBCPP_AVAILABILITY_SYNC
+_LIBCPP_INLINE_VISIBILITY bool __cxx_atomic_wait(_Atp* __a, _Tp const __val, memory_order __order)
+{
+ __cxx_atomic_wait_test_fn_impl<_Atp, _Tp> __test_fn = {__a, __val, __order};
+ return __cxx_atomic_wait(__a, __test_fn);
+}
+
+// general atomic<T>
+
+template <class _Tp, bool = is_integral<_Tp>::value && !is_same<_Tp, bool>::value>
+struct __atomic_base // false
+{
+ mutable __cxx_atomic_impl<_Tp> __a_;
+
+#if defined(__cpp_lib_atomic_is_always_lock_free)
+ static _LIBCPP_CONSTEXPR bool is_always_lock_free = __atomic_always_lock_free(sizeof(__a_), 0);
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool is_lock_free() const volatile _NOEXCEPT
+ {return __cxx_atomic_is_lock_free(sizeof(_Tp));}
+ _LIBCPP_INLINE_VISIBILITY
+ bool is_lock_free() const _NOEXCEPT
+ {return static_cast<__atomic_base const volatile*>(this)->is_lock_free();}
+ _LIBCPP_INLINE_VISIBILITY
+ void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
+ _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m)
+ {__cxx_atomic_store(&__a_, __d, __m);}
+ _LIBCPP_INLINE_VISIBILITY
+ void store(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT
+ _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m)
+ {__cxx_atomic_store(&__a_, __d, __m);}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp load(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT
+ _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m)
+ {return __cxx_atomic_load(&__a_, __m);}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp load(memory_order __m = memory_order_seq_cst) const _NOEXCEPT
+ _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m)
+ {return __cxx_atomic_load(&__a_, __m);}
+ _LIBCPP_INLINE_VISIBILITY
+ operator _Tp() const volatile _NOEXCEPT {return load();}
+ _LIBCPP_INLINE_VISIBILITY
+ operator _Tp() const _NOEXCEPT {return load();}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
+ {return __cxx_atomic_exchange(&__a_, __d, __m);}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT
+ {return __cxx_atomic_exchange(&__a_, __d, __m);}
+ _LIBCPP_INLINE_VISIBILITY
+ bool compare_exchange_weak(_Tp& __e, _Tp __d,
+ memory_order __s, memory_order __f) volatile _NOEXCEPT
+ _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
+ {return __cxx_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);}
+ _LIBCPP_INLINE_VISIBILITY
+ bool compare_exchange_weak(_Tp& __e, _Tp __d,
+ memory_order __s, memory_order __f) _NOEXCEPT
+ _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
+ {return __cxx_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);}
+ _LIBCPP_INLINE_VISIBILITY
+ bool compare_exchange_strong(_Tp& __e, _Tp __d,
+ memory_order __s, memory_order __f) volatile _NOEXCEPT
+ _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
+ {return __cxx_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);}
+ _LIBCPP_INLINE_VISIBILITY
+ bool compare_exchange_strong(_Tp& __e, _Tp __d,
+ memory_order __s, memory_order __f) _NOEXCEPT
+ _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
+ {return __cxx_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);}
+ _LIBCPP_INLINE_VISIBILITY
+ bool compare_exchange_weak(_Tp& __e, _Tp __d,
+ memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
+ {return __cxx_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);}
+ _LIBCPP_INLINE_VISIBILITY
+ bool compare_exchange_weak(_Tp& __e, _Tp __d,
+ memory_order __m = memory_order_seq_cst) _NOEXCEPT
+ {return __cxx_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);}
+ _LIBCPP_INLINE_VISIBILITY
+ bool compare_exchange_strong(_Tp& __e, _Tp __d,
+ memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
+ {return __cxx_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);}
+ _LIBCPP_INLINE_VISIBILITY
+ bool compare_exchange_strong(_Tp& __e, _Tp __d,
+ memory_order __m = memory_order_seq_cst) _NOEXCEPT
+ {return __cxx_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);}
+
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void wait(_Tp __v, memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT
+ {__cxx_atomic_wait(&__a_, __v, __m);}
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void wait(_Tp __v, memory_order __m = memory_order_seq_cst) const _NOEXCEPT
+ {__cxx_atomic_wait(&__a_, __v, __m);}
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void notify_one() volatile _NOEXCEPT
+ {__cxx_atomic_notify_one(&__a_);}
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void notify_one() _NOEXCEPT
+ {__cxx_atomic_notify_one(&__a_);}
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void notify_all() volatile _NOEXCEPT
+ {__cxx_atomic_notify_all(&__a_);}
+ _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 = default;
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {}
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( push )
+#pragma warning ( disable : 4522 )
+#endif
+ __atomic_base(const __atomic_base&) = delete;
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( pop )
+#endif
+};
+
+#if defined(__cpp_lib_atomic_is_always_lock_free)
+template <class _Tp, bool __b>
+_LIBCPP_CONSTEXPR bool __atomic_base<_Tp, __b>::is_always_lock_free;
+#endif
+
+// atomic<Integral>
+
+template <class _Tp>
+struct __atomic_base<_Tp, true>
+ : public __atomic_base<_Tp, false>
+{
+ typedef __atomic_base<_Tp, false> __base;
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ __atomic_base() _NOEXCEPT = default;
+
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
+ {return __cxx_atomic_fetch_add(&this->__a_, __op, __m);}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
+ {return __cxx_atomic_fetch_add(&this->__a_, __op, __m);}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
+ {return __cxx_atomic_fetch_sub(&this->__a_, __op, __m);}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
+ {return __cxx_atomic_fetch_sub(&this->__a_, __op, __m);}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
+ {return __cxx_atomic_fetch_and(&this->__a_, __op, __m);}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
+ {return __cxx_atomic_fetch_and(&this->__a_, __op, __m);}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
+ {return __cxx_atomic_fetch_or(&this->__a_, __op, __m);}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
+ {return __cxx_atomic_fetch_or(&this->__a_, __op, __m);}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
+ {return __cxx_atomic_fetch_xor(&this->__a_, __op, __m);}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
+ {return __cxx_atomic_fetch_xor(&this->__a_, __op, __m);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp operator++(int) volatile _NOEXCEPT {return fetch_add(_Tp(1));}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp operator++(int) _NOEXCEPT {return fetch_add(_Tp(1));}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp operator--(int) volatile _NOEXCEPT {return fetch_sub(_Tp(1));}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp operator--(int) _NOEXCEPT {return fetch_sub(_Tp(1));}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp operator++() volatile _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp operator++() _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp operator--() volatile _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp operator--() _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp operator+=(_Tp __op) volatile _NOEXCEPT {return fetch_add(__op) + __op;}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp operator+=(_Tp __op) _NOEXCEPT {return fetch_add(__op) + __op;}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp operator-=(_Tp __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp operator-=(_Tp __op) _NOEXCEPT {return fetch_sub(__op) - __op;}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp operator&=(_Tp __op) volatile _NOEXCEPT {return fetch_and(__op) & __op;}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp operator&=(_Tp __op) _NOEXCEPT {return fetch_and(__op) & __op;}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp operator|=(_Tp __op) volatile _NOEXCEPT {return fetch_or(__op) | __op;}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp operator|=(_Tp __op) _NOEXCEPT {return fetch_or(__op) | __op;}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp operator^=(_Tp __op) volatile _NOEXCEPT {return fetch_xor(__op) ^ __op;}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp operator^=(_Tp __op) _NOEXCEPT {return fetch_xor(__op) ^ __op;}
+};
+
+// atomic<T>
+
+template <class _Tp>
+struct atomic
+ : public __atomic_base<_Tp>
+{
+ 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 = default;
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR atomic(_Tp __d) _NOEXCEPT : __base(__d) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp operator=(_Tp __d) volatile _NOEXCEPT
+ {__base::store(__d); return __d;}
+ _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*>
+
+template <class _Tp>
+struct atomic<_Tp*>
+ : public __atomic_base<_Tp*>
+{
+ typedef __atomic_base<_Tp*> __base;
+ typedef _Tp* value_type;
+ typedef ptrdiff_t difference_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ atomic() _NOEXCEPT = default;
+
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR atomic(_Tp* __d) _NOEXCEPT : __base(__d) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp* operator=(_Tp* __d) volatile _NOEXCEPT
+ {__base::store(__d); return __d;}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp* operator=(_Tp* __d) _NOEXCEPT
+ {__base::store(__d); return __d;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT {
+ // __atomic_fetch_add accepts function pointers, guard against them.
+ static_assert(!is_function<typename remove_pointer<_Tp>::type>::value, "Pointer to function isn't allowed");
+ return __cxx_atomic_fetch_add(&this->__a_, __op, __m);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT {
+ // __atomic_fetch_add accepts function pointers, guard against them.
+ static_assert(!is_function<typename remove_pointer<_Tp>::type>::value, "Pointer to function isn't allowed");
+ return __cxx_atomic_fetch_add(&this->__a_, __op, __m);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT {
+ // __atomic_fetch_add accepts function pointers, guard against them.
+ static_assert(!is_function<typename remove_pointer<_Tp>::type>::value, "Pointer to function isn't allowed");
+ return __cxx_atomic_fetch_sub(&this->__a_, __op, __m);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT {
+ // __atomic_fetch_add accepts function pointers, guard against them.
+ static_assert(!is_function<typename remove_pointer<_Tp>::type>::value, "Pointer to function isn't allowed");
+ return __cxx_atomic_fetch_sub(&this->__a_, __op, __m);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp* operator++(int) volatile _NOEXCEPT {return fetch_add(1);}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp* operator++(int) _NOEXCEPT {return fetch_add(1);}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp* operator--(int) volatile _NOEXCEPT {return fetch_sub(1);}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp* operator--(int) _NOEXCEPT {return fetch_sub(1);}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp* operator++() volatile _NOEXCEPT {return fetch_add(1) + 1;}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp* operator++() _NOEXCEPT {return fetch_add(1) + 1;}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp* operator--() volatile _NOEXCEPT {return fetch_sub(1) - 1;}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp* operator--() _NOEXCEPT {return fetch_sub(1) - 1;}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp* operator+=(ptrdiff_t __op) volatile _NOEXCEPT {return fetch_add(__op) + __op;}
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp* operator+=(ptrdiff_t __op) _NOEXCEPT {return fetch_add(__op) + __op;}
+ _LIBCPP_INLINE_VISIBILITY
+ _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
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+bool
+atomic_is_lock_free(const volatile atomic<_Tp>* __o) _NOEXCEPT
+{
+ return __o->is_lock_free();
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+bool
+atomic_is_lock_free(const atomic<_Tp>* __o) _NOEXCEPT
+{
+ return __o->is_lock_free();
+}
+
+// atomic_init
+
+template <class _Tp>
+_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_INLINE_VISIBILITY
+void
+atomic_init(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d) _NOEXCEPT
+{
+ __cxx_atomic_init(&__o->__a_, __d);
+}
+
+template <class _Tp>
+_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_INLINE_VISIBILITY
+void
+atomic_init(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d) _NOEXCEPT
+{
+ __cxx_atomic_init(&__o->__a_, __d);
+}
+
+// atomic_store
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+void
+atomic_store(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d) _NOEXCEPT
+{
+ __o->store(__d);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+void
+atomic_store(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d) _NOEXCEPT
+{
+ __o->store(__d);
+}
+
+// atomic_store_explicit
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+void
+atomic_store_explicit(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d, memory_order __m) _NOEXCEPT
+ _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m)
+{
+ __o->store(__d, __m);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+void
+atomic_store_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d, memory_order __m) _NOEXCEPT
+ _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m)
+{
+ __o->store(__d, __m);
+}
+
+// atomic_load
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp
+atomic_load(const volatile atomic<_Tp>* __o) _NOEXCEPT
+{
+ return __o->load();
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp
+atomic_load(const atomic<_Tp>* __o) _NOEXCEPT
+{
+ return __o->load();
+}
+
+// atomic_load_explicit
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp
+atomic_load_explicit(const volatile atomic<_Tp>* __o, memory_order __m) _NOEXCEPT
+ _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m)
+{
+ return __o->load(__m);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp
+atomic_load_explicit(const atomic<_Tp>* __o, memory_order __m) _NOEXCEPT
+ _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m)
+{
+ return __o->load(__m);
+}
+
+// atomic_exchange
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp
+atomic_exchange(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d) _NOEXCEPT
+{
+ return __o->exchange(__d);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp
+atomic_exchange(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d) _NOEXCEPT
+{
+ return __o->exchange(__d);
+}
+
+// atomic_exchange_explicit
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp
+atomic_exchange_explicit(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d, memory_order __m) _NOEXCEPT
+{
+ return __o->exchange(__d, __m);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp
+atomic_exchange_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d, memory_order __m) _NOEXCEPT
+{
+ return __o->exchange(__d, __m);
+}
+
+// atomic_compare_exchange_weak
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+bool
+atomic_compare_exchange_weak(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type* __e, typename atomic<_Tp>::value_type __d) _NOEXCEPT
+{
+ return __o->compare_exchange_weak(*__e, __d);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+bool
+atomic_compare_exchange_weak(atomic<_Tp>* __o, typename atomic<_Tp>::value_type* __e, typename atomic<_Tp>::value_type __d) _NOEXCEPT
+{
+ return __o->compare_exchange_weak(*__e, __d);
+}
+
+// atomic_compare_exchange_strong
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+bool
+atomic_compare_exchange_strong(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type* __e, typename atomic<_Tp>::value_type __d) _NOEXCEPT
+{
+ return __o->compare_exchange_strong(*__e, __d);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+bool
+atomic_compare_exchange_strong(atomic<_Tp>* __o, typename atomic<_Tp>::value_type* __e, typename atomic<_Tp>::value_type __d) _NOEXCEPT
+{
+ return __o->compare_exchange_strong(*__e, __d);
+}
+
+// atomic_compare_exchange_weak_explicit
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+bool
+atomic_compare_exchange_weak_explicit(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type* __e,
+ typename atomic<_Tp>::value_type __d,
+ memory_order __s, memory_order __f) _NOEXCEPT
+ _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
+{
+ return __o->compare_exchange_weak(*__e, __d, __s, __f);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+bool
+atomic_compare_exchange_weak_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::value_type* __e, typename atomic<_Tp>::value_type __d,
+ memory_order __s, memory_order __f) _NOEXCEPT
+ _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
+{
+ return __o->compare_exchange_weak(*__e, __d, __s, __f);
+}
+
+// atomic_compare_exchange_strong_explicit
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+bool
+atomic_compare_exchange_strong_explicit(volatile atomic<_Tp>* __o,
+ typename atomic<_Tp>::value_type* __e, typename atomic<_Tp>::value_type __d,
+ memory_order __s, memory_order __f) _NOEXCEPT
+ _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
+{
+ return __o->compare_exchange_strong(*__e, __d, __s, __f);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+bool
+atomic_compare_exchange_strong_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::value_type* __e,
+ typename atomic<_Tp>::value_type __d,
+ memory_order __s, memory_order __f) _NOEXCEPT
+ _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
+{
+ return __o->compare_exchange_strong(*__e, __d, __s, __f);
+}
+
+// atomic_wait
+
+template <class _Tp>
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+void atomic_wait(const volatile atomic<_Tp>* __o,
+ typename atomic<_Tp>::value_type __v) _NOEXCEPT
+{
+ return __o->wait(__v);
+}
+
+template <class _Tp>
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+void atomic_wait(const atomic<_Tp>* __o,
+ typename atomic<_Tp>::value_type __v) _NOEXCEPT
+{
+ return __o->wait(__v);
+}
+
+// atomic_wait_explicit
+
+template <class _Tp>
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+void atomic_wait_explicit(const volatile atomic<_Tp>* __o,
+ typename atomic<_Tp>::value_type __v,
+ memory_order __m) _NOEXCEPT
+ _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m)
+{
+ return __o->wait(__v, __m);
+}
+
+template <class _Tp>
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+void atomic_wait_explicit(const atomic<_Tp>* __o,
+ typename atomic<_Tp>::value_type __v,
+ memory_order __m) _NOEXCEPT
+ _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m)
+{
+ return __o->wait(__v, __m);
+}
+
+// atomic_notify_one
+
+template <class _Tp>
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+void atomic_notify_one(volatile atomic<_Tp>* __o) _NOEXCEPT
+{
+ __o->notify_one();
+}
+template <class _Tp>
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+void atomic_notify_one(atomic<_Tp>* __o) _NOEXCEPT
+{
+ __o->notify_one();
+}
+
+// atomic_notify_one
+
+template <class _Tp>
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+void atomic_notify_all(volatile atomic<_Tp>* __o) _NOEXCEPT
+{
+ __o->notify_all();
+}
+template <class _Tp>
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+void atomic_notify_all(atomic<_Tp>* __o) _NOEXCEPT
+{
+ __o->notify_all();
+}
+
+// atomic_fetch_add
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp
+atomic_fetch_add(volatile atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op) _NOEXCEPT
+{
+ return __o->fetch_add(__op);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp
+atomic_fetch_add(atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op) _NOEXCEPT
+{
+ return __o->fetch_add(__op);
+}
+
+// atomic_fetch_add_explicit
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp atomic_fetch_add_explicit(volatile atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op, memory_order __m) _NOEXCEPT
+{
+ return __o->fetch_add(__op, __m);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp atomic_fetch_add_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op, memory_order __m) _NOEXCEPT
+{
+ return __o->fetch_add(__op, __m);
+}
+
+// atomic_fetch_sub
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp atomic_fetch_sub(volatile atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op) _NOEXCEPT
+{
+ return __o->fetch_sub(__op);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp atomic_fetch_sub(atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op) _NOEXCEPT
+{
+ return __o->fetch_sub(__op);
+}
+
+// atomic_fetch_sub_explicit
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp atomic_fetch_sub_explicit(volatile atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op, memory_order __m) _NOEXCEPT
+{
+ return __o->fetch_sub(__op, __m);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp atomic_fetch_sub_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op, memory_order __m) _NOEXCEPT
+{
+ return __o->fetch_sub(__op, __m);
+}
+
+// atomic_fetch_and
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+ _Tp
+>::type
+atomic_fetch_and(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op) _NOEXCEPT
+{
+ return __o->fetch_and(__op);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+ _Tp
+>::type
+atomic_fetch_and(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op) _NOEXCEPT
+{
+ return __o->fetch_and(__op);
+}
+
+// atomic_fetch_and_explicit
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+ _Tp
+>::type
+atomic_fetch_and_explicit(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op, memory_order __m) _NOEXCEPT
+{
+ return __o->fetch_and(__op, __m);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+ _Tp
+>::type
+atomic_fetch_and_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op, memory_order __m) _NOEXCEPT
+{
+ return __o->fetch_and(__op, __m);
+}
+
+// atomic_fetch_or
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+ _Tp
+>::type
+atomic_fetch_or(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op) _NOEXCEPT
+{
+ return __o->fetch_or(__op);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+ _Tp
+>::type
+atomic_fetch_or(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op) _NOEXCEPT
+{
+ return __o->fetch_or(__op);
+}
+
+// atomic_fetch_or_explicit
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+ _Tp
+>::type
+atomic_fetch_or_explicit(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op, memory_order __m) _NOEXCEPT
+{
+ return __o->fetch_or(__op, __m);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+ _Tp
+>::type
+atomic_fetch_or_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op, memory_order __m) _NOEXCEPT
+{
+ return __o->fetch_or(__op, __m);
+}
+
+// atomic_fetch_xor
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+ _Tp
+>::type
+atomic_fetch_xor(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op) _NOEXCEPT
+{
+ return __o->fetch_xor(__op);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+ _Tp
+>::type
+atomic_fetch_xor(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op) _NOEXCEPT
+{
+ return __o->fetch_xor(__op);
+}
+
+// atomic_fetch_xor_explicit
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+ _Tp
+>::type
+atomic_fetch_xor_explicit(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op, memory_order __m) _NOEXCEPT
+{
+ return __o->fetch_xor(__op, __m);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+ _Tp
+>::type
+atomic_fetch_xor_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op, memory_order __m) _NOEXCEPT
+{
+ return __o->fetch_xor(__op, __m);
+}
+
+// flag type and operations
+
+typedef struct atomic_flag
+{
+ __cxx_atomic_impl<_LIBCPP_ATOMIC_FLAG_TYPE> __a_;
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool test(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT
+ {return _LIBCPP_ATOMIC_FLAG_TYPE(true) == __cxx_atomic_load(&__a_, __m);}
+ _LIBCPP_INLINE_VISIBILITY
+ bool test(memory_order __m = memory_order_seq_cst) const _NOEXCEPT
+ {return _LIBCPP_ATOMIC_FLAG_TYPE(true) == __cxx_atomic_load(&__a_, __m);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool test_and_set(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
+ {return __cxx_atomic_exchange(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(true), __m);}
+ _LIBCPP_INLINE_VISIBILITY
+ bool test_and_set(memory_order __m = memory_order_seq_cst) _NOEXCEPT
+ {return __cxx_atomic_exchange(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(true), __m);}
+ _LIBCPP_INLINE_VISIBILITY
+ void clear(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
+ {__cxx_atomic_store(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(false), __m);}
+ _LIBCPP_INLINE_VISIBILITY
+ void clear(memory_order __m = memory_order_seq_cst) _NOEXCEPT
+ {__cxx_atomic_store(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(false), __m);}
+
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ void wait(bool __v, memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT
+ {__cxx_atomic_wait(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(__v), __m);}
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ void wait(bool __v, memory_order __m = memory_order_seq_cst) const _NOEXCEPT
+ {__cxx_atomic_wait(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(__v), __m);}
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ void notify_one() volatile _NOEXCEPT
+ {__cxx_atomic_notify_one(&__a_);}
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ void notify_one() _NOEXCEPT
+ {__cxx_atomic_notify_one(&__a_);}
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ void notify_all() volatile _NOEXCEPT
+ {__cxx_atomic_notify_all(&__a_);}
+ _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_flag() _NOEXCEPT : __a_(false) {}
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ atomic_flag() _NOEXCEPT = default;
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {} // EXTENSION
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( push )
+#pragma warning ( disable : 4522 )
+#endif
+ atomic_flag(const atomic_flag&) = delete;
+ atomic_flag& operator=(const atomic_flag&) = delete;
+ atomic_flag& operator=(const atomic_flag&) volatile = delete;
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( pop )
+#endif
+
+} atomic_flag;
+
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+atomic_flag_test(const volatile atomic_flag* __o) _NOEXCEPT
+{
+ return __o->test();
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+atomic_flag_test(const atomic_flag* __o) _NOEXCEPT
+{
+ return __o->test();
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+atomic_flag_test_explicit(const volatile atomic_flag* __o, memory_order __m) _NOEXCEPT
+{
+ return __o->test(__m);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+atomic_flag_test_explicit(const atomic_flag* __o, memory_order __m) _NOEXCEPT
+{
+ return __o->test(__m);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+atomic_flag_test_and_set(volatile atomic_flag* __o) _NOEXCEPT
+{
+ return __o->test_and_set();
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+atomic_flag_test_and_set(atomic_flag* __o) _NOEXCEPT
+{
+ return __o->test_and_set();
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+atomic_flag_test_and_set_explicit(volatile atomic_flag* __o, memory_order __m) _NOEXCEPT
+{
+ return __o->test_and_set(__m);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+atomic_flag_test_and_set_explicit(atomic_flag* __o, memory_order __m) _NOEXCEPT
+{
+ return __o->test_and_set(__m);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+atomic_flag_clear(volatile atomic_flag* __o) _NOEXCEPT
+{
+ __o->clear();
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+atomic_flag_clear(atomic_flag* __o) _NOEXCEPT
+{
+ __o->clear();
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+atomic_flag_clear_explicit(volatile atomic_flag* __o, memory_order __m) _NOEXCEPT
+{
+ __o->clear(__m);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+atomic_flag_clear_explicit(atomic_flag* __o, memory_order __m) _NOEXCEPT
+{
+ __o->clear(__m);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_SYNC
+void
+atomic_flag_wait(const volatile atomic_flag* __o, bool __v) _NOEXCEPT
+{
+ __o->wait(__v);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_SYNC
+void
+atomic_flag_wait(const atomic_flag* __o, bool __v) _NOEXCEPT
+{
+ __o->wait(__v);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_SYNC
+void
+atomic_flag_wait_explicit(const volatile atomic_flag* __o,
+ bool __v, memory_order __m) _NOEXCEPT
+{
+ __o->wait(__v, __m);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_SYNC
+void
+atomic_flag_wait_explicit(const atomic_flag* __o,
+ bool __v, memory_order __m) _NOEXCEPT
+{
+ __o->wait(__v, __m);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_SYNC
+void
+atomic_flag_notify_one(volatile atomic_flag* __o) _NOEXCEPT
+{
+ __o->notify_one();
+}
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_SYNC
+void
+atomic_flag_notify_one(atomic_flag* __o) _NOEXCEPT
+{
+ __o->notify_one();
+}
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_SYNC
+void
+atomic_flag_notify_all(volatile atomic_flag* __o) _NOEXCEPT
+{
+ __o->notify_all();
+}
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_SYNC
+void
+atomic_flag_notify_all(atomic_flag* __o) _NOEXCEPT
+{
+ __o->notify_all();
+}
+
+// fences
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+atomic_thread_fence(memory_order __m) _NOEXCEPT
+{
+ __cxx_atomic_thread_fence(__m);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+atomic_signal_fence(memory_order __m) _NOEXCEPT
+{
+ __cxx_atomic_signal_fence(__m);
+}
+
+// Atomics for standard typedef types
+
+typedef atomic<bool> atomic_bool;
+typedef atomic<char> atomic_char;
+typedef atomic<signed char> atomic_schar;
+typedef atomic<unsigned char> atomic_uchar;
+typedef atomic<short> atomic_short;
+typedef atomic<unsigned short> atomic_ushort;
+typedef atomic<int> atomic_int;
+typedef atomic<unsigned int> atomic_uint;
+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_HAS_NO_CHAR8_T
+typedef atomic<char8_t> atomic_char8_t;
+#endif
+typedef atomic<char16_t> atomic_char16_t;
+typedef atomic<char32_t> atomic_char32_t;
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+typedef atomic<wchar_t> atomic_wchar_t;
+#endif
+
+typedef atomic<int_least8_t> atomic_int_least8_t;
+typedef atomic<uint_least8_t> atomic_uint_least8_t;
+typedef atomic<int_least16_t> atomic_int_least16_t;
+typedef atomic<uint_least16_t> atomic_uint_least16_t;
+typedef atomic<int_least32_t> atomic_int_least32_t;
+typedef atomic<uint_least32_t> atomic_uint_least32_t;
+typedef atomic<int_least64_t> atomic_int_least64_t;
+typedef atomic<uint_least64_t> atomic_uint_least64_t;
+
+typedef atomic<int_fast8_t> atomic_int_fast8_t;
+typedef atomic<uint_fast8_t> atomic_uint_fast8_t;
+typedef atomic<int_fast16_t> atomic_int_fast16_t;
+typedef atomic<uint_fast16_t> atomic_uint_fast16_t;
+typedef atomic<int_fast32_t> atomic_int_fast32_t;
+typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
+typedef atomic<int_fast64_t> atomic_int_fast64_t;
+typedef atomic<uint_fast64_t> atomic_uint_fast64_t;
+
+typedef atomic< int8_t> atomic_int8_t;
+typedef atomic<uint8_t> atomic_uint8_t;
+typedef atomic< int16_t> atomic_int16_t;
+typedef atomic<uint16_t> atomic_uint16_t;
+typedef atomic< int32_t> atomic_int32_t;
+typedef atomic<uint32_t> atomic_uint32_t;
+typedef atomic< int64_t> atomic_int64_t;
+typedef atomic<uint64_t> atomic_uint64_t;
+
+typedef atomic<intptr_t> atomic_intptr_t;
+typedef atomic<uintptr_t> atomic_uintptr_t;
+typedef atomic<size_t> atomic_size_t;
+typedef atomic<ptrdiff_t> atomic_ptrdiff_t;
+typedef atomic<intmax_t> atomic_intmax_t;
+typedef atomic<uintmax_t> atomic_uintmax_t;
+
+// atomic_*_lock_free : prefer the contention type most highly, then the largest lock-free type
+
+#ifdef __cpp_lib_atomic_is_always_lock_free
+# define _LIBCPP_CONTENTION_LOCK_FREE __atomic_always_lock_free(sizeof(__cxx_contention_t), 0)
+#else
+# define _LIBCPP_CONTENTION_LOCK_FREE false
+#endif
+
+#if ATOMIC_LLONG_LOCK_FREE == 2
+typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, long long>::type __libcpp_signed_lock_free;
+typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned long long>::type __libcpp_unsigned_lock_free;
+#elif ATOMIC_INT_LOCK_FREE == 2
+typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, int>::type __libcpp_signed_lock_free;
+typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned int>::type __libcpp_unsigned_lock_free;
+#elif ATOMIC_SHORT_LOCK_FREE == 2
+typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, short>::type __libcpp_signed_lock_free;
+typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned short>::type __libcpp_unsigned_lock_free;
+#elif ATOMIC_CHAR_LOCK_FREE == 2
+typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, char>::type __libcpp_signed_lock_free;
+typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned char>::type __libcpp_unsigned_lock_free;
+#else
+ // No signed/unsigned lock-free types
+#define _LIBCPP_NO_LOCK_FREE_TYPES
+#endif
+
+#if !defined(_LIBCPP_NO_LOCK_FREE_TYPES)
+typedef atomic<__libcpp_signed_lock_free> atomic_signed_lock_free;
+typedef atomic<__libcpp_unsigned_lock_free> atomic_unsigned_lock_free;
+#endif
+
+#define ATOMIC_FLAG_INIT {false}
+#define ATOMIC_VAR_INIT(__v) {__v}
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
+# if defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 1400
+# pragma clang deprecated(ATOMIC_FLAG_INIT)
+# pragma clang deprecated(ATOMIC_VAR_INIT)
+# endif
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_ATOMIC
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/barrier b/contrib/libs/cxxsupp/libcxxmsvc/include/barrier
new file mode 100644
index 0000000000..b0975a5519
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/barrier
@@ -0,0 +1,330 @@
+// -*- 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_BARRIER
+#define _LIBCPP_BARRIER
+
+/*
+ barrier synopsis
+
+namespace std
+{
+
+ template<class CompletionFunction = see below>
+ class barrier
+ {
+ public:
+ using arrival_token = see below;
+
+ static constexpr ptrdiff_t max() noexcept;
+
+ constexpr explicit barrier(ptrdiff_t phase_count,
+ CompletionFunction f = CompletionFunction());
+ ~barrier();
+
+ barrier(const barrier&) = delete;
+ barrier& operator=(const barrier&) = delete;
+
+ [[nodiscard]] arrival_token arrive(ptrdiff_t update = 1);
+ void wait(arrival_token&& arrival) const;
+
+ void arrive_and_wait();
+ void arrive_and_drop();
+
+ private:
+ CompletionFunction completion; // exposition only
+ };
+
+}
+
+*/
+
+#include <__availability>
+#include <__config>
+#include <__thread/timed_backoff_policy.h>
+#include <atomic>
+#ifndef _LIBCPP_HAS_NO_TREE_BARRIER
+# include <memory>
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifdef _LIBCPP_HAS_NO_THREADS
+# error <barrier> is not supported on this single threaded system
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+#if _LIBCPP_STD_VER >= 14
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+struct __empty_completion
+{
+ inline _LIBCPP_INLINE_VISIBILITY
+ void operator()() noexcept
+ {
+ }
+};
+
+#ifndef _LIBCPP_HAS_NO_TREE_BARRIER
+
+/*
+
+The default implementation of __barrier_base is a classic tree barrier.
+
+It looks different from literature pseudocode for two main reasons:
+ 1. Threads that call into std::barrier functions do not provide indices,
+ so a numbering step is added before the actual barrier algorithm,
+ appearing as an N+1 round to the N rounds of the tree barrier.
+ 2. A great deal of attention has been paid to avoid cache line thrashing
+ by flattening the tree structure into cache-line sized arrays, that
+ are indexed in an efficient way.
+
+*/
+
+using __barrier_phase_t = uint8_t;
+
+class __barrier_algorithm_base;
+
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI
+__barrier_algorithm_base* __construct_barrier_algorithm_base(ptrdiff_t& __expected);
+
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI
+bool __arrive_barrier_algorithm_base(__barrier_algorithm_base* __barrier,
+ __barrier_phase_t __old_phase);
+
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI
+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;
+ __atomic_base<ptrdiff_t> __expected_adjustment;
+ _CompletionF __completion;
+ __atomic_base<__barrier_phase_t> __phase;
+
+public:
+ using arrival_token = __barrier_phase_t;
+
+ static constexpr ptrdiff_t max() noexcept {
+ return numeric_limits<ptrdiff_t>::max();
+ }
+
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ __barrier_base(ptrdiff_t __expected, _CompletionF __completion = _CompletionF())
+ : __expected(__expected), __base(__construct_barrier_algorithm_base(this->__expected),
+ &__destroy_barrier_algorithm_base),
+ __expected_adjustment(0), __completion(move(__completion)), __phase(0)
+ {
+ }
+ [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ arrival_token arrive(ptrdiff_t update)
+ {
+ auto const __old_phase = __phase.load(memory_order_relaxed);
+ for(; update; --update)
+ if(__arrive_barrier_algorithm_base(__base.get(), __old_phase)) {
+ __completion();
+ __expected += __expected_adjustment.load(memory_order_relaxed);
+ __expected_adjustment.store(0, memory_order_relaxed);
+ __phase.store(__old_phase + 2, memory_order_release);
+ __phase.notify_all();
+ }
+ return __old_phase;
+ }
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ void wait(arrival_token&& __old_phase) const
+ {
+ 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());
+ }
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ void arrive_and_drop()
+ {
+ __expected_adjustment.fetch_sub(1, memory_order_relaxed);
+ (void)arrive(1);
+ }
+};
+
+#else
+
+/*
+
+The alternative implementation of __barrier_base is a central barrier.
+
+Two versions of this algorithm are provided:
+ 1. A fairly straightforward implementation of the litterature for the
+ general case where the completion function is not empty.
+ 2. An optimized implementation that exploits 2's complement arithmetic
+ and well-defined overflow in atomic arithmetic, to handle the phase
+ roll-over for free.
+
+*/
+
+template<class _CompletionF>
+class __barrier_base {
+
+ __atomic_base<ptrdiff_t> __expected;
+ __atomic_base<ptrdiff_t> __arrived;
+ _CompletionF __completion;
+ __atomic_base<bool> __phase;
+public:
+ using arrival_token = bool;
+
+ static constexpr ptrdiff_t max() noexcept {
+ return numeric_limits<ptrdiff_t>::max();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __barrier_base(ptrdiff_t __expected, _CompletionF __completion = _CompletionF())
+ : __expected(__expected), __arrived(__expected), __completion(move(__completion)), __phase(false)
+ {
+ }
+ [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ arrival_token arrive(ptrdiff_t update)
+ {
+ auto const __old_phase = __phase.load(memory_order_relaxed);
+ auto const __result = __arrived.fetch_sub(update, memory_order_acq_rel) - update;
+ auto const new_expected = __expected.load(memory_order_relaxed);
+ if(0 == __result) {
+ __completion();
+ __arrived.store(new_expected, memory_order_relaxed);
+ __phase.store(!__old_phase, memory_order_release);
+ __phase.notify_all();
+ }
+ return __old_phase;
+ }
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ void wait(arrival_token&& __old_phase) const
+ {
+ __phase.wait(__old_phase, memory_order_acquire);
+ }
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ void arrive_and_drop()
+ {
+ __expected.fetch_sub(1, memory_order_relaxed);
+ (void)arrive(1);
+ }
+};
+
+template<>
+class __barrier_base<__empty_completion> {
+
+ static constexpr uint64_t __expected_unit = 1ull;
+ static constexpr uint64_t __arrived_unit = 1ull << 32;
+ static constexpr uint64_t __expected_mask = __arrived_unit - 1;
+ static constexpr uint64_t __phase_bit = 1ull << 63;
+ static constexpr uint64_t __arrived_mask = (__phase_bit - 1) & ~__expected_mask;
+
+ __atomic_base<uint64_t> __phase_arrived_expected;
+
+ static _LIBCPP_INLINE_VISIBILITY
+ constexpr uint64_t __init(ptrdiff_t __count) _NOEXCEPT
+ {
+ return ((uint64_t(1u << 31) - __count) << 32)
+ | (uint64_t(1u << 31) - __count);
+ }
+
+public:
+ using arrival_token = uint64_t;
+
+ static constexpr ptrdiff_t max() noexcept {
+ return ptrdiff_t(1u << 31) - 1;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit inline __barrier_base(ptrdiff_t __count, __empty_completion = __empty_completion())
+ : __phase_arrived_expected(__init(__count))
+ {
+ }
+ [[nodiscard]] inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ arrival_token arrive(ptrdiff_t update)
+ {
+ auto const __inc = __arrived_unit * update;
+ auto const __old = __phase_arrived_expected.fetch_add(__inc, memory_order_acq_rel);
+ if((__old ^ (__old + __inc)) & __phase_bit) {
+ __phase_arrived_expected.fetch_add((__old & __expected_mask) << 32, memory_order_relaxed);
+ __phase_arrived_expected.notify_all();
+ }
+ return __old & __phase_bit;
+ }
+ inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ void wait(arrival_token&& __phase) const
+ {
+ auto const __test_fn = [=]() -> bool {
+ uint64_t const __current = __phase_arrived_expected.load(memory_order_acquire);
+ return ((__current & __phase_bit) != __phase);
+ };
+ __libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy());
+ }
+ inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ void arrive_and_drop()
+ {
+ __phase_arrived_expected.fetch_add(__expected_unit, memory_order_relaxed);
+ (void)arrive(1);
+ }
+};
+
+#endif //_LIBCPP_HAS_NO_TREE_BARRIER
+
+template<class _CompletionF = __empty_completion>
+class barrier {
+
+ __barrier_base<_CompletionF> __b;
+public:
+ using arrival_token = typename __barrier_base<_CompletionF>::arrival_token;
+
+ static constexpr ptrdiff_t max() noexcept {
+ return __barrier_base<_CompletionF>::max();
+ }
+
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ barrier(ptrdiff_t __count, _CompletionF __completion = _CompletionF())
+ : __b(__count, _VSTD::move(__completion)) {
+ }
+
+ barrier(barrier const&) = delete;
+ barrier& operator=(barrier const&) = delete;
+
+ [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ arrival_token arrive(ptrdiff_t update = 1)
+ {
+ return __b.arrive(update);
+ }
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ void wait(arrival_token&& __phase) const
+ {
+ __b.wait(_VSTD::move(__phase));
+ }
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ void arrive_and_wait()
+ {
+ wait(arrive());
+ }
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ void arrive_and_drop()
+ {
+ __b.arrive_and_drop();
+ }
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 14
+
+_LIBCPP_POP_MACROS
+
+#endif //_LIBCPP_BARRIER
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/bit b/contrib/libs/cxxsupp/libcxxmsvc/include/bit
new file mode 100644
index 0000000000..7f9318ecde
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/bit
@@ -0,0 +1,350 @@
+// -*- 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_BIT
+#define _LIBCPP_BIT
+
+/*
+ bit synopsis
+
+namespace std {
+ // [bit.cast], bit_cast
+ template<class To, class From>
+ constexpr To bit_cast(const From& from) noexcept; // C++20
+
+ // [bit.byteswap], byteswap
+ template<class T>
+ constexpr T byteswap(T value) noexcept; // C++23
+
+ // [bit.pow.two], integral powers of 2
+ template <class T>
+ constexpr bool has_single_bit(T x) noexcept; // C++20
+ template <class T>
+ constexpr T bit_ceil(T x); // C++20
+ template <class T>
+ constexpr T bit_floor(T x) noexcept; // C++20
+ template <class T>
+ constexpr T bit_width(T x) noexcept; // C++20
+
+ // [bit.rotate], rotating
+ template<class T>
+ constexpr T rotl(T x, unsigned int s) noexcept; // C++20
+ template<class T>
+ constexpr T rotr(T x, unsigned int s) noexcept; // C++20
+
+ // [bit.count], counting
+ template<class T>
+ constexpr int countl_zero(T x) noexcept; // C++20
+ template<class T>
+ constexpr int countl_one(T x) noexcept; // C++20
+ template<class T>
+ constexpr int countr_zero(T x) noexcept; // C++20
+ template<class T>
+ constexpr int countr_one(T x) noexcept; // C++20
+ template<class T>
+ constexpr int popcount(T x) noexcept; // C++20
+
+ // [bit.endian], endian
+ enum class endian {
+ little = see below, // C++20
+ big = see below, // C++20
+ native = see below // C++20
+ };
+
+} // namespace std
+
+*/
+
+#include <__assert>
+#include <__bit/bit_cast.h>
+#include <__bit/byteswap.h>
+#include <__bits> // __libcpp_clz
+#include <__config>
+#include <limits>
+#include <type_traits>
+#include <version>
+
+#if defined(__IBMCPP__)
+#include "__support/ibm/support.h"
+#endif
+#if defined(_LIBCPP_COMPILER_MSVC)
+#include <intrin.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>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_Tp __rotl(_Tp __t, unsigned int __cnt) _NOEXCEPT
+{
+ 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(__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(__libcpp_is_unsigned_integer<_Tp>::value, "__countr_zero requires an unsigned integer type");
+ if (__t == 0)
+ return numeric_limits<_Tp>::digits;
+
+ if (sizeof(_Tp) <= sizeof(unsigned int))
+ return __libcpp_ctz(static_cast<unsigned int>(__t));
+ else if (sizeof(_Tp) <= sizeof(unsigned long))
+ return __libcpp_ctz(static_cast<unsigned long>(__t));
+ else if (sizeof(_Tp) <= sizeof(unsigned long long))
+ return __libcpp_ctz(static_cast<unsigned long long>(__t));
+ else
+ {
+ int __ret = 0;
+ const unsigned int __ulldigits = numeric_limits<unsigned long long>::digits;
+ while (static_cast<unsigned long long>(__t) == 0uLL)
+ {
+ __ret += __ulldigits;
+ __t >>= __ulldigits;
+ }
+ return __ret + __libcpp_ctz(static_cast<unsigned long long>(__t));
+ }
+}
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+int __countl_zero(_Tp __t) _NOEXCEPT
+{
+ static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countl_zero requires an unsigned integer type");
+ if (__t == 0)
+ return numeric_limits<_Tp>::digits;
+
+ if (sizeof(_Tp) <= sizeof(unsigned int))
+ return __libcpp_clz(static_cast<unsigned int>(__t))
+ - (numeric_limits<unsigned int>::digits - numeric_limits<_Tp>::digits);
+ else if (sizeof(_Tp) <= sizeof(unsigned long))
+ return __libcpp_clz(static_cast<unsigned long>(__t))
+ - (numeric_limits<unsigned long>::digits - numeric_limits<_Tp>::digits);
+ else if (sizeof(_Tp) <= sizeof(unsigned long long))
+ return __libcpp_clz(static_cast<unsigned long long>(__t))
+ - (numeric_limits<unsigned long long>::digits - numeric_limits<_Tp>::digits);
+ else
+ {
+ int __ret = 0;
+ int __iter = 0;
+ const unsigned int __ulldigits = numeric_limits<unsigned long long>::digits;
+ while (true) {
+ __t = __rotr(__t, __ulldigits);
+ if ((__iter = __countl_zero(static_cast<unsigned long long>(__t))) != __ulldigits)
+ break;
+ __ret += __iter;
+ }
+ return __ret + __iter;
+ }
+}
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+int __countl_one(_Tp __t) _NOEXCEPT
+{
+ 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(__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
+{
+ 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))
+ return __libcpp_popcount(static_cast<unsigned long>(__t));
+ else if (sizeof(_Tp) <= sizeof(unsigned long long))
+ return __libcpp_popcount(static_cast<unsigned long long>(__t));
+ else
+ {
+ int __ret = 0;
+ while (__t != 0)
+ {
+ __ret += __libcpp_popcount(static_cast<unsigned long long>(__t));
+ __t >>= numeric_limits<unsigned long long>::digits;
+ }
+ return __ret;
+ }
+}
+
+// integral log base 2
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+unsigned __bit_log2(_Tp __t) _NOEXCEPT
+{
+ static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__bit_log2 requires an unsigned integer type");
+ return numeric_limits<_Tp>::digits - 1 - __countl_zero(__t);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+bool __has_single_bit(_Tp __t) _NOEXCEPT
+{
+ 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<__libcpp_is_unsigned_integer<_Tp>::value, _Tp>
+rotl(_Tp __t, unsigned int __cnt) noexcept
+{
+ return __rotl(__t, __cnt);
+}
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<__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<__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<__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<__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<__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<__libcpp_is_unsigned_integer<_Tp>::value, int>
+popcount(_Tp __t) noexcept
+{
+ return __popcount(__t);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, bool>
+has_single_bit(_Tp __t) noexcept
+{
+ return __has_single_bit(__t);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, _Tp>
+bit_floor(_Tp __t) noexcept
+{
+ return __t == 0 ? 0 : _Tp{1} << __bit_log2(__t);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, _Tp>
+bit_ceil(_Tp __t) noexcept
+{
+ if (__t < 2) return 1;
+ const unsigned __n = numeric_limits<_Tp>::digits - countl_zero((_Tp)(__t - 1u));
+ _LIBCPP_ASSERT(__n != numeric_limits<_Tp>::digits, "Bad input to bit_ceil");
+
+ if constexpr (sizeof(_Tp) >= sizeof(unsigned))
+ return _Tp{1} << __n;
+ else
+ {
+ const unsigned __extra = numeric_limits<unsigned>::digits - numeric_limits<_Tp>::digits;
+ const unsigned __retVal = 1u << (__n + __extra);
+ return (_Tp) (__retVal >> __extra);
+ }
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, _Tp>
+bit_width(_Tp __t) noexcept
+{
+ return __t == 0 ? 0 : __bit_log2(__t) + 1;
+}
+
+enum class endian
+{
+ little = 0xDEAD,
+ big = 0xFACE,
+#if defined(_LIBCPP_LITTLE_ENDIAN)
+ native = little
+#elif defined(_LIBCPP_BIG_ENDIAN)
+ native = big
+#else
+ native = 0xCAFE
+#endif
+};
+
+#endif // _LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_BIT
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/bitset b/contrib/libs/cxxsupp/libcxxmsvc/include/bitset
new file mode 100644
index 0000000000..d5c42991d9
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/bitset
@@ -0,0 +1,1109 @@
+// -*- 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_BITSET
+#define _LIBCPP_BITSET
+
+/*
+ bitset synopsis
+
+namespace std
+{
+
+namespace std {
+
+template <size_t N>
+class bitset
+{
+public:
+ // bit reference:
+ class reference
+ {
+ friend class bitset;
+ reference() noexcept;
+ public:
+ ~reference() noexcept;
+ reference& operator=(bool x) noexcept; // for b[i] = x;
+ reference& operator=(const reference&) noexcept; // for b[i] = b[j];
+ bool operator~() const noexcept; // flips the bit
+ operator bool() const noexcept; // for x = b[i];
+ reference& flip() noexcept; // for b[i].flip();
+ };
+
+ // 23.3.5.1 constructors:
+ constexpr bitset() noexcept;
+ constexpr bitset(unsigned long long val) noexcept;
+ template <class charT>
+ explicit bitset(const charT* str,
+ typename basic_string<charT>::size_type n = basic_string<charT>::npos,
+ charT zero = charT('0'), charT one = charT('1'));
+ template<class charT, class traits, class Allocator>
+ explicit bitset(const basic_string<charT,traits,Allocator>& str,
+ typename basic_string<charT,traits,Allocator>::size_type pos = 0,
+ typename basic_string<charT,traits,Allocator>::size_type n =
+ basic_string<charT,traits,Allocator>::npos,
+ charT zero = charT('0'), charT one = charT('1'));
+
+ // 23.3.5.2 bitset operations:
+ bitset& operator&=(const bitset& rhs) noexcept;
+ bitset& operator|=(const bitset& rhs) noexcept;
+ bitset& operator^=(const bitset& rhs) noexcept;
+ bitset& operator<<=(size_t pos) noexcept;
+ bitset& operator>>=(size_t pos) noexcept;
+ bitset& set() noexcept;
+ bitset& set(size_t pos, bool val = true);
+ bitset& reset() noexcept;
+ bitset& reset(size_t pos);
+ bitset operator~() const noexcept;
+ bitset& flip() noexcept;
+ bitset& flip(size_t pos);
+
+ // element access:
+ constexpr bool operator[](size_t pos) const; // for b[i];
+ reference operator[](size_t pos); // for b[i];
+ unsigned long to_ulong() const;
+ unsigned long long to_ullong() const;
+ template <class charT, class traits, class Allocator>
+ basic_string<charT, traits, Allocator> to_string(charT zero = charT('0'), charT one = charT('1')) const;
+ template <class charT, class traits>
+ basic_string<charT, traits, allocator<charT> > to_string(charT zero = charT('0'), charT one = charT('1')) const;
+ template <class charT>
+ basic_string<charT, char_traits<charT>, allocator<charT> > to_string(charT zero = charT('0'), charT one = charT('1')) const;
+ basic_string<char, char_traits<char>, allocator<char> > to_string(char zero = '0', char one = '1') const;
+ size_t count() const noexcept;
+ constexpr size_t size() const noexcept;
+ bool operator==(const bitset& rhs) const noexcept;
+ bool operator!=(const bitset& rhs) const noexcept;
+ bool test(size_t pos) const;
+ bool all() const noexcept;
+ bool any() const noexcept;
+ bool none() const noexcept;
+ bitset operator<<(size_t pos) const noexcept;
+ bitset operator>>(size_t pos) const noexcept;
+};
+
+// 23.3.5.3 bitset operators:
+template <size_t N>
+bitset<N> operator&(const bitset<N>&, const bitset<N>&) noexcept;
+
+template <size_t N>
+bitset<N> operator|(const bitset<N>&, const bitset<N>&) noexcept;
+
+template <size_t N>
+bitset<N> operator^(const bitset<N>&, const bitset<N>&) noexcept;
+
+template <class charT, class traits, size_t N>
+basic_istream<charT, traits>&
+operator>>(basic_istream<charT, traits>& is, bitset<N>& x);
+
+template <class charT, class traits, size_t N>
+basic_ostream<charT, traits>&
+operator<<(basic_ostream<charT, traits>& os, const bitset<N>& x);
+
+template <size_t N> struct hash<std::bitset<N>>;
+
+} // std
+
+*/
+
+#include <__algorithm/fill.h>
+#include <__bit_reference>
+#include <__config>
+#include <__functional/unary_function.h>
+#include <climits>
+#include <cstddef>
+#include <iosfwd>
+#include <stdexcept>
+#include <string>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <size_t _N_words, size_t _Size>
+class __bitset;
+
+template <size_t _N_words, size_t _Size>
+struct __has_storage_type<__bitset<_N_words, _Size> >
+{
+ static const bool value = true;
+};
+
+template <size_t _N_words, size_t _Size>
+class __bitset
+{
+public:
+ typedef ptrdiff_t difference_type;
+ typedef size_t size_type;
+ typedef size_type __storage_type;
+protected:
+ typedef __bitset __self;
+ typedef __storage_type* __storage_pointer;
+ typedef const __storage_type* __const_storage_pointer;
+ static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);
+
+ friend class __bit_reference<__bitset>;
+ friend class __bit_const_reference<__bitset>;
+ friend class __bit_iterator<__bitset, false>;
+ friend class __bit_iterator<__bitset, true>;
+ friend struct __bit_array<__bitset>;
+
+ __storage_type __first_[_N_words];
+
+ typedef __bit_reference<__bitset> reference;
+ typedef __bit_const_reference<__bitset> const_reference;
+ typedef __bit_iterator<__bitset, false> iterator;
+ typedef __bit_iterator<__bitset, true> const_iterator;
+
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t __pos) _NOEXCEPT
+ {return reference(__first_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t __pos) const _NOEXCEPT
+ {return const_reference(__first_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);}
+ _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_t __pos) _NOEXCEPT
+ {return iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);}
+ _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t __pos) const _NOEXCEPT
+ {return const_iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void operator&=(const __bitset& __v) _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ void operator|=(const __bitset& __v) _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ void operator^=(const __bitset& __v) _NOEXCEPT;
+
+ void flip() _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY unsigned long to_ulong() const
+ {return to_ulong(integral_constant<bool, _Size < sizeof(unsigned long) * CHAR_BIT>());}
+ _LIBCPP_INLINE_VISIBILITY unsigned long long to_ullong() const
+ {return to_ullong(integral_constant<bool, _Size < sizeof(unsigned long long) * CHAR_BIT>());}
+
+ bool all() const _NOEXCEPT;
+ bool any() const _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ size_t __hash_code() const _NOEXCEPT;
+private:
+#ifdef _LIBCPP_CXX03_LANG
+ 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
+ unsigned long to_ulong(false_type) const;
+ _LIBCPP_INLINE_VISIBILITY
+ unsigned long to_ulong(true_type) const;
+ unsigned long long to_ullong(false_type) const;
+ _LIBCPP_INLINE_VISIBILITY
+ unsigned long long to_ullong(true_type) const;
+ _LIBCPP_INLINE_VISIBILITY
+ unsigned long long to_ullong(true_type, false_type) const;
+ unsigned long long to_ullong(true_type, true_type) const;
+};
+
+template <size_t _N_words, size_t _Size>
+inline
+_LIBCPP_CONSTEXPR
+__bitset<_N_words, _Size>::__bitset() _NOEXCEPT
+#ifndef _LIBCPP_CXX03_LANG
+ : __first_{0}
+#endif
+{
+#ifdef _LIBCPP_CXX03_LANG
+ _VSTD::fill_n(__first_, _N_words, __storage_type(0));
+#endif
+}
+
+#ifdef _LIBCPP_CXX03_LANG
+
+template <size_t _N_words, size_t _Size>
+void
+__bitset<_N_words, _Size>::__init(unsigned long long __v, false_type) _NOEXCEPT
+{
+ __storage_type __t[sizeof(unsigned long long) / sizeof(__storage_type)];
+ size_t __sz = _Size;
+ for (size_t __i = 0; __i < sizeof(__t)/sizeof(__t[0]); ++__i, __v >>= __bits_per_word, __sz -= __bits_per_word )
+ if ( __sz < __bits_per_word)
+ __t[__i] = static_cast<__storage_type>(__v) & ( 1ULL << __sz ) - 1;
+ else
+ __t[__i] = static_cast<__storage_type>(__v);
+
+ _VSTD::copy(__t, __t + sizeof(__t)/sizeof(__t[0]), __first_);
+ _VSTD::fill(__first_ + sizeof(__t)/sizeof(__t[0]), __first_ + sizeof(__first_)/sizeof(__first_[0]),
+ __storage_type(0));
+}
+
+template <size_t _N_words, size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__bitset<_N_words, _Size>::__init(unsigned long long __v, true_type) _NOEXCEPT
+{
+ __first_[0] = __v;
+ if (_Size < __bits_per_word)
+ __first_[0] &= ( 1ULL << _Size ) - 1;
+
+ _VSTD::fill(__first_ + 1, __first_ + sizeof(__first_)/sizeof(__first_[0]), __storage_type(0));
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <size_t _N_words, size_t _Size>
+inline
+_LIBCPP_CONSTEXPR
+__bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
+#ifndef _LIBCPP_CXX03_LANG
+#if SIZE_MAX == 0xffffffffffffffffULL
+ : __first_{__v}
+#elif SIZE_MAX == 0xffffffffULL
+ : __first_{static_cast<__storage_type>(__v),
+ _Size >= 2 * __bits_per_word ? static_cast<__storage_type>(__v >> __bits_per_word)
+ : static_cast<__storage_type>((__v >> __bits_per_word) & (__storage_type(1) << (_Size - __bits_per_word)) - 1)}
+#else
+#error This constructor has not been ported to this platform
+#endif
+#endif
+{
+#ifdef _LIBCPP_CXX03_LANG
+ __init(__v, integral_constant<bool, sizeof(unsigned long long) == sizeof(__storage_type)>());
+#endif
+}
+
+template <size_t _N_words, size_t _Size>
+inline
+void
+__bitset<_N_words, _Size>::operator&=(const __bitset& __v) _NOEXCEPT
+{
+ for (size_type __i = 0; __i < _N_words; ++__i)
+ __first_[__i] &= __v.__first_[__i];
+}
+
+template <size_t _N_words, size_t _Size>
+inline
+void
+__bitset<_N_words, _Size>::operator|=(const __bitset& __v) _NOEXCEPT
+{
+ for (size_type __i = 0; __i < _N_words; ++__i)
+ __first_[__i] |= __v.__first_[__i];
+}
+
+template <size_t _N_words, size_t _Size>
+inline
+void
+__bitset<_N_words, _Size>::operator^=(const __bitset& __v) _NOEXCEPT
+{
+ for (size_type __i = 0; __i < _N_words; ++__i)
+ __first_[__i] ^= __v.__first_[__i];
+}
+
+template <size_t _N_words, size_t _Size>
+void
+__bitset<_N_words, _Size>::flip() _NOEXCEPT
+{
+ // do middle whole words
+ size_type __n = _Size;
+ __storage_pointer __p = __first_;
+ for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
+ *__p = ~*__p;
+ // do last partial word
+ if (__n > 0)
+ {
+ __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
+ __storage_type __b = *__p & __m;
+ *__p &= ~__m;
+ *__p |= ~__b & __m;
+ }
+}
+
+template <size_t _N_words, size_t _Size>
+unsigned long
+__bitset<_N_words, _Size>::to_ulong(false_type) const
+{
+ const_iterator __e = __make_iter(_Size);
+ const_iterator __i = _VSTD::find(__make_iter(sizeof(unsigned long) * CHAR_BIT), __e, true);
+ if (__i != __e)
+ __throw_overflow_error("bitset to_ulong overflow error");
+
+ return __first_[0];
+}
+
+template <size_t _N_words, size_t _Size>
+inline
+unsigned long
+__bitset<_N_words, _Size>::to_ulong(true_type) const
+{
+ return __first_[0];
+}
+
+template <size_t _N_words, size_t _Size>
+unsigned long long
+__bitset<_N_words, _Size>::to_ullong(false_type) const
+{
+ const_iterator __e = __make_iter(_Size);
+ const_iterator __i = _VSTD::find(__make_iter(sizeof(unsigned long long) * CHAR_BIT), __e, true);
+ if (__i != __e)
+ __throw_overflow_error("bitset to_ullong overflow error");
+
+ return to_ullong(true_type());
+}
+
+template <size_t _N_words, size_t _Size>
+inline
+unsigned long long
+__bitset<_N_words, _Size>::to_ullong(true_type) const
+{
+ return to_ullong(true_type(), integral_constant<bool, sizeof(__storage_type) < sizeof(unsigned long long)>());
+}
+
+template <size_t _N_words, size_t _Size>
+inline
+unsigned long long
+__bitset<_N_words, _Size>::to_ullong(true_type, false_type) const
+{
+ return __first_[0];
+}
+
+template <size_t _N_words, size_t _Size>
+unsigned long long
+__bitset<_N_words, _Size>::to_ullong(true_type, true_type) const
+{
+ unsigned long long __r = __first_[0];
+ for (size_t __i = 1; __i < sizeof(unsigned long long) / sizeof(__storage_type); ++__i)
+ __r |= static_cast<unsigned long long>(__first_[__i]) << (sizeof(__storage_type) * CHAR_BIT);
+ return __r;
+}
+
+template <size_t _N_words, size_t _Size>
+bool
+__bitset<_N_words, _Size>::all() const _NOEXCEPT
+{
+ // do middle whole words
+ size_type __n = _Size;
+ __const_storage_pointer __p = __first_;
+ for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
+ if (~*__p)
+ return false;
+ // do last partial word
+ if (__n > 0)
+ {
+ __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
+ if (~*__p & __m)
+ return false;
+ }
+ return true;
+}
+
+template <size_t _N_words, size_t _Size>
+bool
+__bitset<_N_words, _Size>::any() const _NOEXCEPT
+{
+ // do middle whole words
+ size_type __n = _Size;
+ __const_storage_pointer __p = __first_;
+ for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
+ if (*__p)
+ return true;
+ // do last partial word
+ if (__n > 0)
+ {
+ __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
+ if (*__p & __m)
+ return true;
+ }
+ return false;
+}
+
+template <size_t _N_words, size_t _Size>
+inline
+size_t
+__bitset<_N_words, _Size>::__hash_code() const _NOEXCEPT
+{
+ size_t __h = 0;
+ for (size_type __i = 0; __i < _N_words; ++__i)
+ __h ^= __first_[__i];
+ return __h;
+}
+
+template <size_t _Size>
+class __bitset<1, _Size>
+{
+public:
+ typedef ptrdiff_t difference_type;
+ typedef size_t size_type;
+ typedef size_type __storage_type;
+protected:
+ typedef __bitset __self;
+ typedef __storage_type* __storage_pointer;
+ typedef const __storage_type* __const_storage_pointer;
+ static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);
+
+ friend class __bit_reference<__bitset>;
+ friend class __bit_const_reference<__bitset>;
+ friend class __bit_iterator<__bitset, false>;
+ friend class __bit_iterator<__bitset, true>;
+ friend struct __bit_array<__bitset>;
+
+ __storage_type __first_;
+
+ typedef __bit_reference<__bitset> reference;
+ typedef __bit_const_reference<__bitset> const_reference;
+ typedef __bit_iterator<__bitset, false> iterator;
+ typedef __bit_iterator<__bitset, true> const_iterator;
+
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t __pos) _NOEXCEPT
+ {return reference(&__first_, __storage_type(1) << __pos);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t __pos) const _NOEXCEPT
+ {return const_reference(&__first_, __storage_type(1) << __pos);}
+ _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_t __pos) _NOEXCEPT
+ {return iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);}
+ _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t __pos) const _NOEXCEPT
+ {return const_iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void operator&=(const __bitset& __v) _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ void operator|=(const __bitset& __v) _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ void operator^=(const __bitset& __v) _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY
+ void flip() _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY
+ unsigned long to_ulong() const;
+ _LIBCPP_INLINE_VISIBILITY
+ unsigned long long to_ullong() const;
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool all() const _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ bool any() const _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_t __hash_code() const _NOEXCEPT;
+};
+
+template <size_t _Size>
+inline
+_LIBCPP_CONSTEXPR
+__bitset<1, _Size>::__bitset() _NOEXCEPT
+ : __first_(0)
+{
+}
+
+template <size_t _Size>
+inline
+_LIBCPP_CONSTEXPR
+__bitset<1, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
+ : __first_(
+ _Size == __bits_per_word ? static_cast<__storage_type>(__v)
+ : static_cast<__storage_type>(__v) & ((__storage_type(1) << _Size) - 1)
+ )
+{
+}
+
+template <size_t _Size>
+inline
+void
+__bitset<1, _Size>::operator&=(const __bitset& __v) _NOEXCEPT
+{
+ __first_ &= __v.__first_;
+}
+
+template <size_t _Size>
+inline
+void
+__bitset<1, _Size>::operator|=(const __bitset& __v) _NOEXCEPT
+{
+ __first_ |= __v.__first_;
+}
+
+template <size_t _Size>
+inline
+void
+__bitset<1, _Size>::operator^=(const __bitset& __v) _NOEXCEPT
+{
+ __first_ ^= __v.__first_;
+}
+
+template <size_t _Size>
+inline
+void
+__bitset<1, _Size>::flip() _NOEXCEPT
+{
+ __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size);
+ __first_ = ~__first_;
+ __first_ &= __m;
+}
+
+template <size_t _Size>
+inline
+unsigned long
+__bitset<1, _Size>::to_ulong() const
+{
+ return __first_;
+}
+
+template <size_t _Size>
+inline
+unsigned long long
+__bitset<1, _Size>::to_ullong() const
+{
+ return __first_;
+}
+
+template <size_t _Size>
+inline
+bool
+__bitset<1, _Size>::all() const _NOEXCEPT
+{
+ __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size);
+ return !(~__first_ & __m);
+}
+
+template <size_t _Size>
+inline
+bool
+__bitset<1, _Size>::any() const _NOEXCEPT
+{
+ __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size);
+ return __first_ & __m;
+}
+
+template <size_t _Size>
+inline
+size_t
+__bitset<1, _Size>::__hash_code() const _NOEXCEPT
+{
+ return __first_;
+}
+
+template <>
+class __bitset<0, 0>
+{
+public:
+ typedef ptrdiff_t difference_type;
+ typedef size_t size_type;
+ typedef size_type __storage_type;
+protected:
+ typedef __bitset __self;
+ typedef __storage_type* __storage_pointer;
+ typedef const __storage_type* __const_storage_pointer;
+ static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);
+
+ friend class __bit_reference<__bitset>;
+ friend class __bit_const_reference<__bitset>;
+ friend class __bit_iterator<__bitset, false>;
+ friend class __bit_iterator<__bitset, true>;
+ friend struct __bit_array<__bitset>;
+
+ typedef __bit_reference<__bitset> reference;
+ typedef __bit_const_reference<__bitset> const_reference;
+ typedef __bit_iterator<__bitset, false> iterator;
+ typedef __bit_iterator<__bitset, true> const_iterator;
+
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long) _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t) _NOEXCEPT
+ {return reference(nullptr, 1);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t) const _NOEXCEPT
+ {return const_reference(nullptr, 1);}
+ _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_t) _NOEXCEPT
+ {return iterator(nullptr, 0);}
+ _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t) const _NOEXCEPT
+ {return const_iterator(nullptr, 0);}
+
+ _LIBCPP_INLINE_VISIBILITY void operator&=(const __bitset&) _NOEXCEPT {}
+ _LIBCPP_INLINE_VISIBILITY void operator|=(const __bitset&) _NOEXCEPT {}
+ _LIBCPP_INLINE_VISIBILITY void operator^=(const __bitset&) _NOEXCEPT {}
+
+ _LIBCPP_INLINE_VISIBILITY void flip() _NOEXCEPT {}
+
+ _LIBCPP_INLINE_VISIBILITY unsigned long to_ulong() const {return 0;}
+ _LIBCPP_INLINE_VISIBILITY unsigned long long to_ullong() const {return 0;}
+
+ _LIBCPP_INLINE_VISIBILITY bool all() const _NOEXCEPT {return true;}
+ _LIBCPP_INLINE_VISIBILITY bool any() const _NOEXCEPT {return false;}
+
+ _LIBCPP_INLINE_VISIBILITY size_t __hash_code() const _NOEXCEPT {return 0;}
+};
+
+inline
+_LIBCPP_CONSTEXPR
+__bitset<0, 0>::__bitset() _NOEXCEPT
+{
+}
+
+inline
+_LIBCPP_CONSTEXPR
+__bitset<0, 0>::__bitset(unsigned long long) _NOEXCEPT
+{
+}
+
+template <size_t _Size> class _LIBCPP_TEMPLATE_VIS bitset;
+template <size_t _Size> struct hash<bitset<_Size> >;
+
+template <size_t _Size>
+class _LIBCPP_TEMPLATE_VIS bitset
+ : private __bitset<_Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1, _Size>
+{
+public:
+ static const unsigned __n_words = _Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1;
+ typedef __bitset<__n_words, _Size> base;
+
+public:
+ typedef typename base::reference reference;
+ typedef typename base::const_reference const_reference;
+
+ // 23.3.5.1 constructors:
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bitset() _NOEXCEPT {}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ bitset(unsigned long long __v) _NOEXCEPT : base(__v) {}
+ template<class _CharT, class = __enable_if_t<_IsCharLikeType<_CharT>::value> >
+ explicit bitset(const _CharT* __str,
+ typename basic_string<_CharT>::size_type __n = basic_string<_CharT>::npos,
+ _CharT __zero = _CharT('0'), _CharT __one = _CharT('1'));
+ template<class _CharT, class _Traits, class _Allocator>
+ explicit bitset(const basic_string<_CharT,_Traits,_Allocator>& __str,
+ typename basic_string<_CharT,_Traits,_Allocator>::size_type __pos = 0,
+ typename basic_string<_CharT,_Traits,_Allocator>::size_type __n =
+ (basic_string<_CharT,_Traits,_Allocator>::npos),
+ _CharT __zero = _CharT('0'), _CharT __one = _CharT('1'));
+
+ // 23.3.5.2 bitset operations:
+ _LIBCPP_INLINE_VISIBILITY
+ bitset& operator&=(const bitset& __rhs) _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ bitset& operator|=(const bitset& __rhs) _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ bitset& operator^=(const bitset& __rhs) _NOEXCEPT;
+ bitset& operator<<=(size_t __pos) _NOEXCEPT;
+ bitset& operator>>=(size_t __pos) _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ bitset& set() _NOEXCEPT;
+ bitset& set(size_t __pos, bool __val = true);
+ _LIBCPP_INLINE_VISIBILITY
+ bitset& reset() _NOEXCEPT;
+ bitset& reset(size_t __pos);
+ _LIBCPP_INLINE_VISIBILITY
+ bitset operator~() const _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ bitset& flip() _NOEXCEPT;
+ bitset& flip(size_t __pos);
+
+ // element access:
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ const_reference operator[](size_t __p) const {return base::__make_ref(__p);}
+ _LIBCPP_INLINE_VISIBILITY reference operator[](size_t __p) {return base::__make_ref(__p);}
+ _LIBCPP_INLINE_VISIBILITY
+ unsigned long to_ulong() const;
+ _LIBCPP_INLINE_VISIBILITY
+ unsigned long long to_ullong() const;
+ template <class _CharT, class _Traits, class _Allocator>
+ basic_string<_CharT, _Traits, _Allocator> to_string(_CharT __zero = _CharT('0'),
+ _CharT __one = _CharT('1')) const;
+ template <class _CharT, class _Traits>
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string<_CharT, _Traits, allocator<_CharT> > to_string(_CharT __zero = _CharT('0'),
+ _CharT __one = _CharT('1')) const;
+ template <class _CharT>
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > to_string(_CharT __zero = _CharT('0'),
+ _CharT __one = _CharT('1')) const;
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string<char, char_traits<char>, allocator<char> > to_string(char __zero = '0',
+ char __one = '1') const;
+ _LIBCPP_INLINE_VISIBILITY
+ size_t count() const _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR size_t size() const _NOEXCEPT {return _Size;}
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const bitset& __rhs) const _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const bitset& __rhs) const _NOEXCEPT;
+ bool test(size_t __pos) const;
+ _LIBCPP_INLINE_VISIBILITY
+ bool all() const _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ bool any() const _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY bool none() const _NOEXCEPT {return !any();}
+ _LIBCPP_INLINE_VISIBILITY
+ bitset operator<<(size_t __pos) const _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ bitset operator>>(size_t __pos) const _NOEXCEPT;
+
+private:
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_t __hash_code() const _NOEXCEPT {return base::__hash_code();}
+
+ friend struct hash<bitset>;
+};
+
+template <size_t _Size>
+template<class _CharT, class>
+bitset<_Size>::bitset(const _CharT* __str,
+ typename basic_string<_CharT>::size_type __n,
+ _CharT __zero, _CharT __one)
+{
+ size_t __rlen = _VSTD::min(__n, char_traits<_CharT>::length(__str));
+ for (size_t __i = 0; __i < __rlen; ++__i)
+ if (__str[__i] != __zero && __str[__i] != __one)
+ __throw_invalid_argument("bitset string ctor has invalid argument");
+
+ size_t _Mp = _VSTD::min(__rlen, _Size);
+ size_t __i = 0;
+ for (; __i < _Mp; ++__i)
+ {
+ _CharT __c = __str[_Mp - 1 - __i];
+ (*this)[__i] = (__c == __one);
+ }
+ _VSTD::fill(base::__make_iter(__i), base::__make_iter(_Size), false);
+}
+
+template <size_t _Size>
+template<class _CharT, class _Traits, class _Allocator>
+bitset<_Size>::bitset(const basic_string<_CharT,_Traits,_Allocator>& __str,
+ typename basic_string<_CharT,_Traits,_Allocator>::size_type __pos,
+ typename basic_string<_CharT,_Traits,_Allocator>::size_type __n,
+ _CharT __zero, _CharT __one)
+{
+ if (__pos > __str.size())
+ __throw_out_of_range("bitset string pos out of range");
+
+ size_t __rlen = _VSTD::min(__n, __str.size() - __pos);
+ for (size_t __i = __pos; __i < __pos + __rlen; ++__i)
+ if (!_Traits::eq(__str[__i], __zero) && !_Traits::eq(__str[__i], __one))
+ __throw_invalid_argument("bitset string ctor has invalid argument");
+
+ size_t _Mp = _VSTD::min(__rlen, _Size);
+ size_t __i = 0;
+ for (; __i < _Mp; ++__i)
+ {
+ _CharT __c = __str[__pos + _Mp - 1 - __i];
+ (*this)[__i] = _Traits::eq(__c, __one);
+ }
+ _VSTD::fill(base::__make_iter(__i), base::__make_iter(_Size), false);
+}
+
+template <size_t _Size>
+inline
+bitset<_Size>&
+bitset<_Size>::operator&=(const bitset& __rhs) _NOEXCEPT
+{
+ base::operator&=(__rhs);
+ return *this;
+}
+
+template <size_t _Size>
+inline
+bitset<_Size>&
+bitset<_Size>::operator|=(const bitset& __rhs) _NOEXCEPT
+{
+ base::operator|=(__rhs);
+ return *this;
+}
+
+template <size_t _Size>
+inline
+bitset<_Size>&
+bitset<_Size>::operator^=(const bitset& __rhs) _NOEXCEPT
+{
+ base::operator^=(__rhs);
+ return *this;
+}
+
+template <size_t _Size>
+bitset<_Size>&
+bitset<_Size>::operator<<=(size_t __pos) _NOEXCEPT
+{
+ __pos = _VSTD::min(__pos, _Size);
+ _VSTD::copy_backward(base::__make_iter(0), base::__make_iter(_Size - __pos), base::__make_iter(_Size));
+ _VSTD::fill_n(base::__make_iter(0), __pos, false);
+ return *this;
+}
+
+template <size_t _Size>
+bitset<_Size>&
+bitset<_Size>::operator>>=(size_t __pos) _NOEXCEPT
+{
+ __pos = _VSTD::min(__pos, _Size);
+ _VSTD::copy(base::__make_iter(__pos), base::__make_iter(_Size), base::__make_iter(0));
+ _VSTD::fill_n(base::__make_iter(_Size - __pos), __pos, false);
+ return *this;
+}
+
+template <size_t _Size>
+inline
+bitset<_Size>&
+bitset<_Size>::set() _NOEXCEPT
+{
+ _VSTD::fill_n(base::__make_iter(0), _Size, true);
+ return *this;
+}
+
+template <size_t _Size>
+bitset<_Size>&
+bitset<_Size>::set(size_t __pos, bool __val)
+{
+ if (__pos >= _Size)
+ __throw_out_of_range("bitset set argument out of range");
+
+ (*this)[__pos] = __val;
+ return *this;
+}
+
+template <size_t _Size>
+inline
+bitset<_Size>&
+bitset<_Size>::reset() _NOEXCEPT
+{
+ _VSTD::fill_n(base::__make_iter(0), _Size, false);
+ return *this;
+}
+
+template <size_t _Size>
+bitset<_Size>&
+bitset<_Size>::reset(size_t __pos)
+{
+ if (__pos >= _Size)
+ __throw_out_of_range("bitset reset argument out of range");
+
+ (*this)[__pos] = false;
+ return *this;
+}
+
+template <size_t _Size>
+inline
+bitset<_Size>
+bitset<_Size>::operator~() const _NOEXCEPT
+{
+ bitset __x(*this);
+ __x.flip();
+ return __x;
+}
+
+template <size_t _Size>
+inline
+bitset<_Size>&
+bitset<_Size>::flip() _NOEXCEPT
+{
+ base::flip();
+ return *this;
+}
+
+template <size_t _Size>
+bitset<_Size>&
+bitset<_Size>::flip(size_t __pos)
+{
+ if (__pos >= _Size)
+ __throw_out_of_range("bitset flip argument out of range");
+
+ reference r = base::__make_ref(__pos);
+ r = ~r;
+ return *this;
+}
+
+template <size_t _Size>
+inline
+unsigned long
+bitset<_Size>::to_ulong() const
+{
+ return base::to_ulong();
+}
+
+template <size_t _Size>
+inline
+unsigned long long
+bitset<_Size>::to_ullong() const
+{
+ return base::to_ullong();
+}
+
+template <size_t _Size>
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>
+bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
+{
+ basic_string<_CharT, _Traits, _Allocator> __r(_Size, __zero);
+ for (size_t __i = 0; __i < _Size; ++__i)
+ {
+ if ((*this)[__i])
+ __r[_Size - 1 - __i] = __one;
+ }
+ return __r;
+}
+
+template <size_t _Size>
+template <class _CharT, class _Traits>
+inline
+basic_string<_CharT, _Traits, allocator<_CharT> >
+bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
+{
+ return to_string<_CharT, _Traits, allocator<_CharT> >(__zero, __one);
+}
+
+template <size_t _Size>
+template <class _CharT>
+inline
+basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> >
+bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
+{
+ return to_string<_CharT, char_traits<_CharT>, allocator<_CharT> >(__zero, __one);
+}
+
+template <size_t _Size>
+inline
+basic_string<char, char_traits<char>, allocator<char> >
+bitset<_Size>::to_string(char __zero, char __one) const
+{
+ return to_string<char, char_traits<char>, allocator<char> >(__zero, __one);
+}
+
+template <size_t _Size>
+inline
+size_t
+bitset<_Size>::count() const _NOEXCEPT
+{
+ return static_cast<size_t>(_VSTD::__count_bool_true(base::__make_iter(0), _Size));
+}
+
+template <size_t _Size>
+inline
+bool
+bitset<_Size>::operator==(const bitset& __rhs) const _NOEXCEPT
+{
+ return _VSTD::equal(base::__make_iter(0), base::__make_iter(_Size), __rhs.__make_iter(0));
+}
+
+template <size_t _Size>
+inline
+bool
+bitset<_Size>::operator!=(const bitset& __rhs) const _NOEXCEPT
+{
+ return !(*this == __rhs);
+}
+
+template <size_t _Size>
+bool
+bitset<_Size>::test(size_t __pos) const
+{
+ if (__pos >= _Size)
+ __throw_out_of_range("bitset test argument out of range");
+
+ return (*this)[__pos];
+}
+
+template <size_t _Size>
+inline
+bool
+bitset<_Size>::all() const _NOEXCEPT
+{
+ return base::all();
+}
+
+template <size_t _Size>
+inline
+bool
+bitset<_Size>::any() const _NOEXCEPT
+{
+ return base::any();
+}
+
+template <size_t _Size>
+inline
+bitset<_Size>
+bitset<_Size>::operator<<(size_t __pos) const _NOEXCEPT
+{
+ bitset __r = *this;
+ __r <<= __pos;
+ return __r;
+}
+
+template <size_t _Size>
+inline
+bitset<_Size>
+bitset<_Size>::operator>>(size_t __pos) const _NOEXCEPT
+{
+ bitset __r = *this;
+ __r >>= __pos;
+ return __r;
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+bitset<_Size>
+operator&(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT
+{
+ bitset<_Size> __r = __x;
+ __r &= __y;
+ return __r;
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+bitset<_Size>
+operator|(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT
+{
+ bitset<_Size> __r = __x;
+ __r |= __y;
+ return __r;
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+bitset<_Size>
+operator^(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT
+{
+ bitset<_Size> __r = __x;
+ __r ^= __y;
+ return __r;
+}
+
+template <size_t _Size>
+struct _LIBCPP_TEMPLATE_VIS hash<bitset<_Size> >
+ : public unary_function<bitset<_Size>, size_t>
+{
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(const bitset<_Size>& __bs) const _NOEXCEPT
+ {return __bs.__hash_code();}
+};
+
+template <class _CharT, class _Traits, size_t _Size>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x);
+
+template <class _CharT, class _Traits, size_t _Size>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x);
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_BITSET
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/cassert b/contrib/libs/cxxsupp/libcxxmsvc/include/cassert
new file mode 100644
index 0000000000..3c5bb7b110
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/cassert
@@ -0,0 +1,24 @@
+// -*- 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
+//
+//===----------------------------------------------------------------------===//
+
+/*
+ cassert synopsis
+
+Macros:
+
+ assert
+
+*/
+
+#include <__config>
+#include <assert.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/ccomplex b/contrib/libs/cxxsupp/libcxxmsvc/include/ccomplex
new file mode 100644
index 0000000000..f1037f2841
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/ccomplex
@@ -0,0 +1,28 @@
+// -*- 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_CCOMPLEX
+#define _LIBCPP_CCOMPLEX
+
+/*
+ ccomplex synopsis
+
+#include <complex>
+
+*/
+
+#include <complex>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+// hh 080623 Created
+
+#endif // _LIBCPP_CCOMPLEX
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/cctype b/contrib/libs/cxxsupp/libcxxmsvc/include/cctype
new file mode 100644
index 0000000000..fc770cfba3
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/cctype
@@ -0,0 +1,120 @@
+// -*- 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_CCTYPE
+#define _LIBCPP_CCTYPE
+
+/*
+ cctype synopsis
+
+namespace std
+{
+
+int isalnum(int c);
+int isalpha(int c);
+int isblank(int c); // C99
+int iscntrl(int c);
+int isdigit(int c);
+int isgraph(int c);
+int islower(int c);
+int isprint(int c);
+int ispunct(int c);
+int isspace(int c);
+int isupper(int c);
+int isxdigit(int c);
+int tolower(int c);
+int toupper(int c);
+
+} // std
+*/
+
+#include <__config>
+#include <ctype.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifdef isalnum
+#undef isalnum
+#endif
+
+#ifdef isalpha
+#undef isalpha
+#endif
+
+#ifdef isblank
+#undef isblank
+#endif
+
+#ifdef iscntrl
+#undef iscntrl
+#endif
+
+#ifdef isdigit
+#undef isdigit
+#endif
+
+#ifdef isgraph
+#undef isgraph
+#endif
+
+#ifdef islower
+#undef islower
+#endif
+
+#ifdef isprint
+#undef isprint
+#endif
+
+#ifdef ispunct
+#undef ispunct
+#endif
+
+#ifdef isspace
+#undef isspace
+#endif
+
+#ifdef isupper
+#undef isupper
+#endif
+
+#ifdef isxdigit
+#undef isxdigit
+#endif
+
+#ifdef tolower
+#undef tolower
+#endif
+
+#ifdef toupper
+#undef toupper
+#endif
+
+
+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
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/cerrno b/contrib/libs/cxxsupp/libcxxmsvc/include/cerrno
new file mode 100644
index 0000000000..9946c855b5
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/cerrno
@@ -0,0 +1,32 @@
+// -*- 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_CERRNO
+#define _LIBCPP_CERRNO
+
+/*
+ cerrno synopsis
+
+Macros:
+
+ EDOM
+ EILSEQ // C99
+ ERANGE
+ errno
+
+*/
+
+#include <__config>
+#include <errno.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#endif // _LIBCPP_CERRNO
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/cfenv b/contrib/libs/cxxsupp/libcxxmsvc/include/cfenv
new file mode 100644
index 0000000000..e1aae2f009
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/cfenv
@@ -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_CFENV
+#define _LIBCPP_CFENV
+
+/*
+ cfenv synopsis
+
+This entire header is C99 / C++0X
+
+Macros:
+
+ FE_DIVBYZERO
+ FE_INEXACT
+ FE_INVALID
+ FE_OVERFLOW
+ FE_UNDERFLOW
+ FE_ALL_EXCEPT
+ FE_DOWNWARD
+ FE_TONEAREST
+ FE_TOWARDZERO
+ FE_UPWARD
+ FE_DFL_ENV
+
+namespace std
+{
+
+Types:
+
+ fenv_t
+ fexcept_t
+
+int feclearexcept(int excepts);
+int fegetexceptflag(fexcept_t* flagp, int excepts);
+int feraiseexcept(int excepts);
+int fesetexceptflag(const fexcept_t* flagp, int excepts);
+int fetestexcept(int excepts);
+int fegetround();
+int fesetround(int round);
+int fegetenv(fenv_t* envp);
+int feholdexcept(fenv_t* envp);
+int fesetenv(const fenv_t* envp);
+int feupdateenv(const fenv_t* envp);
+
+} // std
+*/
+
+#include <__config>
+#include <fenv.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+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
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/cfloat b/contrib/libs/cxxsupp/libcxxmsvc/include/cfloat
new file mode 100644
index 0000000000..ff806cef9c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/cfloat
@@ -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_CFLOAT
+#define _LIBCPP_CFLOAT
+
+/*
+ cfloat synopsis
+
+Macros:
+
+ FLT_ROUNDS
+ FLT_EVAL_METHOD // C99
+ FLT_RADIX
+
+ FLT_HAS_SUBNORM // C11
+ DBL_HAS_SUBNORM // C11
+ LDBL_HAS_SUBNORM // C11
+
+ FLT_MANT_DIG
+ DBL_MANT_DIG
+ LDBL_MANT_DIG
+
+ DECIMAL_DIG // C99
+ FLT_DECIMAL_DIG // C11
+ DBL_DECIMAL_DIG // C11
+ LDBL_DECIMAL_DIG // C11
+
+ FLT_DIG
+ DBL_DIG
+ LDBL_DIG
+
+ FLT_MIN_EXP
+ DBL_MIN_EXP
+ LDBL_MIN_EXP
+
+ FLT_MIN_10_EXP
+ DBL_MIN_10_EXP
+ LDBL_MIN_10_EXP
+
+ FLT_MAX_EXP
+ DBL_MAX_EXP
+ LDBL_MAX_EXP
+
+ FLT_MAX_10_EXP
+ DBL_MAX_10_EXP
+ LDBL_MAX_10_EXP
+
+ FLT_MAX
+ DBL_MAX
+ LDBL_MAX
+
+ FLT_EPSILON
+ DBL_EPSILON
+ LDBL_EPSILON
+
+ FLT_MIN
+ DBL_MIN
+ LDBL_MIN
+
+ FLT_TRUE_MIN // C11
+ DBL_TRUE_MIN // C11
+ LDBL_TRUE_MIN // C11
+*/
+
+#include <__config>
+#include <float.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#endif // _LIBCPP_CFLOAT
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/charconv b/contrib/libs/cxxsupp/libcxxmsvc/include/charconv
new file mode 100644
index 0000000000..86cbbd8c9a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/charconv
@@ -0,0 +1,640 @@
+// -*- 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_CHARCONV
+#define _LIBCPP_CHARCONV
+
+/*
+ charconv synopsis
+
+namespace std {
+
+ // floating-point format for primitive numerical conversion
+ enum class chars_format {
+ scientific = unspecified,
+ fixed = unspecified,
+ hex = unspecified,
+ general = fixed | scientific
+ };
+
+ // 23.20.2, primitive numerical output conversion
+ struct to_chars_result {
+ char* ptr;
+ errc ec;
+ friend bool operator==(const to_chars_result&, const to_chars_result&) = default; // since C++20
+ };
+
+ to_chars_result to_chars(char* first, char* last, see below value,
+ int base = 10);
+ to_chars_result to_chars(char* first, char* last, bool value,
+ int base = 10) = delete;
+
+ to_chars_result to_chars(char* first, char* last, float value);
+ to_chars_result to_chars(char* first, char* last, double value);
+ to_chars_result to_chars(char* first, char* last, long double value);
+
+ to_chars_result to_chars(char* first, char* last, float value,
+ chars_format fmt);
+ to_chars_result to_chars(char* first, char* last, double value,
+ chars_format fmt);
+ to_chars_result to_chars(char* first, char* last, long double value,
+ chars_format fmt);
+
+ to_chars_result to_chars(char* first, char* last, float value,
+ chars_format fmt, int precision);
+ to_chars_result to_chars(char* first, char* last, double value,
+ chars_format fmt, int precision);
+ to_chars_result to_chars(char* first, char* last, long double value,
+ chars_format fmt, int precision);
+
+ // 23.20.3, primitive numerical input conversion
+ struct from_chars_result {
+ const char* ptr;
+ errc ec;
+ friend bool operator==(const from_chars_result&, const from_chars_result&) = default; // since C++20
+ };
+
+ from_chars_result from_chars(const char* first, const char* last,
+ see below& value, int base = 10);
+
+ from_chars_result from_chars(const char* first, const char* last,
+ float& value,
+ chars_format fmt = chars_format::general);
+ from_chars_result from_chars(const char* first, const char* last,
+ double& value,
+ chars_format fmt = chars_format::general);
+ from_chars_result from_chars(const char* first, const char* last,
+ long double& value,
+ chars_format fmt = chars_format::general);
+
+} // namespace std
+
+*/
+
+#include <__assert>
+#include <__availability>
+#include <__bits>
+#include <__charconv/chars_format.h>
+#include <__charconv/from_chars_result.h>
+#include <__charconv/to_chars_result.h>
+#include <__config>
+#include <__debug>
+#include <__errc>
+#include <__utility/unreachable.h>
+#include <cmath> // for log2f
+#include <cstdint>
+#include <cstdlib>
+#include <cstring>
+#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
+
+namespace __itoa {
+_LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_FUNC_VIS char* __u64toa(uint64_t __value, char* __buffer) _NOEXCEPT;
+_LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_FUNC_VIS char* __u32toa(uint32_t __value, char* __buffer) _NOEXCEPT;
+} // namespace __itoa
+
+#ifndef _LIBCPP_CXX03_LANG
+
+to_chars_result to_chars(char*, char*, bool, int = 10) = delete;
+from_chars_result from_chars(const char*, const char*, bool, int = 10) = delete;
+
+namespace __itoa
+{
+
+static _LIBCPP_CONSTEXPR uint64_t __pow10_64[] = {
+ UINT64_C(0),
+ UINT64_C(10),
+ UINT64_C(100),
+ UINT64_C(1000),
+ UINT64_C(10000),
+ UINT64_C(100000),
+ UINT64_C(1000000),
+ UINT64_C(10000000),
+ UINT64_C(100000000),
+ UINT64_C(1000000000),
+ UINT64_C(10000000000),
+ UINT64_C(100000000000),
+ UINT64_C(1000000000000),
+ UINT64_C(10000000000000),
+ UINT64_C(100000000000000),
+ UINT64_C(1000000000000000),
+ UINT64_C(10000000000000000),
+ UINT64_C(100000000000000000),
+ UINT64_C(1000000000000000000),
+ UINT64_C(10000000000000000000),
+};
+
+static _LIBCPP_CONSTEXPR uint32_t __pow10_32[] = {
+ UINT32_C(0), UINT32_C(10), UINT32_C(100),
+ UINT32_C(1000), UINT32_C(10000), UINT32_C(100000),
+ UINT32_C(1000000), UINT32_C(10000000), UINT32_C(100000000),
+ UINT32_C(1000000000),
+};
+
+template <typename _Tp, typename = void>
+struct _LIBCPP_HIDDEN __traits_base
+{
+ using type = uint64_t;
+
+ static _LIBCPP_INLINE_VISIBILITY int __width(_Tp __v)
+ {
+ auto __t = (64 - _VSTD::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12;
+ return __t - (__v < __pow10_64[__t]) + 1;
+ }
+
+ _LIBCPP_AVAILABILITY_TO_CHARS
+ static _LIBCPP_INLINE_VISIBILITY char* __convert(_Tp __v, char* __p)
+ {
+ return __u64toa(__v, __p);
+ }
+
+ static _LIBCPP_INLINE_VISIBILITY decltype(__pow10_64)& __pow() { return __pow10_64; }
+};
+
+template <typename _Tp>
+struct _LIBCPP_HIDDEN
+ __traits_base<_Tp, decltype(void(uint32_t{declval<_Tp>()}))>
+{
+ using type = uint32_t;
+
+ static _LIBCPP_INLINE_VISIBILITY int __width(_Tp __v)
+ {
+ auto __t = (32 - _VSTD::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12;
+ return __t - (__v < __pow10_32[__t]) + 1;
+ }
+
+ _LIBCPP_AVAILABILITY_TO_CHARS
+ static _LIBCPP_INLINE_VISIBILITY char* __convert(_Tp __v, char* __p)
+ {
+ return __u32toa(__v, __p);
+ }
+
+ static _LIBCPP_INLINE_VISIBILITY decltype(__pow10_32)& __pow() { return __pow10_32; }
+};
+
+template <typename _Tp>
+inline _LIBCPP_INLINE_VISIBILITY bool
+__mul_overflowed(unsigned char __a, _Tp __b, unsigned char& __r)
+{
+ auto __c = __a * __b;
+ __r = __c;
+ return __c > numeric_limits<unsigned char>::max();
+}
+
+template <typename _Tp>
+inline _LIBCPP_INLINE_VISIBILITY bool
+__mul_overflowed(unsigned short __a, _Tp __b, unsigned short& __r)
+{
+ auto __c = __a * __b;
+ __r = __c;
+ return __c > numeric_limits<unsigned short>::max();
+}
+
+template <typename _Tp>
+inline _LIBCPP_INLINE_VISIBILITY bool
+__mul_overflowed(_Tp __a, _Tp __b, _Tp& __r)
+{
+ static_assert(is_unsigned<_Tp>::value, "");
+#if !defined(_LIBCPP_COMPILER_MSVC)
+ return __builtin_mul_overflow(__a, __b, &__r);
+#else
+ bool __did = __b && (numeric_limits<_Tp>::max() / __b) < __a;
+ __r = __a * __b;
+ return __did;
+#endif
+}
+
+template <typename _Tp, typename _Up>
+inline _LIBCPP_INLINE_VISIBILITY bool
+__mul_overflowed(_Tp __a, _Up __b, _Tp& __r)
+{
+ return __mul_overflowed(__a, static_cast<_Tp>(__b), __r);
+}
+
+template <typename _Tp>
+struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp>
+{
+ static _LIBCPP_CONSTEXPR int digits = numeric_limits<_Tp>::digits10 + 1;
+ using __traits_base<_Tp>::__pow;
+ using typename __traits_base<_Tp>::type;
+
+ // precondition: at least one non-zero character available
+ static _LIBCPP_INLINE_VISIBILITY char const*
+ __read(char const* __p, char const* __ep, type& __a, type& __b)
+ {
+ type __cprod[digits];
+ int __j = digits - 1;
+ int __i = digits;
+ do
+ {
+ if (!('0' <= *__p && *__p <= '9'))
+ break;
+ __cprod[--__i] = *__p++ - '0';
+ } while (__p != __ep && __i != 0);
+
+ __a = __inner_product(__cprod + __i + 1, __cprod + __j, __pow() + 1,
+ __cprod[__i]);
+ if (__mul_overflowed(__cprod[__j], __pow()[__j - __i], __b))
+ --__p;
+ return __p;
+ }
+
+ template <typename _It1, typename _It2, class _Up>
+ static _LIBCPP_INLINE_VISIBILITY _Up
+ __inner_product(_It1 __first1, _It1 __last1, _It2 __first2, _Up __init)
+ {
+ for (; __first1 < __last1; ++__first1, ++__first2)
+ __init = __init + *__first1 * *__first2;
+ return __init;
+ }
+};
+
+} // namespace __itoa
+
+template <typename _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _Tp
+__complement(_Tp __x)
+{
+ static_assert(is_unsigned<_Tp>::value, "cast to unsigned first");
+ return _Tp(~__x + 1);
+}
+
+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_like(__value);
+ if (__value < 0 && __first != __last)
+ {
+ *__first++ = '-';
+ __x = __complement(__x);
+ }
+
+ return __to_chars_itoa(__first, __last, __x, false_type());
+}
+
+template <typename _Tp>
+_LIBCPP_AVAILABILITY_TO_CHARS
+inline _LIBCPP_INLINE_VISIBILITY to_chars_result
+__to_chars_itoa(char* __first, char* __last, _Tp __value, false_type)
+{
+ using __tx = __itoa::__traits<_Tp>;
+ auto __diff = __last - __first;
+
+ if (__tx::digits <= __diff || __tx::__width(__value) <= __diff)
+ return {__tx::__convert(__value, __first), errc(0)};
+ else
+ return {__last, errc::value_too_large};
+}
+
+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,
+ true_type)
+{
+ auto __x = __to_unsigned_like(__value);
+ if (__value < 0 && __first != __last)
+ {
+ *__first++ = '-';
+ __x = __complement(__x);
+ }
+
+ return __to_chars_integral(__first, __last, __x, __base, false_type());
+}
+
+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());
+
+ 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>
+_LIBCPP_AVAILABILITY_TO_CHARS
+inline _LIBCPP_INLINE_VISIBILITY to_chars_result
+to_chars(char* __first, char* __last, _Tp __value)
+{
+ return __to_chars_itoa(__first, __last, __value, is_signed<_Tp>());
+}
+
+template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
+_LIBCPP_AVAILABILITY_TO_CHARS
+inline _LIBCPP_INLINE_VISIBILITY to_chars_result
+to_chars(char* __first, char* __last, _Tp __value, int __base)
+{
+ _LIBCPP_ASSERT(2 <= __base && __base <= 36, "base not in [2, 36]");
+ return __to_chars_integral(__first, __last, __value, __base,
+ is_signed<_Tp>());
+}
+
+template <typename _It, typename _Tp, typename _Fn, typename... _Ts>
+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_like(__value)) __x;
+
+ bool __neg = (__first != __last && *__first == '-');
+ auto __r = __f(__neg ? __first + 1 : __first, __last, __x, __args...);
+ switch (__r.ec)
+ {
+ case errc::invalid_argument:
+ return {__first, __r.ec};
+ case errc::result_out_of_range:
+ return __r;
+ default:
+ break;
+ }
+
+ if (__neg)
+ {
+ if (__x <= __complement(__to_unsigned_like(__tl::min())))
+ {
+ __x = __complement(__x);
+ _VSTD::memcpy(&__value, &__x, sizeof(__x));
+ return __r;
+ }
+ }
+ else
+ {
+ if (__x <= __tl::max())
+ {
+ __value = __x;
+ return __r;
+ }
+ }
+
+ return {__r.ptr, errc::result_out_of_range};
+}
+
+template <typename _Tp>
+inline _LIBCPP_INLINE_VISIBILITY bool
+__in_pattern(_Tp __c)
+{
+ return '0' <= __c && __c <= '9';
+}
+
+struct _LIBCPP_HIDDEN __in_pattern_result
+{
+ bool __ok;
+ int __val;
+
+ explicit _LIBCPP_INLINE_VISIBILITY operator bool() const { return __ok; }
+};
+
+template <typename _Tp>
+inline _LIBCPP_INLINE_VISIBILITY __in_pattern_result
+__in_pattern(_Tp __c, int __base)
+{
+ if (__base <= 10)
+ return {'0' <= __c && __c < '0' + __base, __c - '0'};
+ else if (__in_pattern(__c))
+ return {true, __c - '0'};
+ else if ('a' <= __c && __c < 'a' + __base - 10)
+ return {true, __c - 'a' + 10};
+ else
+ return {'A' <= __c && __c < 'A' + __base - 10, __c - 'A' + 10};
+}
+
+template <typename _It, typename _Tp, typename _Fn, typename... _Ts>
+inline _LIBCPP_INLINE_VISIBILITY from_chars_result
+__subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f,
+ _Ts... __args)
+{
+ auto __find_non_zero = [](_It __first, _It __last) {
+ for (; __first != __last; ++__first)
+ if (*__first != '0')
+ break;
+ return __first;
+ };
+
+ auto __p = __find_non_zero(__first, __last);
+ if (__p == __last || !__in_pattern(*__p, __args...))
+ {
+ if (__p == __first)
+ return {__first, errc::invalid_argument};
+ else
+ {
+ __value = 0;
+ return {__p, {}};
+ }
+ }
+
+ auto __r = __f(__p, __last, __value, __args...);
+ if (__r.ec == errc::result_out_of_range)
+ {
+ for (; __r.ptr != __last; ++__r.ptr)
+ {
+ if (!__in_pattern(*__r.ptr, __args...))
+ break;
+ }
+ }
+
+ return __r;
+}
+
+template <typename _Tp, typename enable_if<is_unsigned<_Tp>::value, int>::type = 0>
+inline _LIBCPP_INLINE_VISIBILITY from_chars_result
+__from_chars_atoi(const char* __first, const char* __last, _Tp& __value)
+{
+ using __tx = __itoa::__traits<_Tp>;
+ using __output_type = typename __tx::type;
+
+ return __subject_seq_combinator(
+ __first, __last, __value,
+ [](const char* __first, const char* __last,
+ _Tp& __value) -> from_chars_result {
+ __output_type __a, __b;
+ auto __p = __tx::__read(__first, __last, __a, __b);
+ if (__p == __last || !__in_pattern(*__p))
+ {
+ __output_type __m = numeric_limits<_Tp>::max();
+ if (__m >= __a && __m - __a >= __b)
+ {
+ __value = __a + __b;
+ return {__p, {}};
+ }
+ }
+ return {__p, errc::result_out_of_range};
+ });
+}
+
+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_like(__value));
+ return __sign_combinator(__first, __last, __value, __from_chars_atoi<__t>);
+}
+
+template <typename _Tp, typename enable_if<is_unsigned<_Tp>::value, int>::type = 0>
+inline _LIBCPP_INLINE_VISIBILITY from_chars_result
+__from_chars_integral(const char* __first, const char* __last, _Tp& __value,
+ int __base)
+{
+ if (__base == 10)
+ return __from_chars_atoi(__first, __last, __value);
+
+ return __subject_seq_combinator(
+ __first, __last, __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 != __lastx; ++__i, ++__p)
+ {
+ if (auto __c = __in_pattern(*__p, __base))
+ {
+ if (__i < __digits - 1)
+ __a = __a * __base + __c.__val;
+ else
+ {
+ if (!__itoa::__mul_overflowed(__a, __base, __a))
+ ++__p;
+ __b = __c.__val;
+ break;
+ }
+ }
+ else
+ break;
+ }
+
+ if (__p == __lastx || !__in_pattern(*__p, __base))
+ {
+ if (__tl::max() - __a >= __b)
+ {
+ __value = __a + __b;
+ return {__p, {}};
+ }
+ }
+ return {__p, errc::result_out_of_range};
+ },
+ __base);
+}
+
+template <typename _Tp, typename enable_if<is_signed<_Tp>::value, int>::type = 0>
+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_like(__value));
+ return __sign_combinator(__first, __last, __value,
+ __from_chars_integral<__t>, __base);
+}
+
+template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
+inline _LIBCPP_INLINE_VISIBILITY from_chars_result
+from_chars(const char* __first, const char* __last, _Tp& __value)
+{
+ return __from_chars_atoi(__first, __last, __value);
+}
+
+template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
+inline _LIBCPP_INLINE_VISIBILITY from_chars_result
+from_chars(const char* __first, const char* __last, _Tp& __value, int __base)
+{
+ _LIBCPP_ASSERT(2 <= __base && __base <= 36, "base not in [2, 36]");
+ return __from_chars_integral(__first, __last, __value, __base);
+}
+
+// Floating-point implementation starts here.
+// Unlike the other parts of charconv this is only available in C++17 and newer.
+#if _LIBCPP_STD_VER > 14
+
+_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
+to_chars_result to_chars(char* __first, char* __last, float __value);
+
+_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
+to_chars_result to_chars(char* __first, char* __last, double __value);
+
+_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
+to_chars_result to_chars(char* __first, char* __last, long double __value);
+
+_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
+to_chars_result to_chars(char* __first, char* __last, float __value, chars_format __fmt);
+
+_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
+to_chars_result to_chars(char* __first, char* __last, double __value, chars_format __fmt);
+
+_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
+to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt);
+
+_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
+to_chars_result to_chars(char* __first, char* __last, float __value, chars_format __fmt, int __precision);
+
+_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
+to_chars_result to_chars(char* __first, char* __last, double __value, chars_format __fmt, int __precision);
+
+_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
+to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt, int __precision);
+
+# endif // _LIBCPP_STD_VER > 14
+#endif // _LIBCPP_CXX03_LANG
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_CHARCONV
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/chrono b/contrib/libs/cxxsupp/libcxxmsvc/include/chrono
new file mode 100644
index 0000000000..63558adbc4
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/chrono
@@ -0,0 +1,713 @@
+// -*- 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_CHRONO
+#define _LIBCPP_CHRONO
+
+/*
+ chrono synopsis
+
+namespace std
+{
+namespace chrono
+{
+
+template <class ToDuration, class Rep, class Period>
+constexpr
+ToDuration
+duration_cast(const duration<Rep, Period>& fd);
+
+template <class Rep> struct treat_as_floating_point : is_floating_point<Rep> {};
+
+template <class Rep> inline constexpr bool treat_as_floating_point_v
+ = treat_as_floating_point<Rep>::value; // C++17
+
+template <class Rep>
+struct duration_values
+{
+public:
+ static constexpr Rep zero(); // noexcept in C++20
+ static constexpr Rep max(); // noexcept in C++20
+ static constexpr Rep min(); // noexcept in C++20
+};
+
+// duration
+
+template <class Rep, class Period = ratio<1>>
+class duration
+{
+ static_assert(!__is_duration<Rep>::value, "A duration representation can not be a duration");
+ static_assert(__is_ratio<Period>::value, "Second template parameter of duration must be a std::ratio");
+ static_assert(Period::num > 0, "duration period must be positive");
+public:
+ typedef Rep rep;
+ typedef typename _Period::type period;
+
+ constexpr duration() = default;
+ template <class Rep2>
+ constexpr explicit duration(const Rep2& r,
+ typename enable_if
+ <
+ is_convertible<Rep2, rep>::value &&
+ (treat_as_floating_point<rep>::value ||
+ !treat_as_floating_point<rep>::value && !treat_as_floating_point<Rep2>::value)
+ >::type* = 0);
+
+ // conversions
+ template <class Rep2, class Period2>
+ constexpr duration(const duration<Rep2, Period2>& d,
+ typename enable_if
+ <
+ treat_as_floating_point<rep>::value ||
+ ratio_divide<Period2, period>::type::den == 1
+ >::type* = 0);
+
+ // observer
+
+ constexpr rep count() const;
+
+ // arithmetic
+
+ constexpr common_type<duration>::type operator+() const;
+ constexpr common_type<duration>::type operator-() const;
+ constexpr duration& operator++(); // constexpr in C++17
+ constexpr duration operator++(int); // constexpr in C++17
+ constexpr duration& operator--(); // constexpr in C++17
+ constexpr duration operator--(int); // constexpr in C++17
+
+ constexpr duration& operator+=(const duration& d); // constexpr in C++17
+ constexpr duration& operator-=(const duration& d); // constexpr in C++17
+
+ duration& operator*=(const rep& rhs); // constexpr in C++17
+ duration& operator/=(const rep& rhs); // constexpr in C++17
+ duration& operator%=(const rep& rhs); // constexpr in C++17
+ duration& operator%=(const duration& rhs); // constexpr in C++17
+
+ // special values
+
+ static constexpr duration zero(); // noexcept in C++20
+ static constexpr duration min(); // noexcept in C++20
+ static constexpr duration max(); // noexcept in C++20
+};
+
+typedef duration<long long, nano> nanoseconds;
+typedef duration<long long, micro> microseconds;
+typedef duration<long long, milli> milliseconds;
+typedef duration<long long > seconds;
+typedef duration< long, ratio< 60> > minutes;
+typedef duration< long, ratio<3600> > hours;
+
+template <class Clock, class Duration = typename Clock::duration>
+class time_point
+{
+public:
+ typedef Clock clock;
+ typedef Duration duration;
+ typedef typename duration::rep rep;
+ typedef typename duration::period period;
+private:
+ duration d_; // exposition only
+
+public:
+ time_point(); // has value "epoch" // constexpr in C++14
+ explicit time_point(const duration& d); // same as time_point() + d // constexpr in C++14
+
+ // conversions
+ template <class Duration2>
+ time_point(const time_point<clock, Duration2>& t); // constexpr in C++14
+
+ // observer
+
+ duration time_since_epoch() const; // constexpr in C++14
+
+ // arithmetic
+
+ time_point& operator+=(const duration& d); // constexpr in C++17
+ time_point& operator-=(const duration& d); // constexpr in C++17
+
+ // special values
+
+ static constexpr time_point min(); // noexcept in C++20
+ static constexpr time_point max(); // noexcept in C++20
+};
+
+} // chrono
+
+// common_type traits
+template <class Rep1, class Period1, class Rep2, class Period2>
+ struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>>;
+
+template <class Clock, class Duration1, class Duration2>
+ struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>>;
+
+namespace chrono {
+
+// duration arithmetic
+template <class Rep1, class Period1, class Rep2, class Period2>
+ constexpr
+ typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
+ operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+template <class Rep1, class Period1, class Rep2, class Period2>
+ constexpr
+ typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
+ operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+template <class Rep1, class Period, class Rep2>
+ constexpr
+ duration<typename common_type<Rep1, Rep2>::type, Period>
+ operator*(const duration<Rep1, Period>& d, const Rep2& s);
+template <class Rep1, class Period, class Rep2>
+ constexpr
+ duration<typename common_type<Rep1, Rep2>::type, Period>
+ operator*(const Rep1& s, const duration<Rep2, Period>& d);
+template <class Rep1, class Period, class Rep2>
+ constexpr
+ duration<typename common_type<Rep1, Rep2>::type, Period>
+ operator/(const duration<Rep1, Period>& d, const Rep2& s);
+template <class Rep1, class Period1, class Rep2, class Period2>
+ constexpr
+ typename common_type<Rep1, Rep2>::type
+ operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+
+// duration comparisons
+template <class Rep1, class Period1, class Rep2, class Period2>
+ constexpr
+ bool operator==(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+template <class Rep1, class Period1, class Rep2, class Period2>
+ constexpr
+ bool operator!=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+template <class Rep1, class Period1, class Rep2, class Period2>
+ constexpr
+ bool operator< (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+template <class Rep1, class Period1, class Rep2, class Period2>
+ constexpr
+ bool operator<=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+template <class Rep1, class Period1, class Rep2, class Period2>
+ constexpr
+ bool operator> (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+template <class Rep1, class Period1, class Rep2, class Period2>
+ constexpr
+ bool operator>=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+
+// duration_cast
+template <class ToDuration, class Rep, class Period>
+ ToDuration duration_cast(const duration<Rep, Period>& d);
+
+template <class ToDuration, class Rep, class Period>
+ constexpr ToDuration floor(const duration<Rep, Period>& d); // C++17
+template <class ToDuration, class Rep, class Period>
+ constexpr ToDuration ceil(const duration<Rep, Period>& d); // C++17
+template <class ToDuration, class Rep, class Period>
+ constexpr ToDuration round(const duration<Rep, Period>& d); // C++17
+
+// duration I/O is elsewhere
+
+// time_point arithmetic (all constexpr in C++14)
+template <class Clock, class Duration1, class Rep2, class Period2>
+ time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
+ operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
+template <class Rep1, class Period1, class Clock, class Duration2>
+ time_point<Clock, typename common_type<duration<Rep1, Period1>, Duration2>::type>
+ operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
+template <class Clock, class Duration1, class Rep2, class Period2>
+ time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
+ operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
+template <class Clock, class Duration1, class Duration2>
+ typename common_type<Duration1, Duration2>::type
+ operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// time_point comparisons (all constexpr in C++14)
+template <class Clock, class Duration1, class Duration2>
+ bool operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+template <class Clock, class Duration1, class Duration2>
+ bool operator!=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+template <class Clock, class Duration1, class Duration2>
+ bool operator< (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+template <class Clock, class Duration1, class Duration2>
+ bool operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+template <class Clock, class Duration1, class Duration2>
+ bool operator> (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+template <class Clock, class Duration1, class Duration2>
+ bool operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// time_point_cast (constexpr in C++14)
+
+template <class ToDuration, class Clock, class Duration>
+ time_point<Clock, ToDuration> time_point_cast(const time_point<Clock, Duration>& t);
+
+template <class ToDuration, class Clock, class Duration>
+ constexpr time_point<Clock, ToDuration>
+ floor(const time_point<Clock, Duration>& tp); // C++17
+
+template <class ToDuration, class Clock, class Duration>
+ constexpr time_point<Clock, ToDuration>
+ ceil(const time_point<Clock, Duration>& tp); // C++17
+
+template <class ToDuration, class Clock, class Duration>
+ constexpr time_point<Clock, ToDuration>
+ round(const time_point<Clock, Duration>& tp); // C++17
+
+template <class Rep, class Period>
+ constexpr duration<Rep, Period> abs(duration<Rep, Period> d); // C++17
+
+// Clocks
+
+class system_clock
+{
+public:
+ typedef microseconds duration;
+ typedef duration::rep rep;
+ typedef duration::period period;
+ typedef chrono::time_point<system_clock> time_point;
+ static const bool is_steady = false; // constexpr in C++14
+
+ static time_point now() noexcept;
+ static time_t to_time_t (const time_point& __t) noexcept;
+ static time_point from_time_t(time_t __t) noexcept;
+};
+
+template <class Duration>
+ using sys_time = time_point<system_clock, Duration>; // C++20
+using sys_seconds = sys_time<seconds>; // C++20
+using sys_days = sys_time<days>; // C++20
+
+class file_clock // C++20
+{
+public:
+ typedef see-below rep;
+ typedef nano period;
+ typedef chrono::duration<rep, period> duration;
+ typedef chrono::time_point<file_clock> time_point;
+ static constexpr bool is_steady = false;
+
+ static time_point now() noexcept;
+
+ template<class Duration>
+ static sys_time<see-below> to_sys(const file_time<Duration>&);
+
+ template<class Duration>
+ static file_time<see-below> from_sys(const sys_time<Duration>&);
+};
+
+template<class Duration>
+ using file_time = time_point<file_clock, Duration>; // C++20
+
+class steady_clock
+{
+public:
+ typedef nanoseconds duration;
+ typedef duration::rep rep;
+ typedef duration::period period;
+ typedef chrono::time_point<steady_clock, duration> time_point;
+ static const bool is_steady = true; // constexpr in C++14
+
+ static time_point now() noexcept;
+};
+
+typedef steady_clock high_resolution_clock;
+
+// 25.7.8, local time // C++20
+struct local_t {};
+template<class Duration>
+ using local_time = time_point<local_t, Duration>;
+using local_seconds = local_time<seconds>;
+using local_days = local_time<days>;
+
+// 25.8.2, class last_spec // C++20
+struct last_spec;
+
+// 25.8.3, class day // C++20
+
+class day;
+constexpr bool operator==(const day& x, const day& y) noexcept;
+constexpr bool operator!=(const day& x, const day& y) noexcept;
+constexpr bool operator< (const day& x, const day& y) noexcept;
+constexpr bool operator> (const day& x, const day& y) noexcept;
+constexpr bool operator<=(const day& x, const day& y) noexcept;
+constexpr bool operator>=(const day& x, const day& y) noexcept;
+constexpr day operator+(const day& x, const days& y) noexcept;
+constexpr day operator+(const days& x, const day& y) noexcept;
+constexpr day operator-(const day& x, const days& y) noexcept;
+constexpr days operator-(const day& x, const day& y) noexcept;
+
+// 25.8.4, class month // C++20
+class month;
+constexpr bool operator==(const month& x, const month& y) noexcept;
+constexpr bool operator!=(const month& x, const month& y) noexcept;
+constexpr bool operator< (const month& x, const month& y) noexcept;
+constexpr bool operator> (const month& x, const month& y) noexcept;
+constexpr bool operator<=(const month& x, const month& y) noexcept;
+constexpr bool operator>=(const month& x, const month& y) noexcept;
+constexpr month operator+(const month& x, const months& y) noexcept;
+constexpr month operator+(const months& x, const month& y) noexcept;
+constexpr month operator-(const month& x, const months& y) noexcept;
+constexpr months operator-(const month& x, const month& y) noexcept;
+
+// 25.8.5, class year // C++20
+class year;
+constexpr bool operator==(const year& x, const year& y) noexcept;
+constexpr bool operator!=(const year& x, const year& y) noexcept;
+constexpr bool operator< (const year& x, const year& y) noexcept;
+constexpr bool operator> (const year& x, const year& y) noexcept;
+constexpr bool operator<=(const year& x, const year& y) noexcept;
+constexpr bool operator>=(const year& x, const year& y) noexcept;
+constexpr year operator+(const year& x, const years& y) noexcept;
+constexpr year operator+(const years& x, const year& y) noexcept;
+constexpr year operator-(const year& x, const years& y) noexcept;
+constexpr years operator-(const year& x, const year& y) noexcept;
+
+// 25.8.6, class weekday // C++20
+class weekday;
+
+constexpr bool operator==(const weekday& x, const weekday& y) noexcept;
+constexpr bool operator!=(const weekday& x, const weekday& y) noexcept;
+constexpr weekday operator+(const weekday& x, const days& y) noexcept;
+constexpr weekday operator+(const days& x, const weekday& y) noexcept;
+constexpr weekday operator-(const weekday& x, const days& y) noexcept;
+constexpr days operator-(const weekday& x, const weekday& y) noexcept;
+
+// 25.8.7, class weekday_indexed // C++20
+
+class weekday_indexed;
+constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept;
+constexpr bool operator!=(const weekday_indexed& x, const weekday_indexed& y) noexcept;
+
+// 25.8.8, class weekday_last // C++20
+class weekday_last;
+
+constexpr bool operator==(const weekday_last& x, const weekday_last& y) noexcept;
+constexpr bool operator!=(const weekday_last& x, const weekday_last& y) noexcept;
+
+// 25.8.9, class month_day // C++20
+class month_day;
+
+constexpr bool operator==(const month_day& x, const month_day& y) noexcept;
+constexpr bool operator!=(const month_day& x, const month_day& y) noexcept;
+constexpr bool operator< (const month_day& x, const month_day& y) noexcept;
+constexpr bool operator> (const month_day& x, const month_day& y) noexcept;
+constexpr bool operator<=(const month_day& x, const month_day& y) noexcept;
+constexpr bool operator>=(const month_day& x, const month_day& y) noexcept;
+
+
+// 25.8.10, class month_day_last // C++20
+class month_day_last;
+
+constexpr bool operator==(const month_day_last& x, const month_day_last& y) noexcept;
+constexpr bool operator!=(const month_day_last& x, const month_day_last& y) noexcept;
+constexpr bool operator< (const month_day_last& x, const month_day_last& y) noexcept;
+constexpr bool operator> (const month_day_last& x, const month_day_last& y) noexcept;
+constexpr bool operator<=(const month_day_last& x, const month_day_last& y) noexcept;
+constexpr bool operator>=(const month_day_last& x, const month_day_last& y) noexcept;
+
+// 25.8.11, class month_weekday // C++20
+class month_weekday;
+
+constexpr bool operator==(const month_weekday& x, const month_weekday& y) noexcept;
+constexpr bool operator!=(const month_weekday& x, const month_weekday& y) noexcept;
+
+// 25.8.12, class month_weekday_last // C++20
+class month_weekday_last;
+
+constexpr bool operator==(const month_weekday_last& x, const month_weekday_last& y) noexcept;
+constexpr bool operator!=(const month_weekday_last& x, const month_weekday_last& y) noexcept;
+
+
+// 25.8.13, class year_month // C++20
+class year_month;
+
+constexpr bool operator==(const year_month& x, const year_month& y) noexcept;
+constexpr bool operator!=(const year_month& x, const year_month& y) noexcept;
+constexpr bool operator< (const year_month& x, const year_month& y) noexcept;
+constexpr bool operator> (const year_month& x, const year_month& y) noexcept;
+constexpr bool operator<=(const year_month& x, const year_month& y) noexcept;
+constexpr bool operator>=(const year_month& x, const year_month& y) noexcept;
+
+constexpr year_month operator+(const year_month& ym, const months& dm) noexcept;
+constexpr year_month operator+(const months& dm, const year_month& ym) noexcept;
+constexpr year_month operator-(const year_month& ym, const months& dm) noexcept;
+constexpr months operator-(const year_month& x, const year_month& y) noexcept;
+constexpr year_month operator+(const year_month& ym, const years& dy) noexcept;
+constexpr year_month operator+(const years& dy, const year_month& ym) noexcept;
+constexpr year_month operator-(const year_month& ym, const years& dy) noexcept;
+
+// 25.8.14, class year_month_day class // C++20
+year_month_day;
+
+constexpr bool operator==(const year_month_day& x, const year_month_day& y) noexcept;
+constexpr bool operator!=(const year_month_day& x, const year_month_day& y) noexcept;
+constexpr bool operator< (const year_month_day& x, const year_month_day& y) noexcept;
+constexpr bool operator> (const year_month_day& x, const year_month_day& y) noexcept;
+constexpr bool operator<=(const year_month_day& x, const year_month_day& y) noexcept;
+constexpr bool operator>=(const year_month_day& x, const year_month_day& y) noexcept;
+
+constexpr year_month_day operator+(const year_month_day& ymd, const months& dm) noexcept;
+constexpr year_month_day operator+(const months& dm, const year_month_day& ymd) noexcept;
+constexpr year_month_day operator+(const year_month_day& ymd, const years& dy) noexcept;
+constexpr year_month_day operator+(const years& dy, const year_month_day& ymd) noexcept;
+constexpr year_month_day operator-(const year_month_day& ymd, const months& dm) noexcept;
+constexpr year_month_day operator-(const year_month_day& ymd, const years& dy) noexcept;
+
+
+// 25.8.15, class year_month_day_last // C++20
+class year_month_day_last;
+
+constexpr bool operator==(const year_month_day_last& x,
+ const year_month_day_last& y) noexcept;
+constexpr bool operator!=(const year_month_day_last& x,
+ const year_month_day_last& y) noexcept;
+constexpr bool operator< (const year_month_day_last& x,
+ const year_month_day_last& y) noexcept;
+constexpr bool operator> (const year_month_day_last& x,
+ const year_month_day_last& y) noexcept;
+constexpr bool operator<=(const year_month_day_last& x,
+ const year_month_day_last& y) noexcept;
+constexpr bool operator>=(const year_month_day_last& x,
+ const year_month_day_last& y) noexcept;
+
+constexpr year_month_day_last
+ operator+(const year_month_day_last& ymdl, const months& dm) noexcept;
+constexpr year_month_day_last
+ operator+(const months& dm, const year_month_day_last& ymdl) noexcept;
+constexpr year_month_day_last
+ operator+(const year_month_day_last& ymdl, const years& dy) noexcept;
+constexpr year_month_day_last
+ operator+(const years& dy, const year_month_day_last& ymdl) noexcept;
+constexpr year_month_day_last
+ operator-(const year_month_day_last& ymdl, const months& dm) noexcept;
+constexpr year_month_day_last
+ operator-(const year_month_day_last& ymdl, const years& dy) noexcept;
+
+// 25.8.16, class year_month_weekday // C++20
+class year_month_weekday;
+
+constexpr bool operator==(const year_month_weekday& x,
+ const year_month_weekday& y) noexcept;
+constexpr bool operator!=(const year_month_weekday& x,
+ const year_month_weekday& y) noexcept;
+
+constexpr year_month_weekday
+ operator+(const year_month_weekday& ymwd, const months& dm) noexcept;
+constexpr year_month_weekday
+ operator+(const months& dm, const year_month_weekday& ymwd) noexcept;
+constexpr year_month_weekday
+ operator+(const year_month_weekday& ymwd, const years& dy) noexcept;
+constexpr year_month_weekday
+ operator+(const years& dy, const year_month_weekday& ymwd) noexcept;
+constexpr year_month_weekday
+ operator-(const year_month_weekday& ymwd, const months& dm) noexcept;
+constexpr year_month_weekday
+ operator-(const year_month_weekday& ymwd, const years& dy) noexcept;
+
+// 25.8.17, class year_month_weekday_last // C++20
+class year_month_weekday_last;
+
+constexpr bool operator==(const year_month_weekday_last& x,
+ const year_month_weekday_last& y) noexcept;
+constexpr bool operator!=(const year_month_weekday_last& x,
+ const year_month_weekday_last& y) noexcept;
+constexpr year_month_weekday_last
+ operator+(const year_month_weekday_last& ymwdl, const months& dm) noexcept;
+constexpr year_month_weekday_last
+ operator+(const months& dm, const year_month_weekday_last& ymwdl) noexcept;
+constexpr year_month_weekday_last
+ operator+(const year_month_weekday_last& ymwdl, const years& dy) noexcept;
+constexpr year_month_weekday_last
+ operator+(const years& dy, const year_month_weekday_last& ymwdl) noexcept;
+constexpr year_month_weekday_last
+ operator-(const year_month_weekday_last& ymwdl, const months& dm) noexcept;
+constexpr year_month_weekday_last
+ operator-(const year_month_weekday_last& ymwdl, const years& dy) noexcept;
+
+// 25.8.18, civil calendar conventional syntax operators // C++20
+constexpr year_month
+ operator/(const year& y, const month& m) noexcept;
+constexpr year_month
+ operator/(const year& y, int m) noexcept;
+constexpr month_day
+ operator/(const month& m, const day& d) noexcept;
+constexpr month_day
+ operator/(const month& m, int d) noexcept;
+constexpr month_day
+ operator/(int m, const day& d) noexcept;
+constexpr month_day
+ operator/(const day& d, const month& m) noexcept;
+constexpr month_day
+ operator/(const day& d, int m) noexcept;
+constexpr month_day_last
+ operator/(const month& m, last_spec) noexcept;
+constexpr month_day_last
+ operator/(int m, last_spec) noexcept;
+constexpr month_day_last
+ operator/(last_spec, const month& m) noexcept;
+constexpr month_day_last
+ operator/(last_spec, int m) noexcept;
+constexpr month_weekday
+ operator/(const month& m, const weekday_indexed& wdi) noexcept;
+constexpr month_weekday
+ operator/(int m, const weekday_indexed& wdi) noexcept;
+constexpr month_weekday
+ operator/(const weekday_indexed& wdi, const month& m) noexcept;
+constexpr month_weekday
+ operator/(const weekday_indexed& wdi, int m) noexcept;
+constexpr month_weekday_last
+ operator/(const month& m, const weekday_last& wdl) noexcept;
+constexpr month_weekday_last
+ operator/(int m, const weekday_last& wdl) noexcept;
+constexpr month_weekday_last
+ operator/(const weekday_last& wdl, const month& m) noexcept;
+constexpr month_weekday_last
+ operator/(const weekday_last& wdl, int m) noexcept;
+constexpr year_month_day
+ operator/(const year_month& ym, const day& d) noexcept;
+constexpr year_month_day
+ operator/(const year_month& ym, int d) noexcept;
+constexpr year_month_day
+ operator/(const year& y, const month_day& md) noexcept;
+constexpr year_month_day
+ operator/(int y, const month_day& md) noexcept;
+constexpr year_month_day
+ operator/(const month_day& md, const year& y) noexcept;
+constexpr year_month_day
+ operator/(const month_day& md, int y) noexcept;
+constexpr year_month_day_last
+ operator/(const year_month& ym, last_spec) noexcept;
+constexpr year_month_day_last
+ operator/(const year& y, const month_day_last& mdl) noexcept;
+constexpr year_month_day_last
+ operator/(int y, const month_day_last& mdl) noexcept;
+constexpr year_month_day_last
+ operator/(const month_day_last& mdl, const year& y) noexcept;
+constexpr year_month_day_last
+ operator/(const month_day_last& mdl, int y) noexcept;
+constexpr year_month_weekday
+ operator/(const year_month& ym, const weekday_indexed& wdi) noexcept;
+constexpr year_month_weekday
+ operator/(const year& y, const month_weekday& mwd) noexcept;
+constexpr year_month_weekday
+ operator/(int y, const month_weekday& mwd) noexcept;
+constexpr year_month_weekday
+ operator/(const month_weekday& mwd, const year& y) noexcept;
+constexpr year_month_weekday
+ operator/(const month_weekday& mwd, int y) noexcept;
+constexpr year_month_weekday_last
+ operator/(const year_month& ym, const weekday_last& wdl) noexcept;
+constexpr year_month_weekday_last
+ operator/(const year& y, const month_weekday_last& mwdl) noexcept;
+constexpr year_month_weekday_last
+ operator/(int y, const month_weekday_last& mwdl) noexcept;
+constexpr year_month_weekday_last
+ operator/(const month_weekday_last& mwdl, const year& y) noexcept;
+constexpr year_month_weekday_last
+ operator/(const month_weekday_last& mwdl, int y) noexcept;
+
+// 26.9, class template hh_mm_ss
+template <class Duration>
+class hh_mm_ss
+{
+ bool is_neg; // exposition only
+ chrono::hours h; // exposition only
+ chrono::minutes m; // exposition only
+ chrono::seconds s; // exposition only
+ precision ss; // exposition only
+
+public:
+ static unsigned constexpr fractional_width = see below;
+ using precision = see below;
+
+ constexpr hh_mm_ss() noexcept : hh_mm_ss{Duration::zero()} {}
+ constexpr explicit hh_mm_ss(Duration d) noexcept;
+
+ constexpr bool is_negative() const noexcept;
+ constexpr chrono::hours hours() const noexcept;
+ constexpr chrono::minutes minutes() const noexcept;
+ constexpr chrono::seconds seconds() const noexcept;
+ constexpr precision subseconds() const noexcept;
+
+ constexpr explicit operator precision() const noexcept;
+ constexpr precision to_duration() const noexcept;
+};
+
+// 26.10, 12/24 hour functions
+constexpr bool is_am(hours const& h) noexcept;
+constexpr bool is_pm(hours const& h) noexcept;
+constexpr hours make12(const hours& h) noexcept;
+constexpr hours make24(const hours& h, bool is_pm) noexcept;
+
+// 25.10.5, class time_zone // C++20
+enum class choose {earliest, latest};
+class time_zone;
+bool operator==(const time_zone& x, const time_zone& y) noexcept;
+bool operator!=(const time_zone& x, const time_zone& y) noexcept;
+bool operator<(const time_zone& x, const time_zone& y) noexcept;
+bool operator>(const time_zone& x, const time_zone& y) noexcept;
+bool operator<=(const time_zone& x, const time_zone& y) noexcept;
+bool operator>=(const time_zone& x, const time_zone& y) noexcept;
+
+// calendrical constants
+inline constexpr last_spec last{}; // C++20
+inline constexpr chrono::weekday Sunday{0}; // C++20
+inline constexpr chrono::weekday Monday{1}; // C++20
+inline constexpr chrono::weekday Tuesday{2}; // C++20
+inline constexpr chrono::weekday Wednesday{3}; // C++20
+inline constexpr chrono::weekday Thursday{4}; // C++20
+inline constexpr chrono::weekday Friday{5}; // C++20
+inline constexpr chrono::weekday Saturday{6}; // C++20
+
+inline constexpr chrono::month January{1}; // C++20
+inline constexpr chrono::month February{2}; // C++20
+inline constexpr chrono::month March{3}; // C++20
+inline constexpr chrono::month April{4}; // C++20
+inline constexpr chrono::month May{5}; // C++20
+inline constexpr chrono::month June{6}; // C++20
+inline constexpr chrono::month July{7}; // C++20
+inline constexpr chrono::month August{8}; // C++20
+inline constexpr chrono::month September{9}; // C++20
+inline constexpr chrono::month October{10}; // C++20
+inline constexpr chrono::month November{11}; // C++20
+inline constexpr chrono::month December{12}; // C++20
+} // chrono
+
+inline namespace literals {
+ inline namespace chrono_literals {
+constexpr chrono::hours operator ""h(unsigned long long); // C++14
+constexpr chrono::duration<unspecified , ratio<3600,1>> operator ""h(long double); // C++14
+constexpr chrono::minutes operator ""min(unsigned long long); // C++14
+constexpr chrono::duration<unspecified , ratio<60,1>> operator ""min(long double); // C++14
+constexpr chrono::seconds operator ""s(unsigned long long); // C++14
+constexpr chrono::duration<unspecified > operator ""s(long double); // C++14
+constexpr chrono::milliseconds operator ""ms(unsigned long long); // C++14
+constexpr chrono::duration<unspecified , milli> operator ""ms(long double); // C++14
+constexpr chrono::microseconds operator ""us(unsigned long long); // C++14
+constexpr chrono::duration<unspecified , micro> operator ""us(long double); // C++14
+constexpr chrono::nanoseconds operator ""ns(unsigned long long); // C++14
+constexpr chrono::duration<unspecified , nano> operator ""ns(long double); // C++14
+constexpr chrono::day operator ""d(unsigned long long d) noexcept; // C++20
+constexpr chrono::year operator ""y(unsigned long long y) noexcept; // C++20
+} // chrono_literals
+} // literals
+
+} // std
+*/
+
+#include <__chrono/calendar.h>
+#include <__chrono/convert_to_timespec.h>
+#include <__chrono/duration.h>
+#include <__chrono/file_clock.h>
+#include <__chrono/high_resolution_clock.h>
+#include <__chrono/steady_clock.h>
+#include <__chrono/system_clock.h>
+#include <__chrono/time_point.h>
+#include <__config>
+#include <compare>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#endif // _LIBCPP_CHRONO
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/cinttypes b/contrib/libs/cxxsupp/libcxxmsvc/include/cinttypes
new file mode 100644
index 0000000000..0674384b79
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/cinttypes
@@ -0,0 +1,257 @@
+// -*- 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_CINTTYPES
+#define _LIBCPP_CINTTYPES
+
+/*
+ cinttypes synopsis
+
+This entire header is C99 / C++0X
+
+#include <cstdint> // <cinttypes> includes <cstdint>
+
+Macros:
+
+ PRId8
+ PRId16
+ PRId32
+ PRId64
+
+ PRIdLEAST8
+ PRIdLEAST16
+ PRIdLEAST32
+ PRIdLEAST64
+
+ PRIdFAST8
+ PRIdFAST16
+ PRIdFAST32
+ PRIdFAST64
+
+ PRIdMAX
+ PRIdPTR
+
+ PRIi8
+ PRIi16
+ PRIi32
+ PRIi64
+
+ PRIiLEAST8
+ PRIiLEAST16
+ PRIiLEAST32
+ PRIiLEAST64
+
+ PRIiFAST8
+ PRIiFAST16
+ PRIiFAST32
+ PRIiFAST64
+
+ PRIiMAX
+ PRIiPTR
+
+ PRIo8
+ PRIo16
+ PRIo32
+ PRIo64
+
+ PRIoLEAST8
+ PRIoLEAST16
+ PRIoLEAST32
+ PRIoLEAST64
+
+ PRIoFAST8
+ PRIoFAST16
+ PRIoFAST32
+ PRIoFAST64
+
+ PRIoMAX
+ PRIoPTR
+
+ PRIu8
+ PRIu16
+ PRIu32
+ PRIu64
+
+ PRIuLEAST8
+ PRIuLEAST16
+ PRIuLEAST32
+ PRIuLEAST64
+
+ PRIuFAST8
+ PRIuFAST16
+ PRIuFAST32
+ PRIuFAST64
+
+ PRIuMAX
+ PRIuPTR
+
+ PRIx8
+ PRIx16
+ PRIx32
+ PRIx64
+
+ PRIxLEAST8
+ PRIxLEAST16
+ PRIxLEAST32
+ PRIxLEAST64
+
+ PRIxFAST8
+ PRIxFAST16
+ PRIxFAST32
+ PRIxFAST64
+
+ PRIxMAX
+ PRIxPTR
+
+ PRIX8
+ PRIX16
+ PRIX32
+ PRIX64
+
+ PRIXLEAST8
+ PRIXLEAST16
+ PRIXLEAST32
+ PRIXLEAST64
+
+ PRIXFAST8
+ PRIXFAST16
+ PRIXFAST32
+ PRIXFAST64
+
+ PRIXMAX
+ PRIXPTR
+
+ SCNd8
+ SCNd16
+ SCNd32
+ SCNd64
+
+ SCNdLEAST8
+ SCNdLEAST16
+ SCNdLEAST32
+ SCNdLEAST64
+
+ SCNdFAST8
+ SCNdFAST16
+ SCNdFAST32
+ SCNdFAST64
+
+ SCNdMAX
+ SCNdPTR
+
+ SCNi8
+ SCNi16
+ SCNi32
+ SCNi64
+
+ SCNiLEAST8
+ SCNiLEAST16
+ SCNiLEAST32
+ SCNiLEAST64
+
+ SCNiFAST8
+ SCNiFAST16
+ SCNiFAST32
+ SCNiFAST64
+
+ SCNiMAX
+ SCNiPTR
+
+ SCNo8
+ SCNo16
+ SCNo32
+ SCNo64
+
+ SCNoLEAST8
+ SCNoLEAST16
+ SCNoLEAST32
+ SCNoLEAST64
+
+ SCNoFAST8
+ SCNoFAST16
+ SCNoFAST32
+ SCNoFAST64
+
+ SCNoMAX
+ SCNoPTR
+
+ SCNu8
+ SCNu16
+ SCNu32
+ SCNu64
+
+ SCNuLEAST8
+ SCNuLEAST16
+ SCNuLEAST32
+ SCNuLEAST64
+
+ SCNuFAST8
+ SCNuFAST16
+ SCNuFAST32
+ SCNuFAST64
+
+ SCNuMAX
+ SCNuPTR
+
+ SCNx8
+ SCNx16
+ SCNx32
+ SCNx64
+
+ SCNxLEAST8
+ SCNxLEAST16
+ SCNxLEAST32
+ SCNxLEAST64
+
+ SCNxFAST8
+ SCNxFAST16
+ SCNxFAST32
+ SCNxFAST64
+
+ SCNxMAX
+ SCNxPTR
+
+namespace std
+{
+
+Types:
+
+ imaxdiv_t
+
+intmax_t imaxabs(intmax_t j);
+imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom);
+intmax_t strtoimax(const char* restrict nptr, char** restrict endptr, int base);
+uintmax_t strtoumax(const char* restrict nptr, char** restrict endptr, int base);
+intmax_t wcstoimax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
+uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
+
+} // std
+*/
+
+#include <__config>
+#include <cstdint>
+#include <inttypes.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+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
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/ciso646 b/contrib/libs/cxxsupp/libcxxmsvc/include/ciso646
new file mode 100644
index 0000000000..1d859f08fa
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/ciso646
@@ -0,0 +1,24 @@
+// -*- 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_CISO646
+#define _LIBCPP_CISO646
+
+/*
+ ciso646 synopsis
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#endif // _LIBCPP_CISO646
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/climits b/contrib/libs/cxxsupp/libcxxmsvc/include/climits
new file mode 100644
index 0000000000..c365ca79a4
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/climits
@@ -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_CLIMITS
+#define _LIBCPP_CLIMITS
+
+/*
+ climits synopsis
+
+Macros:
+
+ CHAR_BIT
+ SCHAR_MIN
+ SCHAR_MAX
+ UCHAR_MAX
+ CHAR_MIN
+ CHAR_MAX
+ MB_LEN_MAX
+ SHRT_MIN
+ SHRT_MAX
+ USHRT_MAX
+ INT_MIN
+ INT_MAX
+ UINT_MAX
+ LONG_MIN
+ LONG_MAX
+ ULONG_MAX
+ LLONG_MIN // C99
+ LLONG_MAX // C99
+ ULLONG_MAX // C99
+
+*/
+
+#include <__config>
+#include <limits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#endif // _LIBCPP_CLIMITS
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/clocale b/contrib/libs/cxxsupp/libcxxmsvc/include/clocale
new file mode 100644
index 0000000000..1c1f244d2a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/clocale
@@ -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_CLOCALE
+#define _LIBCPP_CLOCALE
+
+/*
+ clocale synopsis
+
+Macros:
+
+ LC_ALL
+ LC_COLLATE
+ LC_CTYPE
+ LC_MONETARY
+ LC_NUMERIC
+ LC_TIME
+ NULL
+
+namespace std
+{
+
+struct lconv;
+char* setlocale(int category, const char* locale);
+lconv* localeconv();
+
+} // std
+
+*/
+
+#include <__config>
+#include <locale.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+using ::lconv _LIBCPP_USING_IF_EXISTS;
+using ::setlocale _LIBCPP_USING_IF_EXISTS;
+using ::localeconv _LIBCPP_USING_IF_EXISTS;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_CLOCALE
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/cmath b/contrib/libs/cxxsupp/libcxxmsvc/include/cmath
new file mode 100644
index 0000000000..be5cbe3626
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/cmath
@@ -0,0 +1,662 @@
+// -*- 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_CMATH
+#define _LIBCPP_CMATH
+
+/*
+ cmath synopsis
+
+Macros:
+
+ HUGE_VAL
+ HUGE_VALF // C99
+ HUGE_VALL // C99
+ INFINITY // C99
+ NAN // C99
+ FP_INFINITE // C99
+ FP_NAN // C99
+ FP_NORMAL // C99
+ FP_SUBNORMAL // C99
+ FP_ZERO // C99
+ FP_FAST_FMA // C99
+ FP_FAST_FMAF // C99
+ FP_FAST_FMAL // C99
+ FP_ILOGB0 // C99
+ FP_ILOGBNAN // C99
+ MATH_ERRNO // C99
+ MATH_ERREXCEPT // C99
+ math_errhandling // C99
+
+namespace std
+{
+
+Types:
+
+ float_t // C99
+ double_t // C99
+
+// C90
+
+floating_point abs(floating_point x);
+
+floating_point acos (arithmetic x);
+float acosf(float x);
+long double acosl(long double x);
+
+floating_point asin (arithmetic x);
+float asinf(float x);
+long double asinl(long double x);
+
+floating_point atan (arithmetic x);
+float atanf(float x);
+long double atanl(long double x);
+
+floating_point atan2 (arithmetic y, arithmetic x);
+float atan2f(float y, float x);
+long double atan2l(long double y, long double x);
+
+floating_point ceil (arithmetic x);
+float ceilf(float x);
+long double ceill(long double x);
+
+floating_point cos (arithmetic x);
+float cosf(float x);
+long double cosl(long double x);
+
+floating_point cosh (arithmetic x);
+float coshf(float x);
+long double coshl(long double x);
+
+floating_point exp (arithmetic x);
+float expf(float x);
+long double expl(long double x);
+
+floating_point fabs (arithmetic x);
+float fabsf(float x);
+long double fabsl(long double x);
+
+floating_point floor (arithmetic x);
+float floorf(float x);
+long double floorl(long double x);
+
+floating_point fmod (arithmetic x, arithmetic y);
+float fmodf(float x, float y);
+long double fmodl(long double x, long double y);
+
+floating_point frexp (arithmetic value, int* exp);
+float frexpf(float value, int* exp);
+long double frexpl(long double value, int* exp);
+
+floating_point ldexp (arithmetic value, int exp);
+float ldexpf(float value, int exp);
+long double ldexpl(long double value, int exp);
+
+floating_point log (arithmetic x);
+float logf(float x);
+long double logl(long double x);
+
+floating_point log10 (arithmetic x);
+float log10f(float x);
+long double log10l(long double x);
+
+floating_point modf (floating_point value, floating_point* iptr);
+float modff(float value, float* iptr);
+long double modfl(long double value, long double* iptr);
+
+floating_point pow (arithmetic x, arithmetic y);
+float powf(float x, float y);
+long double powl(long double x, long double y);
+
+floating_point sin (arithmetic x);
+float sinf(float x);
+long double sinl(long double x);
+
+floating_point sinh (arithmetic x);
+float sinhf(float x);
+long double sinhl(long double x);
+
+floating_point sqrt (arithmetic x);
+float sqrtf(float x);
+long double sqrtl(long double x);
+
+floating_point tan (arithmetic x);
+float tanf(float x);
+long double tanl(long double x);
+
+floating_point tanh (arithmetic x);
+float tanhf(float x);
+long double tanhl(long double x);
+
+// C99
+
+bool signbit(arithmetic x);
+
+int fpclassify(arithmetic x);
+
+bool isfinite(arithmetic x);
+bool isinf(arithmetic x);
+bool isnan(arithmetic x);
+bool isnormal(arithmetic x);
+
+bool isgreater(arithmetic x, arithmetic y);
+bool isgreaterequal(arithmetic x, arithmetic y);
+bool isless(arithmetic x, arithmetic y);
+bool islessequal(arithmetic x, arithmetic y);
+bool islessgreater(arithmetic x, arithmetic y);
+bool isunordered(arithmetic x, arithmetic y);
+
+floating_point acosh (arithmetic x);
+float acoshf(float x);
+long double acoshl(long double x);
+
+floating_point asinh (arithmetic x);
+float asinhf(float x);
+long double asinhl(long double x);
+
+floating_point atanh (arithmetic x);
+float atanhf(float x);
+long double atanhl(long double x);
+
+floating_point cbrt (arithmetic x);
+float cbrtf(float x);
+long double cbrtl(long double x);
+
+floating_point copysign (arithmetic x, arithmetic y);
+float copysignf(float x, float y);
+long double copysignl(long double x, long double y);
+
+floating_point erf (arithmetic x);
+float erff(float x);
+long double erfl(long double x);
+
+floating_point erfc (arithmetic x);
+float erfcf(float x);
+long double erfcl(long double x);
+
+floating_point exp2 (arithmetic x);
+float exp2f(float x);
+long double exp2l(long double x);
+
+floating_point expm1 (arithmetic x);
+float expm1f(float x);
+long double expm1l(long double x);
+
+floating_point fdim (arithmetic x, arithmetic y);
+float fdimf(float x, float y);
+long double fdiml(long double x, long double y);
+
+floating_point fma (arithmetic x, arithmetic y, arithmetic z);
+float fmaf(float x, float y, float z);
+long double fmal(long double x, long double y, long double z);
+
+floating_point fmax (arithmetic x, arithmetic y);
+float fmaxf(float x, float y);
+long double fmaxl(long double x, long double y);
+
+floating_point fmin (arithmetic x, arithmetic y);
+float fminf(float x, float y);
+long double fminl(long double x, long double y);
+
+floating_point hypot (arithmetic x, arithmetic y);
+float hypotf(float x, float y);
+long double hypotl(long double x, long double y);
+
+double hypot(double x, double y, double z); // C++17
+float hypot(float x, float y, float z); // C++17
+long double hypot(long double x, long double y, long double z); // C++17
+
+int ilogb (arithmetic x);
+int ilogbf(float x);
+int ilogbl(long double x);
+
+floating_point lgamma (arithmetic x);
+float lgammaf(float x);
+long double lgammal(long double x);
+
+long long llrint (arithmetic x);
+long long llrintf(float x);
+long long llrintl(long double x);
+
+long long llround (arithmetic x);
+long long llroundf(float x);
+long long llroundl(long double x);
+
+floating_point log1p (arithmetic x);
+float log1pf(float x);
+long double log1pl(long double x);
+
+floating_point log2 (arithmetic x);
+float log2f(float x);
+long double log2l(long double x);
+
+floating_point logb (arithmetic x);
+float logbf(float x);
+long double logbl(long double x);
+
+long lrint (arithmetic x);
+long lrintf(float x);
+long lrintl(long double x);
+
+long lround (arithmetic x);
+long lroundf(float x);
+long lroundl(long double x);
+
+double nan (const char* str);
+float nanf(const char* str);
+long double nanl(const char* str);
+
+floating_point nearbyint (arithmetic x);
+float nearbyintf(float x);
+long double nearbyintl(long double x);
+
+floating_point nextafter (arithmetic x, arithmetic y);
+float nextafterf(float x, float y);
+long double nextafterl(long double x, long double y);
+
+floating_point nexttoward (arithmetic x, long double y);
+float nexttowardf(float x, long double y);
+long double nexttowardl(long double x, long double y);
+
+floating_point remainder (arithmetic x, arithmetic y);
+float remainderf(float x, float y);
+long double remainderl(long double x, long double y);
+
+floating_point remquo (arithmetic x, arithmetic y, int* pquo);
+float remquof(float x, float y, int* pquo);
+long double remquol(long double x, long double y, int* pquo);
+
+floating_point rint (arithmetic x);
+float rintf(float x);
+long double rintl(long double x);
+
+floating_point round (arithmetic x);
+float roundf(float x);
+long double roundl(long double x);
+
+floating_point scalbln (arithmetic x, long ex);
+float scalblnf(float x, long ex);
+long double scalblnl(long double x, long ex);
+
+floating_point scalbn (arithmetic x, int ex);
+float scalbnf(float x, int ex);
+long double scalbnl(long double x, int ex);
+
+floating_point tgamma (arithmetic x);
+float tgammaf(float x);
+long double tgammal(long double x);
+
+floating_point trunc (arithmetic x);
+float truncf(float x);
+long double truncl(long double x);
+
+constexpr float lerp(float a, float b, float t) noexcept; // C++20
+constexpr double lerp(double a, double b, double t) noexcept; // C++20
+constexpr long double lerp(long double a, long double b, long double t) noexcept; // C++20
+
+} // std
+
+*/
+
+#include <__config>
+#include <math.h>
+#include <type_traits>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+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); }
+inline _LIBCPP_INLINE_VISIBILITY double hypot( double x, double y, double z ) { return sqrt(x*x + y*y + z*z); }
+inline _LIBCPP_INLINE_VISIBILITY long double hypot( long double x, long double y, long double z ) { return sqrt(x*x + y*y + z*z); }
+
+template <class _A1, class _A2, class _A3>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if_t
+<
+ is_arithmetic<_A1>::value &&
+ is_arithmetic<_A2>::value &&
+ is_arithmetic<_A3>::value,
+ __promote<_A1, _A2, _A3>
+>::type
+hypot(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
+{
+ typedef typename __promote<_A1, _A2, _A3>::type __result_type;
+ static_assert((!(is_same<_A1, __result_type>::value &&
+ is_same<_A2, __result_type>::value &&
+ is_same<_A3, __result_type>::value)), "");
+ return hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z);
+}
+#endif
+
+template <class _A1>
+_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
+__libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT
+{
+#if __has_builtin(__builtin_isnan)
+ return __builtin_isnan(__lcpp_x);
+#else
+ return isnan(__lcpp_x);
+#endif
+}
+
+template <class _A1>
+_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
+__libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT
+{
+ return isnan(__lcpp_x);
+}
+
+template <class _A1>
+_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
+__libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT
+{
+#if __has_builtin(__builtin_isinf)
+ return __builtin_isinf(__lcpp_x);
+#else
+ return isinf(__lcpp_x);
+#endif
+}
+
+template <class _A1>
+_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
+__libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT
+{
+ return isinf(__lcpp_x);
+}
+
+template <class _A1>
+_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
+__libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT
+{
+#if __has_builtin(__builtin_isfinite)
+ return __builtin_isfinite(__lcpp_x);
+#else
+ return isfinite(__lcpp_x);
+#endif
+}
+
+template <class _A1>
+_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
+__libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT
+{
+ return isfinite(__lcpp_x);
+}
+
+#if _LIBCPP_STD_VER > 17
+template <typename _Fp>
+constexpr
+_Fp __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept {
+ if ((__a <= 0 && __b >= 0) || (__a >= 0 && __b <= 0))
+ return __t * __b + (1 - __t) * __a;
+
+ if (__t == 1) return __b;
+ const _Fp __x = __a + __t * (__b - __a);
+ if ((__t > 1) == (__b > __a))
+ return __b < __x ? __x : __b;
+ else
+ return __x < __b ? __x : __b;
+}
+
+constexpr float
+lerp(float __a, float __b, float __t) _NOEXCEPT { return __lerp(__a, __b, __t); }
+
+constexpr double
+lerp(double __a, double __b, double __t) _NOEXCEPT { return __lerp(__a, __b, __t); }
+
+constexpr long double
+lerp(long double __a, long double __b, long double __t) _NOEXCEPT { return __lerp(__a, __b, __t); }
+
+template <class _A1, class _A2, class _A3>
+inline _LIBCPP_HIDE_FROM_ABI
+constexpr typename enable_if_t
+<
+ is_arithmetic<_A1>::value &&
+ is_arithmetic<_A2>::value &&
+ is_arithmetic<_A3>::value,
+ __promote<_A1, _A2, _A3>
+>::type
+lerp(_A1 __a, _A2 __b, _A3 __t) noexcept
+{
+ typedef typename __promote<_A1, _A2, _A3>::type __result_type;
+ static_assert(!(_IsSame<_A1, __result_type>::value &&
+ _IsSame<_A2, __result_type>::value &&
+ _IsSame<_A3, __result_type>::value));
+ return __lerp((__result_type)__a, (__result_type)__b, (__result_type)__t);
+}
+#endif // _LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_CMATH
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/codecvt b/contrib/libs/cxxsupp/libcxxmsvc/include/codecvt
new file mode 100644
index 0000000000..b9b38b3834
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/codecvt
@@ -0,0 +1,580 @@
+// -*- 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_CODECVT
+#define _LIBCPP_CODECVT
+
+/*
+ codecvt synopsis
+
+namespace std
+{
+
+enum codecvt_mode
+{
+ consume_header = 4,
+ generate_header = 2,
+ little_endian = 1
+};
+
+template <class Elem, unsigned long Maxcode = 0x10ffff,
+ codecvt_mode Mode = (codecvt_mode)0>
+class codecvt_utf8
+ : public codecvt<Elem, char, mbstate_t>
+{
+ explicit codecvt_utf8(size_t refs = 0);
+ ~codecvt_utf8();
+};
+
+template <class Elem, unsigned long Maxcode = 0x10ffff,
+ codecvt_mode Mode = (codecvt_mode)0>
+class codecvt_utf16
+ : public codecvt<Elem, char, mbstate_t>
+{
+ explicit codecvt_utf16(size_t refs = 0);
+ ~codecvt_utf16();
+};
+
+template <class Elem, unsigned long Maxcode = 0x10ffff,
+ codecvt_mode Mode = (codecvt_mode)0>
+class codecvt_utf8_utf16
+ : public codecvt<Elem, char, mbstate_t>
+{
+ explicit codecvt_utf8_utf16(size_t refs = 0);
+ ~codecvt_utf8_utf16();
+};
+
+} // std
+
+*/
+
+#include <__config>
+#include <__locale>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+enum codecvt_mode
+{
+ consume_header = 4,
+ generate_header = 2,
+ little_endian = 1
+};
+
+// codecvt_utf8
+
+template <class _Elem> class __codecvt_utf8;
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+class _LIBCPP_TYPE_VIS __codecvt_utf8<wchar_t>
+ : public codecvt<wchar_t, char, mbstate_t>
+{
+ unsigned long _Maxcode_;
+ codecvt_mode _Mode_;
+public:
+ typedef wchar_t intern_type;
+ typedef char extern_type;
+ typedef mbstate_t state_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,
+ codecvt_mode _Mode)
+ : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
+ _Mode_(_Mode) {}
+protected:
+ virtual result
+ do_out(state_type& __st,
+ const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual result
+ do_in(state_type& __st,
+ const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+ intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+ virtual result
+ do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual int do_encoding() const _NOEXCEPT;
+ virtual bool do_always_noconv() const _NOEXCEPT;
+ virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
+ size_t __mx) const;
+ virtual int do_max_length() const _NOEXCEPT;
+};
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <>
+class _LIBCPP_TYPE_VIS __codecvt_utf8<char16_t>
+ : public codecvt<char16_t, char, mbstate_t>
+{
+ unsigned long _Maxcode_;
+ codecvt_mode _Mode_;
+public:
+ typedef char16_t intern_type;
+ typedef char extern_type;
+ typedef mbstate_t state_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,
+ codecvt_mode _Mode)
+ : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
+ _Mode_(_Mode) {}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+
+protected:
+ virtual result
+ do_out(state_type& __st,
+ const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual result
+ do_in(state_type& __st,
+ const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+ intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+ virtual result
+ do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual int do_encoding() const _NOEXCEPT;
+ virtual bool do_always_noconv() const _NOEXCEPT;
+ virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
+ size_t __mx) const;
+ virtual int do_max_length() const _NOEXCEPT;
+};
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <>
+class _LIBCPP_TYPE_VIS __codecvt_utf8<char32_t>
+ : public codecvt<char32_t, char, mbstate_t>
+{
+ unsigned long _Maxcode_;
+ codecvt_mode _Mode_;
+public:
+ typedef char32_t intern_type;
+ typedef char extern_type;
+ typedef mbstate_t state_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,
+ codecvt_mode _Mode)
+ : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
+ _Mode_(_Mode) {}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+
+protected:
+ virtual result
+ do_out(state_type& __st,
+ const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual result
+ do_in(state_type& __st,
+ const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+ intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+ virtual result
+ do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual int do_encoding() const _NOEXCEPT;
+ virtual bool do_always_noconv() const _NOEXCEPT;
+ virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
+ size_t __mx) const;
+ virtual int do_max_length() const _NOEXCEPT;
+};
+
+template <class _Elem, unsigned long _Maxcode = 0x10ffff,
+ codecvt_mode _Mode = (codecvt_mode)0>
+class _LIBCPP_TEMPLATE_VIS codecvt_utf8
+ : public __codecvt_utf8<_Elem>
+{
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit codecvt_utf8(size_t __refs = 0)
+ : __codecvt_utf8<_Elem>(__refs, _Maxcode, _Mode) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ ~codecvt_utf8() {}
+};
+
+// codecvt_utf16
+
+template <class _Elem, bool _LittleEndian> class __codecvt_utf16;
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+class _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, false>
+ : public codecvt<wchar_t, char, mbstate_t>
+{
+ unsigned long _Maxcode_;
+ codecvt_mode _Mode_;
+public:
+ typedef wchar_t intern_type;
+ typedef char extern_type;
+ typedef mbstate_t state_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
+ codecvt_mode _Mode)
+ : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
+ _Mode_(_Mode) {}
+protected:
+ virtual result
+ do_out(state_type& __st,
+ const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual result
+ do_in(state_type& __st,
+ const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+ intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+ virtual result
+ do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual int do_encoding() const _NOEXCEPT;
+ virtual bool do_always_noconv() const _NOEXCEPT;
+ virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
+ size_t __mx) const;
+ virtual int do_max_length() const _NOEXCEPT;
+};
+
+template <>
+class _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, true>
+ : public codecvt<wchar_t, char, mbstate_t>
+{
+ unsigned long _Maxcode_;
+ codecvt_mode _Mode_;
+public:
+ typedef wchar_t intern_type;
+ typedef char extern_type;
+ typedef mbstate_t state_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
+ codecvt_mode _Mode)
+ : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
+ _Mode_(_Mode) {}
+protected:
+ virtual result
+ do_out(state_type& __st,
+ const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual result
+ do_in(state_type& __st,
+ const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+ intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+ virtual result
+ do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual int do_encoding() const _NOEXCEPT;
+ virtual bool do_always_noconv() const _NOEXCEPT;
+ virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
+ size_t __mx) const;
+ virtual int do_max_length() const _NOEXCEPT;
+};
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <>
+class _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, false>
+ : public codecvt<char16_t, char, mbstate_t>
+{
+ unsigned long _Maxcode_;
+ codecvt_mode _Mode_;
+public:
+ typedef char16_t intern_type;
+ typedef char extern_type;
+ typedef mbstate_t state_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
+ codecvt_mode _Mode)
+ : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
+ _Mode_(_Mode) {}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+
+protected:
+ virtual result
+ do_out(state_type& __st,
+ const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual result
+ do_in(state_type& __st,
+ const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+ intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+ virtual result
+ do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual int do_encoding() const _NOEXCEPT;
+ virtual bool do_always_noconv() const _NOEXCEPT;
+ virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
+ size_t __mx) const;
+ virtual int do_max_length() const _NOEXCEPT;
+};
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <>
+class _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, true>
+ : public codecvt<char16_t, char, mbstate_t>
+{
+ unsigned long _Maxcode_;
+ codecvt_mode _Mode_;
+public:
+ typedef char16_t intern_type;
+ typedef char extern_type;
+ typedef mbstate_t state_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
+ codecvt_mode _Mode)
+ : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
+ _Mode_(_Mode) {}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+
+protected:
+ virtual result
+ do_out(state_type& __st,
+ const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual result
+ do_in(state_type& __st,
+ const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+ intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+ virtual result
+ do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual int do_encoding() const _NOEXCEPT;
+ virtual bool do_always_noconv() const _NOEXCEPT;
+ virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
+ size_t __mx) const;
+ virtual int do_max_length() const _NOEXCEPT;
+};
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <>
+class _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, false>
+ : public codecvt<char32_t, char, mbstate_t>
+{
+ unsigned long _Maxcode_;
+ codecvt_mode _Mode_;
+public:
+ typedef char32_t intern_type;
+ typedef char extern_type;
+ typedef mbstate_t state_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
+ codecvt_mode _Mode)
+ : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
+ _Mode_(_Mode) {}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+
+protected:
+ virtual result
+ do_out(state_type& __st,
+ const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual result
+ do_in(state_type& __st,
+ const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+ intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+ virtual result
+ do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual int do_encoding() const _NOEXCEPT;
+ virtual bool do_always_noconv() const _NOEXCEPT;
+ virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
+ size_t __mx) const;
+ virtual int do_max_length() const _NOEXCEPT;
+};
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <>
+class _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, true>
+ : public codecvt<char32_t, char, mbstate_t>
+{
+ unsigned long _Maxcode_;
+ codecvt_mode _Mode_;
+public:
+ typedef char32_t intern_type;
+ typedef char extern_type;
+ typedef mbstate_t state_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
+ codecvt_mode _Mode)
+ : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
+ _Mode_(_Mode) {}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+
+protected:
+ virtual result
+ do_out(state_type& __st,
+ const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual result
+ do_in(state_type& __st,
+ const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+ intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+ virtual result
+ do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual int do_encoding() const _NOEXCEPT;
+ virtual bool do_always_noconv() const _NOEXCEPT;
+ virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
+ size_t __mx) const;
+ virtual int do_max_length() const _NOEXCEPT;
+};
+
+template <class _Elem, unsigned long _Maxcode = 0x10ffff,
+ codecvt_mode _Mode = (codecvt_mode)0>
+class _LIBCPP_TEMPLATE_VIS codecvt_utf16
+ : public __codecvt_utf16<_Elem, _Mode & little_endian>
+{
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit codecvt_utf16(size_t __refs = 0)
+ : __codecvt_utf16<_Elem, _Mode & little_endian>(__refs, _Maxcode, _Mode) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ ~codecvt_utf16() {}
+};
+
+// codecvt_utf8_utf16
+
+template <class _Elem> class __codecvt_utf8_utf16;
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<wchar_t>
+ : public codecvt<wchar_t, char, mbstate_t>
+{
+ unsigned long _Maxcode_;
+ codecvt_mode _Mode_;
+public:
+ typedef wchar_t intern_type;
+ typedef char extern_type;
+ typedef mbstate_t state_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,
+ codecvt_mode _Mode)
+ : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
+ _Mode_(_Mode) {}
+protected:
+ virtual result
+ do_out(state_type& __st,
+ const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual result
+ do_in(state_type& __st,
+ const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+ intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+ virtual result
+ do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual int do_encoding() const _NOEXCEPT;
+ virtual bool do_always_noconv() const _NOEXCEPT;
+ virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
+ size_t __mx) const;
+ virtual int do_max_length() const _NOEXCEPT;
+};
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <>
+class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char32_t>
+ : public codecvt<char32_t, char, mbstate_t>
+{
+ unsigned long _Maxcode_;
+ codecvt_mode _Mode_;
+public:
+ typedef char32_t intern_type;
+ typedef char extern_type;
+ typedef mbstate_t state_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,
+ codecvt_mode _Mode)
+ : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
+ _Mode_(_Mode) {}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+
+protected:
+ virtual result
+ do_out(state_type& __st,
+ const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual result
+ do_in(state_type& __st,
+ const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+ intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+ virtual result
+ do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual int do_encoding() const _NOEXCEPT;
+ virtual bool do_always_noconv() const _NOEXCEPT;
+ virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
+ size_t __mx) const;
+ virtual int do_max_length() const _NOEXCEPT;
+};
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <>
+class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char16_t>
+ : public codecvt<char16_t, char, mbstate_t>
+{
+ unsigned long _Maxcode_;
+ codecvt_mode _Mode_;
+public:
+ typedef char16_t intern_type;
+ typedef char extern_type;
+ typedef mbstate_t state_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,
+ codecvt_mode _Mode)
+ : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
+ _Mode_(_Mode) {}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+
+protected:
+ virtual result
+ do_out(state_type& __st,
+ const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual result
+ do_in(state_type& __st,
+ const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+ intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+ virtual result
+ do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+ virtual int do_encoding() const _NOEXCEPT;
+ virtual bool do_always_noconv() const _NOEXCEPT;
+ virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
+ size_t __mx) const;
+ virtual int do_max_length() const _NOEXCEPT;
+};
+
+template <class _Elem, unsigned long _Maxcode = 0x10ffff,
+ codecvt_mode _Mode = (codecvt_mode)0>
+class _LIBCPP_TEMPLATE_VIS codecvt_utf8_utf16
+ : public __codecvt_utf8_utf16<_Elem>
+{
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit codecvt_utf8_utf16(size_t __refs = 0)
+ : __codecvt_utf8_utf16<_Elem>(__refs, _Maxcode, _Mode) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ ~codecvt_utf8_utf16() {}
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_CODECVT
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/compare b/contrib/libs/cxxsupp/libcxxmsvc/include/compare
new file mode 100644
index 0000000000..6f620e48f7
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/compare
@@ -0,0 +1,162 @@
+// -*- 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_COMPARE
+#define _LIBCPP_COMPARE
+
+/*
+ compare synopsis
+
+namespace std {
+ // [cmp.categories], comparison category types
+ class partial_ordering;
+ class weak_ordering;
+ class strong_ordering;
+
+ // named comparison functions
+ constexpr bool is_eq (partial_ordering cmp) noexcept { return cmp == 0; }
+ constexpr bool is_neq (partial_ordering cmp) noexcept { return cmp != 0; }
+ constexpr bool is_lt (partial_ordering cmp) noexcept { return cmp < 0; }
+ constexpr bool is_lteq(partial_ordering cmp) noexcept { return cmp <= 0; }
+ constexpr bool is_gt (partial_ordering cmp) noexcept { return cmp > 0; }
+ constexpr bool is_gteq(partial_ordering cmp) noexcept { return cmp >= 0; }
+
+ // [cmp.common], common comparison category type
+ template<class... Ts>
+ struct common_comparison_category {
+ using type = see below;
+ };
+ template<class... Ts>
+ using common_comparison_category_t = typename common_comparison_category<Ts...>::type;
+
+ // [cmp.concept], concept three_way_comparable
+ template<class T, class Cat = partial_ordering>
+ concept three_way_comparable = see below;
+ template<class T, class U, class Cat = partial_ordering>
+ concept three_way_comparable_with = see below;
+
+ // [cmp.result], result of three-way comparison
+ template<class T, class U = T> struct compare_three_way_result;
+
+ template<class T, class U = T>
+ using compare_three_way_result_t = typename compare_three_way_result<T, U>::type;
+
+ // [comparisons.three.way], class compare_three_way
+ struct compare_three_way; // C++20
+
+ // [cmp.alg], comparison algorithms
+ inline namespace unspecified {
+ inline constexpr unspecified strong_order = unspecified;
+ inline constexpr unspecified weak_order = unspecified;
+ inline constexpr unspecified partial_order = unspecified;
+ inline constexpr unspecified compare_strong_order_fallback = unspecified;
+ inline constexpr unspecified compare_weak_order_fallback = unspecified;
+ inline constexpr unspecified compare_partial_order_fallback = unspecified;
+ }
+
+ // [cmp.partialord], Class partial_ordering
+ class partial_ordering {
+ public:
+ // valid values
+ static const partial_ordering less;
+ static const partial_ordering equivalent;
+ static const partial_ordering greater;
+ static const partial_ordering unordered;
+
+ // comparisons
+ friend constexpr bool operator==(partial_ordering v, unspecified) noexcept;
+ friend constexpr bool operator==(partial_ordering v, partial_ordering w) noexcept = default;
+ friend constexpr bool operator< (partial_ordering v, unspecified) noexcept;
+ friend constexpr bool operator> (partial_ordering v, unspecified) noexcept;
+ friend constexpr bool operator<=(partial_ordering v, unspecified) noexcept;
+ friend constexpr bool operator>=(partial_ordering v, unspecified) noexcept;
+ friend constexpr bool operator< (unspecified, partial_ordering v) noexcept;
+ friend constexpr bool operator> (unspecified, partial_ordering v) noexcept;
+ friend constexpr bool operator<=(unspecified, partial_ordering v) noexcept;
+ friend constexpr bool operator>=(unspecified, partial_ordering v) noexcept;
+ friend constexpr partial_ordering operator<=>(partial_ordering v, unspecified) noexcept;
+ friend constexpr partial_ordering operator<=>(unspecified, partial_ordering v) noexcept;
+ };
+
+ // [cmp.weakord], Class weak_ordering
+ class weak_ordering {
+ public:
+ // valid values
+ static const weak_ordering less;
+ static const weak_ordering equivalent;
+ static const weak_ordering greater;
+
+ // conversions
+ constexpr operator partial_ordering() const noexcept;
+
+ // comparisons
+ friend constexpr bool operator==(weak_ordering v, unspecified) noexcept;
+ friend constexpr bool operator==(weak_ordering v, weak_ordering w) noexcept = default;
+ friend constexpr bool operator< (weak_ordering v, unspecified) noexcept;
+ friend constexpr bool operator> (weak_ordering v, unspecified) noexcept;
+ friend constexpr bool operator<=(weak_ordering v, unspecified) noexcept;
+ friend constexpr bool operator>=(weak_ordering v, unspecified) noexcept;
+ friend constexpr bool operator< (unspecified, weak_ordering v) noexcept;
+ friend constexpr bool operator> (unspecified, weak_ordering v) noexcept;
+ friend constexpr bool operator<=(unspecified, weak_ordering v) noexcept;
+ friend constexpr bool operator>=(unspecified, weak_ordering v) noexcept;
+ friend constexpr weak_ordering operator<=>(weak_ordering v, unspecified) noexcept;
+ friend constexpr weak_ordering operator<=>(unspecified, weak_ordering v) noexcept;
+ };
+
+ // [cmp.strongord], Class strong_ordering
+ class strong_ordering {
+ public:
+ // valid values
+ static const strong_ordering less;
+ static const strong_ordering equal;
+ static const strong_ordering equivalent;
+ static const strong_ordering greater;
+
+ // conversions
+ constexpr operator partial_ordering() const noexcept;
+ constexpr operator weak_ordering() const noexcept;
+
+ // comparisons
+ friend constexpr bool operator==(strong_ordering v, unspecified) noexcept;
+ friend constexpr bool operator==(strong_ordering v, strong_ordering w) noexcept = default;
+ friend constexpr bool operator< (strong_ordering v, unspecified) noexcept;
+ friend constexpr bool operator> (strong_ordering v, unspecified) noexcept;
+ friend constexpr bool operator<=(strong_ordering v, unspecified) noexcept;
+ friend constexpr bool operator>=(strong_ordering v, unspecified) noexcept;
+ friend constexpr bool operator< (unspecified, strong_ordering v) noexcept;
+ friend constexpr bool operator> (unspecified, strong_ordering v) noexcept;
+ friend constexpr bool operator<=(unspecified, strong_ordering v) noexcept;
+ friend constexpr bool operator>=(unspecified, strong_ordering v) noexcept;
+ friend constexpr strong_ordering operator<=>(strong_ordering v, unspecified) noexcept;
+ friend constexpr strong_ordering operator<=>(unspecified, strong_ordering v) noexcept;
+ };
+}
+*/
+
+#include <__compare/common_comparison_category.h>
+#include <__compare/compare_partial_order_fallback.h>
+#include <__compare/compare_strong_order_fallback.h>
+#include <__compare/compare_three_way.h>
+#include <__compare/compare_three_way_result.h>
+#include <__compare/compare_weak_order_fallback.h>
+#include <__compare/is_eq.h>
+#include <__compare/ordering.h>
+#include <__compare/partial_order.h>
+#include <__compare/strong_order.h>
+#include <__compare/three_way_comparable.h>
+#include <__compare/weak_order.h>
+#include <__config>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#endif // _LIBCPP_COMPARE
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/complex b/contrib/libs/cxxsupp/libcxxmsvc/include/complex
new file mode 100644
index 0000000000..a11334f6cf
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/complex
@@ -0,0 +1,1496 @@
+// -*- 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_COMPLEX
+#define _LIBCPP_COMPLEX
+
+/*
+ complex synopsis
+
+namespace std
+{
+
+template<class T>
+class complex
+{
+public:
+ typedef T value_type;
+
+ complex(const T& re = T(), const T& im = T()); // constexpr in C++14
+ complex(const complex&); // constexpr in C++14
+ template<class X> complex(const complex<X>&); // constexpr in C++14
+
+ T real() const; // constexpr in C++14
+ T imag() const; // constexpr in C++14
+
+ void real(T);
+ void imag(T);
+
+ complex<T>& operator= (const T&);
+ complex<T>& operator+=(const T&);
+ complex<T>& operator-=(const T&);
+ complex<T>& operator*=(const T&);
+ complex<T>& operator/=(const T&);
+
+ complex& operator=(const complex&);
+ template<class X> complex<T>& operator= (const complex<X>&);
+ template<class X> complex<T>& operator+=(const complex<X>&);
+ template<class X> complex<T>& operator-=(const complex<X>&);
+ template<class X> complex<T>& operator*=(const complex<X>&);
+ template<class X> complex<T>& operator/=(const complex<X>&);
+};
+
+template<>
+class complex<float>
+{
+public:
+ typedef float value_type;
+
+ constexpr complex(float re = 0.0f, float im = 0.0f);
+ explicit constexpr complex(const complex<double>&);
+ explicit constexpr complex(const complex<long double>&);
+
+ constexpr float real() const;
+ void real(float);
+ constexpr float imag() const;
+ void imag(float);
+
+ complex<float>& operator= (float);
+ complex<float>& operator+=(float);
+ complex<float>& operator-=(float);
+ complex<float>& operator*=(float);
+ complex<float>& operator/=(float);
+
+ complex<float>& operator=(const complex<float>&);
+ template<class X> complex<float>& operator= (const complex<X>&);
+ template<class X> complex<float>& operator+=(const complex<X>&);
+ template<class X> complex<float>& operator-=(const complex<X>&);
+ template<class X> complex<float>& operator*=(const complex<X>&);
+ template<class X> complex<float>& operator/=(const complex<X>&);
+};
+
+template<>
+class complex<double>
+{
+public:
+ typedef double value_type;
+
+ constexpr complex(double re = 0.0, double im = 0.0);
+ constexpr complex(const complex<float>&);
+ explicit constexpr complex(const complex<long double>&);
+
+ constexpr double real() const;
+ void real(double);
+ constexpr double imag() const;
+ void imag(double);
+
+ complex<double>& operator= (double);
+ complex<double>& operator+=(double);
+ complex<double>& operator-=(double);
+ complex<double>& operator*=(double);
+ complex<double>& operator/=(double);
+ complex<double>& operator=(const complex<double>&);
+
+ template<class X> complex<double>& operator= (const complex<X>&);
+ template<class X> complex<double>& operator+=(const complex<X>&);
+ template<class X> complex<double>& operator-=(const complex<X>&);
+ template<class X> complex<double>& operator*=(const complex<X>&);
+ template<class X> complex<double>& operator/=(const complex<X>&);
+};
+
+template<>
+class complex<long double>
+{
+public:
+ typedef long double value_type;
+
+ constexpr complex(long double re = 0.0L, long double im = 0.0L);
+ constexpr complex(const complex<float>&);
+ constexpr complex(const complex<double>&);
+
+ constexpr long double real() const;
+ void real(long double);
+ constexpr long double imag() const;
+ void imag(long double);
+
+ complex<long double>& operator=(const complex<long double>&);
+ complex<long double>& operator= (long double);
+ complex<long double>& operator+=(long double);
+ complex<long double>& operator-=(long double);
+ complex<long double>& operator*=(long double);
+ complex<long double>& operator/=(long double);
+
+ template<class X> complex<long double>& operator= (const complex<X>&);
+ template<class X> complex<long double>& operator+=(const complex<X>&);
+ template<class X> complex<long double>& operator-=(const complex<X>&);
+ template<class X> complex<long double>& operator*=(const complex<X>&);
+ template<class X> complex<long double>& operator/=(const complex<X>&);
+};
+
+// 26.3.6 operators:
+template<class T> complex<T> operator+(const complex<T>&, const complex<T>&);
+template<class T> complex<T> operator+(const complex<T>&, const T&);
+template<class T> complex<T> operator+(const T&, const complex<T>&);
+template<class T> complex<T> operator-(const complex<T>&, const complex<T>&);
+template<class T> complex<T> operator-(const complex<T>&, const T&);
+template<class T> complex<T> operator-(const T&, const complex<T>&);
+template<class T> complex<T> operator*(const complex<T>&, const complex<T>&);
+template<class T> complex<T> operator*(const complex<T>&, const T&);
+template<class T> complex<T> operator*(const T&, const complex<T>&);
+template<class T> complex<T> operator/(const complex<T>&, const complex<T>&);
+template<class T> complex<T> operator/(const complex<T>&, const T&);
+template<class T> complex<T> operator/(const T&, const complex<T>&);
+template<class T> complex<T> operator+(const complex<T>&);
+template<class T> complex<T> operator-(const complex<T>&);
+template<class T> bool operator==(const complex<T>&, const complex<T>&); // constexpr in C++14
+template<class T> bool operator==(const complex<T>&, const T&); // constexpr in C++14
+template<class T> bool operator==(const T&, const complex<T>&); // constexpr in C++14
+template<class T> bool operator!=(const complex<T>&, const complex<T>&); // constexpr in C++14
+template<class T> bool operator!=(const complex<T>&, const T&); // constexpr in C++14
+template<class T> bool operator!=(const T&, const complex<T>&); // constexpr in C++14
+
+template<class T, class charT, class traits>
+ basic_istream<charT, traits>&
+ operator>>(basic_istream<charT, traits>&, complex<T>&);
+template<class T, class charT, class traits>
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>&, const complex<T>&);
+
+// 26.3.7 values:
+
+template<class T> T real(const complex<T>&); // constexpr in C++14
+ long double real(long double); // constexpr in C++14
+ double real(double); // constexpr in C++14
+template<Integral T> double real(T); // constexpr in C++14
+ float real(float); // constexpr in C++14
+
+template<class T> T imag(const complex<T>&); // constexpr in C++14
+ long double imag(long double); // constexpr in C++14
+ double imag(double); // constexpr in C++14
+template<Integral T> double imag(T); // constexpr in C++14
+ float imag(float); // constexpr in C++14
+
+template<class T> T abs(const complex<T>&);
+
+template<class T> T arg(const complex<T>&);
+ long double arg(long double);
+ double arg(double);
+template<Integral T> double arg(T);
+ float arg(float);
+
+template<class T> T norm(const complex<T>&);
+ long double norm(long double);
+ double norm(double);
+template<Integral T> double norm(T);
+ float norm(float);
+
+template<class T> complex<T> conj(const complex<T>&);
+ complex<long double> conj(long double);
+ complex<double> conj(double);
+template<Integral T> complex<double> conj(T);
+ complex<float> conj(float);
+
+template<class T> complex<T> proj(const complex<T>&);
+ complex<long double> proj(long double);
+ complex<double> proj(double);
+template<Integral T> complex<double> proj(T);
+ complex<float> proj(float);
+
+template<class T> complex<T> polar(const T&, const T& = T());
+
+// 26.3.8 transcendentals:
+template<class T> complex<T> acos(const complex<T>&);
+template<class T> complex<T> asin(const complex<T>&);
+template<class T> complex<T> atan(const complex<T>&);
+template<class T> complex<T> acosh(const complex<T>&);
+template<class T> complex<T> asinh(const complex<T>&);
+template<class T> complex<T> atanh(const complex<T>&);
+template<class T> complex<T> cos (const complex<T>&);
+template<class T> complex<T> cosh (const complex<T>&);
+template<class T> complex<T> exp (const complex<T>&);
+template<class T> complex<T> log (const complex<T>&);
+template<class T> complex<T> log10(const complex<T>&);
+
+template<class T> complex<T> pow(const complex<T>&, const T&);
+template<class T> complex<T> pow(const complex<T>&, const complex<T>&);
+template<class T> complex<T> pow(const T&, const complex<T>&);
+
+template<class T> complex<T> sin (const complex<T>&);
+template<class T> complex<T> sinh (const complex<T>&);
+template<class T> complex<T> sqrt (const complex<T>&);
+template<class T> complex<T> tan (const complex<T>&);
+template<class T> complex<T> tanh (const complex<T>&);
+
+} // std
+
+*/
+
+#include <__config>
+#include <cmath>
+#include <iosfwd>
+#include <stdexcept>
+#include <type_traits>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# include <sstream> // for std::basic_ostringstream
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template<class _Tp> class _LIBCPP_TEMPLATE_VIS complex;
+
+template<class _Tp> complex<_Tp> operator*(const complex<_Tp>& __z, const complex<_Tp>& __w);
+template<class _Tp> complex<_Tp> operator/(const complex<_Tp>& __x, const complex<_Tp>& __y);
+
+template<class _Tp>
+class _LIBCPP_TEMPLATE_VIS complex
+{
+public:
+ typedef _Tp value_type;
+private:
+ value_type __re_;
+ value_type __im_;
+public:
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ complex(const value_type& __re = value_type(), const value_type& __im = value_type())
+ : __re_(__re), __im_(__im) {}
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ complex(const complex<_Xp>& __c)
+ : __re_(__c.real()), __im_(__c.imag()) {}
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 value_type real() const {return __re_;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 value_type imag() const {return __im_;}
+
+ _LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;}
+ _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;}
+
+ _LIBCPP_INLINE_VISIBILITY complex& operator= (const value_type& __re)
+ {__re_ = __re; __im_ = value_type(); return *this;}
+ _LIBCPP_INLINE_VISIBILITY complex& operator+=(const value_type& __re) {__re_ += __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY complex& operator-=(const value_type& __re) {__re_ -= __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY complex& operator*=(const value_type& __re) {__re_ *= __re; __im_ *= __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY complex& operator/=(const value_type& __re) {__re_ /= __re; __im_ /= __re; return *this;}
+
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator= (const complex<_Xp>& __c)
+ {
+ __re_ = __c.real();
+ __im_ = __c.imag();
+ return *this;
+ }
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator+=(const complex<_Xp>& __c)
+ {
+ __re_ += __c.real();
+ __im_ += __c.imag();
+ return *this;
+ }
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator-=(const complex<_Xp>& __c)
+ {
+ __re_ -= __c.real();
+ __im_ -= __c.imag();
+ return *this;
+ }
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c)
+ {
+ *this = *this * complex(__c.real(), __c.imag());
+ return *this;
+ }
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c)
+ {
+ *this = *this / complex(__c.real(), __c.imag());
+ return *this;
+ }
+};
+
+template<> class _LIBCPP_TEMPLATE_VIS complex<double>;
+template<> class _LIBCPP_TEMPLATE_VIS complex<long double>;
+
+template<>
+class _LIBCPP_TEMPLATE_VIS complex<float>
+{
+ float __re_;
+ float __im_;
+public:
+ typedef float value_type;
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR complex(float __re = 0.0f, float __im = 0.0f)
+ : __re_(__re), __im_(__im) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit _LIBCPP_CONSTEXPR complex(const complex<double>& __c);
+ _LIBCPP_INLINE_VISIBILITY
+ explicit _LIBCPP_CONSTEXPR complex(const complex<long double>& __c);
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR float real() const {return __re_;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR float imag() const {return __im_;}
+
+ _LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;}
+ _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;}
+
+ _LIBCPP_INLINE_VISIBILITY complex& operator= (float __re)
+ {__re_ = __re; __im_ = value_type(); return *this;}
+ _LIBCPP_INLINE_VISIBILITY complex& operator+=(float __re) {__re_ += __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY complex& operator-=(float __re) {__re_ -= __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY complex& operator*=(float __re) {__re_ *= __re; __im_ *= __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY complex& operator/=(float __re) {__re_ /= __re; __im_ /= __re; return *this;}
+
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator= (const complex<_Xp>& __c)
+ {
+ __re_ = __c.real();
+ __im_ = __c.imag();
+ return *this;
+ }
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator+=(const complex<_Xp>& __c)
+ {
+ __re_ += __c.real();
+ __im_ += __c.imag();
+ return *this;
+ }
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator-=(const complex<_Xp>& __c)
+ {
+ __re_ -= __c.real();
+ __im_ -= __c.imag();
+ return *this;
+ }
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c)
+ {
+ *this = *this * complex(__c.real(), __c.imag());
+ return *this;
+ }
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c)
+ {
+ *this = *this / complex(__c.real(), __c.imag());
+ return *this;
+ }
+};
+
+template<>
+class _LIBCPP_TEMPLATE_VIS complex<double>
+{
+ double __re_;
+ double __im_;
+public:
+ typedef double value_type;
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR complex(double __re = 0.0, double __im = 0.0)
+ : __re_(__re), __im_(__im) {}
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR complex(const complex<float>& __c);
+ _LIBCPP_INLINE_VISIBILITY
+ explicit _LIBCPP_CONSTEXPR complex(const complex<long double>& __c);
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR double real() const {return __re_;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR double imag() const {return __im_;}
+
+ _LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;}
+ _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;}
+
+ _LIBCPP_INLINE_VISIBILITY complex& operator= (double __re)
+ {__re_ = __re; __im_ = value_type(); return *this;}
+ _LIBCPP_INLINE_VISIBILITY complex& operator+=(double __re) {__re_ += __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY complex& operator-=(double __re) {__re_ -= __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY complex& operator*=(double __re) {__re_ *= __re; __im_ *= __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY complex& operator/=(double __re) {__re_ /= __re; __im_ /= __re; return *this;}
+
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator= (const complex<_Xp>& __c)
+ {
+ __re_ = __c.real();
+ __im_ = __c.imag();
+ return *this;
+ }
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator+=(const complex<_Xp>& __c)
+ {
+ __re_ += __c.real();
+ __im_ += __c.imag();
+ return *this;
+ }
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator-=(const complex<_Xp>& __c)
+ {
+ __re_ -= __c.real();
+ __im_ -= __c.imag();
+ return *this;
+ }
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c)
+ {
+ *this = *this * complex(__c.real(), __c.imag());
+ return *this;
+ }
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c)
+ {
+ *this = *this / complex(__c.real(), __c.imag());
+ return *this;
+ }
+};
+
+template<>
+class _LIBCPP_TEMPLATE_VIS complex<long double>
+{
+ long double __re_;
+ long double __im_;
+public:
+ typedef long double value_type;
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR complex(long double __re = 0.0L, long double __im = 0.0L)
+ : __re_(__re), __im_(__im) {}
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR complex(const complex<float>& __c);
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR complex(const complex<double>& __c);
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR long double real() const {return __re_;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR long double imag() const {return __im_;}
+
+ _LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;}
+ _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;}
+
+ _LIBCPP_INLINE_VISIBILITY complex& operator= (long double __re)
+ {__re_ = __re; __im_ = value_type(); return *this;}
+ _LIBCPP_INLINE_VISIBILITY complex& operator+=(long double __re) {__re_ += __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY complex& operator-=(long double __re) {__re_ -= __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY complex& operator*=(long double __re) {__re_ *= __re; __im_ *= __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY complex& operator/=(long double __re) {__re_ /= __re; __im_ /= __re; return *this;}
+
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator= (const complex<_Xp>& __c)
+ {
+ __re_ = __c.real();
+ __im_ = __c.imag();
+ return *this;
+ }
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator+=(const complex<_Xp>& __c)
+ {
+ __re_ += __c.real();
+ __im_ += __c.imag();
+ return *this;
+ }
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator-=(const complex<_Xp>& __c)
+ {
+ __re_ -= __c.real();
+ __im_ -= __c.imag();
+ return *this;
+ }
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c)
+ {
+ *this = *this * complex(__c.real(), __c.imag());
+ return *this;
+ }
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c)
+ {
+ *this = *this / complex(__c.real(), __c.imag());
+ return *this;
+ }
+};
+
+inline
+_LIBCPP_CONSTEXPR
+complex<float>::complex(const complex<double>& __c)
+ : __re_(__c.real()), __im_(__c.imag()) {}
+
+inline
+_LIBCPP_CONSTEXPR
+complex<float>::complex(const complex<long double>& __c)
+ : __re_(__c.real()), __im_(__c.imag()) {}
+
+inline
+_LIBCPP_CONSTEXPR
+complex<double>::complex(const complex<float>& __c)
+ : __re_(__c.real()), __im_(__c.imag()) {}
+
+inline
+_LIBCPP_CONSTEXPR
+complex<double>::complex(const complex<long double>& __c)
+ : __re_(__c.real()), __im_(__c.imag()) {}
+
+inline
+_LIBCPP_CONSTEXPR
+complex<long double>::complex(const complex<float>& __c)
+ : __re_(__c.real()), __im_(__c.imag()) {}
+
+inline
+_LIBCPP_CONSTEXPR
+complex<long double>::complex(const complex<double>& __c)
+ : __re_(__c.real()), __im_(__c.imag()) {}
+
+// 26.3.6 operators:
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+operator+(const complex<_Tp>& __x, const complex<_Tp>& __y)
+{
+ complex<_Tp> __t(__x);
+ __t += __y;
+ return __t;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+operator+(const complex<_Tp>& __x, const _Tp& __y)
+{
+ complex<_Tp> __t(__x);
+ __t += __y;
+ return __t;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+operator+(const _Tp& __x, const complex<_Tp>& __y)
+{
+ complex<_Tp> __t(__y);
+ __t += __x;
+ return __t;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+operator-(const complex<_Tp>& __x, const complex<_Tp>& __y)
+{
+ complex<_Tp> __t(__x);
+ __t -= __y;
+ return __t;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+operator-(const complex<_Tp>& __x, const _Tp& __y)
+{
+ complex<_Tp> __t(__x);
+ __t -= __y;
+ return __t;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+operator-(const _Tp& __x, const complex<_Tp>& __y)
+{
+ complex<_Tp> __t(-__y);
+ __t += __x;
+ return __t;
+}
+
+template<class _Tp>
+complex<_Tp>
+operator*(const complex<_Tp>& __z, const complex<_Tp>& __w)
+{
+ _Tp __a = __z.real();
+ _Tp __b = __z.imag();
+ _Tp __c = __w.real();
+ _Tp __d = __w.imag();
+ _Tp __ac = __a * __c;
+ _Tp __bd = __b * __d;
+ _Tp __ad = __a * __d;
+ _Tp __bc = __b * __c;
+ _Tp __x = __ac - __bd;
+ _Tp __y = __ad + __bc;
+ if (__libcpp_isnan_or_builtin(__x) && __libcpp_isnan_or_builtin(__y))
+ {
+ bool __recalc = false;
+ if (__libcpp_isinf_or_builtin(__a) || __libcpp_isinf_or_builtin(__b))
+ {
+ __a = copysign(__libcpp_isinf_or_builtin(__a) ? _Tp(1) : _Tp(0), __a);
+ __b = copysign(__libcpp_isinf_or_builtin(__b) ? _Tp(1) : _Tp(0), __b);
+ if (__libcpp_isnan_or_builtin(__c))
+ __c = copysign(_Tp(0), __c);
+ if (__libcpp_isnan_or_builtin(__d))
+ __d = copysign(_Tp(0), __d);
+ __recalc = true;
+ }
+ if (__libcpp_isinf_or_builtin(__c) || __libcpp_isinf_or_builtin(__d))
+ {
+ __c = copysign(__libcpp_isinf_or_builtin(__c) ? _Tp(1) : _Tp(0), __c);
+ __d = copysign(__libcpp_isinf_or_builtin(__d) ? _Tp(1) : _Tp(0), __d);
+ if (__libcpp_isnan_or_builtin(__a))
+ __a = copysign(_Tp(0), __a);
+ if (__libcpp_isnan_or_builtin(__b))
+ __b = copysign(_Tp(0), __b);
+ __recalc = true;
+ }
+ if (!__recalc && (__libcpp_isinf_or_builtin(__ac) || __libcpp_isinf_or_builtin(__bd) ||
+ __libcpp_isinf_or_builtin(__ad) || __libcpp_isinf_or_builtin(__bc)))
+ {
+ if (__libcpp_isnan_or_builtin(__a))
+ __a = copysign(_Tp(0), __a);
+ if (__libcpp_isnan_or_builtin(__b))
+ __b = copysign(_Tp(0), __b);
+ if (__libcpp_isnan_or_builtin(__c))
+ __c = copysign(_Tp(0), __c);
+ if (__libcpp_isnan_or_builtin(__d))
+ __d = copysign(_Tp(0), __d);
+ __recalc = true;
+ }
+ if (__recalc)
+ {
+ __x = _Tp(INFINITY) * (__a * __c - __b * __d);
+ __y = _Tp(INFINITY) * (__a * __d + __b * __c);
+ }
+ }
+ return complex<_Tp>(__x, __y);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+operator*(const complex<_Tp>& __x, const _Tp& __y)
+{
+ complex<_Tp> __t(__x);
+ __t *= __y;
+ return __t;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+operator*(const _Tp& __x, const complex<_Tp>& __y)
+{
+ complex<_Tp> __t(__y);
+ __t *= __x;
+ return __t;
+}
+
+template<class _Tp>
+complex<_Tp>
+operator/(const complex<_Tp>& __z, const complex<_Tp>& __w)
+{
+ int __ilogbw = 0;
+ _Tp __a = __z.real();
+ _Tp __b = __z.imag();
+ _Tp __c = __w.real();
+ _Tp __d = __w.imag();
+ _Tp __logbw = logb(fmax(fabs(__c), fabs(__d)));
+ if (__libcpp_isfinite_or_builtin(__logbw))
+ {
+ __ilogbw = static_cast<int>(__logbw);
+ __c = scalbn(__c, -__ilogbw);
+ __d = scalbn(__d, -__ilogbw);
+ }
+ _Tp __denom = __c * __c + __d * __d;
+ _Tp __x = scalbn((__a * __c + __b * __d) / __denom, -__ilogbw);
+ _Tp __y = scalbn((__b * __c - __a * __d) / __denom, -__ilogbw);
+ if (__libcpp_isnan_or_builtin(__x) && __libcpp_isnan_or_builtin(__y))
+ {
+ if ((__denom == _Tp(0)) && (!__libcpp_isnan_or_builtin(__a) || !__libcpp_isnan_or_builtin(__b)))
+ {
+ __x = copysign(_Tp(INFINITY), __c) * __a;
+ __y = copysign(_Tp(INFINITY), __c) * __b;
+ }
+ else if ((__libcpp_isinf_or_builtin(__a) || __libcpp_isinf_or_builtin(__b)) && __libcpp_isfinite_or_builtin(__c) && __libcpp_isfinite_or_builtin(__d))
+ {
+ __a = copysign(__libcpp_isinf_or_builtin(__a) ? _Tp(1) : _Tp(0), __a);
+ __b = copysign(__libcpp_isinf_or_builtin(__b) ? _Tp(1) : _Tp(0), __b);
+ __x = _Tp(INFINITY) * (__a * __c + __b * __d);
+ __y = _Tp(INFINITY) * (__b * __c - __a * __d);
+ }
+ else if (__libcpp_isinf_or_builtin(__logbw) && __logbw > _Tp(0) && __libcpp_isfinite_or_builtin(__a) && __libcpp_isfinite_or_builtin(__b))
+ {
+ __c = copysign(__libcpp_isinf_or_builtin(__c) ? _Tp(1) : _Tp(0), __c);
+ __d = copysign(__libcpp_isinf_or_builtin(__d) ? _Tp(1) : _Tp(0), __d);
+ __x = _Tp(0) * (__a * __c + __b * __d);
+ __y = _Tp(0) * (__b * __c - __a * __d);
+ }
+ }
+ return complex<_Tp>(__x, __y);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+operator/(const complex<_Tp>& __x, const _Tp& __y)
+{
+ return complex<_Tp>(__x.real() / __y, __x.imag() / __y);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+operator/(const _Tp& __x, const complex<_Tp>& __y)
+{
+ complex<_Tp> __t(__x);
+ __t /= __y;
+ return __t;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+operator+(const complex<_Tp>& __x)
+{
+ return __x;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+operator-(const complex<_Tp>& __x)
+{
+ return complex<_Tp>(-__x.real(), -__x.imag());
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator==(const complex<_Tp>& __x, const complex<_Tp>& __y)
+{
+ return __x.real() == __y.real() && __x.imag() == __y.imag();
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator==(const complex<_Tp>& __x, const _Tp& __y)
+{
+ return __x.real() == __y && __x.imag() == 0;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator==(const _Tp& __x, const complex<_Tp>& __y)
+{
+ return __x == __y.real() && 0 == __y.imag();
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y)
+{
+ return !(__x == __y);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator!=(const complex<_Tp>& __x, const _Tp& __y)
+{
+ return !(__x == __y);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator!=(const _Tp& __x, const complex<_Tp>& __y)
+{
+ return !(__x == __y);
+}
+
+// 26.3.7 values:
+
+template <class _Tp, bool = is_integral<_Tp>::value,
+ bool = is_floating_point<_Tp>::value
+ >
+struct __libcpp_complex_overload_traits {};
+
+// Integral Types
+template <class _Tp>
+struct __libcpp_complex_overload_traits<_Tp, true, false>
+{
+ typedef double _ValueType;
+ typedef complex<double> _ComplexType;
+};
+
+// Floating point types
+template <class _Tp>
+struct __libcpp_complex_overload_traits<_Tp, false, true>
+{
+ typedef _Tp _ValueType;
+ typedef complex<_Tp> _ComplexType;
+};
+
+// real
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_Tp
+real(const complex<_Tp>& __c)
+{
+ return __c.real();
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+typename __libcpp_complex_overload_traits<_Tp>::_ValueType
+real(_Tp __re)
+{
+ return __re;
+}
+
+// imag
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_Tp
+imag(const complex<_Tp>& __c)
+{
+ return __c.imag();
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+typename __libcpp_complex_overload_traits<_Tp>::_ValueType
+imag(_Tp)
+{
+ return 0;
+}
+
+// abs
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp
+abs(const complex<_Tp>& __c)
+{
+ return hypot(__c.real(), __c.imag());
+}
+
+// arg
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp
+arg(const complex<_Tp>& __c)
+{
+ return atan2(__c.imag(), __c.real());
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<
+ is_same<_Tp, long double>::value,
+ long double
+>::type
+arg(_Tp __re)
+{
+ return atan2l(0.L, __re);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ is_integral<_Tp>::value || is_same<_Tp, double>::value,
+ double
+>::type
+arg(_Tp __re)
+{
+ return atan2(0., __re);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<
+ is_same<_Tp, float>::value,
+ float
+>::type
+arg(_Tp __re)
+{
+ return atan2f(0.F, __re);
+}
+
+// norm
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp
+norm(const complex<_Tp>& __c)
+{
+ if (__libcpp_isinf_or_builtin(__c.real()))
+ return abs(__c.real());
+ if (__libcpp_isinf_or_builtin(__c.imag()))
+ return abs(__c.imag());
+ return __c.real() * __c.real() + __c.imag() * __c.imag();
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename __libcpp_complex_overload_traits<_Tp>::_ValueType
+norm(_Tp __re)
+{
+ typedef typename __libcpp_complex_overload_traits<_Tp>::_ValueType _ValueType;
+ return static_cast<_ValueType>(__re) * __re;
+}
+
+// conj
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+conj(const complex<_Tp>& __c)
+{
+ return complex<_Tp>(__c.real(), -__c.imag());
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename __libcpp_complex_overload_traits<_Tp>::_ComplexType
+conj(_Tp __re)
+{
+ typedef typename __libcpp_complex_overload_traits<_Tp>::_ComplexType _ComplexType;
+ return _ComplexType(__re);
+}
+
+
+
+// proj
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+proj(const complex<_Tp>& __c)
+{
+ complex<_Tp> __r = __c;
+ if (__libcpp_isinf_or_builtin(__c.real()) || __libcpp_isinf_or_builtin(__c.imag()))
+ __r = complex<_Tp>(INFINITY, copysign(_Tp(0), __c.imag()));
+ return __r;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ is_floating_point<_Tp>::value,
+ typename __libcpp_complex_overload_traits<_Tp>::_ComplexType
+>::type
+proj(_Tp __re)
+{
+ if (__libcpp_isinf_or_builtin(__re))
+ __re = abs(__re);
+ return complex<_Tp>(__re);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ is_integral<_Tp>::value,
+ typename __libcpp_complex_overload_traits<_Tp>::_ComplexType
+>::type
+proj(_Tp __re)
+{
+ typedef typename __libcpp_complex_overload_traits<_Tp>::_ComplexType _ComplexType;
+ return _ComplexType(__re);
+}
+
+// polar
+
+template<class _Tp>
+complex<_Tp>
+polar(const _Tp& __rho, const _Tp& __theta = _Tp())
+{
+ if (__libcpp_isnan_or_builtin(__rho) || signbit(__rho))
+ return complex<_Tp>(_Tp(NAN), _Tp(NAN));
+ if (__libcpp_isnan_or_builtin(__theta))
+ {
+ if (__libcpp_isinf_or_builtin(__rho))
+ return complex<_Tp>(__rho, __theta);
+ return complex<_Tp>(__theta, __theta);
+ }
+ if (__libcpp_isinf_or_builtin(__theta))
+ {
+ if (__libcpp_isinf_or_builtin(__rho))
+ return complex<_Tp>(__rho, _Tp(NAN));
+ return complex<_Tp>(_Tp(NAN), _Tp(NAN));
+ }
+ _Tp __x = __rho * cos(__theta);
+ if (__libcpp_isnan_or_builtin(__x))
+ __x = 0;
+ _Tp __y = __rho * sin(__theta);
+ if (__libcpp_isnan_or_builtin(__y))
+ __y = 0;
+ return complex<_Tp>(__x, __y);
+}
+
+// log
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+log(const complex<_Tp>& __x)
+{
+ return complex<_Tp>(log(abs(__x)), arg(__x));
+}
+
+// log10
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+log10(const complex<_Tp>& __x)
+{
+ return log(__x) / log(_Tp(10));
+}
+
+// sqrt
+
+template<class _Tp>
+complex<_Tp>
+sqrt(const complex<_Tp>& __x)
+{
+ if (__libcpp_isinf_or_builtin(__x.imag()))
+ return complex<_Tp>(_Tp(INFINITY), __x.imag());
+ if (__libcpp_isinf_or_builtin(__x.real()))
+ {
+ if (__x.real() > _Tp(0))
+ return complex<_Tp>(__x.real(), __libcpp_isnan_or_builtin(__x.imag()) ? __x.imag() : copysign(_Tp(0), __x.imag()));
+ return complex<_Tp>(__libcpp_isnan_or_builtin(__x.imag()) ? __x.imag() : _Tp(0), copysign(__x.real(), __x.imag()));
+ }
+ return polar(sqrt(abs(__x)), arg(__x) / _Tp(2));
+}
+
+// exp
+
+template<class _Tp>
+complex<_Tp>
+exp(const complex<_Tp>& __x)
+{
+ _Tp __i = __x.imag();
+ if (__i == 0) {
+ return complex<_Tp>(exp(__x.real()), copysign(_Tp(0), __x.imag()));
+ }
+ if (__libcpp_isinf_or_builtin(__x.real()))
+ {
+ if (__x.real() < _Tp(0))
+ {
+ if (!__libcpp_isfinite_or_builtin(__i))
+ __i = _Tp(1);
+ }
+ else if (__i == 0 || !__libcpp_isfinite_or_builtin(__i))
+ {
+ if (__libcpp_isinf_or_builtin(__i))
+ __i = _Tp(NAN);
+ return complex<_Tp>(__x.real(), __i);
+ }
+ }
+ _Tp __e = exp(__x.real());
+ return complex<_Tp>(__e * cos(__i), __e * sin(__i));
+}
+
+// pow
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+pow(const complex<_Tp>& __x, const complex<_Tp>& __y)
+{
+ return exp(__y * log(__x));
+}
+
+template<class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<typename __promote<_Tp, _Up>::type>
+pow(const complex<_Tp>& __x, const complex<_Up>& __y)
+{
+ typedef complex<typename __promote<_Tp, _Up>::type> result_type;
+ return _VSTD::pow(result_type(__x), result_type(__y));
+}
+
+template<class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ is_arithmetic<_Up>::value,
+ complex<typename __promote<_Tp, _Up>::type>
+>::type
+pow(const complex<_Tp>& __x, const _Up& __y)
+{
+ typedef complex<typename __promote<_Tp, _Up>::type> result_type;
+ return _VSTD::pow(result_type(__x), result_type(__y));
+}
+
+template<class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ is_arithmetic<_Tp>::value,
+ complex<typename __promote<_Tp, _Up>::type>
+>::type
+pow(const _Tp& __x, const complex<_Up>& __y)
+{
+ typedef complex<typename __promote<_Tp, _Up>::type> result_type;
+ return _VSTD::pow(result_type(__x), result_type(__y));
+}
+
+// __sqr, computes pow(x, 2)
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+__sqr(const complex<_Tp>& __x)
+{
+ return complex<_Tp>((__x.real() - __x.imag()) * (__x.real() + __x.imag()),
+ _Tp(2) * __x.real() * __x.imag());
+}
+
+// asinh
+
+template<class _Tp>
+complex<_Tp>
+asinh(const complex<_Tp>& __x)
+{
+ const _Tp __pi(atan2(+0., -0.));
+ if (__libcpp_isinf_or_builtin(__x.real()))
+ {
+ if (__libcpp_isnan_or_builtin(__x.imag()))
+ return __x;
+ if (__libcpp_isinf_or_builtin(__x.imag()))
+ return complex<_Tp>(__x.real(), copysign(__pi * _Tp(0.25), __x.imag()));
+ return complex<_Tp>(__x.real(), copysign(_Tp(0), __x.imag()));
+ }
+ if (__libcpp_isnan_or_builtin(__x.real()))
+ {
+ if (__libcpp_isinf_or_builtin(__x.imag()))
+ return complex<_Tp>(__x.imag(), __x.real());
+ if (__x.imag() == 0)
+ return __x;
+ return complex<_Tp>(__x.real(), __x.real());
+ }
+ if (__libcpp_isinf_or_builtin(__x.imag()))
+ return complex<_Tp>(copysign(__x.imag(), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
+ complex<_Tp> __z = log(__x + sqrt(__sqr(__x) + _Tp(1)));
+ return complex<_Tp>(copysign(__z.real(), __x.real()), copysign(__z.imag(), __x.imag()));
+}
+
+// acosh
+
+template<class _Tp>
+complex<_Tp>
+acosh(const complex<_Tp>& __x)
+{
+ const _Tp __pi(atan2(+0., -0.));
+ if (__libcpp_isinf_or_builtin(__x.real()))
+ {
+ if (__libcpp_isnan_or_builtin(__x.imag()))
+ return complex<_Tp>(abs(__x.real()), __x.imag());
+ if (__libcpp_isinf_or_builtin(__x.imag()))
+ {
+ if (__x.real() > 0)
+ return complex<_Tp>(__x.real(), copysign(__pi * _Tp(0.25), __x.imag()));
+ else
+ return complex<_Tp>(-__x.real(), copysign(__pi * _Tp(0.75), __x.imag()));
+ }
+ if (__x.real() < 0)
+ return complex<_Tp>(-__x.real(), copysign(__pi, __x.imag()));
+ return complex<_Tp>(__x.real(), copysign(_Tp(0), __x.imag()));
+ }
+ if (__libcpp_isnan_or_builtin(__x.real()))
+ {
+ if (__libcpp_isinf_or_builtin(__x.imag()))
+ return complex<_Tp>(abs(__x.imag()), __x.real());
+ return complex<_Tp>(__x.real(), __x.real());
+ }
+ if (__libcpp_isinf_or_builtin(__x.imag()))
+ return complex<_Tp>(abs(__x.imag()), copysign(__pi/_Tp(2), __x.imag()));
+ complex<_Tp> __z = log(__x + sqrt(__sqr(__x) - _Tp(1)));
+ return complex<_Tp>(copysign(__z.real(), _Tp(0)), copysign(__z.imag(), __x.imag()));
+}
+
+// atanh
+
+template<class _Tp>
+complex<_Tp>
+atanh(const complex<_Tp>& __x)
+{
+ const _Tp __pi(atan2(+0., -0.));
+ if (__libcpp_isinf_or_builtin(__x.imag()))
+ {
+ return complex<_Tp>(copysign(_Tp(0), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
+ }
+ if (__libcpp_isnan_or_builtin(__x.imag()))
+ {
+ if (__libcpp_isinf_or_builtin(__x.real()) || __x.real() == 0)
+ return complex<_Tp>(copysign(_Tp(0), __x.real()), __x.imag());
+ return complex<_Tp>(__x.imag(), __x.imag());
+ }
+ if (__libcpp_isnan_or_builtin(__x.real()))
+ {
+ return complex<_Tp>(__x.real(), __x.real());
+ }
+ if (__libcpp_isinf_or_builtin(__x.real()))
+ {
+ return complex<_Tp>(copysign(_Tp(0), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
+ }
+ if (abs(__x.real()) == _Tp(1) && __x.imag() == _Tp(0))
+ {
+ return complex<_Tp>(copysign(_Tp(INFINITY), __x.real()), copysign(_Tp(0), __x.imag()));
+ }
+ complex<_Tp> __z = log((_Tp(1) + __x) / (_Tp(1) - __x)) / _Tp(2);
+ return complex<_Tp>(copysign(__z.real(), __x.real()), copysign(__z.imag(), __x.imag()));
+}
+
+// sinh
+
+template<class _Tp>
+complex<_Tp>
+sinh(const complex<_Tp>& __x)
+{
+ if (__libcpp_isinf_or_builtin(__x.real()) && !__libcpp_isfinite_or_builtin(__x.imag()))
+ return complex<_Tp>(__x.real(), _Tp(NAN));
+ if (__x.real() == 0 && !__libcpp_isfinite_or_builtin(__x.imag()))
+ return complex<_Tp>(__x.real(), _Tp(NAN));
+ if (__x.imag() == 0 && !__libcpp_isfinite_or_builtin(__x.real()))
+ return __x;
+ return complex<_Tp>(sinh(__x.real()) * cos(__x.imag()), cosh(__x.real()) * sin(__x.imag()));
+}
+
+// cosh
+
+template<class _Tp>
+complex<_Tp>
+cosh(const complex<_Tp>& __x)
+{
+ if (__libcpp_isinf_or_builtin(__x.real()) && !__libcpp_isfinite_or_builtin(__x.imag()))
+ return complex<_Tp>(abs(__x.real()), _Tp(NAN));
+ if (__x.real() == 0 && !__libcpp_isfinite_or_builtin(__x.imag()))
+ return complex<_Tp>(_Tp(NAN), __x.real());
+ if (__x.real() == 0 && __x.imag() == 0)
+ return complex<_Tp>(_Tp(1), __x.imag());
+ if (__x.imag() == 0 && !__libcpp_isfinite_or_builtin(__x.real()))
+ return complex<_Tp>(abs(__x.real()), __x.imag());
+ return complex<_Tp>(cosh(__x.real()) * cos(__x.imag()), sinh(__x.real()) * sin(__x.imag()));
+}
+
+// tanh
+
+template<class _Tp>
+complex<_Tp>
+tanh(const complex<_Tp>& __x)
+{
+ if (__libcpp_isinf_or_builtin(__x.real()))
+ {
+ if (!__libcpp_isfinite_or_builtin(__x.imag()))
+ return complex<_Tp>(copysign(_Tp(1), __x.real()), _Tp(0));
+ return complex<_Tp>(copysign(_Tp(1), __x.real()), copysign(_Tp(0), sin(_Tp(2) * __x.imag())));
+ }
+ if (__libcpp_isnan_or_builtin(__x.real()) && __x.imag() == 0)
+ return __x;
+ _Tp __2r(_Tp(2) * __x.real());
+ _Tp __2i(_Tp(2) * __x.imag());
+ _Tp __d(cosh(__2r) + cos(__2i));
+ _Tp __2rsh(sinh(__2r));
+ if (__libcpp_isinf_or_builtin(__2rsh) && __libcpp_isinf_or_builtin(__d))
+ return complex<_Tp>(__2rsh > _Tp(0) ? _Tp(1) : _Tp(-1),
+ __2i > _Tp(0) ? _Tp(0) : _Tp(-0.));
+ return complex<_Tp>(__2rsh/__d, sin(__2i)/__d);
+}
+
+// asin
+
+template<class _Tp>
+complex<_Tp>
+asin(const complex<_Tp>& __x)
+{
+ complex<_Tp> __z = asinh(complex<_Tp>(-__x.imag(), __x.real()));
+ return complex<_Tp>(__z.imag(), -__z.real());
+}
+
+// acos
+
+template<class _Tp>
+complex<_Tp>
+acos(const complex<_Tp>& __x)
+{
+ const _Tp __pi(atan2(+0., -0.));
+ if (__libcpp_isinf_or_builtin(__x.real()))
+ {
+ if (__libcpp_isnan_or_builtin(__x.imag()))
+ return complex<_Tp>(__x.imag(), __x.real());
+ if (__libcpp_isinf_or_builtin(__x.imag()))
+ {
+ if (__x.real() < _Tp(0))
+ return complex<_Tp>(_Tp(0.75) * __pi, -__x.imag());
+ return complex<_Tp>(_Tp(0.25) * __pi, -__x.imag());
+ }
+ if (__x.real() < _Tp(0))
+ return complex<_Tp>(__pi, signbit(__x.imag()) ? -__x.real() : __x.real());
+ return complex<_Tp>(_Tp(0), signbit(__x.imag()) ? __x.real() : -__x.real());
+ }
+ if (__libcpp_isnan_or_builtin(__x.real()))
+ {
+ if (__libcpp_isinf_or_builtin(__x.imag()))
+ return complex<_Tp>(__x.real(), -__x.imag());
+ return complex<_Tp>(__x.real(), __x.real());
+ }
+ if (__libcpp_isinf_or_builtin(__x.imag()))
+ return complex<_Tp>(__pi/_Tp(2), -__x.imag());
+ if (__x.real() == 0 && (__x.imag() == 0 || isnan(__x.imag())))
+ return complex<_Tp>(__pi/_Tp(2), -__x.imag());
+ complex<_Tp> __z = log(__x + sqrt(__sqr(__x) - _Tp(1)));
+ if (signbit(__x.imag()))
+ return complex<_Tp>(abs(__z.imag()), abs(__z.real()));
+ return complex<_Tp>(abs(__z.imag()), -abs(__z.real()));
+}
+
+// atan
+
+template<class _Tp>
+complex<_Tp>
+atan(const complex<_Tp>& __x)
+{
+ complex<_Tp> __z = atanh(complex<_Tp>(-__x.imag(), __x.real()));
+ return complex<_Tp>(__z.imag(), -__z.real());
+}
+
+// sin
+
+template<class _Tp>
+complex<_Tp>
+sin(const complex<_Tp>& __x)
+{
+ complex<_Tp> __z = sinh(complex<_Tp>(-__x.imag(), __x.real()));
+ return complex<_Tp>(__z.imag(), -__z.real());
+}
+
+// cos
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+cos(const complex<_Tp>& __x)
+{
+ return cosh(complex<_Tp>(-__x.imag(), __x.real()));
+}
+
+// tan
+
+template<class _Tp>
+complex<_Tp>
+tan(const complex<_Tp>& __x)
+{
+ complex<_Tp> __z = tanh(complex<_Tp>(-__x.imag(), __x.real()));
+ return complex<_Tp>(__z.imag(), -__z.real());
+}
+
+template<class _Tp, class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)
+{
+ if (__is.good())
+ {
+ ws(__is);
+ if (__is.peek() == _CharT('('))
+ {
+ __is.get();
+ _Tp __r;
+ __is >> __r;
+ if (!__is.fail())
+ {
+ ws(__is);
+ _CharT __c = __is.peek();
+ if (__c == _CharT(','))
+ {
+ __is.get();
+ _Tp __i;
+ __is >> __i;
+ if (!__is.fail())
+ {
+ ws(__is);
+ __c = __is.peek();
+ if (__c == _CharT(')'))
+ {
+ __is.get();
+ __x = complex<_Tp>(__r, __i);
+ }
+ else
+ __is.setstate(__is.failbit);
+ }
+ else
+ __is.setstate(__is.failbit);
+ }
+ else if (__c == _CharT(')'))
+ {
+ __is.get();
+ __x = complex<_Tp>(__r, _Tp(0));
+ }
+ else
+ __is.setstate(__is.failbit);
+ }
+ else
+ __is.setstate(__is.failbit);
+ }
+ else
+ {
+ _Tp __r;
+ __is >> __r;
+ if (!__is.fail())
+ __x = complex<_Tp>(__r, _Tp(0));
+ else
+ __is.setstate(__is.failbit);
+ }
+ }
+ else
+ __is.setstate(__is.failbit);
+ return __is;
+}
+
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+template<class _Tp, class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x)
+{
+ basic_ostringstream<_CharT, _Traits> __s;
+ __s.flags(__os.flags());
+ __s.imbue(__os.getloc());
+ __s.precision(__os.precision());
+ __s << '(' << __x.real() << ',' << __x.imag() << ')';
+ return __os << __s.str();
+}
+#endif // !_LIBCPP_HAS_NO_LOCALIZATION
+
+#if _LIBCPP_STD_VER > 11
+// Literal suffix for complex number literals [complex.literals]
+inline namespace literals
+{
+ inline namespace complex_literals
+ {
+ constexpr complex<long double> operator""il(long double __im)
+ {
+ return { 0.0l, __im };
+ }
+
+ constexpr complex<long double> operator""il(unsigned long long __im)
+ {
+ return { 0.0l, static_cast<long double>(__im) };
+ }
+
+
+ constexpr complex<double> operator""i(long double __im)
+ {
+ return { 0.0, static_cast<double>(__im) };
+ }
+
+ constexpr complex<double> operator""i(unsigned long long __im)
+ {
+ return { 0.0, static_cast<double>(__im) };
+ }
+
+
+#if !defined(__CUDACC__)
+ constexpr complex<float> operator""if(long double __im)
+ {
+ return { 0.0f, static_cast<float>(__im) };
+ }
+
+ constexpr complex<float> operator""if(unsigned long long __im)
+ {
+ return { 0.0f, static_cast<float>(__im) };
+ }
+#endif
+ } // namespace complex_literals
+} // namespace literals
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_COMPLEX
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/complex.h b/contrib/libs/cxxsupp/libcxxmsvc/include/complex.h
new file mode 100644
index 0000000000..58cbbaaeef
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/complex.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_COMPLEX_H
+#define _LIBCPP_COMPLEX_H
+
+/*
+ complex.h synopsis
+
+#include <ccomplex>
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifdef __cplusplus
+
+#include <ccomplex>
+
+#else // __cplusplus
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#include Y_UCRT_INCLUDE_NEXT(complex.h)
+#else
+#include_next <complex.h>
+#endif
+
+#endif // __cplusplus
+
+#endif // _LIBCPP_COMPLEX_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/concepts b/contrib/libs/cxxsupp/libcxxmsvc/include/concepts
new file mode 100644
index 0000000000..99dbcf4561
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/concepts
@@ -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_CONCEPTS
+#define _LIBCPP_CONCEPTS
+
+/*
+ concepts synopsis
+namespace std {
+ // [concepts.lang], language-related concepts
+ // [concept.same], concept same_as
+ template<class T, class U>
+ concept same_as = see below;
+
+ // [concept.derived], concept derived_from
+ template<class Derived, class Base>
+ concept derived_from = see below;
+
+ // [concept.convertible], concept convertible_to
+ template<class From, class To>
+ concept convertible_to = see below;
+
+ // [concept.commonref], concept common_reference_with
+ template<class T, class U>
+ concept common_reference_with = see below;
+
+ // [concept.common], concept common_with
+ template<class T, class U>
+ concept common_with = see below;
+
+ // [concepts.arithmetic], arithmetic concepts
+ template<class T>
+ concept integral = see below;
+ template<class T>
+ concept signed_integral = see below;
+ template<class T>
+ concept unsigned_integral = see below;
+ template<class T>
+ concept floating_point = see below;
+
+ // [concept.assignable], concept assignable_from
+ template<class LHS, class RHS>
+ concept assignable_from = see below;
+
+ // [concept.swappable], concept swappable
+ namespace ranges {
+ inline namespace unspecified {
+ inline constexpr unspecified swap = unspecified;
+ }
+ }
+ template<class T>
+ concept swappable = see below;
+ template<class T, class U>
+ concept swappable_with = see below;
+
+ // [concept.destructible], concept destructible
+ template<class T>
+ concept destructible = see below;
+
+ // [concept.constructible], concept constructible_from
+ template<class T, class... Args>
+ concept constructible_from = see below;
+
+ // [concept.default.init], concept default_initializable
+ template<class T>
+ concept default_initializable = see below;
+
+ // [concept.moveconstructible], concept move_constructible
+ template<class T>
+ concept move_constructible = see below;
+
+ // [concept.copyconstructible], concept copy_constructible
+ template<class T>
+ concept copy_constructible = see below;
+
+ // [concept.equalitycomparable], concept equality_comparable
+ template<class T>
+ concept equality_comparable = see below;
+ template<class T, class U>
+ concept equality_comparable_with = see below;
+
+ // [concept.totallyordered], concept totally_ordered
+ template<class T>
+ concept totally_ordered = see below;
+ template<class T, class U>
+ concept totally_ordered_with = see below;
+
+ // [concepts.object], object concepts
+ template<class T>
+ concept movable = see below;
+ template<class T>
+ concept copyable = see below;
+ template<class T>
+ concept semiregular = see below;
+ template<class T>
+ concept regular = see below;
+
+ // [concepts.callable], callable concepts
+ // [concept.invocable], concept invocable
+ template<class F, class... Args>
+ concept invocable = see below;
+
+ // [concept.regularinvocable], concept regular_invocable
+ template<class F, class... Args>
+ concept regular_invocable = see below;
+
+ // [concept.predicate], concept predicate
+ template<class F, class... Args>
+ concept predicate = see below;
+
+ // [concept.relation], concept relation
+ template<class R, class T, class U>
+ concept relation = see below;
+
+ // [concept.equiv], concept equivalence_relation
+ template<class R, class T, class U>
+ concept equivalence_relation = see below;
+
+ // [concept.strictweakorder], concept strict_weak_order
+ template<class R, class T, class U>
+ concept strict_weak_order = see below;
+}
+
+*/
+
+#include <__concepts/arithmetic.h>
+#include <__concepts/assignable.h>
+#include <__concepts/boolean_testable.h>
+#include <__concepts/class_or_enum.h>
+#include <__concepts/common_reference_with.h>
+#include <__concepts/common_with.h>
+#include <__concepts/constructible.h>
+#include <__concepts/convertible_to.h>
+#include <__concepts/copyable.h>
+#include <__concepts/derived_from.h>
+#include <__concepts/destructible.h>
+#include <__concepts/different_from.h>
+#include <__concepts/equality_comparable.h>
+#include <__concepts/invocable.h>
+#include <__concepts/movable.h>
+#include <__concepts/predicate.h>
+#include <__concepts/regular.h>
+#include <__concepts/relation.h>
+#include <__concepts/same_as.h>
+#include <__concepts/semiregular.h>
+#include <__concepts/swappable.h>
+#include <__concepts/totally_ordered.h>
+#include <__config>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#endif // _LIBCPP_CONCEPTS
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/condition_variable b/contrib/libs/cxxsupp/libcxxmsvc/include/condition_variable
new file mode 100644
index 0000000000..6da7246500
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/condition_variable
@@ -0,0 +1,269 @@
+// -*- 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_CONDITION_VARIABLE
+#define _LIBCPP_CONDITION_VARIABLE
+
+/*
+ condition_variable synopsis
+
+namespace std
+{
+
+enum class cv_status { no_timeout, timeout };
+
+class condition_variable
+{
+public:
+ condition_variable();
+ ~condition_variable();
+
+ condition_variable(const condition_variable&) = delete;
+ condition_variable& operator=(const condition_variable&) = delete;
+
+ void notify_one() noexcept;
+ void notify_all() noexcept;
+
+ void wait(unique_lock<mutex>& lock);
+ template <class Predicate>
+ void wait(unique_lock<mutex>& lock, Predicate pred);
+
+ template <class Clock, class Duration>
+ cv_status
+ wait_until(unique_lock<mutex>& lock,
+ const chrono::time_point<Clock, Duration>& abs_time);
+
+ template <class Clock, class Duration, class Predicate>
+ bool
+ wait_until(unique_lock<mutex>& lock,
+ const chrono::time_point<Clock, Duration>& abs_time,
+ Predicate pred);
+
+ template <class Rep, class Period>
+ cv_status
+ wait_for(unique_lock<mutex>& lock,
+ const chrono::duration<Rep, Period>& rel_time);
+
+ template <class Rep, class Period, class Predicate>
+ bool
+ wait_for(unique_lock<mutex>& lock,
+ const chrono::duration<Rep, Period>& rel_time,
+ Predicate pred);
+
+ typedef pthread_cond_t* native_handle_type;
+ native_handle_type native_handle();
+};
+
+void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk);
+
+class condition_variable_any
+{
+public:
+ condition_variable_any();
+ ~condition_variable_any();
+
+ condition_variable_any(const condition_variable_any&) = delete;
+ condition_variable_any& operator=(const condition_variable_any&) = delete;
+
+ void notify_one() noexcept;
+ void notify_all() noexcept;
+
+ template <class Lock>
+ void wait(Lock& lock);
+ template <class Lock, class Predicate>
+ void wait(Lock& lock, Predicate pred);
+
+ template <class Lock, class Clock, class Duration>
+ cv_status
+ wait_until(Lock& lock,
+ const chrono::time_point<Clock, Duration>& abs_time);
+
+ template <class Lock, class Clock, class Duration, class Predicate>
+ bool
+ wait_until(Lock& lock,
+ const chrono::time_point<Clock, Duration>& abs_time,
+ Predicate pred);
+
+ template <class Lock, class Rep, class Period>
+ cv_status
+ wait_for(Lock& lock,
+ const chrono::duration<Rep, Period>& rel_time);
+
+ template <class Lock, class Rep, class Period, class Predicate>
+ bool
+ wait_for(Lock& lock,
+ const chrono::duration<Rep, Period>& rel_time,
+ Predicate pred);
+};
+
+} // std
+
+*/
+
+#include <__config>
+#include <__mutex_base>
+#include <memory>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifndef _LIBCPP_HAS_NO_THREADS
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+class _LIBCPP_TYPE_VIS condition_variable_any
+{
+ condition_variable __cv_;
+ shared_ptr<mutex> __mut_;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ condition_variable_any();
+
+ _LIBCPP_INLINE_VISIBILITY
+ void notify_one() _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ void notify_all() _NOEXCEPT;
+
+ template <class _Lock>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ void wait(_Lock& __lock);
+ template <class _Lock, class _Predicate>
+ _LIBCPP_INLINE_VISIBILITY
+ void wait(_Lock& __lock, _Predicate __pred);
+
+ template <class _Lock, class _Clock, class _Duration>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ cv_status
+ wait_until(_Lock& __lock,
+ const chrono::time_point<_Clock, _Duration>& __t);
+
+ template <class _Lock, class _Clock, class _Duration, class _Predicate>
+ bool
+ _LIBCPP_INLINE_VISIBILITY
+ wait_until(_Lock& __lock,
+ const chrono::time_point<_Clock, _Duration>& __t,
+ _Predicate __pred);
+
+ template <class _Lock, class _Rep, class _Period>
+ cv_status
+ _LIBCPP_INLINE_VISIBILITY
+ wait_for(_Lock& __lock,
+ const chrono::duration<_Rep, _Period>& __d);
+
+ template <class _Lock, class _Rep, class _Period, class _Predicate>
+ bool
+ _LIBCPP_INLINE_VISIBILITY
+ wait_for(_Lock& __lock,
+ const chrono::duration<_Rep, _Period>& __d,
+ _Predicate __pred);
+};
+
+inline
+condition_variable_any::condition_variable_any()
+ : __mut_(make_shared<mutex>()) {}
+
+inline
+void
+condition_variable_any::notify_one() _NOEXCEPT
+{
+ {lock_guard<mutex> __lx(*__mut_);}
+ __cv_.notify_one();
+}
+
+inline
+void
+condition_variable_any::notify_all() _NOEXCEPT
+{
+ {lock_guard<mutex> __lx(*__mut_);}
+ __cv_.notify_all();
+}
+
+struct __lock_external
+{
+ template <class _Lock>
+ void operator()(_Lock* __m) {__m->lock();}
+};
+
+template <class _Lock>
+void
+condition_variable_any::wait(_Lock& __lock)
+{
+ shared_ptr<mutex> __mut = __mut_;
+ unique_lock<mutex> __lk(*__mut);
+ __lock.unlock();
+ unique_ptr<_Lock, __lock_external> __lxx(&__lock);
+ lock_guard<unique_lock<mutex> > __lx(__lk, adopt_lock);
+ __cv_.wait(__lk);
+} // __mut_.unlock(), __lock.lock()
+
+template <class _Lock, class _Predicate>
+inline
+void
+condition_variable_any::wait(_Lock& __lock, _Predicate __pred)
+{
+ while (!__pred())
+ wait(__lock);
+}
+
+template <class _Lock, class _Clock, class _Duration>
+cv_status
+condition_variable_any::wait_until(_Lock& __lock,
+ const chrono::time_point<_Clock, _Duration>& __t)
+{
+ shared_ptr<mutex> __mut = __mut_;
+ unique_lock<mutex> __lk(*__mut);
+ __lock.unlock();
+ unique_ptr<_Lock, __lock_external> __lxx(&__lock);
+ lock_guard<unique_lock<mutex> > __lx(__lk, adopt_lock);
+ return __cv_.wait_until(__lk, __t);
+} // __mut_.unlock(), __lock.lock()
+
+template <class _Lock, class _Clock, class _Duration, class _Predicate>
+inline
+bool
+condition_variable_any::wait_until(_Lock& __lock,
+ const chrono::time_point<_Clock, _Duration>& __t,
+ _Predicate __pred)
+{
+ while (!__pred())
+ if (wait_until(__lock, __t) == cv_status::timeout)
+ return __pred();
+ return true;
+}
+
+template <class _Lock, class _Rep, class _Period>
+inline
+cv_status
+condition_variable_any::wait_for(_Lock& __lock,
+ const chrono::duration<_Rep, _Period>& __d)
+{
+ return wait_until(__lock, chrono::steady_clock::now() + __d);
+}
+
+template <class _Lock, class _Rep, class _Period, class _Predicate>
+inline
+bool
+condition_variable_any::wait_for(_Lock& __lock,
+ const chrono::duration<_Rep, _Period>& __d,
+ _Predicate __pred)
+{
+ return wait_until(__lock, chrono::steady_clock::now() + __d,
+ _VSTD::move(__pred));
+}
+
+_LIBCPP_FUNC_VIS
+void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk);
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // !_LIBCPP_HAS_NO_THREADS
+
+#endif // _LIBCPP_CONDITION_VARIABLE
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/coroutine b/contrib/libs/cxxsupp/libcxxmsvc/include/coroutine
new file mode 100644
index 0000000000..478f4723f9
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/coroutine
@@ -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_COROUTINE
+#define _LIBCPP_COROUTINE
+
+/**
+ coroutine synopsis
+
+namespace std {
+// [coroutine.traits]
+template <class R, class... ArgTypes>
+ struct coroutine_traits;
+// [coroutine.handle]
+template <class Promise = void>
+ struct coroutine_handle;
+// [coroutine.handle.compare]
+constexpr bool operator==(coroutine_handle<> x, coroutine_handle<> y) noexcept;
+constexpr strong_ordering operator<=>(coroutine_handle<> x, coroutine_handle<> y) noexcept;
+// [coroutine.handle.hash]
+template <class T> struct hash;
+template <class P> struct hash<coroutine_handle<P>>;
+// [coroutine.noop]
+struct noop_coroutine_promise;
+template<> struct coroutine_handle<noop_coroutine_promise>;
+using noop_coroutine_handle = coroutine_handle<noop_coroutine_promise>;
+noop_coroutine_handle noop_coroutine() noexcept;
+// [coroutine.trivial.awaitables]
+struct suspend_never;
+struct suspend_always;
+} // namespace std
+
+ */
+
+#include <__config>
+#include <__coroutine/coroutine_handle.h>
+#include <__coroutine/coroutine_traits.h>
+#include <__coroutine/noop_coroutine_handle.h>
+#include <__coroutine/trivial_awaitables.h>
+#include <version>
+
+#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
+# pragma GCC system_header
+#endif
+
+#endif // _LIBCPP_COROUTINE
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/csignal b/contrib/libs/cxxsupp/libcxxmsvc/include/csignal
new file mode 100644
index 0000000000..19091cfaa2
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/csignal
@@ -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_CSIGNAL
+#define _LIBCPP_CSIGNAL
+
+/*
+ csignal synopsis
+
+Macros:
+
+ SIG_DFL
+ SIG_ERR
+ SIG_IGN
+ SIGABRT
+ SIGFPE
+ SIGILL
+ SIGINT
+ SIGSEGV
+ SIGTERM
+
+namespace std
+{
+
+Types:
+
+ sig_atomic_t
+
+void (*signal(int sig, void (*func)(int)))(int);
+int raise(int sig);
+
+} // std
+
+*/
+
+#include <__config>
+#include <signal.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+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
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/cstdarg b/contrib/libs/cxxsupp/libcxxmsvc/include/cstdarg
new file mode 100644
index 0000000000..7dd906866a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/cstdarg
@@ -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_CSTDARG
+#define _LIBCPP_CSTDARG
+
+/*
+ cstdarg synopsis
+
+Macros:
+
+ type va_arg(va_list ap, type);
+ void va_copy(va_list dest, va_list src); // C99
+ void va_end(va_list ap);
+ void va_start(va_list ap, parmN);
+
+namespace std
+{
+
+Types:
+
+ va_list
+
+} // std
+
+*/
+
+#include <__config>
+#include <stdarg.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+using ::va_list _LIBCPP_USING_IF_EXISTS;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_CSTDARG
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/cstddef b/contrib/libs/cxxsupp/libcxxmsvc/include/cstddef
new file mode 100644
index 0000000000..5dce7c0dbd
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/cstddef
@@ -0,0 +1,166 @@
+// -*- 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_CSTDDEF
+#define _LIBCPP_CSTDDEF
+
+/*
+ cstddef synopsis
+
+Macros:
+
+ offsetof(type,member-designator)
+ NULL
+
+namespace std
+{
+
+Types:
+
+ ptrdiff_t
+ size_t
+ max_align_t // C++11
+ nullptr_t
+ byte // C++17
+
+} // std
+
+*/
+
+#include <__config>
+#include <stddef.h>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifdef _LIBCPP_ABI_VCRUNTIME
+typedef double max_align_t;
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+using ::nullptr_t;
+using ::ptrdiff_t _LIBCPP_USING_IF_EXISTS;
+using ::size_t _LIBCPP_USING_IF_EXISTS;
+
+#if !defined(_LIBCPP_CXX03_LANG)
+using ::max_align_t _LIBCPP_USING_IF_EXISTS;
+#endif
+
+template <class _Tp> struct __libcpp_is_integral { enum { value = 0 }; };
+template <> struct __libcpp_is_integral<bool> { enum { value = 1 }; };
+template <> struct __libcpp_is_integral<char> { enum { value = 1 }; };
+template <> struct __libcpp_is_integral<signed char> { enum { value = 1 }; };
+template <> struct __libcpp_is_integral<unsigned char> { enum { value = 1 }; };
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <> struct __libcpp_is_integral<wchar_t> { enum { value = 1 }; };
+#endif
+#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
+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 }; };
+template <> struct __libcpp_is_integral<unsigned int> { enum { value = 1 }; };
+template <> struct __libcpp_is_integral<long> { enum { value = 1 }; };
+template <> struct __libcpp_is_integral<unsigned long> { enum { value = 1 }; };
+template <> struct __libcpp_is_integral<long long> { enum { value = 1 }; };
+template <> struct __libcpp_is_integral<unsigned long long> { enum { value = 1 }; };
+#ifndef _LIBCPP_HAS_NO_INT128
+template <> struct __libcpp_is_integral<__int128_t> { enum { value = 1 }; };
+template <> struct __libcpp_is_integral<__uint128_t> { enum { value = 1 }; };
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 14
+namespace std // purposefully not versioned
+{
+enum class byte : unsigned char {};
+
+
+template <bool> struct __enable_if_integral_imp {};
+template <> struct __enable_if_integral_imp<true> { using type = byte; };
+template <class _Tp> using _EnableByteOverload = typename __enable_if_integral_imp<__libcpp_is_integral<_Tp>::value>::type;
+
+constexpr byte operator| (byte __lhs, byte __rhs) noexcept
+{
+ return static_cast<byte>(
+ static_cast<unsigned char>(
+ static_cast<unsigned int>(__lhs) | static_cast<unsigned int>(__rhs)
+ ));
+}
+
+constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept
+{ return __lhs = __lhs | __rhs; }
+
+constexpr byte operator& (byte __lhs, byte __rhs) noexcept
+{
+ return static_cast<byte>(
+ static_cast<unsigned char>(
+ static_cast<unsigned int>(__lhs) & static_cast<unsigned int>(__rhs)
+ ));
+}
+
+constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept
+{ return __lhs = __lhs & __rhs; }
+
+constexpr byte operator^ (byte __lhs, byte __rhs) noexcept
+{
+ return static_cast<byte>(
+ static_cast<unsigned char>(
+ static_cast<unsigned int>(__lhs) ^ static_cast<unsigned int>(__rhs)
+ ));
+}
+
+constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept
+{ return __lhs = __lhs ^ __rhs; }
+
+constexpr byte operator~ (byte __b) noexcept
+{
+ return static_cast<byte>(
+ static_cast<unsigned char>(
+ ~static_cast<unsigned int>(__b)
+ ));
+}
+template <class _Integer>
+ constexpr _EnableByteOverload<_Integer> &
+ operator<<=(byte& __lhs, _Integer __shift) noexcept
+ { return __lhs = __lhs << __shift; }
+
+template <class _Integer>
+ constexpr _EnableByteOverload<_Integer>
+ operator<< (byte __lhs, _Integer __shift) noexcept
+ { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) << __shift)); }
+
+template <class _Integer>
+ constexpr _EnableByteOverload<_Integer> &
+ operator>>=(byte& __lhs, _Integer __shift) noexcept
+ { return __lhs = __lhs >> __shift; }
+
+template <class _Integer>
+ constexpr _EnableByteOverload<_Integer>
+ operator>> (byte __lhs, _Integer __shift) noexcept
+ { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift)); }
+
+template <class _Integer, class = _EnableByteOverload<_Integer> >
+ _LIBCPP_NODISCARD_EXT constexpr _Integer
+ to_integer(byte __b) noexcept { return static_cast<_Integer>(__b); }
+
+} // namespace std
+
+#endif
+
+#endif // _LIBCPP_CSTDDEF
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/cstdint b/contrib/libs/cxxsupp/libcxxmsvc/include/cstdint
new file mode 100644
index 0000000000..cac715bf0a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/cstdint
@@ -0,0 +1,190 @@
+// -*- 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_CSTDINT
+#define _LIBCPP_CSTDINT
+
+/*
+ cstdint synopsis
+
+Macros:
+
+ INT8_MIN
+ INT16_MIN
+ INT32_MIN
+ INT64_MIN
+
+ INT8_MAX
+ INT16_MAX
+ INT32_MAX
+ INT64_MAX
+
+ UINT8_MAX
+ UINT16_MAX
+ UINT32_MAX
+ UINT64_MAX
+
+ INT_LEAST8_MIN
+ INT_LEAST16_MIN
+ INT_LEAST32_MIN
+ INT_LEAST64_MIN
+
+ INT_LEAST8_MAX
+ INT_LEAST16_MAX
+ INT_LEAST32_MAX
+ INT_LEAST64_MAX
+
+ UINT_LEAST8_MAX
+ UINT_LEAST16_MAX
+ UINT_LEAST32_MAX
+ UINT_LEAST64_MAX
+
+ INT_FAST8_MIN
+ INT_FAST16_MIN
+ INT_FAST32_MIN
+ INT_FAST64_MIN
+
+ INT_FAST8_MAX
+ INT_FAST16_MAX
+ INT_FAST32_MAX
+ INT_FAST64_MAX
+
+ UINT_FAST8_MAX
+ UINT_FAST16_MAX
+ UINT_FAST32_MAX
+ UINT_FAST64_MAX
+
+ INTPTR_MIN
+ INTPTR_MAX
+ UINTPTR_MAX
+
+ INTMAX_MIN
+ INTMAX_MAX
+
+ UINTMAX_MAX
+
+ PTRDIFF_MIN
+ PTRDIFF_MAX
+
+ SIG_ATOMIC_MIN
+ SIG_ATOMIC_MAX
+
+ SIZE_MAX
+
+ WCHAR_MIN
+ WCHAR_MAX
+
+ WINT_MIN
+ WINT_MAX
+
+ INT8_C(value)
+ INT16_C(value)
+ INT32_C(value)
+ INT64_C(value)
+
+ UINT8_C(value)
+ UINT16_C(value)
+ UINT32_C(value)
+ UINT64_C(value)
+
+ INTMAX_C(value)
+ UINTMAX_C(value)
+
+namespace std
+{
+
+Types:
+
+ int8_t
+ int16_t
+ int32_t
+ int64_t
+
+ uint8_t
+ uint16_t
+ uint32_t
+ uint64_t
+
+ int_least8_t
+ int_least16_t
+ int_least32_t
+ int_least64_t
+
+ uint_least8_t
+ uint_least16_t
+ uint_least32_t
+ uint_least64_t
+
+ int_fast8_t
+ int_fast16_t
+ int_fast32_t
+ int_fast64_t
+
+ uint_fast8_t
+ uint_fast16_t
+ uint_fast32_t
+ uint_fast64_t
+
+ intptr_t
+ uintptr_t
+
+ intmax_t
+ uintmax_t
+
+} // std
+*/
+
+#include <__config>
+#include <stdint.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+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
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/cstdio b/contrib/libs/cxxsupp/libcxxmsvc/include/cstdio
new file mode 100644
index 0000000000..d5b748d86e
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/cstdio
@@ -0,0 +1,169 @@
+// -*- 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_CSTDIO
+#define _LIBCPP_CSTDIO
+
+/*
+ cstdio synopsis
+
+Macros:
+
+ BUFSIZ
+ EOF
+ FILENAME_MAX
+ FOPEN_MAX
+ L_tmpnam
+ NULL
+ SEEK_CUR
+ SEEK_END
+ SEEK_SET
+ TMP_MAX
+ _IOFBF
+ _IOLBF
+ _IONBF
+ stderr
+ stdin
+ stdout
+
+namespace std
+{
+
+Types:
+
+FILE
+fpos_t
+size_t
+
+int remove(const char* filename);
+int rename(const char* old, const char* new);
+FILE* tmpfile(void);
+char* tmpnam(char* s);
+int fclose(FILE* stream);
+int fflush(FILE* stream);
+FILE* fopen(const char* restrict filename, const char* restrict mode);
+FILE* freopen(const char* restrict filename, const char * restrict mode,
+ FILE * restrict stream);
+void setbuf(FILE* restrict stream, char* restrict buf);
+int setvbuf(FILE* restrict stream, char* restrict buf, int mode, size_t size);
+int fprintf(FILE* restrict stream, const char* restrict format, ...);
+int fscanf(FILE* restrict stream, const char * restrict format, ...);
+int printf(const char* restrict format, ...);
+int scanf(const char* restrict format, ...);
+int snprintf(char* restrict s, size_t n, const char* restrict format, ...); // C99
+int sprintf(char* restrict s, const char* restrict format, ...);
+int sscanf(const char* restrict s, const char* restrict format, ...);
+int vfprintf(FILE* restrict stream, const char* restrict format, va_list arg);
+int vfscanf(FILE* restrict stream, const char* restrict format, va_list arg); // C99
+int vprintf(const char* restrict format, va_list arg);
+int vscanf(const char* restrict format, va_list arg); // C99
+int vsnprintf(char* restrict s, size_t n, const char* restrict format, // C99
+ va_list arg);
+int vsprintf(char* restrict s, const char* restrict format, va_list arg);
+int vsscanf(const char* restrict s, const char* restrict format, va_list arg); // C99
+int fgetc(FILE* stream);
+char* fgets(char* restrict s, int n, FILE* restrict stream);
+int fputc(int c, FILE* stream);
+int fputs(const char* restrict s, FILE* restrict stream);
+int getc(FILE* stream);
+int getchar(void);
+char* gets(char* s); // removed in C++14
+int putc(int c, FILE* stream);
+int putchar(int c);
+int puts(const char* s);
+int ungetc(int c, FILE* stream);
+size_t fread(void* restrict ptr, size_t size, size_t nmemb,
+ FILE* restrict stream);
+size_t fwrite(const void* restrict ptr, size_t size, size_t nmemb,
+ FILE* restrict stream);
+int fgetpos(FILE* restrict stream, fpos_t* restrict pos);
+int fseek(FILE* stream, long offset, int whence);
+int fsetpos(FILE*stream, const fpos_t* pos);
+long ftell(FILE* stream);
+void rewind(FILE* stream);
+void clearerr(FILE* stream);
+int feof(FILE* stream);
+int ferror(FILE* stream);
+void perror(const char* s);
+
+} // std
+*/
+
+#include <__config>
+#include <stdio.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+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 _LIBCPP_USING_IF_EXISTS;
+#endif
+using ::fseek _LIBCPP_USING_IF_EXISTS;
+#ifndef _LIBCPP_HAS_NO_FGETPOS_FSETPOS
+using ::fsetpos _LIBCPP_USING_IF_EXISTS;
+#endif
+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;
+
+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;
+
+using ::getchar _LIBCPP_USING_IF_EXISTS;
+#if _LIBCPP_STD_VER <= 11 && !defined(_LIBCPP_C_HAS_NO_GETS)
+using ::gets _LIBCPP_USING_IF_EXISTS;
+#endif
+using ::scanf _LIBCPP_USING_IF_EXISTS;
+using ::vscanf _LIBCPP_USING_IF_EXISTS;
+
+using ::printf _LIBCPP_USING_IF_EXISTS;
+using ::putchar _LIBCPP_USING_IF_EXISTS;
+using ::puts _LIBCPP_USING_IF_EXISTS;
+using ::vprintf _LIBCPP_USING_IF_EXISTS;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_CSTDIO
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/cstdlib b/contrib/libs/cxxsupp/libcxxmsvc/include/cstdlib
new file mode 100644
index 0000000000..82fe9efba8
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/cstdlib
@@ -0,0 +1,145 @@
+// -*- 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_CSTDLIB
+#define _LIBCPP_CSTDLIB
+
+/*
+ cstdlib synopsis
+
+Macros:
+
+ EXIT_FAILURE
+ EXIT_SUCCESS
+ MB_CUR_MAX
+ NULL
+ RAND_MAX
+
+namespace std
+{
+
+Types:
+
+ size_t
+ div_t
+ ldiv_t
+ lldiv_t // C99
+
+double atof (const char* nptr);
+int atoi (const char* nptr);
+long atol (const char* nptr);
+long long atoll(const char* nptr); // C99
+double strtod (const char* restrict nptr, char** restrict endptr);
+float strtof (const char* restrict nptr, char** restrict endptr); // C99
+long double strtold (const char* restrict nptr, char** restrict endptr); // C99
+long strtol (const char* restrict nptr, char** restrict endptr, int base);
+long long strtoll (const char* restrict nptr, char** restrict endptr, int base); // C99
+unsigned long strtoul (const char* restrict nptr, char** restrict endptr, int base);
+unsigned long long strtoull(const char* restrict nptr, char** restrict endptr, int base); // C99
+int rand(void);
+void srand(unsigned int seed);
+void* calloc(size_t nmemb, size_t size);
+void free(void* ptr);
+void* malloc(size_t size);
+void* realloc(void* ptr, size_t size);
+void abort(void);
+int atexit(void (*func)(void));
+void exit(int status);
+void _Exit(int status);
+char* getenv(const char* name);
+int system(const char* string);
+void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
+ int (*compar)(const void *, const void *));
+void qsort(void* base, size_t nmemb, size_t size,
+ int (*compar)(const void *, const void *));
+int abs( int j);
+long abs( long j);
+long long abs(long long j); // C++0X
+long labs( long j);
+long long llabs(long long j); // C99
+div_t div( int numer, int denom);
+ldiv_t div( long numer, long denom);
+lldiv_t div(long long numer, long long denom); // C++0X
+ldiv_t ldiv( long numer, long denom);
+lldiv_t lldiv(long long numer, long long denom); // C99
+int mblen(const char* s, size_t n);
+int mbtowc(wchar_t* restrict pwc, const char* restrict s, size_t n);
+int wctomb(char* s, wchar_t wchar);
+size_t mbstowcs(wchar_t* restrict pwcs, const char* restrict s, size_t n);
+size_t wcstombs(char* restrict s, const wchar_t* restrict pwcs, size_t n);
+int at_quick_exit(void (*func)(void)) // C++11
+void quick_exit(int status); // C++11
+void *aligned_alloc(size_t alignment, size_t size); // C11
+
+} // std
+
+*/
+
+#include <__config>
+#include <stdlib.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+using ::size_t _LIBCPP_USING_IF_EXISTS;
+using ::div_t _LIBCPP_USING_IF_EXISTS;
+using ::ldiv_t _LIBCPP_USING_IF_EXISTS;
+using ::lldiv_t _LIBCPP_USING_IF_EXISTS;
+using ::atof _LIBCPP_USING_IF_EXISTS;
+using ::atoi _LIBCPP_USING_IF_EXISTS;
+using ::atol _LIBCPP_USING_IF_EXISTS;
+using ::atoll _LIBCPP_USING_IF_EXISTS;
+using ::strtod _LIBCPP_USING_IF_EXISTS;
+using ::strtof _LIBCPP_USING_IF_EXISTS;
+using ::strtold _LIBCPP_USING_IF_EXISTS;
+using ::strtol _LIBCPP_USING_IF_EXISTS;
+using ::strtoll _LIBCPP_USING_IF_EXISTS;
+using ::strtoul _LIBCPP_USING_IF_EXISTS;
+using ::strtoull _LIBCPP_USING_IF_EXISTS;
+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 _LIBCPP_USING_IF_EXISTS;
+using ::system _LIBCPP_USING_IF_EXISTS;
+#endif
+using ::bsearch _LIBCPP_USING_IF_EXISTS;
+using ::qsort _LIBCPP_USING_IF_EXISTS;
+using ::abs _LIBCPP_USING_IF_EXISTS;
+using ::labs _LIBCPP_USING_IF_EXISTS;
+using ::llabs _LIBCPP_USING_IF_EXISTS;
+using ::div _LIBCPP_USING_IF_EXISTS;
+using ::ldiv _LIBCPP_USING_IF_EXISTS;
+using ::lldiv _LIBCPP_USING_IF_EXISTS;
+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 _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 _LIBCPP_USING_IF_EXISTS;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_CSTDLIB
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/cstring b/contrib/libs/cxxsupp/libcxxmsvc/include/cstring
new file mode 100644
index 0000000000..acf1c4d326
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/cstring
@@ -0,0 +1,94 @@
+// -*- 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_CSTRING
+#define _LIBCPP_CSTRING
+
+/*
+ cstring synopsis
+
+Macros:
+
+ NULL
+
+namespace std
+{
+
+Types:
+
+ size_t
+
+void* memcpy(void* restrict s1, const void* restrict s2, size_t n);
+void* memmove(void* s1, const void* s2, size_t n);
+char* strcpy (char* restrict s1, const char* restrict s2);
+char* strncpy(char* restrict s1, const char* restrict s2, size_t n);
+char* strcat (char* restrict s1, const char* restrict s2);
+char* strncat(char* restrict s1, const char* restrict s2, size_t n);
+int memcmp(const void* s1, const void* s2, size_t n);
+int strcmp (const char* s1, const char* s2);
+int strncmp(const char* s1, const char* s2, size_t n);
+int strcoll(const char* s1, const char* s2);
+size_t strxfrm(char* restrict s1, const char* restrict s2, size_t n);
+const void* memchr(const void* s, int c, size_t n);
+ void* memchr( void* s, int c, size_t n);
+const char* strchr(const char* s, int c);
+ char* strchr( char* s, int c);
+size_t strcspn(const char* s1, const char* s2);
+const char* strpbrk(const char* s1, const char* s2);
+ char* strpbrk( char* s1, const char* s2);
+const char* strrchr(const char* s, int c);
+ char* strrchr( char* s, int c);
+size_t strspn(const char* s1, const char* s2);
+const char* strstr(const char* s1, const char* s2);
+ char* strstr( char* s1, const char* s2);
+char* strtok(char* restrict s1, const char* restrict s2);
+void* memset(void* s, int c, size_t n);
+char* strerror(int errnum);
+size_t strlen(const char* s);
+
+} // std
+
+*/
+
+#include <__config>
+#include <string.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+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;
+using ::strtok _LIBCPP_USING_IF_EXISTS;
+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
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/ctime b/contrib/libs/cxxsupp/libcxxmsvc/include/ctime
new file mode 100644
index 0000000000..d5c094f2cc
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/ctime
@@ -0,0 +1,93 @@
+// -*- 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_CTIME
+#define _LIBCPP_CTIME
+
+/*
+ ctime synopsis
+
+Macros:
+
+ NULL
+ CLOCKS_PER_SEC
+ TIME_UTC // C++17
+
+namespace std
+{
+
+Types:
+
+ clock_t
+ size_t
+ time_t
+ tm
+ timespec // C++17
+
+clock_t clock();
+double difftime(time_t time1, time_t time0);
+time_t mktime(tm* timeptr);
+time_t time(time_t* timer);
+char* asctime(const tm* timeptr);
+char* ctime(const time_t* timer);
+tm* gmtime(const time_t* timer);
+tm* localtime(const time_t* timer);
+size_t strftime(char* restrict s, size_t maxsize, const char* restrict format,
+ const tm* restrict timeptr);
+int timespec_get( struct timespec *ts, int base); // C++17
+} // std
+
+*/
+
+#include <__config>
+#include <time.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+// FIXME:
+// Apple SDKs don't define ::timespec_get unconditionally in C++ mode. This
+// should be fixed in future SDKs, but for the time being we need to avoid
+// trying to use that declaration when the SDK doesn't provide it. Note that
+// we're detecting this here instead of in <__config> because we can't include
+// system headers from <__config>, since it leads to circular module dependencies.
+// This is also meant to be a very temporary workaround until the SDKs are fixed.
+#if defined(__APPLE__) && !__has_attribute(using_if_exists)
+# include <sys/cdefs.h>
+# if defined(_LIBCPP_HAS_TIMESPEC_GET) && (__DARWIN_C_LEVEL < __DARWIN_C_FULL)
+# define _LIBCPP_HAS_TIMESPEC_GET_NOT_ACTUALLY_PROVIDED
+# endif
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+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 _LIBCPP_USING_IF_EXISTS;
+#endif
+using ::clock _LIBCPP_USING_IF_EXISTS;
+using ::difftime _LIBCPP_USING_IF_EXISTS;
+using ::mktime _LIBCPP_USING_IF_EXISTS;
+using ::time _LIBCPP_USING_IF_EXISTS;
+using ::asctime _LIBCPP_USING_IF_EXISTS;
+using ::ctime _LIBCPP_USING_IF_EXISTS;
+using ::gmtime _LIBCPP_USING_IF_EXISTS;
+using ::localtime _LIBCPP_USING_IF_EXISTS;
+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 _LIBCPP_USING_IF_EXISTS;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_CTIME
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/ctype.h b/contrib/libs/cxxsupp/libcxxmsvc/include/ctype.h
new file mode 100644
index 0000000000..b1637504eb
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/ctype.h
@@ -0,0 +1,63 @@
+// -*- 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_CTYPE_H
+#define _LIBCPP_CTYPE_H
+
+/*
+ ctype.h synopsis
+
+int isalnum(int c);
+int isalpha(int c);
+int isblank(int c); // C99
+int iscntrl(int c);
+int isdigit(int c);
+int isgraph(int c);
+int islower(int c);
+int isprint(int c);
+int ispunct(int c);
+int isspace(int c);
+int isupper(int c);
+int isxdigit(int c);
+int tolower(int c);
+int toupper(int c);
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#include Y_UCRT_INCLUDE_NEXT(ctype.h)
+#else
+#include_next <ctype.h>
+#endif
+
+#ifdef __cplusplus
+
+#undef isalnum
+#undef isalpha
+#undef isblank
+#undef iscntrl
+#undef isdigit
+#undef isgraph
+#undef islower
+#undef isprint
+#undef ispunct
+#undef isspace
+#undef isupper
+#undef isxdigit
+#undef tolower
+#undef toupper
+
+#endif
+
+#endif // _LIBCPP_CTYPE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/cwchar b/contrib/libs/cxxsupp/libcxxmsvc/include/cwchar
new file mode 100644
index 0000000000..c4d85215a2
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/cwchar
@@ -0,0 +1,184 @@
+// -*- 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_CWCHAR
+#define _LIBCPP_CWCHAR
+
+/*
+ cwchar synopsis
+
+Macros:
+
+ NULL
+ WCHAR_MAX
+ WCHAR_MIN
+ WEOF
+
+namespace std
+{
+
+Types:
+
+ mbstate_t
+ size_t
+ tm
+ wint_t
+
+int fwprintf(FILE* restrict stream, const wchar_t* restrict format, ...);
+int fwscanf(FILE* restrict stream, const wchar_t* restrict format, ...);
+int swprintf(wchar_t* restrict s, size_t n, const wchar_t* restrict format, ...);
+int swscanf(const wchar_t* restrict s, const wchar_t* restrict format, ...);
+int vfwprintf(FILE* restrict stream, const wchar_t* restrict format, va_list arg);
+int vfwscanf(FILE* restrict stream, const wchar_t* restrict format, va_list arg); // C99
+int vswprintf(wchar_t* restrict s, size_t n, const wchar_t* restrict format, va_list arg);
+int vswscanf(const wchar_t* restrict s, const wchar_t* restrict format, va_list arg); // C99
+int vwprintf(const wchar_t* restrict format, va_list arg);
+int vwscanf(const wchar_t* restrict format, va_list arg); // C99
+int wprintf(const wchar_t* restrict format, ...);
+int wscanf(const wchar_t* restrict format, ...);
+wint_t fgetwc(FILE* stream);
+wchar_t* fgetws(wchar_t* restrict s, int n, FILE* restrict stream);
+wint_t fputwc(wchar_t c, FILE* stream);
+int fputws(const wchar_t* restrict s, FILE* restrict stream);
+int fwide(FILE* stream, int mode);
+wint_t getwc(FILE* stream);
+wint_t getwchar();
+wint_t putwc(wchar_t c, FILE* stream);
+wint_t putwchar(wchar_t c);
+wint_t ungetwc(wint_t c, FILE* stream);
+double wcstod(const wchar_t* restrict nptr, wchar_t** restrict endptr);
+float wcstof(const wchar_t* restrict nptr, wchar_t** restrict endptr); // C99
+long double wcstold(const wchar_t* restrict nptr, wchar_t** restrict endptr); // C99
+long wcstol(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
+long long wcstoll(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); // C99
+unsigned long wcstoul(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
+unsigned long long wcstoull(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); // C99
+wchar_t* wcscpy(wchar_t* restrict s1, const wchar_t* restrict s2);
+wchar_t* wcsncpy(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
+wchar_t* wcscat(wchar_t* restrict s1, const wchar_t* restrict s2);
+wchar_t* wcsncat(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
+int wcscmp(const wchar_t* s1, const wchar_t* s2);
+int wcscoll(const wchar_t* s1, const wchar_t* s2);
+int wcsncmp(const wchar_t* s1, const wchar_t* s2, size_t n);
+size_t wcsxfrm(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
+const wchar_t* wcschr(const wchar_t* s, wchar_t c);
+ wchar_t* wcschr( wchar_t* s, wchar_t c);
+size_t wcscspn(const wchar_t* s1, const wchar_t* s2);
+size_t wcslen(const wchar_t* s);
+const wchar_t* wcspbrk(const wchar_t* s1, const wchar_t* s2);
+ wchar_t* wcspbrk( wchar_t* s1, const wchar_t* s2);
+const wchar_t* wcsrchr(const wchar_t* s, wchar_t c);
+ wchar_t* wcsrchr( wchar_t* s, wchar_t c);
+size_t wcsspn(const wchar_t* s1, const wchar_t* s2);
+const wchar_t* wcsstr(const wchar_t* s1, const wchar_t* s2);
+ wchar_t* wcsstr( wchar_t* s1, const wchar_t* s2);
+wchar_t* wcstok(wchar_t* restrict s1, const wchar_t* restrict s2, wchar_t** restrict ptr);
+const wchar_t* wmemchr(const wchar_t* s, wchar_t c, size_t n);
+ wchar_t* wmemchr( wchar_t* s, wchar_t c, size_t n);
+int wmemcmp(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
+wchar_t* wmemcpy(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
+wchar_t* wmemmove(wchar_t* s1, const wchar_t* s2, size_t n);
+wchar_t* wmemset(wchar_t* s, wchar_t c, size_t n);
+size_t wcsftime(wchar_t* restrict s, size_t maxsize, const wchar_t* restrict format,
+ const tm* restrict timeptr);
+wint_t btowc(int c);
+int wctob(wint_t c);
+int mbsinit(const mbstate_t* ps);
+size_t mbrlen(const char* restrict s, size_t n, mbstate_t* restrict ps);
+size_t mbrtowc(wchar_t* restrict pwc, const char* restrict s, size_t n, mbstate_t* restrict ps);
+size_t wcrtomb(char* restrict s, wchar_t wc, mbstate_t* restrict ps);
+size_t mbsrtowcs(wchar_t* restrict dst, const char** restrict src, size_t len,
+ mbstate_t* restrict ps);
+size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
+ mbstate_t* restrict ps);
+
+} // std
+
+*/
+
+#include <__config>
+#include <cwctype>
+#include <wchar.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+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;
+using ::wcstoll _LIBCPP_USING_IF_EXISTS;
+using ::wcstoul _LIBCPP_USING_IF_EXISTS;
+using ::wcstoull _LIBCPP_USING_IF_EXISTS;
+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;
+
+using ::getwchar _LIBCPP_USING_IF_EXISTS;
+using ::vwscanf _LIBCPP_USING_IF_EXISTS;
+using ::wscanf _LIBCPP_USING_IF_EXISTS;
+
+using ::putwchar _LIBCPP_USING_IF_EXISTS;
+using ::vwprintf _LIBCPP_USING_IF_EXISTS;
+using ::wprintf _LIBCPP_USING_IF_EXISTS;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_CWCHAR
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/cwctype b/contrib/libs/cxxsupp/libcxxmsvc/include/cwctype
new file mode 100644
index 0000000000..b4434f62d4
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/cwctype
@@ -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_CWCTYPE
+#define _LIBCPP_CWCTYPE
+
+/*
+ cwctype synopsis
+
+Macros:
+
+ WEOF
+
+namespace std
+{
+
+Types:
+
+ wint_t
+ wctrans_t
+ wctype_t
+
+int iswalnum(wint_t wc);
+int iswalpha(wint_t wc);
+int iswblank(wint_t wc); // C99
+int iswcntrl(wint_t wc);
+int iswdigit(wint_t wc);
+int iswgraph(wint_t wc);
+int iswlower(wint_t wc);
+int iswprint(wint_t wc);
+int iswpunct(wint_t wc);
+int iswspace(wint_t wc);
+int iswupper(wint_t wc);
+int iswxdigit(wint_t wc);
+int iswctype(wint_t wc, wctype_t desc);
+wctype_t wctype(const char* property);
+wint_t towlower(wint_t wc);
+wint_t towupper(wint_t wc);
+wint_t towctrans(wint_t wc, wctrans_t desc);
+wctrans_t wctrans(const char* property);
+
+} // std
+
+*/
+
+#include <__config>
+#include <cctype>
+#include <wctype.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if defined(_LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H)
+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;
+#endif // _LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_CWCTYPE
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/deque b/contrib/libs/cxxsupp/libcxxmsvc/include/deque
new file mode 100644
index 0000000000..a4ab230742
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/deque
@@ -0,0 +1,3040 @@
+// -*- 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_DEQUE
+#define _LIBCPP_DEQUE
+
+/*
+ deque synopsis
+
+namespace std
+{
+
+template <class T, class Allocator = allocator<T> >
+class deque
+{
+public:
+ // types:
+ typedef T value_type;
+ typedef Allocator allocator_type;
+
+ typedef typename allocator_type::reference reference;
+ typedef typename allocator_type::const_reference const_reference;
+ typedef implementation-defined iterator;
+ typedef implementation-defined const_iterator;
+ typedef typename allocator_type::size_type size_type;
+ typedef typename allocator_type::difference_type difference_type;
+
+ typedef typename allocator_type::pointer pointer;
+ typedef typename allocator_type::const_pointer const_pointer;
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+
+ // construct/copy/destroy:
+ deque() noexcept(is_nothrow_default_constructible<allocator_type>::value);
+ explicit deque(const allocator_type& a);
+ explicit deque(size_type n);
+ explicit deque(size_type n, const allocator_type& a); // C++14
+ deque(size_type n, const value_type& v);
+ deque(size_type n, const value_type& v, const allocator_type& a);
+ template <class InputIterator>
+ deque(InputIterator f, InputIterator l);
+ template <class InputIterator>
+ deque(InputIterator f, InputIterator l, const allocator_type& a);
+ deque(const deque& c);
+ deque(deque&& c)
+ noexcept(is_nothrow_move_constructible<allocator_type>::value);
+ deque(initializer_list<value_type> il, const Allocator& a = allocator_type());
+ deque(const deque& c, const allocator_type& a);
+ deque(deque&& c, const allocator_type& a);
+ ~deque();
+
+ deque& operator=(const deque& c);
+ deque& operator=(deque&& c)
+ noexcept(
+ allocator_type::propagate_on_container_move_assignment::value &&
+ is_nothrow_move_assignable<allocator_type>::value);
+ deque& operator=(initializer_list<value_type> il);
+
+ template <class InputIterator>
+ void assign(InputIterator f, InputIterator l);
+ void assign(size_type n, const value_type& v);
+ void assign(initializer_list<value_type> il);
+
+ allocator_type get_allocator() const noexcept;
+
+ // iterators:
+
+ iterator begin() noexcept;
+ const_iterator begin() const noexcept;
+ iterator end() noexcept;
+ const_iterator end() const noexcept;
+
+ reverse_iterator rbegin() noexcept;
+ const_reverse_iterator rbegin() const noexcept;
+ reverse_iterator rend() noexcept;
+ const_reverse_iterator rend() const noexcept;
+
+ const_iterator cbegin() const noexcept;
+ const_iterator cend() const noexcept;
+ const_reverse_iterator crbegin() const noexcept;
+ const_reverse_iterator crend() const noexcept;
+
+ // capacity:
+ size_type size() const noexcept;
+ size_type max_size() const noexcept;
+ void resize(size_type n);
+ void resize(size_type n, const value_type& v);
+ void shrink_to_fit();
+ bool empty() const noexcept;
+
+ // element access:
+ reference operator[](size_type i);
+ const_reference operator[](size_type i) const;
+ reference at(size_type i);
+ const_reference at(size_type i) const;
+ reference front();
+ const_reference front() const;
+ reference back();
+ const_reference back() const;
+
+ // modifiers:
+ void push_front(const value_type& v);
+ void push_front(value_type&& v);
+ void push_back(const value_type& v);
+ void push_back(value_type&& v);
+ template <class... Args> reference emplace_front(Args&&... args); // reference in C++17
+ template <class... Args> reference emplace_back(Args&&... args); // reference in C++17
+ template <class... Args> iterator emplace(const_iterator p, Args&&... args);
+ iterator insert(const_iterator p, const value_type& v);
+ iterator insert(const_iterator p, value_type&& v);
+ iterator insert(const_iterator p, size_type n, const value_type& v);
+ template <class InputIterator>
+ iterator insert(const_iterator p, InputIterator f, InputIterator l);
+ iterator insert(const_iterator p, initializer_list<value_type> il);
+ void pop_front();
+ void pop_back();
+ iterator erase(const_iterator p);
+ iterator erase(const_iterator f, const_iterator l);
+ void swap(deque& c)
+ noexcept(allocator_traits<allocator_type>::is_always_equal::value); // C++17
+ void clear() noexcept;
+};
+
+template <class InputIterator, class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
+ deque(InputIterator, InputIterator, Allocator = Allocator())
+ -> deque<typename iterator_traits<InputIterator>::value_type, Allocator>; // C++17
+
+template <class T, class Allocator>
+ bool operator==(const deque<T,Allocator>& x, const deque<T,Allocator>& y);
+template <class T, class Allocator>
+ bool operator< (const deque<T,Allocator>& x, const deque<T,Allocator>& y);
+template <class T, class Allocator>
+ bool operator!=(const deque<T,Allocator>& x, const deque<T,Allocator>& y);
+template <class T, class Allocator>
+ bool operator> (const deque<T,Allocator>& x, const deque<T,Allocator>& y);
+template <class T, class Allocator>
+ bool operator>=(const deque<T,Allocator>& x, const deque<T,Allocator>& y);
+template <class T, class Allocator>
+ bool operator<=(const deque<T,Allocator>& x, const deque<T,Allocator>& y);
+
+// specialized algorithms:
+template <class T, class Allocator>
+ void swap(deque<T,Allocator>& x, deque<T,Allocator>& y)
+ noexcept(noexcept(x.swap(y)));
+
+template <class T, class Allocator, class U>
+ typename deque<T, Allocator>::size_type
+ erase(deque<T, Allocator>& c, const U& value); // C++20
+template <class T, class Allocator, class Predicate>
+ typename deque<T, Allocator>::size_type
+ erase_if(deque<T, Allocator>& c, Predicate pred); // C++20
+
+} // std
+
+*/
+
+#include <__algorithm/copy.h>
+#include <__algorithm/copy_backward.h>
+#include <__algorithm/equal.h>
+#include <__algorithm/fill_n.h>
+#include <__algorithm/lexicographical_compare.h>
+#include <__algorithm/min.h>
+#include <__algorithm/remove.h>
+#include <__algorithm/remove_if.h>
+#include <__algorithm/unwrap_iter.h>
+#include <__assert>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <__split_buffer>
+#include <__utility/forward.h>
+#include <compare>
+#include <initializer_list>
+#include <iterator>
+#include <limits>
+#include <stdexcept>
+#include <type_traits>
+#include <version>
+
+#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> class __deque_base;
+template <class _Tp, class _Allocator = allocator<_Tp> > class _LIBCPP_TEMPLATE_VIS deque;
+
+template <class _ValueType, class _Pointer, class _Reference, class _MapPointer,
+ class _DiffType, _DiffType _BlockSize>
+class _LIBCPP_TEMPLATE_VIS __deque_iterator;
+
+template <class _RAIter,
+ class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+copy(_RAIter __f,
+ _RAIter __l,
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
+ typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type* = 0);
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+ class _OutputIterator>
+_OutputIterator
+copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+ __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+ _OutputIterator __r);
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+ class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+ __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r);
+
+template <class _RAIter,
+ class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+copy_backward(_RAIter __f,
+ _RAIter __l,
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
+ typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type* = 0);
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+ class _OutputIterator>
+_OutputIterator
+copy_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+ __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+ _OutputIterator __r);
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+ class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+copy_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+ __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r);
+
+template <class _RAIter,
+ class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+move(_RAIter __f,
+ _RAIter __l,
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
+ typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type* = 0);
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+ class _OutputIterator>
+_OutputIterator
+move(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+ __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+ _OutputIterator __r);
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+ class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+move(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+ __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r);
+
+template <class _RAIter,
+ class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+move_backward(_RAIter __f,
+ _RAIter __l,
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
+ typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type* = 0);
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+ class _OutputIterator>
+_OutputIterator
+move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+ __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+ _OutputIterator __r);
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+ class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+ __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r);
+
+template <class _ValueType, class _DiffType>
+struct __deque_block_size {
+ static const _DiffType __buf_size = 64 * sizeof(void*);
+ static const _DiffType value = (__buf_size / sizeof(_ValueType)) > 2 ? (__buf_size / sizeof(_ValueType)) : 2;
+ //static const _DiffType value = sizeof(_ValueType) < 256 ? 4096 / sizeof(_ValueType) : 16;
+};
+
+template <class _ValueType, class _Pointer, class _Reference, class _MapPointer,
+ class _DiffType, _DiffType _BS =
+#ifdef _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
+// Keep template parameter to avoid changing all template declarations thoughout
+// this file.
+ 0
+#else
+ __deque_block_size<_ValueType, _DiffType>::value
+#endif
+ >
+class _LIBCPP_TEMPLATE_VIS __deque_iterator
+{
+ typedef _MapPointer __map_iterator;
+public:
+ typedef _Pointer pointer;
+ typedef _DiffType difference_type;
+private:
+ __map_iterator __m_iter_;
+ pointer __ptr_;
+
+ static const difference_type __block_size;
+public:
+ typedef _ValueType value_type;
+ typedef random_access_iterator_tag iterator_category;
+ typedef _Reference reference;
+
+ _LIBCPP_INLINE_VISIBILITY __deque_iterator() _NOEXCEPT
+#if _LIBCPP_STD_VER > 11
+ : __m_iter_(nullptr), __ptr_(nullptr)
+#endif
+ {}
+
+ template <class _Pp, class _Rp, class _MP>
+ _LIBCPP_INLINE_VISIBILITY
+ __deque_iterator(const __deque_iterator<value_type, _Pp, _Rp, _MP, difference_type, _BS>& __it,
+ typename enable_if<is_convertible<_Pp, pointer>::value>::type* = 0) _NOEXCEPT
+ : __m_iter_(__it.__m_iter_), __ptr_(__it.__ptr_) {}
+
+ _LIBCPP_INLINE_VISIBILITY reference operator*() const {return *__ptr_;}
+ _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return __ptr_;}
+
+ _LIBCPP_INLINE_VISIBILITY __deque_iterator& operator++()
+ {
+ if (++__ptr_ - *__m_iter_ == __block_size)
+ {
+ ++__m_iter_;
+ __ptr_ = *__m_iter_;
+ }
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY __deque_iterator operator++(int)
+ {
+ __deque_iterator __tmp = *this;
+ ++(*this);
+ return __tmp;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY __deque_iterator& operator--()
+ {
+ if (__ptr_ == *__m_iter_)
+ {
+ --__m_iter_;
+ __ptr_ = *__m_iter_ + __block_size;
+ }
+ --__ptr_;
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY __deque_iterator operator--(int)
+ {
+ __deque_iterator __tmp = *this;
+ --(*this);
+ return __tmp;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY __deque_iterator& operator+=(difference_type __n)
+ {
+ if (__n != 0)
+ {
+ __n += __ptr_ - *__m_iter_;
+ if (__n > 0)
+ {
+ __m_iter_ += __n / __block_size;
+ __ptr_ = *__m_iter_ + __n % __block_size;
+ }
+ else // (__n < 0)
+ {
+ difference_type __z = __block_size - 1 - __n;
+ __m_iter_ -= __z / __block_size;
+ __ptr_ = *__m_iter_ + (__block_size - 1 - __z % __block_size);
+ }
+ }
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY __deque_iterator& operator-=(difference_type __n)
+ {
+ return *this += -__n;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY __deque_iterator operator+(difference_type __n) const
+ {
+ __deque_iterator __t(*this);
+ __t += __n;
+ return __t;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY __deque_iterator operator-(difference_type __n) const
+ {
+ __deque_iterator __t(*this);
+ __t -= __n;
+ return __t;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ friend __deque_iterator operator+(difference_type __n, const __deque_iterator& __it)
+ {return __it + __n;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ friend difference_type operator-(const __deque_iterator& __x, const __deque_iterator& __y)
+ {
+ if (__x != __y)
+ return (__x.__m_iter_ - __y.__m_iter_) * __block_size
+ + (__x.__ptr_ - *__x.__m_iter_)
+ - (__y.__ptr_ - *__y.__m_iter_);
+ return 0;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY reference operator[](difference_type __n) const
+ {return *(*this + __n);}
+
+ _LIBCPP_INLINE_VISIBILITY friend
+ bool operator==(const __deque_iterator& __x, const __deque_iterator& __y)
+ {return __x.__ptr_ == __y.__ptr_;}
+
+ _LIBCPP_INLINE_VISIBILITY friend
+ bool operator!=(const __deque_iterator& __x, const __deque_iterator& __y)
+ {return !(__x == __y);}
+
+ _LIBCPP_INLINE_VISIBILITY friend
+ bool operator<(const __deque_iterator& __x, const __deque_iterator& __y)
+ {return __x.__m_iter_ < __y.__m_iter_ ||
+ (__x.__m_iter_ == __y.__m_iter_ && __x.__ptr_ < __y.__ptr_);}
+
+ _LIBCPP_INLINE_VISIBILITY friend
+ bool operator>(const __deque_iterator& __x, const __deque_iterator& __y)
+ {return __y < __x;}
+
+ _LIBCPP_INLINE_VISIBILITY friend
+ bool operator<=(const __deque_iterator& __x, const __deque_iterator& __y)
+ {return !(__y < __x);}
+
+ _LIBCPP_INLINE_VISIBILITY friend
+ bool operator>=(const __deque_iterator& __x, const __deque_iterator& __y)
+ {return !(__x < __y);}
+
+private:
+ _LIBCPP_INLINE_VISIBILITY __deque_iterator(__map_iterator __m, pointer __p) _NOEXCEPT
+ : __m_iter_(__m), __ptr_(__p) {}
+
+ template <class _Tp, class _Ap> friend class __deque_base;
+ template <class _Tp, class _Ap> friend class _LIBCPP_TEMPLATE_VIS deque;
+ template <class _Vp, class _Pp, class _Rp, class _MP, class _Dp, _Dp>
+ friend class _LIBCPP_TEMPLATE_VIS __deque_iterator;
+
+ template <class _RAIter,
+ class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+ friend
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+ copy(_RAIter __f,
+ _RAIter __l,
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
+ typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type*);
+
+ template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+ class _OutputIterator>
+ friend
+ _OutputIterator
+ copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+ __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+ _OutputIterator __r);
+
+ template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+ class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+ friend
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+ copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+ __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r);
+
+ template <class _RAIter,
+ class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+ friend
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+ copy_backward(_RAIter __f,
+ _RAIter __l,
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
+ typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type*);
+
+ template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+ class _OutputIterator>
+ friend
+ _OutputIterator
+ copy_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+ __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+ _OutputIterator __r);
+
+ template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+ class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+ friend
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+ copy_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+ __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r);
+
+ template <class _RAIter,
+ class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+ friend
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+ move(_RAIter __f,
+ _RAIter __l,
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
+ typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type*);
+
+ template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+ class _OutputIterator>
+ friend
+ _OutputIterator
+ move(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+ __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+ _OutputIterator __r);
+
+ template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+ class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+ friend
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+ move(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+ __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r);
+
+ template <class _RAIter,
+ class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+ friend
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+ move_backward(_RAIter __f,
+ _RAIter __l,
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
+ typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type*);
+
+ template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+ class _OutputIterator>
+ friend
+ _OutputIterator
+ move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+ __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+ _OutputIterator __r);
+
+ template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+ class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+ friend
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+ move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+ __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r);
+};
+
+template <class _ValueType, class _Pointer, class _Reference, class _MapPointer,
+ class _DiffType, _DiffType _BlockSize>
+const _DiffType __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer,
+ _DiffType, _BlockSize>::__block_size =
+ __deque_block_size<_ValueType, _DiffType>::value;
+
+// copy
+
+template <class _RAIter,
+ class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+copy(_RAIter __f,
+ _RAIter __l,
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
+ typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type*)
+{
+ typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::difference_type difference_type;
+ typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::pointer pointer;
+ const difference_type __block_size = __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::__block_size;
+ while (__f != __l)
+ {
+ pointer __rb = __r.__ptr_;
+ pointer __re = *__r.__m_iter_ + __block_size;
+ difference_type __bs = __re - __rb;
+ difference_type __n = __l - __f;
+ _RAIter __m = __l;
+ if (__n > __bs)
+ {
+ __n = __bs;
+ __m = __f + __n;
+ }
+ _VSTD::copy(__f, __m, __rb);
+ __f = __m;
+ __r += __n;
+ }
+ return __r;
+}
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+ class _OutputIterator>
+_OutputIterator
+copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+ __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+ _OutputIterator __r)
+{
+ typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type;
+ typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer;
+ const difference_type __block_size = __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::__block_size;
+ difference_type __n = __l - __f;
+ while (__n > 0)
+ {
+ pointer __fb = __f.__ptr_;
+ pointer __fe = *__f.__m_iter_ + __block_size;
+ difference_type __bs = __fe - __fb;
+ if (__bs > __n)
+ {
+ __bs = __n;
+ __fe = __fb + __bs;
+ }
+ __r = _VSTD::copy(__fb, __fe, __r);
+ __n -= __bs;
+ __f += __bs;
+ }
+ return __r;
+}
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+ class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+ __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r)
+{
+ typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type;
+ typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer;
+ const difference_type __block_size = __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::__block_size;
+ difference_type __n = __l - __f;
+ while (__n > 0)
+ {
+ pointer __fb = __f.__ptr_;
+ pointer __fe = *__f.__m_iter_ + __block_size;
+ difference_type __bs = __fe - __fb;
+ if (__bs > __n)
+ {
+ __bs = __n;
+ __fe = __fb + __bs;
+ }
+ __r = _VSTD::copy(__fb, __fe, __r);
+ __n -= __bs;
+ __f += __bs;
+ }
+ return __r;
+}
+
+// copy_backward
+
+template <class _RAIter,
+ class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+copy_backward(_RAIter __f,
+ _RAIter __l,
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
+ typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type*)
+{
+ typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::difference_type difference_type;
+ typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::pointer pointer;
+ while (__f != __l)
+ {
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __rp = _VSTD::prev(__r);
+ pointer __rb = *__rp.__m_iter_;
+ pointer __re = __rp.__ptr_ + 1;
+ difference_type __bs = __re - __rb;
+ difference_type __n = __l - __f;
+ _RAIter __m = __f;
+ if (__n > __bs)
+ {
+ __n = __bs;
+ __m = __l - __n;
+ }
+ _VSTD::copy_backward(__m, __l, __re);
+ __l = __m;
+ __r -= __n;
+ }
+ return __r;
+}
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+ class _OutputIterator>
+_OutputIterator
+copy_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+ __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+ _OutputIterator __r)
+{
+ typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type;
+ typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer;
+ difference_type __n = __l - __f;
+ while (__n > 0)
+ {
+ --__l;
+ pointer __lb = *__l.__m_iter_;
+ pointer __le = __l.__ptr_ + 1;
+ difference_type __bs = __le - __lb;
+ if (__bs > __n)
+ {
+ __bs = __n;
+ __lb = __le - __bs;
+ }
+ __r = _VSTD::copy_backward(__lb, __le, __r);
+ __n -= __bs;
+ __l -= __bs - 1;
+ }
+ return __r;
+}
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+ class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+copy_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+ __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r)
+{
+ typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type;
+ typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer;
+ difference_type __n = __l - __f;
+ while (__n > 0)
+ {
+ --__l;
+ pointer __lb = *__l.__m_iter_;
+ pointer __le = __l.__ptr_ + 1;
+ difference_type __bs = __le - __lb;
+ if (__bs > __n)
+ {
+ __bs = __n;
+ __lb = __le - __bs;
+ }
+ __r = _VSTD::copy_backward(__lb, __le, __r);
+ __n -= __bs;
+ __l -= __bs - 1;
+ }
+ return __r;
+}
+
+// move
+
+template <class _RAIter,
+ class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+move(_RAIter __f,
+ _RAIter __l,
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
+ typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type*)
+{
+ typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::difference_type difference_type;
+ typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::pointer pointer;
+ const difference_type __block_size = __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::__block_size;
+ while (__f != __l)
+ {
+ pointer __rb = __r.__ptr_;
+ pointer __re = *__r.__m_iter_ + __block_size;
+ difference_type __bs = __re - __rb;
+ difference_type __n = __l - __f;
+ _RAIter __m = __l;
+ if (__n > __bs)
+ {
+ __n = __bs;
+ __m = __f + __n;
+ }
+ _VSTD::move(__f, __m, __rb);
+ __f = __m;
+ __r += __n;
+ }
+ return __r;
+}
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+ class _OutputIterator>
+_OutputIterator
+move(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+ __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+ _OutputIterator __r)
+{
+ typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type;
+ typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer;
+ const difference_type __block_size = __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::__block_size;
+ difference_type __n = __l - __f;
+ while (__n > 0)
+ {
+ pointer __fb = __f.__ptr_;
+ pointer __fe = *__f.__m_iter_ + __block_size;
+ difference_type __bs = __fe - __fb;
+ if (__bs > __n)
+ {
+ __bs = __n;
+ __fe = __fb + __bs;
+ }
+ __r = _VSTD::move(__fb, __fe, __r);
+ __n -= __bs;
+ __f += __bs;
+ }
+ return __r;
+}
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+ class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+move(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+ __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r)
+{
+ typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type;
+ typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer;
+ const difference_type __block_size = __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::__block_size;
+ difference_type __n = __l - __f;
+ while (__n > 0)
+ {
+ pointer __fb = __f.__ptr_;
+ pointer __fe = *__f.__m_iter_ + __block_size;
+ difference_type __bs = __fe - __fb;
+ if (__bs > __n)
+ {
+ __bs = __n;
+ __fe = __fb + __bs;
+ }
+ __r = _VSTD::move(__fb, __fe, __r);
+ __n -= __bs;
+ __f += __bs;
+ }
+ return __r;
+}
+
+// move_backward
+
+template <class _RAIter,
+ class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+move_backward(_RAIter __f,
+ _RAIter __l,
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
+ typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type*)
+{
+ typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::difference_type difference_type;
+ typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::pointer pointer;
+ while (__f != __l)
+ {
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __rp = _VSTD::prev(__r);
+ pointer __rb = *__rp.__m_iter_;
+ pointer __re = __rp.__ptr_ + 1;
+ difference_type __bs = __re - __rb;
+ difference_type __n = __l - __f;
+ _RAIter __m = __f;
+ if (__n > __bs)
+ {
+ __n = __bs;
+ __m = __l - __n;
+ }
+ _VSTD::move_backward(__m, __l, __re);
+ __l = __m;
+ __r -= __n;
+ }
+ return __r;
+}
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+ class _OutputIterator>
+_OutputIterator
+move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+ __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+ _OutputIterator __r)
+{
+ typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type;
+ typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer;
+ difference_type __n = __l - __f;
+ while (__n > 0)
+ {
+ --__l;
+ pointer __lb = *__l.__m_iter_;
+ pointer __le = __l.__ptr_ + 1;
+ difference_type __bs = __le - __lb;
+ if (__bs > __n)
+ {
+ __bs = __n;
+ __lb = __le - __bs;
+ }
+ __r = _VSTD::move_backward(__lb, __le, __r);
+ __n -= __bs;
+ __l -= __bs - 1;
+ }
+ return __r;
+}
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+ class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+ __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r)
+{
+ typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type;
+ typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer;
+ difference_type __n = __l - __f;
+ while (__n > 0)
+ {
+ --__l;
+ pointer __lb = *__l.__m_iter_;
+ pointer __le = __l.__ptr_ + 1;
+ difference_type __bs = __le - __lb;
+ if (__bs > __n)
+ {
+ __bs = __n;
+ __lb = __le - __bs;
+ }
+ __r = _VSTD::move_backward(__lb, __le, __r);
+ __n -= __bs;
+ __l -= __bs - 1;
+ }
+ return __r;
+}
+
+template <class _Tp, class _Allocator>
+class __deque_base
+{
+ __deque_base(const __deque_base& __c);
+ __deque_base& operator=(const __deque_base& __c);
+public:
+ typedef _Allocator allocator_type;
+ typedef allocator_traits<allocator_type> __alloc_traits;
+ typedef typename __alloc_traits::size_type size_type;
+
+ typedef _Tp value_type;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef typename __alloc_traits::difference_type difference_type;
+ typedef typename __alloc_traits::pointer pointer;
+ typedef typename __alloc_traits::const_pointer const_pointer;
+
+ static const difference_type __block_size;
+
+ typedef typename __rebind_alloc_helper<__alloc_traits, pointer>::type __pointer_allocator;
+ typedef allocator_traits<__pointer_allocator> __map_traits;
+ typedef typename __map_traits::pointer __map_pointer;
+ typedef typename __rebind_alloc_helper<__alloc_traits, const_pointer>::type __const_pointer_allocator;
+ typedef typename allocator_traits<__const_pointer_allocator>::const_pointer __map_const_pointer;
+ typedef __split_buffer<pointer, __pointer_allocator> __map;
+
+ typedef __deque_iterator<value_type, pointer, reference, __map_pointer,
+ difference_type> iterator;
+ typedef __deque_iterator<value_type, const_pointer, const_reference, __map_const_pointer,
+ difference_type> const_iterator;
+
+ struct __deque_block_range {
+ explicit __deque_block_range(pointer __b, pointer __e) _NOEXCEPT : __begin_(__b), __end_(__e) {}
+ const pointer __begin_;
+ const pointer __end_;
+ };
+
+ struct __deque_range {
+ iterator __pos_;
+ const iterator __end_;
+
+ __deque_range(iterator __pos, iterator __e) _NOEXCEPT
+ : __pos_(__pos), __end_(__e) {}
+
+ explicit operator bool() const _NOEXCEPT {
+ return __pos_ != __end_;
+ }
+
+ __deque_range begin() const {
+ return *this;
+ }
+
+ __deque_range end() const {
+ return __deque_range(__end_, __end_);
+ }
+ __deque_block_range operator*() const _NOEXCEPT {
+ if (__pos_.__m_iter_ == __end_.__m_iter_) {
+ return __deque_block_range(__pos_.__ptr_, __end_.__ptr_);
+ }
+ return __deque_block_range(__pos_.__ptr_, *__pos_.__m_iter_ + __block_size);
+ }
+
+ __deque_range& operator++() _NOEXCEPT {
+ if (__pos_.__m_iter_ == __end_.__m_iter_) {
+ __pos_ = __end_;
+ } else {
+ ++__pos_.__m_iter_;
+ __pos_.__ptr_ = *__pos_.__m_iter_;
+ }
+ return *this;
+ }
+
+
+ friend bool operator==(__deque_range const& __lhs, __deque_range const& __rhs) {
+ return __lhs.__pos_ == __rhs.__pos_;
+ }
+ friend bool operator!=(__deque_range const& __lhs, __deque_range const& __rhs) {
+ return !(__lhs == __rhs);
+ }
+ };
+
+
+
+ struct _ConstructTransaction {
+ _ConstructTransaction(__deque_base* __db, __deque_block_range& __r)
+ : __pos_(__r.__begin_), __end_(__r.__end_), __begin_(__r.__begin_), __base_(__db) {}
+
+
+ ~_ConstructTransaction() {
+ __base_->size() += (__pos_ - __begin_);
+ }
+
+ pointer __pos_;
+ const pointer __end_;
+ private:
+ const pointer __begin_;
+ __deque_base * const __base_;
+ };
+
+protected:
+ __map __map_;
+ size_type __start_;
+ __compressed_pair<size_type, allocator_type> __size_;
+
+ iterator begin() _NOEXCEPT;
+ const_iterator begin() const _NOEXCEPT;
+ iterator end() _NOEXCEPT;
+ const_iterator end() const _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY size_type& size() {return __size_.first();}
+ _LIBCPP_INLINE_VISIBILITY
+ const size_type& size() const _NOEXCEPT {return __size_.first();}
+ _LIBCPP_INLINE_VISIBILITY allocator_type& __alloc() {return __size_.second();}
+ _LIBCPP_INLINE_VISIBILITY
+ const allocator_type& __alloc() const _NOEXCEPT {return __size_.second();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __deque_base()
+ _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __deque_base(const allocator_type& __a);
+public:
+ ~__deque_base();
+
+#ifndef _LIBCPP_CXX03_LANG
+ __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
+
+ void swap(__deque_base& __c)
+#if _LIBCPP_STD_VER >= 14
+ _NOEXCEPT;
+#else
+ _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
+ __is_nothrow_swappable<allocator_type>::value);
+#endif
+protected:
+ void clear() _NOEXCEPT;
+
+ bool __invariants() const;
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __move_assign(__deque_base& __c)
+ _NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value &&
+ is_nothrow_move_assignable<allocator_type>::value)
+ {
+ __map_ = _VSTD::move(__c.__map_);
+ __start_ = __c.__start_;
+ size() = __c.size();
+ __move_assign_alloc(__c);
+ __c.__start_ = __c.size() = 0;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __move_assign_alloc(__deque_base& __c)
+ _NOEXCEPT_(!__alloc_traits::propagate_on_container_move_assignment::value ||
+ is_nothrow_move_assignable<allocator_type>::value)
+ {__move_assign_alloc(__c, integral_constant<bool,
+ __alloc_traits::propagate_on_container_move_assignment::value>());}
+
+private:
+ _LIBCPP_INLINE_VISIBILITY
+ void __move_assign_alloc(__deque_base& __c, true_type)
+ _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
+ {
+ __alloc() = _VSTD::move(__c.__alloc());
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __move_assign_alloc(__deque_base&, false_type) _NOEXCEPT
+ {}
+};
+
+template <class _Tp, class _Allocator>
+const typename __deque_base<_Tp, _Allocator>::difference_type
+ __deque_base<_Tp, _Allocator>::__block_size =
+ __deque_block_size<value_type, difference_type>::value;
+
+template <class _Tp, class _Allocator>
+bool
+__deque_base<_Tp, _Allocator>::__invariants() const
+{
+ if (!__map_.__invariants())
+ return false;
+ if (__map_.size() >= size_type(-1) / __block_size)
+ return false;
+ for (typename __map::const_iterator __i = __map_.begin(), __e = __map_.end();
+ __i != __e; ++__i)
+ if (*__i == nullptr)
+ return false;
+ if (__map_.size() != 0)
+ {
+ if (size() >= __map_.size() * __block_size)
+ return false;
+ if (__start_ >= __map_.size() * __block_size - size())
+ return false;
+ }
+ else
+ {
+ if (size() != 0)
+ return false;
+ if (__start_ != 0)
+ return false;
+ }
+ return true;
+}
+
+template <class _Tp, class _Allocator>
+typename __deque_base<_Tp, _Allocator>::iterator
+__deque_base<_Tp, _Allocator>::begin() _NOEXCEPT
+{
+ __map_pointer __mp = __map_.begin() + __start_ / __block_size;
+ return iterator(__mp, __map_.empty() ? 0 : *__mp + __start_ % __block_size);
+}
+
+template <class _Tp, class _Allocator>
+typename __deque_base<_Tp, _Allocator>::const_iterator
+__deque_base<_Tp, _Allocator>::begin() const _NOEXCEPT
+{
+ __map_const_pointer __mp = static_cast<__map_const_pointer>(__map_.begin() + __start_ / __block_size);
+ return const_iterator(__mp, __map_.empty() ? 0 : *__mp + __start_ % __block_size);
+}
+
+template <class _Tp, class _Allocator>
+typename __deque_base<_Tp, _Allocator>::iterator
+__deque_base<_Tp, _Allocator>::end() _NOEXCEPT
+{
+ size_type __p = size() + __start_;
+ __map_pointer __mp = __map_.begin() + __p / __block_size;
+ return iterator(__mp, __map_.empty() ? 0 : *__mp + __p % __block_size);
+}
+
+template <class _Tp, class _Allocator>
+typename __deque_base<_Tp, _Allocator>::const_iterator
+__deque_base<_Tp, _Allocator>::end() const _NOEXCEPT
+{
+ size_type __p = size() + __start_;
+ __map_const_pointer __mp = static_cast<__map_const_pointer>(__map_.begin() + __p / __block_size);
+ return const_iterator(__mp, __map_.empty() ? 0 : *__mp + __p % __block_size);
+}
+
+template <class _Tp, class _Allocator>
+inline
+__deque_base<_Tp, _Allocator>::__deque_base()
+ _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
+ : __start_(0), __size_(0, __default_init_tag()) {}
+
+template <class _Tp, class _Allocator>
+inline
+__deque_base<_Tp, _Allocator>::__deque_base(const allocator_type& __a)
+ : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) {}
+
+template <class _Tp, class _Allocator>
+__deque_base<_Tp, _Allocator>::~__deque_base()
+{
+ clear();
+ typename __map::iterator __i = __map_.begin();
+ typename __map::iterator __e = __map_.end();
+ for (; __i != __e; ++__i)
+ __alloc_traits::deallocate(__alloc(), *__i, __block_size);
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Allocator>
+__deque_base<_Tp, _Allocator>::__deque_base(__deque_base&& __c)
+ _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
+ : __map_(_VSTD::move(__c.__map_)),
+ __start_(_VSTD::move(__c.__start_)),
+ __size_(_VSTD::move(__c.__size_))
+{
+ __c.__start_ = 0;
+ __c.size() = 0;
+}
+
+template <class _Tp, class _Allocator>
+__deque_base<_Tp, _Allocator>::__deque_base(__deque_base&& __c, const allocator_type& __a)
+ : __map_(_VSTD::move(__c.__map_), __pointer_allocator(__a)),
+ __start_(_VSTD::move(__c.__start_)),
+ __size_(_VSTD::move(__c.size()), __a)
+{
+ if (__a == __c.__alloc())
+ {
+ __c.__start_ = 0;
+ __c.size() = 0;
+ }
+ else
+ {
+ __map_.clear();
+ __start_ = 0;
+ size() = 0;
+ }
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Allocator>
+void
+__deque_base<_Tp, _Allocator>::swap(__deque_base& __c)
+#if _LIBCPP_STD_VER >= 14
+ _NOEXCEPT
+#else
+ _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
+ __is_nothrow_swappable<allocator_type>::value)
+#endif
+{
+ __map_.swap(__c.__map_);
+ _VSTD::swap(__start_, __c.__start_);
+ _VSTD::swap(size(), __c.size());
+ _VSTD::__swap_allocator(__alloc(), __c.__alloc());
+}
+
+template <class _Tp, class _Allocator>
+void
+__deque_base<_Tp, _Allocator>::clear() _NOEXCEPT
+{
+ allocator_type& __a = __alloc();
+ for (iterator __i = begin(), __e = end(); __i != __e; ++__i)
+ __alloc_traits::destroy(__a, _VSTD::addressof(*__i));
+ size() = 0;
+ while (__map_.size() > 2)
+ {
+ __alloc_traits::deallocate(__a, __map_.front(), __block_size);
+ __map_.pop_front();
+ }
+ switch (__map_.size())
+ {
+ case 1:
+ __start_ = __block_size / 2;
+ break;
+ case 2:
+ __start_ = __block_size;
+ break;
+ }
+}
+
+template <class _Tp, class _Allocator /*= allocator<_Tp>*/>
+class _LIBCPP_TEMPLATE_VIS deque
+ : private __deque_base<_Tp, _Allocator>
+{
+public:
+ // types:
+
+ typedef _Tp value_type;
+ typedef _Allocator allocator_type;
+
+ static_assert((is_same<typename allocator_type::value_type, value_type>::value),
+ "Allocator::value_type must be same type as value_type");
+
+ typedef __deque_base<value_type, allocator_type> __base;
+
+ typedef typename __base::__alloc_traits __alloc_traits;
+ typedef typename __base::reference reference;
+ typedef typename __base::const_reference const_reference;
+ typedef typename __base::iterator iterator;
+ typedef typename __base::const_iterator const_iterator;
+ typedef typename __base::size_type size_type;
+ typedef typename __base::difference_type difference_type;
+
+ typedef typename __base::pointer pointer;
+ typedef typename __base::const_pointer const_pointer;
+ typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
+ typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
+
+ using typename __base::__deque_range;
+ using typename __base::__deque_block_range;
+ using typename __base::_ConstructTransaction;
+
+ // construct/copy/destroy:
+ _LIBCPP_INLINE_VISIBILITY
+ deque()
+ _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
+ {}
+ _LIBCPP_INLINE_VISIBILITY explicit deque(const allocator_type& __a) : __base(__a) {}
+ explicit deque(size_type __n);
+#if _LIBCPP_STD_VER > 11
+ explicit deque(size_type __n, const _Allocator& __a);
+#endif
+ deque(size_type __n, const value_type& __v);
+
+ template <class = __enable_if_t<__is_allocator<_Allocator>::value> >
+ deque(size_type __n, const value_type& __v, const allocator_type& __a) : __base(__a)
+ {
+ if (__n > 0)
+ __append(__n, __v);
+ }
+
+ template <class _InputIter>
+ deque(_InputIter __f, _InputIter __l,
+ typename enable_if<__is_cpp17_input_iterator<_InputIter>::value>::type* = 0);
+ template <class _InputIter>
+ 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 __identity_t<allocator_type>& __a);
+
+ deque& operator=(const deque& __c);
+
+#ifndef _LIBCPP_CXX03_LANG
+ deque(initializer_list<value_type> __il);
+ deque(initializer_list<value_type> __il, const allocator_type& __a);
+
+ _LIBCPP_INLINE_VISIBILITY
+ deque& operator=(initializer_list<value_type> __il) {assign(__il); return *this;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ deque(deque&& __c) _NOEXCEPT_(is_nothrow_move_constructible<__base>::value);
+ _LIBCPP_INLINE_VISIBILITY
+ 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 &&
+ is_nothrow_move_assignable<allocator_type>::value);
+
+ _LIBCPP_INLINE_VISIBILITY
+ void assign(initializer_list<value_type> __il) {assign(__il.begin(), __il.end());}
+#endif // _LIBCPP_CXX03_LANG
+
+ template <class _InputIter>
+ void assign(_InputIter __f, _InputIter __l,
+ typename enable_if<__is_cpp17_input_iterator<_InputIter>::value &&
+ !__is_cpp17_random_access_iterator<_InputIter>::value>::type* = 0);
+ template <class _RAIter>
+ void assign(_RAIter __f, _RAIter __l,
+ typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type* = 0);
+ void assign(size_type __n, const value_type& __v);
+
+ _LIBCPP_INLINE_VISIBILITY
+ allocator_type get_allocator() const _NOEXCEPT;
+
+ // iterators:
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator begin() _NOEXCEPT {return __base::begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator begin() const _NOEXCEPT {return __base::begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator end() _NOEXCEPT {return __base::end();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator end() const _NOEXCEPT {return __base::end();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ reverse_iterator rbegin() _NOEXCEPT
+ {return reverse_iterator(__base::end());}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator rbegin() const _NOEXCEPT
+ {return const_reverse_iterator(__base::end());}
+ _LIBCPP_INLINE_VISIBILITY
+ reverse_iterator rend() _NOEXCEPT
+ {return reverse_iterator(__base::begin());}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator rend() const _NOEXCEPT
+ {return const_reverse_iterator(__base::begin());}
+
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator cbegin() const _NOEXCEPT
+ {return __base::begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator cend() const _NOEXCEPT
+ {return __base::end();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator crbegin() const _NOEXCEPT
+ {return const_reverse_iterator(__base::end());}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator crend() const _NOEXCEPT
+ {return const_reverse_iterator(__base::begin());}
+
+ // capacity:
+ _LIBCPP_INLINE_VISIBILITY
+ size_type size() const _NOEXCEPT {return __base::size();}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type max_size() const _NOEXCEPT
+ {return _VSTD::min<size_type>(
+ __alloc_traits::max_size(__base::__alloc()),
+ numeric_limits<difference_type>::max());}
+ void resize(size_type __n);
+ void resize(size_type __n, const value_type& __v);
+ void shrink_to_fit() _NOEXCEPT;
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+ bool empty() const _NOEXCEPT {return __base::size() == 0;}
+
+ // element access:
+ _LIBCPP_INLINE_VISIBILITY
+ reference operator[](size_type __i) _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ const_reference operator[](size_type __i) const _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ reference at(size_type __i);
+ _LIBCPP_INLINE_VISIBILITY
+ const_reference at(size_type __i) const;
+ _LIBCPP_INLINE_VISIBILITY
+ reference front() _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ const_reference front() const _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ reference back() _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ const_reference back() const _NOEXCEPT;
+
+ // 23.2.2.3 modifiers:
+ void push_front(const value_type& __v);
+ void push_back(const value_type& __v);
+#ifndef _LIBCPP_CXX03_LANG
+#if _LIBCPP_STD_VER > 14
+ template <class... _Args> reference emplace_front(_Args&&... __args);
+ template <class... _Args> reference emplace_back (_Args&&... __args);
+#else
+ template <class... _Args> void emplace_front(_Args&&... __args);
+ template <class... _Args> void emplace_back (_Args&&... __args);
+#endif
+ template <class... _Args> iterator emplace(const_iterator __p, _Args&&... __args);
+
+ void push_front(value_type&& __v);
+ void push_back(value_type&& __v);
+ iterator insert(const_iterator __p, value_type&& __v);
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const_iterator __p, initializer_list<value_type> __il)
+ {return insert(__p, __il.begin(), __il.end());}
+#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>
+ iterator insert(const_iterator __p, _InputIter __f, _InputIter __l,
+ typename enable_if<__is_cpp17_input_iterator<_InputIter>::value
+ &&!__is_cpp17_forward_iterator<_InputIter>::value>::type* = 0);
+ template <class _ForwardIterator>
+ iterator insert(const_iterator __p, _ForwardIterator __f, _ForwardIterator __l,
+ typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value
+ &&!__is_cpp17_bidirectional_iterator<_ForwardIterator>::value>::type* = 0);
+ template <class _BiIter>
+ iterator insert(const_iterator __p, _BiIter __f, _BiIter __l,
+ typename enable_if<__is_cpp17_bidirectional_iterator<_BiIter>::value>::type* = 0);
+
+ void pop_front();
+ void pop_back();
+ iterator erase(const_iterator __p);
+ iterator erase(const_iterator __f, const_iterator __l);
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(deque& __c)
+#if _LIBCPP_STD_VER >= 14
+ _NOEXCEPT;
+#else
+ _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
+ __is_nothrow_swappable<allocator_type>::value);
+#endif
+ _LIBCPP_REINITIALIZES_OBJECT _LIBCPP_INLINE_VISIBILITY
+ void clear() _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool __invariants() const {return __base::__invariants();}
+
+ typedef typename __base::__map_const_pointer __map_const_pointer;
+
+ _LIBCPP_INLINE_VISIBILITY
+ static size_type __recommend_blocks(size_type __n)
+ {
+ return __n / __base::__block_size + (__n % __base::__block_size != 0);
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ size_type __capacity() const
+ {
+ return __base::__map_.size() == 0 ? 0 : __base::__map_.size() * __base::__block_size - 1;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ size_type __block_count() const
+ {
+ return __base::__map_.size();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type __front_spare() const
+ {
+ return __base::__start_;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ size_type __front_spare_blocks() const {
+ return __front_spare() / __base::__block_size;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ size_type __back_spare() const
+ {
+ return __capacity() - (__base::__start_ + __base::size());
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ size_type __back_spare_blocks() const {
+ return __back_spare() / __base::__block_size;
+ }
+
+ private:
+ _LIBCPP_INLINE_VISIBILITY
+ bool __maybe_remove_front_spare(bool __keep_one = true) {
+ if (__front_spare_blocks() >= 2 || (!__keep_one && __front_spare_blocks())) {
+ __alloc_traits::deallocate(__base::__alloc(), __base::__map_.front(),
+ __base::__block_size);
+ __base::__map_.pop_front();
+ __base::__start_ -= __base::__block_size;
+ return true;
+ }
+ return false;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool __maybe_remove_back_spare(bool __keep_one = true) {
+ if (__back_spare_blocks() >= 2 || (!__keep_one && __back_spare_blocks())) {
+ __alloc_traits::deallocate(__base::__alloc(), __base::__map_.back(),
+ __base::__block_size);
+ __base::__map_.pop_back();
+ return true;
+ }
+ return false;
+ }
+
+ template <class _InpIter>
+ void __append(_InpIter __f, _InpIter __l,
+ typename enable_if<__is_cpp17_input_iterator<_InpIter>::value &&
+ !__is_cpp17_forward_iterator<_InpIter>::value>::type* = 0);
+ template <class _ForIter>
+ void __append(_ForIter __f, _ForIter __l,
+ typename enable_if<__is_cpp17_forward_iterator<_ForIter>::value>::type* = 0);
+ void __append(size_type __n);
+ void __append(size_type __n, const value_type& __v);
+ void __erase_to_end(const_iterator __f);
+ void __add_front_capacity();
+ void __add_front_capacity(size_type __n);
+ void __add_back_capacity();
+ void __add_back_capacity(size_type __n);
+ iterator __move_and_check(iterator __f, iterator __l, iterator __r,
+ const_pointer& __vt);
+ iterator __move_backward_and_check(iterator __f, iterator __l, iterator __r,
+ const_pointer& __vt);
+ void __move_construct_and_check(iterator __f, iterator __l,
+ iterator __r, const_pointer& __vt);
+ void __move_construct_backward_and_check(iterator __f, iterator __l,
+ iterator __r, const_pointer& __vt);
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __copy_assign_alloc(const deque& __c)
+ {__copy_assign_alloc(__c, integral_constant<bool,
+ __alloc_traits::propagate_on_container_copy_assignment::value>());}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __copy_assign_alloc(const deque& __c, true_type)
+ {
+ if (__base::__alloc() != __c.__alloc())
+ {
+ clear();
+ shrink_to_fit();
+ }
+ __base::__alloc() = __c.__alloc();
+ __base::__map_.__alloc() = __c.__map_.__alloc();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __copy_assign_alloc(const deque&, false_type)
+ {}
+
+ void __move_assign(deque& __c, true_type)
+ _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
+ void __move_assign(deque& __c, false_type);
+};
+
+#if _LIBCPP_STD_VER >= 17
+template<class _InputIterator,
+ class _Alloc = allocator<__iter_value_type<_InputIterator>>,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = enable_if_t<__is_allocator<_Alloc>::value>
+ >
+deque(_InputIterator, _InputIterator)
+ -> deque<__iter_value_type<_InputIterator>, _Alloc>;
+
+template<class _InputIterator,
+ class _Alloc,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = enable_if_t<__is_allocator<_Alloc>::value>
+ >
+deque(_InputIterator, _InputIterator, _Alloc)
+ -> deque<__iter_value_type<_InputIterator>, _Alloc>;
+#endif
+
+template <class _Tp, class _Allocator>
+deque<_Tp, _Allocator>::deque(size_type __n)
+{
+ if (__n > 0)
+ __append(__n);
+}
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp, class _Allocator>
+deque<_Tp, _Allocator>::deque(size_type __n, const _Allocator& __a)
+ : __base(__a)
+{
+ if (__n > 0)
+ __append(__n);
+}
+#endif
+
+template <class _Tp, class _Allocator>
+deque<_Tp, _Allocator>::deque(size_type __n, const value_type& __v)
+{
+ if (__n > 0)
+ __append(__n, __v);
+}
+
+template <class _Tp, class _Allocator>
+template <class _InputIter>
+deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l,
+ typename enable_if<__is_cpp17_input_iterator<_InputIter>::value>::type*)
+{
+ __append(__f, __l);
+}
+
+template <class _Tp, class _Allocator>
+template <class _InputIter>
+deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l, const allocator_type& __a,
+ typename enable_if<__is_cpp17_input_iterator<_InputIter>::value>::type*)
+ : __base(__a)
+{
+ __append(__f, __l);
+}
+
+template <class _Tp, class _Allocator>
+deque<_Tp, _Allocator>::deque(const deque& __c)
+ : __base(__alloc_traits::select_on_container_copy_construction(__c.__alloc()))
+{
+ __append(__c.begin(), __c.end());
+}
+
+template <class _Tp, class _Allocator>
+deque<_Tp, _Allocator>::deque(const deque& __c, const __identity_t<allocator_type>& __a)
+ : __base(__a)
+{
+ __append(__c.begin(), __c.end());
+}
+
+template <class _Tp, class _Allocator>
+deque<_Tp, _Allocator>&
+deque<_Tp, _Allocator>::operator=(const deque& __c)
+{
+ if (this != _VSTD::addressof(__c))
+ {
+ __copy_assign_alloc(__c);
+ assign(__c.begin(), __c.end());
+ }
+ return *this;
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Allocator>
+deque<_Tp, _Allocator>::deque(initializer_list<value_type> __il)
+{
+ __append(__il.begin(), __il.end());
+}
+
+template <class _Tp, class _Allocator>
+deque<_Tp, _Allocator>::deque(initializer_list<value_type> __il, const allocator_type& __a)
+ : __base(__a)
+{
+ __append(__il.begin(), __il.end());
+}
+
+template <class _Tp, class _Allocator>
+inline
+deque<_Tp, _Allocator>::deque(deque&& __c)
+ _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
+ : __base(_VSTD::move(__c))
+{
+}
+
+template <class _Tp, class _Allocator>
+inline
+deque<_Tp, _Allocator>::deque(deque&& __c, const __identity_t<allocator_type>& __a)
+ : __base(_VSTD::move(__c), __a)
+{
+ if (__a != __c.__alloc())
+ {
+ typedef move_iterator<iterator> _Ip;
+ assign(_Ip(__c.begin()), _Ip(__c.end()));
+ }
+}
+
+template <class _Tp, class _Allocator>
+inline
+deque<_Tp, _Allocator>&
+deque<_Tp, _Allocator>::operator=(deque&& __c)
+ _NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value &&
+ is_nothrow_move_assignable<allocator_type>::value)
+{
+ __move_assign(__c, integral_constant<bool,
+ __alloc_traits::propagate_on_container_move_assignment::value>());
+ return *this;
+}
+
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::__move_assign(deque& __c, false_type)
+{
+ if (__base::__alloc() != __c.__alloc())
+ {
+ typedef move_iterator<iterator> _Ip;
+ assign(_Ip(__c.begin()), _Ip(__c.end()));
+ }
+ else
+ __move_assign(__c, true_type());
+}
+
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::__move_assign(deque& __c, true_type)
+ _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
+{
+ clear();
+ shrink_to_fit();
+ __base::__move_assign(__c);
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Allocator>
+template <class _InputIter>
+void
+deque<_Tp, _Allocator>::assign(_InputIter __f, _InputIter __l,
+ typename enable_if<__is_cpp17_input_iterator<_InputIter>::value &&
+ !__is_cpp17_random_access_iterator<_InputIter>::value>::type*)
+{
+ iterator __i = __base::begin();
+ iterator __e = __base::end();
+ for (; __f != __l && __i != __e; ++__f, (void) ++__i)
+ *__i = *__f;
+ if (__f != __l)
+ __append(__f, __l);
+ else
+ __erase_to_end(__i);
+}
+
+template <class _Tp, class _Allocator>
+template <class _RAIter>
+void
+deque<_Tp, _Allocator>::assign(_RAIter __f, _RAIter __l,
+ typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type*)
+{
+ if (static_cast<size_type>(__l - __f) > __base::size())
+ {
+ _RAIter __m = __f + __base::size();
+ _VSTD::copy(__f, __m, __base::begin());
+ __append(__m, __l);
+ }
+ else
+ __erase_to_end(_VSTD::copy(__f, __l, __base::begin()));
+}
+
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::assign(size_type __n, const value_type& __v)
+{
+ if (__n > __base::size())
+ {
+ _VSTD::fill_n(__base::begin(), __base::size(), __v);
+ __n -= __base::size();
+ __append(__n, __v);
+ }
+ else
+ __erase_to_end(_VSTD::fill_n(__base::begin(), __n, __v));
+}
+
+template <class _Tp, class _Allocator>
+inline
+_Allocator
+deque<_Tp, _Allocator>::get_allocator() const _NOEXCEPT
+{
+ return __base::__alloc();
+}
+
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::resize(size_type __n)
+{
+ if (__n > __base::size())
+ __append(__n - __base::size());
+ else if (__n < __base::size())
+ __erase_to_end(__base::begin() + __n);
+}
+
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::resize(size_type __n, const value_type& __v)
+{
+ if (__n > __base::size())
+ __append(__n - __base::size(), __v);
+ else if (__n < __base::size())
+ __erase_to_end(__base::begin() + __n);
+}
+
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
+{
+ allocator_type& __a = __base::__alloc();
+ if (empty())
+ {
+ while (__base::__map_.size() > 0)
+ {
+ __alloc_traits::deallocate(__a, __base::__map_.back(), __base::__block_size);
+ __base::__map_.pop_back();
+ }
+ __base::__start_ = 0;
+ }
+ else
+ {
+ __maybe_remove_front_spare(/*__keep_one=*/false);
+ __maybe_remove_back_spare(/*__keep_one=*/false);
+ }
+ __base::__map_.shrink_to_fit();
+}
+
+template <class _Tp, class _Allocator>
+inline
+typename deque<_Tp, _Allocator>::reference
+deque<_Tp, _Allocator>::operator[](size_type __i) _NOEXCEPT
+{
+ size_type __p = __base::__start_ + __i;
+ return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size);
+}
+
+template <class _Tp, class _Allocator>
+inline
+typename deque<_Tp, _Allocator>::const_reference
+deque<_Tp, _Allocator>::operator[](size_type __i) const _NOEXCEPT
+{
+ size_type __p = __base::__start_ + __i;
+ return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size);
+}
+
+template <class _Tp, class _Allocator>
+inline
+typename deque<_Tp, _Allocator>::reference
+deque<_Tp, _Allocator>::at(size_type __i)
+{
+ if (__i >= __base::size())
+ _VSTD::__throw_out_of_range("deque");
+ size_type __p = __base::__start_ + __i;
+ return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size);
+}
+
+template <class _Tp, class _Allocator>
+inline
+typename deque<_Tp, _Allocator>::const_reference
+deque<_Tp, _Allocator>::at(size_type __i) const
+{
+ if (__i >= __base::size())
+ _VSTD::__throw_out_of_range("deque");
+ size_type __p = __base::__start_ + __i;
+ return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size);
+}
+
+template <class _Tp, class _Allocator>
+inline
+typename deque<_Tp, _Allocator>::reference
+deque<_Tp, _Allocator>::front() _NOEXCEPT
+{
+ return *(*(__base::__map_.begin() + __base::__start_ / __base::__block_size)
+ + __base::__start_ % __base::__block_size);
+}
+
+template <class _Tp, class _Allocator>
+inline
+typename deque<_Tp, _Allocator>::const_reference
+deque<_Tp, _Allocator>::front() const _NOEXCEPT
+{
+ return *(*(__base::__map_.begin() + __base::__start_ / __base::__block_size)
+ + __base::__start_ % __base::__block_size);
+}
+
+template <class _Tp, class _Allocator>
+inline
+typename deque<_Tp, _Allocator>::reference
+deque<_Tp, _Allocator>::back() _NOEXCEPT
+{
+ size_type __p = __base::size() + __base::__start_ - 1;
+ return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size);
+}
+
+template <class _Tp, class _Allocator>
+inline
+typename deque<_Tp, _Allocator>::const_reference
+deque<_Tp, _Allocator>::back() const _NOEXCEPT
+{
+ size_type __p = __base::size() + __base::__start_ - 1;
+ return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size);
+}
+
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::push_back(const value_type& __v)
+{
+ allocator_type& __a = __base::__alloc();
+ if (__back_spare() == 0)
+ __add_back_capacity();
+ // __back_spare() >= 1
+ __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()), __v);
+ ++__base::size();
+}
+
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::push_front(const value_type& __v)
+{
+ allocator_type& __a = __base::__alloc();
+ if (__front_spare() == 0)
+ __add_front_capacity();
+ // __front_spare() >= 1
+ __alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), __v);
+ --__base::__start_;
+ ++__base::size();
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::push_back(value_type&& __v)
+{
+ allocator_type& __a = __base::__alloc();
+ if (__back_spare() == 0)
+ __add_back_capacity();
+ // __back_spare() >= 1
+ __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()), _VSTD::move(__v));
+ ++__base::size();
+}
+
+template <class _Tp, class _Allocator>
+template <class... _Args>
+#if _LIBCPP_STD_VER > 14
+typename deque<_Tp, _Allocator>::reference
+#else
+void
+#endif
+deque<_Tp, _Allocator>::emplace_back(_Args&&... __args)
+{
+ allocator_type& __a = __base::__alloc();
+ if (__back_spare() == 0)
+ __add_back_capacity();
+ // __back_spare() >= 1
+ __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()),
+ _VSTD::forward<_Args>(__args)...);
+ ++__base::size();
+#if _LIBCPP_STD_VER > 14
+ return *--__base::end();
+#endif
+}
+
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::push_front(value_type&& __v)
+{
+ allocator_type& __a = __base::__alloc();
+ if (__front_spare() == 0)
+ __add_front_capacity();
+ // __front_spare() >= 1
+ __alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), _VSTD::move(__v));
+ --__base::__start_;
+ ++__base::size();
+}
+
+
+template <class _Tp, class _Allocator>
+template <class... _Args>
+#if _LIBCPP_STD_VER > 14
+typename deque<_Tp, _Allocator>::reference
+#else
+void
+#endif
+deque<_Tp, _Allocator>::emplace_front(_Args&&... __args)
+{
+ allocator_type& __a = __base::__alloc();
+ if (__front_spare() == 0)
+ __add_front_capacity();
+ // __front_spare() >= 1
+ __alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), _VSTD::forward<_Args>(__args)...);
+ --__base::__start_;
+ ++__base::size();
+#if _LIBCPP_STD_VER > 14
+ return *__base::begin();
+#endif
+}
+
+template <class _Tp, class _Allocator>
+typename deque<_Tp, _Allocator>::iterator
+deque<_Tp, _Allocator>::insert(const_iterator __p, value_type&& __v)
+{
+ size_type __pos = __p - __base::begin();
+ size_type __to_end = __base::size() - __pos;
+ allocator_type& __a = __base::__alloc();
+ if (__pos < __to_end)
+ { // insert by shifting things backward
+ if (__front_spare() == 0)
+ __add_front_capacity();
+ // __front_spare() >= 1
+ if (__pos == 0)
+ {
+ __alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), _VSTD::move(__v));
+ --__base::__start_;
+ ++__base::size();
+ }
+ else
+ {
+ iterator __b = __base::begin();
+ iterator __bm1 = _VSTD::prev(__b);
+ __alloc_traits::construct(__a, _VSTD::addressof(*__bm1), _VSTD::move(*__b));
+ --__base::__start_;
+ ++__base::size();
+ if (__pos > 1)
+ __b = _VSTD::move(_VSTD::next(__b), __b + __pos, __b);
+ *__b = _VSTD::move(__v);
+ }
+ }
+ else
+ { // insert by shifting things forward
+ if (__back_spare() == 0)
+ __add_back_capacity();
+ // __back_capacity >= 1
+ size_type __de = __base::size() - __pos;
+ if (__de == 0)
+ {
+ __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()), _VSTD::move(__v));
+ ++__base::size();
+ }
+ else
+ {
+ iterator __e = __base::end();
+ iterator __em1 = _VSTD::prev(__e);
+ __alloc_traits::construct(__a, _VSTD::addressof(*__e), _VSTD::move(*__em1));
+ ++__base::size();
+ if (__de > 1)
+ __e = _VSTD::move_backward(__e - __de, __em1, __e);
+ *--__e = _VSTD::move(__v);
+ }
+ }
+ return __base::begin() + __pos;
+}
+
+template <class _Tp, class _Allocator>
+template <class... _Args>
+typename deque<_Tp, _Allocator>::iterator
+deque<_Tp, _Allocator>::emplace(const_iterator __p, _Args&&... __args)
+{
+ size_type __pos = __p - __base::begin();
+ size_type __to_end = __base::size() - __pos;
+ allocator_type& __a = __base::__alloc();
+ if (__pos < __to_end)
+ { // insert by shifting things backward
+ if (__front_spare() == 0)
+ __add_front_capacity();
+ // __front_spare() >= 1
+ if (__pos == 0)
+ {
+ __alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), _VSTD::forward<_Args>(__args)...);
+ --__base::__start_;
+ ++__base::size();
+ }
+ else
+ {
+ __temp_value<value_type, _Allocator> __tmp(this->__alloc(), _VSTD::forward<_Args>(__args)...);
+ iterator __b = __base::begin();
+ iterator __bm1 = _VSTD::prev(__b);
+ __alloc_traits::construct(__a, _VSTD::addressof(*__bm1), _VSTD::move(*__b));
+ --__base::__start_;
+ ++__base::size();
+ if (__pos > 1)
+ __b = _VSTD::move(_VSTD::next(__b), __b + __pos, __b);
+ *__b = _VSTD::move(__tmp.get());
+ }
+ }
+ else
+ { // insert by shifting things forward
+ if (__back_spare() == 0)
+ __add_back_capacity();
+ // __back_capacity >= 1
+ size_type __de = __base::size() - __pos;
+ if (__de == 0)
+ {
+ __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()), _VSTD::forward<_Args>(__args)...);
+ ++__base::size();
+ }
+ else
+ {
+ __temp_value<value_type, _Allocator> __tmp(this->__alloc(), _VSTD::forward<_Args>(__args)...);
+ iterator __e = __base::end();
+ iterator __em1 = _VSTD::prev(__e);
+ __alloc_traits::construct(__a, _VSTD::addressof(*__e), _VSTD::move(*__em1));
+ ++__base::size();
+ if (__de > 1)
+ __e = _VSTD::move_backward(__e - __de, __em1, __e);
+ *--__e = _VSTD::move(__tmp.get());
+ }
+ }
+ return __base::begin() + __pos;
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+
+template <class _Tp, class _Allocator>
+typename deque<_Tp, _Allocator>::iterator
+deque<_Tp, _Allocator>::insert(const_iterator __p, const value_type& __v)
+{
+ size_type __pos = __p - __base::begin();
+ size_type __to_end = __base::size() - __pos;
+ allocator_type& __a = __base::__alloc();
+ if (__pos < __to_end)
+ { // insert by shifting things backward
+ if (__front_spare() == 0)
+ __add_front_capacity();
+ // __front_spare() >= 1
+ if (__pos == 0)
+ {
+ __alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), __v);
+ --__base::__start_;
+ ++__base::size();
+ }
+ else
+ {
+ const_pointer __vt = pointer_traits<const_pointer>::pointer_to(__v);
+ iterator __b = __base::begin();
+ iterator __bm1 = _VSTD::prev(__b);
+ if (__vt == pointer_traits<const_pointer>::pointer_to(*__b))
+ __vt = pointer_traits<const_pointer>::pointer_to(*__bm1);
+ __alloc_traits::construct(__a, _VSTD::addressof(*__bm1), _VSTD::move(*__b));
+ --__base::__start_;
+ ++__base::size();
+ if (__pos > 1)
+ __b = __move_and_check(_VSTD::next(__b), __b + __pos, __b, __vt);
+ *__b = *__vt;
+ }
+ }
+ else
+ { // insert by shifting things forward
+ if (__back_spare() == 0)
+ __add_back_capacity();
+ // __back_capacity >= 1
+ size_type __de = __base::size() - __pos;
+ if (__de == 0)
+ {
+ __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()), __v);
+ ++__base::size();
+ }
+ else
+ {
+ const_pointer __vt = pointer_traits<const_pointer>::pointer_to(__v);
+ iterator __e = __base::end();
+ iterator __em1 = _VSTD::prev(__e);
+ if (__vt == pointer_traits<const_pointer>::pointer_to(*__em1))
+ __vt = pointer_traits<const_pointer>::pointer_to(*__e);
+ __alloc_traits::construct(__a, _VSTD::addressof(*__e), _VSTD::move(*__em1));
+ ++__base::size();
+ if (__de > 1)
+ __e = __move_backward_and_check(__e - __de, __em1, __e, __vt);
+ *--__e = *__vt;
+ }
+ }
+ return __base::begin() + __pos;
+}
+
+template <class _Tp, class _Allocator>
+typename deque<_Tp, _Allocator>::iterator
+deque<_Tp, _Allocator>::insert(const_iterator __p, size_type __n, const value_type& __v)
+{
+ size_type __pos = __p - __base::begin();
+ size_type __to_end = __base::size() - __pos;
+ allocator_type& __a = __base::__alloc();
+ if (__pos < __to_end)
+ { // insert by shifting things backward
+ if (__n > __front_spare())
+ __add_front_capacity(__n - __front_spare());
+ // __n <= __front_spare()
+ iterator __old_begin = __base::begin();
+ iterator __i = __old_begin;
+ if (__n > __pos)
+ {
+ for (size_type __m = __n - __pos; __m; --__m, --__base::__start_, ++__base::size())
+ __alloc_traits::construct(__a, _VSTD::addressof(*--__i), __v);
+ __n = __pos;
+ }
+ if (__n > 0)
+ {
+ const_pointer __vt = pointer_traits<const_pointer>::pointer_to(__v);
+ iterator __obn = __old_begin + __n;
+ __move_construct_backward_and_check(__old_begin, __obn, __i, __vt);
+ if (__n < __pos)
+ __old_begin = __move_and_check(__obn, __old_begin + __pos, __old_begin, __vt);
+ _VSTD::fill_n(__old_begin, __n, *__vt);
+ }
+ }
+ else
+ { // insert by shifting things forward
+ size_type __back_capacity = __back_spare();
+ if (__n > __back_capacity)
+ __add_back_capacity(__n - __back_capacity);
+ // __n <= __back_capacity
+ iterator __old_end = __base::end();
+ iterator __i = __old_end;
+ size_type __de = __base::size() - __pos;
+ if (__n > __de)
+ {
+ for (size_type __m = __n - __de; __m; --__m, (void) ++__i, ++__base::size())
+ __alloc_traits::construct(__a, _VSTD::addressof(*__i), __v);
+ __n = __de;
+ }
+ if (__n > 0)
+ {
+ const_pointer __vt = pointer_traits<const_pointer>::pointer_to(__v);
+ iterator __oen = __old_end - __n;
+ __move_construct_and_check(__oen, __old_end, __i, __vt);
+ if (__n < __de)
+ __old_end = __move_backward_and_check(__old_end - __de, __oen, __old_end, __vt);
+ _VSTD::fill_n(__old_end - __n, __n, *__vt);
+ }
+ }
+ return __base::begin() + __pos;
+}
+
+template <class _Tp, class _Allocator>
+template <class _InputIter>
+typename deque<_Tp, _Allocator>::iterator
+deque<_Tp, _Allocator>::insert(const_iterator __p, _InputIter __f, _InputIter __l,
+ typename enable_if<__is_cpp17_input_iterator<_InputIter>::value
+ &&!__is_cpp17_forward_iterator<_InputIter>::value>::type*)
+{
+ __split_buffer<value_type, allocator_type&> __buf(__base::__alloc());
+ __buf.__construct_at_end(__f, __l);
+ typedef typename __split_buffer<value_type, allocator_type&>::iterator __bi;
+ return insert(__p, move_iterator<__bi>(__buf.begin()), move_iterator<__bi>(__buf.end()));
+}
+
+template <class _Tp, class _Allocator>
+template <class _ForwardIterator>
+typename deque<_Tp, _Allocator>::iterator
+deque<_Tp, _Allocator>::insert(const_iterator __p, _ForwardIterator __f, _ForwardIterator __l,
+ typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value
+ &&!__is_cpp17_bidirectional_iterator<_ForwardIterator>::value>::type*)
+{
+ size_type __n = _VSTD::distance(__f, __l);
+ __split_buffer<value_type, allocator_type&> __buf(__n, 0, __base::__alloc());
+ __buf.__construct_at_end(__f, __l);
+ typedef typename __split_buffer<value_type, allocator_type&>::iterator __fwd;
+ return insert(__p, move_iterator<__fwd>(__buf.begin()), move_iterator<__fwd>(__buf.end()));
+}
+
+template <class _Tp, class _Allocator>
+template <class _BiIter>
+typename deque<_Tp, _Allocator>::iterator
+deque<_Tp, _Allocator>::insert(const_iterator __p, _BiIter __f, _BiIter __l,
+ typename enable_if<__is_cpp17_bidirectional_iterator<_BiIter>::value>::type*)
+{
+ size_type __n = _VSTD::distance(__f, __l);
+ size_type __pos = __p - __base::begin();
+ size_type __to_end = __base::size() - __pos;
+ allocator_type& __a = __base::__alloc();
+ if (__pos < __to_end)
+ { // insert by shifting things backward
+ if (__n > __front_spare())
+ __add_front_capacity(__n - __front_spare());
+ // __n <= __front_spare()
+ iterator __old_begin = __base::begin();
+ iterator __i = __old_begin;
+ _BiIter __m = __f;
+ if (__n > __pos)
+ {
+ __m = __pos < __n / 2 ? _VSTD::prev(__l, __pos) : _VSTD::next(__f, __n - __pos);
+ for (_BiIter __j = __m; __j != __f; --__base::__start_, ++__base::size())
+ __alloc_traits::construct(__a, _VSTD::addressof(*--__i), *--__j);
+ __n = __pos;
+ }
+ if (__n > 0)
+ {
+ iterator __obn = __old_begin + __n;
+ for (iterator __j = __obn; __j != __old_begin;)
+ {
+ __alloc_traits::construct(__a, _VSTD::addressof(*--__i), _VSTD::move(*--__j));
+ --__base::__start_;
+ ++__base::size();
+ }
+ if (__n < __pos)
+ __old_begin = _VSTD::move(__obn, __old_begin + __pos, __old_begin);
+ _VSTD::copy(__m, __l, __old_begin);
+ }
+ }
+ else
+ { // insert by shifting things forward
+ size_type __back_capacity = __back_spare();
+ if (__n > __back_capacity)
+ __add_back_capacity(__n - __back_capacity);
+ // __n <= __back_capacity
+ iterator __old_end = __base::end();
+ iterator __i = __old_end;
+ _BiIter __m = __l;
+ size_type __de = __base::size() - __pos;
+ if (__n > __de)
+ {
+ __m = __de < __n / 2 ? _VSTD::next(__f, __de) : _VSTD::prev(__l, __n - __de);
+ for (_BiIter __j = __m; __j != __l; ++__i, (void) ++__j, ++__base::size())
+ __alloc_traits::construct(__a, _VSTD::addressof(*__i), *__j);
+ __n = __de;
+ }
+ if (__n > 0)
+ {
+ iterator __oen = __old_end - __n;
+ for (iterator __j = __oen; __j != __old_end; ++__i, (void) ++__j, ++__base::size())
+ __alloc_traits::construct(__a, _VSTD::addressof(*__i), _VSTD::move(*__j));
+ if (__n < __de)
+ __old_end = _VSTD::move_backward(__old_end - __de, __oen, __old_end);
+ _VSTD::copy_backward(__f, __m, __old_end);
+ }
+ }
+ return __base::begin() + __pos;
+}
+
+template <class _Tp, class _Allocator>
+template <class _InpIter>
+void
+deque<_Tp, _Allocator>::__append(_InpIter __f, _InpIter __l,
+ typename enable_if<__is_cpp17_input_iterator<_InpIter>::value &&
+ !__is_cpp17_forward_iterator<_InpIter>::value>::type*)
+{
+ for (; __f != __l; ++__f)
+#ifdef _LIBCPP_CXX03_LANG
+ push_back(*__f);
+#else
+ emplace_back(*__f);
+#endif
+}
+
+template <class _Tp, class _Allocator>
+template <class _ForIter>
+void
+deque<_Tp, _Allocator>::__append(_ForIter __f, _ForIter __l,
+ typename enable_if<__is_cpp17_forward_iterator<_ForIter>::value>::type*)
+{
+ size_type __n = _VSTD::distance(__f, __l);
+ allocator_type& __a = __base::__alloc();
+ size_type __back_capacity = __back_spare();
+ if (__n > __back_capacity)
+ __add_back_capacity(__n - __back_capacity);
+ // __n <= __back_capacity
+ for (__deque_block_range __br : __deque_range(__base::end(), __base::end() + __n)) {
+ _ConstructTransaction __tx(this, __br);
+ for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_, (void)++__f) {
+ __alloc_traits::construct(__a, _VSTD::__to_address(__tx.__pos_), *__f);
+ }
+ }
+}
+
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::__append(size_type __n)
+{
+ allocator_type& __a = __base::__alloc();
+ size_type __back_capacity = __back_spare();
+ if (__n > __back_capacity)
+ __add_back_capacity(__n - __back_capacity);
+ // __n <= __back_capacity
+ for (__deque_block_range __br : __deque_range(__base::end(), __base::end() + __n)) {
+ _ConstructTransaction __tx(this, __br);
+ for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {
+ __alloc_traits::construct(__a, _VSTD::__to_address(__tx.__pos_));
+ }
+ }
+}
+
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::__append(size_type __n, const value_type& __v)
+{
+ allocator_type& __a = __base::__alloc();
+ size_type __back_capacity = __back_spare();
+ if (__n > __back_capacity)
+ __add_back_capacity(__n - __back_capacity);
+ // __n <= __back_capacity
+ for (__deque_block_range __br : __deque_range(__base::end(), __base::end() + __n)) {
+ _ConstructTransaction __tx(this, __br);
+ for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {
+ __alloc_traits::construct(__a, _VSTD::__to_address(__tx.__pos_), __v);
+ }
+ }
+
+}
+
+// Create front capacity for one block of elements.
+// Strong guarantee. Either do it or don't touch anything.
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::__add_front_capacity()
+{
+ allocator_type& __a = __base::__alloc();
+ if (__back_spare() >= size_type(__base::__block_size))
+ {
+ __base::__start_ += __base::__block_size;
+ pointer __pt = __base::__map_.back();
+ __base::__map_.pop_back();
+ __base::__map_.push_front(__pt);
+ }
+ // Else if __base::__map_.size() < __base::__map_.capacity() then we need to allocate 1 buffer
+ else if (__base::__map_.size() < __base::__map_.capacity())
+ { // we can put the new buffer into the map, but don't shift things around
+ // until all buffers are allocated. If we throw, we don't need to fix
+ // anything up (any added buffers are undetectible)
+ if (__base::__map_.__front_spare() > 0)
+ __base::__map_.push_front(__alloc_traits::allocate(__a, __base::__block_size));
+ else
+ {
+ __base::__map_.push_back(__alloc_traits::allocate(__a, __base::__block_size));
+ // Done allocating, reorder capacity
+ pointer __pt = __base::__map_.back();
+ __base::__map_.pop_back();
+ __base::__map_.push_front(__pt);
+ }
+ __base::__start_ = __base::__map_.size() == 1 ?
+ __base::__block_size / 2 :
+ __base::__start_ + __base::__block_size;
+ }
+ // Else need to allocate 1 buffer, *and* we need to reallocate __map_.
+ else
+ {
+ __split_buffer<pointer, typename __base::__pointer_allocator&>
+ __buf(max<size_type>(2 * __base::__map_.capacity(), 1),
+ 0, __base::__map_.__alloc());
+
+ typedef __allocator_destructor<_Allocator> _Dp;
+ unique_ptr<pointer, _Dp> __hold(
+ __alloc_traits::allocate(__a, __base::__block_size),
+ _Dp(__a, __base::__block_size));
+ __buf.push_back(__hold.get());
+ __hold.release();
+
+ for (typename __base::__map_pointer __i = __base::__map_.begin();
+ __i != __base::__map_.end(); ++__i)
+ __buf.push_back(*__i);
+ _VSTD::swap(__base::__map_.__first_, __buf.__first_);
+ _VSTD::swap(__base::__map_.__begin_, __buf.__begin_);
+ _VSTD::swap(__base::__map_.__end_, __buf.__end_);
+ _VSTD::swap(__base::__map_.__end_cap(), __buf.__end_cap());
+ __base::__start_ = __base::__map_.size() == 1 ?
+ __base::__block_size / 2 :
+ __base::__start_ + __base::__block_size;
+ }
+}
+
+// Create front capacity for __n elements.
+// Strong guarantee. Either do it or don't touch anything.
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::__add_front_capacity(size_type __n)
+{
+ allocator_type& __a = __base::__alloc();
+ size_type __nb = __recommend_blocks(__n + __base::__map_.empty());
+ // Number of unused blocks at back:
+ size_type __back_capacity = __back_spare() / __base::__block_size;
+ __back_capacity = _VSTD::min(__back_capacity, __nb); // don't take more than you need
+ __nb -= __back_capacity; // number of blocks need to allocate
+ // If __nb == 0, then we have sufficient capacity.
+ if (__nb == 0)
+ {
+ __base::__start_ += __base::__block_size * __back_capacity;
+ for (; __back_capacity > 0; --__back_capacity)
+ {
+ pointer __pt = __base::__map_.back();
+ __base::__map_.pop_back();
+ __base::__map_.push_front(__pt);
+ }
+ }
+ // Else if __nb <= __map_.capacity() - __map_.size() then we need to allocate __nb buffers
+ else if (__nb <= __base::__map_.capacity() - __base::__map_.size())
+ { // we can put the new buffers into the map, but don't shift things around
+ // until all buffers are allocated. If we throw, we don't need to fix
+ // anything up (any added buffers are undetectible)
+ for (; __nb > 0; --__nb, __base::__start_ += __base::__block_size - (__base::__map_.size() == 1))
+ {
+ if (__base::__map_.__front_spare() == 0)
+ break;
+ __base::__map_.push_front(__alloc_traits::allocate(__a, __base::__block_size));
+ }
+ for (; __nb > 0; --__nb, ++__back_capacity)
+ __base::__map_.push_back(__alloc_traits::allocate(__a, __base::__block_size));
+ // Done allocating, reorder capacity
+ __base::__start_ += __back_capacity * __base::__block_size;
+ for (; __back_capacity > 0; --__back_capacity)
+ {
+ pointer __pt = __base::__map_.back();
+ __base::__map_.pop_back();
+ __base::__map_.push_front(__pt);
+ }
+ }
+ // Else need to allocate __nb buffers, *and* we need to reallocate __map_.
+ else
+ {
+ size_type __ds = (__nb + __back_capacity) * __base::__block_size - __base::__map_.empty();
+ __split_buffer<pointer, typename __base::__pointer_allocator&>
+ __buf(max<size_type>(2* __base::__map_.capacity(),
+ __nb + __base::__map_.size()),
+ 0, __base::__map_.__alloc());
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ for (; __nb > 0; --__nb)
+ __buf.push_back(__alloc_traits::allocate(__a, __base::__block_size));
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ for (typename __base::__map_pointer __i = __buf.begin();
+ __i != __buf.end(); ++__i)
+ __alloc_traits::deallocate(__a, *__i, __base::__block_size);
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ for (; __back_capacity > 0; --__back_capacity)
+ {
+ __buf.push_back(__base::__map_.back());
+ __base::__map_.pop_back();
+ }
+ for (typename __base::__map_pointer __i = __base::__map_.begin();
+ __i != __base::__map_.end(); ++__i)
+ __buf.push_back(*__i);
+ _VSTD::swap(__base::__map_.__first_, __buf.__first_);
+ _VSTD::swap(__base::__map_.__begin_, __buf.__begin_);
+ _VSTD::swap(__base::__map_.__end_, __buf.__end_);
+ _VSTD::swap(__base::__map_.__end_cap(), __buf.__end_cap());
+ __base::__start_ += __ds;
+ }
+}
+
+// Create back capacity for one block of elements.
+// Strong guarantee. Either do it or don't touch anything.
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::__add_back_capacity()
+{
+ allocator_type& __a = __base::__alloc();
+ if (__front_spare() >= size_type(__base::__block_size))
+ {
+ __base::__start_ -= __base::__block_size;
+ pointer __pt = __base::__map_.front();
+ __base::__map_.pop_front();
+ __base::__map_.push_back(__pt);
+ }
+ // Else if __nb <= __map_.capacity() - __map_.size() then we need to allocate __nb buffers
+ else if (__base::__map_.size() < __base::__map_.capacity())
+ { // we can put the new buffer into the map, but don't shift things around
+ // until it is allocated. If we throw, we don't need to fix
+ // anything up (any added buffers are undetectible)
+ if (__base::__map_.__back_spare() != 0)
+ __base::__map_.push_back(__alloc_traits::allocate(__a, __base::__block_size));
+ else
+ {
+ __base::__map_.push_front(__alloc_traits::allocate(__a, __base::__block_size));
+ // Done allocating, reorder capacity
+ pointer __pt = __base::__map_.front();
+ __base::__map_.pop_front();
+ __base::__map_.push_back(__pt);
+ }
+ }
+ // Else need to allocate 1 buffer, *and* we need to reallocate __map_.
+ else
+ {
+ __split_buffer<pointer, typename __base::__pointer_allocator&>
+ __buf(max<size_type>(2* __base::__map_.capacity(), 1),
+ __base::__map_.size(),
+ __base::__map_.__alloc());
+
+ typedef __allocator_destructor<_Allocator> _Dp;
+ unique_ptr<pointer, _Dp> __hold(
+ __alloc_traits::allocate(__a, __base::__block_size),
+ _Dp(__a, __base::__block_size));
+ __buf.push_back(__hold.get());
+ __hold.release();
+
+ for (typename __base::__map_pointer __i = __base::__map_.end();
+ __i != __base::__map_.begin();)
+ __buf.push_front(*--__i);
+ _VSTD::swap(__base::__map_.__first_, __buf.__first_);
+ _VSTD::swap(__base::__map_.__begin_, __buf.__begin_);
+ _VSTD::swap(__base::__map_.__end_, __buf.__end_);
+ _VSTD::swap(__base::__map_.__end_cap(), __buf.__end_cap());
+ }
+}
+
+// Create back capacity for __n elements.
+// Strong guarantee. Either do it or don't touch anything.
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::__add_back_capacity(size_type __n)
+{
+ allocator_type& __a = __base::__alloc();
+ size_type __nb = __recommend_blocks(__n + __base::__map_.empty());
+ // Number of unused blocks at front:
+ size_type __front_capacity = __front_spare() / __base::__block_size;
+ __front_capacity = _VSTD::min(__front_capacity, __nb); // don't take more than you need
+ __nb -= __front_capacity; // number of blocks need to allocate
+ // If __nb == 0, then we have sufficient capacity.
+ if (__nb == 0)
+ {
+ __base::__start_ -= __base::__block_size * __front_capacity;
+ for (; __front_capacity > 0; --__front_capacity)
+ {
+ pointer __pt = __base::__map_.front();
+ __base::__map_.pop_front();
+ __base::__map_.push_back(__pt);
+ }
+ }
+ // Else if __nb <= __map_.capacity() - __map_.size() then we need to allocate __nb buffers
+ else if (__nb <= __base::__map_.capacity() - __base::__map_.size())
+ { // we can put the new buffers into the map, but don't shift things around
+ // until all buffers are allocated. If we throw, we don't need to fix
+ // anything up (any added buffers are undetectible)
+ for (; __nb > 0; --__nb)
+ {
+ if (__base::__map_.__back_spare() == 0)
+ break;
+ __base::__map_.push_back(__alloc_traits::allocate(__a, __base::__block_size));
+ }
+ for (; __nb > 0; --__nb, ++__front_capacity, __base::__start_ +=
+ __base::__block_size - (__base::__map_.size() == 1))
+ __base::__map_.push_front(__alloc_traits::allocate(__a, __base::__block_size));
+ // Done allocating, reorder capacity
+ __base::__start_ -= __base::__block_size * __front_capacity;
+ for (; __front_capacity > 0; --__front_capacity)
+ {
+ pointer __pt = __base::__map_.front();
+ __base::__map_.pop_front();
+ __base::__map_.push_back(__pt);
+ }
+ }
+ // Else need to allocate __nb buffers, *and* we need to reallocate __map_.
+ else
+ {
+ size_type __ds = __front_capacity * __base::__block_size;
+ __split_buffer<pointer, typename __base::__pointer_allocator&>
+ __buf(max<size_type>(2* __base::__map_.capacity(),
+ __nb + __base::__map_.size()),
+ __base::__map_.size() - __front_capacity,
+ __base::__map_.__alloc());
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ for (; __nb > 0; --__nb)
+ __buf.push_back(__alloc_traits::allocate(__a, __base::__block_size));
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ for (typename __base::__map_pointer __i = __buf.begin();
+ __i != __buf.end(); ++__i)
+ __alloc_traits::deallocate(__a, *__i, __base::__block_size);
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ for (; __front_capacity > 0; --__front_capacity)
+ {
+ __buf.push_back(__base::__map_.front());
+ __base::__map_.pop_front();
+ }
+ for (typename __base::__map_pointer __i = __base::__map_.end();
+ __i != __base::__map_.begin();)
+ __buf.push_front(*--__i);
+ _VSTD::swap(__base::__map_.__first_, __buf.__first_);
+ _VSTD::swap(__base::__map_.__begin_, __buf.__begin_);
+ _VSTD::swap(__base::__map_.__end_, __buf.__end_);
+ _VSTD::swap(__base::__map_.__end_cap(), __buf.__end_cap());
+ __base::__start_ -= __ds;
+ }
+}
+
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::pop_front()
+{
+ allocator_type& __a = __base::__alloc();
+ __alloc_traits::destroy(__a, _VSTD::__to_address(*(__base::__map_.begin() +
+ __base::__start_ / __base::__block_size) +
+ __base::__start_ % __base::__block_size));
+ --__base::size();
+ ++__base::__start_;
+ __maybe_remove_front_spare();
+}
+
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::pop_back()
+{
+ _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() +
+ __p / __base::__block_size) +
+ __p % __base::__block_size));
+ --__base::size();
+ __maybe_remove_back_spare();
+}
+
+// move assign [__f, __l) to [__r, __r + (__l-__f)).
+// If __vt points into [__f, __l), then subtract (__f - __r) from __vt.
+template <class _Tp, class _Allocator>
+typename deque<_Tp, _Allocator>::iterator
+deque<_Tp, _Allocator>::__move_and_check(iterator __f, iterator __l, iterator __r,
+ const_pointer& __vt)
+{
+ // as if
+ // for (; __f != __l; ++__f, ++__r)
+ // *__r = _VSTD::move(*__f);
+ difference_type __n = __l - __f;
+ while (__n > 0)
+ {
+ pointer __fb = __f.__ptr_;
+ pointer __fe = *__f.__m_iter_ + __base::__block_size;
+ difference_type __bs = __fe - __fb;
+ if (__bs > __n)
+ {
+ __bs = __n;
+ __fe = __fb + __bs;
+ }
+ if (__fb <= __vt && __vt < __fe)
+ __vt = (const_iterator(static_cast<__map_const_pointer>(__f.__m_iter_), __vt) -= __f - __r).__ptr_;
+ __r = _VSTD::move(__fb, __fe, __r);
+ __n -= __bs;
+ __f += __bs;
+ }
+ return __r;
+}
+
+// move assign [__f, __l) to [__r - (__l-__f), __r) backwards.
+// If __vt points into [__f, __l), then add (__r - __l) to __vt.
+template <class _Tp, class _Allocator>
+typename deque<_Tp, _Allocator>::iterator
+deque<_Tp, _Allocator>::__move_backward_and_check(iterator __f, iterator __l, iterator __r,
+ const_pointer& __vt)
+{
+ // as if
+ // while (__f != __l)
+ // *--__r = _VSTD::move(*--__l);
+ difference_type __n = __l - __f;
+ while (__n > 0)
+ {
+ --__l;
+ pointer __lb = *__l.__m_iter_;
+ pointer __le = __l.__ptr_ + 1;
+ difference_type __bs = __le - __lb;
+ if (__bs > __n)
+ {
+ __bs = __n;
+ __lb = __le - __bs;
+ }
+ if (__lb <= __vt && __vt < __le)
+ __vt = (const_iterator(static_cast<__map_const_pointer>(__l.__m_iter_), __vt) += __r - __l - 1).__ptr_;
+ __r = _VSTD::move_backward(__lb, __le, __r);
+ __n -= __bs;
+ __l -= __bs - 1;
+ }
+ return __r;
+}
+
+// move construct [__f, __l) to [__r, __r + (__l-__f)).
+// If __vt points into [__f, __l), then add (__r - __f) to __vt.
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::__move_construct_and_check(iterator __f, iterator __l,
+ iterator __r, const_pointer& __vt)
+{
+ allocator_type& __a = __base::__alloc();
+ // as if
+ // for (; __f != __l; ++__r, ++__f, ++__base::size())
+ // __alloc_traits::construct(__a, _VSTD::addressof(*__r), _VSTD::move(*__f));
+ difference_type __n = __l - __f;
+ while (__n > 0)
+ {
+ pointer __fb = __f.__ptr_;
+ pointer __fe = *__f.__m_iter_ + __base::__block_size;
+ difference_type __bs = __fe - __fb;
+ if (__bs > __n)
+ {
+ __bs = __n;
+ __fe = __fb + __bs;
+ }
+ if (__fb <= __vt && __vt < __fe)
+ __vt = (const_iterator(static_cast<__map_const_pointer>(__f.__m_iter_), __vt) += __r - __f).__ptr_;
+ for (; __fb != __fe; ++__fb, ++__r, ++__base::size())
+ __alloc_traits::construct(__a, _VSTD::addressof(*__r), _VSTD::move(*__fb));
+ __n -= __bs;
+ __f += __bs;
+ }
+}
+
+// move construct [__f, __l) to [__r - (__l-__f), __r) backwards.
+// If __vt points into [__f, __l), then subtract (__l - __r) from __vt.
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::__move_construct_backward_and_check(iterator __f, iterator __l,
+ iterator __r, const_pointer& __vt)
+{
+ allocator_type& __a = __base::__alloc();
+ // as if
+ // for (iterator __j = __l; __j != __f;)
+ // {
+ // __alloc_traitsconstruct(__a, _VSTD::addressof(*--__r), _VSTD::move(*--__j));
+ // --__base::__start_;
+ // ++__base::size();
+ // }
+ difference_type __n = __l - __f;
+ while (__n > 0)
+ {
+ --__l;
+ pointer __lb = *__l.__m_iter_;
+ pointer __le = __l.__ptr_ + 1;
+ difference_type __bs = __le - __lb;
+ if (__bs > __n)
+ {
+ __bs = __n;
+ __lb = __le - __bs;
+ }
+ if (__lb <= __vt && __vt < __le)
+ __vt = (const_iterator(static_cast<__map_const_pointer>(__l.__m_iter_), __vt) -= __l - __r + 1).__ptr_;
+ while (__le != __lb)
+ {
+ __alloc_traits::construct(__a, _VSTD::addressof(*--__r), _VSTD::move(*--__le));
+ --__base::__start_;
+ ++__base::size();
+ }
+ __n -= __bs;
+ __l -= __bs - 1;
+ }
+}
+
+template <class _Tp, class _Allocator>
+typename deque<_Tp, _Allocator>::iterator
+deque<_Tp, _Allocator>::erase(const_iterator __f)
+{
+ iterator __b = __base::begin();
+ difference_type __pos = __f - __b;
+ iterator __p = __b + __pos;
+ allocator_type& __a = __base::__alloc();
+ if (static_cast<size_t>(__pos) <= (__base::size() - 1) / 2)
+ { // erase from front
+ _VSTD::move_backward(__b, __p, _VSTD::next(__p));
+ __alloc_traits::destroy(__a, _VSTD::addressof(*__b));
+ --__base::size();
+ ++__base::__start_;
+ __maybe_remove_front_spare();
+ }
+ else
+ { // erase from back
+ iterator __i = _VSTD::move(_VSTD::next(__p), __base::end(), __p);
+ __alloc_traits::destroy(__a, _VSTD::addressof(*__i));
+ --__base::size();
+ __maybe_remove_back_spare();
+ }
+ return __base::begin() + __pos;
+}
+
+template <class _Tp, class _Allocator>
+typename deque<_Tp, _Allocator>::iterator
+deque<_Tp, _Allocator>::erase(const_iterator __f, const_iterator __l)
+{
+ difference_type __n = __l - __f;
+ iterator __b = __base::begin();
+ difference_type __pos = __f - __b;
+ iterator __p = __b + __pos;
+ if (__n > 0)
+ {
+ allocator_type& __a = __base::__alloc();
+ if (static_cast<size_t>(__pos) <= (__base::size() - __n) / 2)
+ { // erase from front
+ iterator __i = _VSTD::move_backward(__b, __p, __p + __n);
+ for (; __b != __i; ++__b)
+ __alloc_traits::destroy(__a, _VSTD::addressof(*__b));
+ __base::size() -= __n;
+ __base::__start_ += __n;
+ while (__maybe_remove_front_spare()) {
+ }
+ }
+ else
+ { // erase from back
+ iterator __i = _VSTD::move(__p + __n, __base::end(), __p);
+ for (iterator __e = __base::end(); __i != __e; ++__i)
+ __alloc_traits::destroy(__a, _VSTD::addressof(*__i));
+ __base::size() -= __n;
+ while (__maybe_remove_back_spare()) {
+ }
+ }
+ }
+ return __base::begin() + __pos;
+}
+
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::__erase_to_end(const_iterator __f)
+{
+ iterator __e = __base::end();
+ difference_type __n = __e - __f;
+ if (__n > 0)
+ {
+ allocator_type& __a = __base::__alloc();
+ iterator __b = __base::begin();
+ difference_type __pos = __f - __b;
+ for (iterator __p = __b + __pos; __p != __e; ++__p)
+ __alloc_traits::destroy(__a, _VSTD::addressof(*__p));
+ __base::size() -= __n;
+ while (__maybe_remove_back_spare()) {
+ }
+ }
+}
+
+template <class _Tp, class _Allocator>
+inline
+void
+deque<_Tp, _Allocator>::swap(deque& __c)
+#if _LIBCPP_STD_VER >= 14
+ _NOEXCEPT
+#else
+ _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
+ __is_nothrow_swappable<allocator_type>::value)
+#endif
+{
+ __base::swap(__c);
+}
+
+template <class _Tp, class _Allocator>
+_LIBCPP_REINITIALIZES_OBJECT
+inline
+void
+deque<_Tp, _Allocator>::clear() _NOEXCEPT
+{
+ __base::clear();
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
+{
+ const typename deque<_Tp, _Allocator>::size_type __sz = __x.size();
+ return __sz == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
+{
+ return !(__x == __y);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator< (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
+{
+ return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator> (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
+{
+ return __y < __x;
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
+{
+ return !(__x < __y);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
+{
+ return !(__y < __x);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(deque<_Tp, _Allocator>& __x, deque<_Tp, _Allocator>& __y)
+ _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+ __x.swap(__y);
+}
+
+#if _LIBCPP_STD_VER > 17
+template <class _Tp, class _Allocator, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY typename deque<_Tp, _Allocator>::size_type
+erase(deque<_Tp, _Allocator>& __c, const _Up& __v) {
+ auto __old_size = __c.size();
+ __c.erase(_VSTD::remove(__c.begin(), __c.end(), __v), __c.end());
+ return __old_size - __c.size();
+}
+
+template <class _Tp, class _Allocator, class _Predicate>
+inline _LIBCPP_INLINE_VISIBILITY typename deque<_Tp, _Allocator>::size_type
+erase_if(deque<_Tp, _Allocator>& __c, _Predicate __pred) {
+ auto __old_size = __c.size();
+ __c.erase(_VSTD::remove_if(__c.begin(), __c.end(), __pred), __c.end());
+ return __old_size - __c.size();
+}
+#endif
+
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_DEQUE
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/errno.h b/contrib/libs/cxxsupp/libcxxmsvc/include/errno.h
new file mode 100644
index 0000000000..907a4f179e
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/errno.h
@@ -0,0 +1,410 @@
+// -*- 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_ERRNO_H
+#define _LIBCPP_ERRNO_H
+
+/*
+ errno.h synopsis
+
+Macros:
+
+ EDOM
+ EILSEQ // C99
+ ERANGE
+ errno
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifdef _LIBCPP_COMPILER_MSVC
+// errno is defined in several files so we can't use #ifndef errno here
+#ifdef errno
+// undefine errno to avoid substitution in errno.h include file name.
+#pragma push_macro("errno")
+#undef errno
+#include Y_UCRT_INCLUDE_NEXT(errno.h)
+#pragma pop_macro("errno")
+#else
+#include Y_UCRT_INCLUDE_NEXT(errno.h)
+#endif
+#else
+#include_next <errno.h>
+#endif
+
+#ifdef __cplusplus
+
+#if !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE)
+
+#ifdef ELAST
+
+static const int __elast1 = ELAST+1;
+static const int __elast2 = ELAST+2;
+
+#else
+
+static const int __elast1 = 104;
+static const int __elast2 = 105;
+
+#endif
+
+#ifdef ENOTRECOVERABLE
+
+#define EOWNERDEAD __elast1
+
+#ifdef ELAST
+#undef ELAST
+#define ELAST EOWNERDEAD
+#endif
+
+#elif defined(EOWNERDEAD)
+
+#define ENOTRECOVERABLE __elast1
+#ifdef ELAST
+#undef ELAST
+#define ELAST ENOTRECOVERABLE
+#endif
+
+#else // defined(EOWNERDEAD)
+
+#define EOWNERDEAD __elast1
+#define ENOTRECOVERABLE __elast2
+#ifdef ELAST
+#undef ELAST
+#define ELAST ENOTRECOVERABLE
+#endif
+
+#endif // defined(EOWNERDEAD)
+
+#endif // !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE)
+
+// supply errno values likely to be missing, particularly on Windows
+
+#ifndef EAFNOSUPPORT
+#define EAFNOSUPPORT 9901
+#endif
+
+#ifndef EADDRINUSE
+#define EADDRINUSE 9902
+#endif
+
+#ifndef EADDRNOTAVAIL
+#define EADDRNOTAVAIL 9903
+#endif
+
+#ifndef EISCONN
+#define EISCONN 9904
+#endif
+
+#ifndef EBADMSG
+#define EBADMSG 9905
+#endif
+
+#ifndef ECONNABORTED
+#define ECONNABORTED 9906
+#endif
+
+#ifndef EALREADY
+#define EALREADY 9907
+#endif
+
+#ifndef ECONNREFUSED
+#define ECONNREFUSED 9908
+#endif
+
+#ifndef ECONNRESET
+#define ECONNRESET 9909
+#endif
+
+#ifndef EDESTADDRREQ
+#define EDESTADDRREQ 9910
+#endif
+
+#ifndef EHOSTUNREACH
+#define EHOSTUNREACH 9911
+#endif
+
+#ifndef EIDRM
+#define EIDRM 9912
+#endif
+
+#ifndef EMSGSIZE
+#define EMSGSIZE 9913
+#endif
+
+#ifndef ENETDOWN
+#define ENETDOWN 9914
+#endif
+
+#ifndef ENETRESET
+#define ENETRESET 9915
+#endif
+
+#ifndef ENETUNREACH
+#define ENETUNREACH 9916
+#endif
+
+#ifndef ENOBUFS
+#define ENOBUFS 9917
+#endif
+
+#ifndef ENOLINK
+#define ENOLINK 9918
+#endif
+
+#ifndef ENODATA
+#define ENODATA 9919
+#endif
+
+#ifndef ENOMSG
+#define ENOMSG 9920
+#endif
+
+#ifndef ENOPROTOOPT
+#define ENOPROTOOPT 9921
+#endif
+
+#ifndef ENOSR
+#define ENOSR 9922
+#endif
+
+#ifndef ENOTSOCK
+#define ENOTSOCK 9923
+#endif
+
+#ifndef ENOSTR
+#define ENOSTR 9924
+#endif
+
+#ifndef ENOTCONN
+#define ENOTCONN 9925
+#endif
+
+#ifndef ENOTSUP
+#define ENOTSUP 9926
+#endif
+
+#ifndef ECANCELED
+#define ECANCELED 9927
+#endif
+
+#ifndef EINPROGRESS
+#define EINPROGRESS 9928
+#endif
+
+#ifndef EOPNOTSUPP
+#define EOPNOTSUPP 9929
+#endif
+
+#ifndef EWOULDBLOCK
+#define EWOULDBLOCK 9930
+#endif
+
+#ifndef EOWNERDEAD
+#define EOWNERDEAD 9931
+#endif
+
+#ifndef EPROTO
+#define EPROTO 9932
+#endif
+
+#ifndef EPROTONOSUPPORT
+#define EPROTONOSUPPORT 9933
+#endif
+
+#ifndef ENOTRECOVERABLE
+#define ENOTRECOVERABLE 9934
+#endif
+
+#ifndef ETIME
+#define ETIME 9935
+#endif
+
+#ifndef ETXTBSY
+#define ETXTBSY 9936
+#endif
+
+#ifndef ETIMEDOUT
+#define ETIMEDOUT 9938
+#endif
+
+#ifndef ELOOP
+#define ELOOP 9939
+#endif
+
+#ifndef EOVERFLOW
+#define EOVERFLOW 9940
+#endif
+
+#ifndef EPROTOTYPE
+#define EPROTOTYPE 9941
+#endif
+
+#ifndef ENOSYS
+#define ENOSYS 9942
+#endif
+
+#ifndef EINVAL
+#define EINVAL 9943
+#endif
+
+#ifndef ERANGE
+#define ERANGE 9944
+#endif
+
+#ifndef EILSEQ
+#define EILSEQ 9945
+#endif
+
+// Windows Mobile doesn't appear to define these:
+
+#ifndef E2BIG
+#define E2BIG 9946
+#endif
+
+#ifndef EDOM
+#define EDOM 9947
+#endif
+
+#ifndef EFAULT
+#define EFAULT 9948
+#endif
+
+#ifndef EBADF
+#define EBADF 9949
+#endif
+
+#ifndef EPIPE
+#define EPIPE 9950
+#endif
+
+#ifndef EXDEV
+#define EXDEV 9951
+#endif
+
+#ifndef EBUSY
+#define EBUSY 9952
+#endif
+
+#ifndef ENOTEMPTY
+#define ENOTEMPTY 9953
+#endif
+
+#ifndef ENOEXEC
+#define ENOEXEC 9954
+#endif
+
+#ifndef EEXIST
+#define EEXIST 9955
+#endif
+
+#ifndef EFBIG
+#define EFBIG 9956
+#endif
+
+#ifndef ENAMETOOLONG
+#define ENAMETOOLONG 9957
+#endif
+
+#ifndef ENOTTY
+#define ENOTTY 9958
+#endif
+
+#ifndef EINTR
+#define EINTR 9959
+#endif
+
+#ifndef ESPIPE
+#define ESPIPE 9960
+#endif
+
+#ifndef EIO
+#define EIO 9961
+#endif
+
+#ifndef EISDIR
+#define EISDIR 9962
+#endif
+
+#ifndef ECHILD
+#define ECHILD 9963
+#endif
+
+#ifndef ENOLCK
+#define ENOLCK 9964
+#endif
+
+#ifndef ENOSPC
+#define ENOSPC 9965
+#endif
+
+#ifndef ENXIO
+#define ENXIO 9966
+#endif
+
+#ifndef ENODEV
+#define ENODEV 9967
+#endif
+
+#ifndef ENOENT
+#define ENOENT 9968
+#endif
+
+#ifndef ESRCH
+#define ESRCH 9969
+#endif
+
+#ifndef ENOTDIR
+#define ENOTDIR 9970
+#endif
+
+#ifndef ENOMEM
+#define ENOMEM 9971
+#endif
+
+#ifndef EPERM
+#define EPERM 9972
+#endif
+
+#ifndef EACCES
+#define EACCES 9973
+#endif
+
+#ifndef EROFS
+#define EROFS 9974
+#endif
+
+#ifndef EDEADLK
+#define EDEADLK 9975
+#endif
+
+#ifndef EAGAIN
+#define EAGAIN 9976
+#endif
+
+#ifndef ENFILE
+#define ENFILE 9977
+#endif
+
+#ifndef EMFILE
+#define EMFILE 9978
+#endif
+
+#ifndef EMLINK
+#define EMLINK 9979
+#endif
+
+#endif // __cplusplus
+
+#endif // _LIBCPP_ERRNO_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/exception b/contrib/libs/cxxsupp/libcxxmsvc/include/exception
new file mode 100644
index 0000000000..a5a1f99cf9
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/exception
@@ -0,0 +1,308 @@
+// -*- 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_EXCEPTION
+#define _LIBCPP_EXCEPTION
+
+/*
+ exception synopsis
+
+namespace std
+{
+
+class exception
+{
+public:
+ exception() noexcept;
+ exception(const exception&) noexcept;
+ exception& operator=(const exception&) noexcept;
+ virtual ~exception() noexcept;
+ virtual const char* what() const noexcept;
+};
+
+class bad_exception
+ : public exception
+{
+public:
+ bad_exception() noexcept;
+ bad_exception(const bad_exception&) noexcept;
+ bad_exception& operator=(const bad_exception&) noexcept;
+ virtual ~bad_exception() noexcept;
+ virtual const char* what() const noexcept;
+};
+
+typedef void (*unexpected_handler)();
+unexpected_handler set_unexpected(unexpected_handler f ) noexcept;
+unexpected_handler get_unexpected() noexcept;
+[[noreturn]] void unexpected();
+
+typedef void (*terminate_handler)();
+terminate_handler set_terminate(terminate_handler f ) noexcept;
+terminate_handler get_terminate() noexcept;
+[[noreturn]] void terminate() noexcept;
+
+bool uncaught_exception() noexcept;
+int uncaught_exceptions() noexcept; // C++17
+
+typedef unspecified exception_ptr;
+
+exception_ptr current_exception() noexcept;
+void rethrow_exception [[noreturn]] (exception_ptr p);
+template<class E> exception_ptr make_exception_ptr(E e) noexcept;
+
+class nested_exception
+{
+public:
+ nested_exception() noexcept;
+ nested_exception(const nested_exception&) noexcept = default;
+ nested_exception& operator=(const nested_exception&) noexcept = default;
+ virtual ~nested_exception() = default;
+
+ // access functions
+ [[noreturn]] void rethrow_nested() const;
+ exception_ptr nested_ptr() const noexcept;
+};
+
+template <class T> [[noreturn]] void throw_with_nested(T&& t);
+template <class E> void rethrow_if_nested(const E& e);
+
+} // std
+
+*/
+
+#include <__availability>
+#include <__config>
+#include <__memory/addressof.h>
+#include <cstddef>
+#include <cstdlib>
+#include <type_traits>
+#include <version>
+
+#if defined(_LIBCPP_ABI_VCRUNTIME)
+#include <vcruntime_exception.h>
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+namespace std // purposefully not using versioning namespace
+{
+
+#if !defined(_LIBCPP_ABI_VCRUNTIME)
+class _LIBCPP_EXCEPTION_ABI exception
+{
+public:
+ _LIBCPP_INLINE_VISIBILITY exception() _NOEXCEPT {}
+ _LIBCPP_INLINE_VISIBILITY exception(const exception&) _NOEXCEPT = default;
+
+ virtual ~exception() _NOEXCEPT;
+ virtual const char* what() const _NOEXCEPT;
+};
+
+class _LIBCPP_EXCEPTION_ABI bad_exception
+ : public exception
+{
+public:
+ _LIBCPP_INLINE_VISIBILITY bad_exception() _NOEXCEPT {}
+ virtual ~bad_exception() _NOEXCEPT;
+ virtual const char* what() const _NOEXCEPT;
+};
+#endif // !_LIBCPP_ABI_VCRUNTIME
+
+#if _LIBCPP_STD_VER <= 14 \
+ || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS) \
+ || defined(_LIBCPP_BUILDING_LIBRARY)
+typedef void (*unexpected_handler)();
+_LIBCPP_FUNC_VIS unexpected_handler set_unexpected(unexpected_handler) _NOEXCEPT;
+_LIBCPP_FUNC_VIS unexpected_handler get_unexpected() _NOEXCEPT;
+_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void unexpected();
+#endif
+
+typedef void (*terminate_handler)();
+_LIBCPP_FUNC_VIS terminate_handler set_terminate(terminate_handler) _NOEXCEPT;
+_LIBCPP_FUNC_VIS terminate_handler get_terminate() _NOEXCEPT;
+_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void terminate() _NOEXCEPT;
+
+_LIBCPP_FUNC_VIS bool uncaught_exception() _NOEXCEPT;
+_LIBCPP_FUNC_VIS _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS int uncaught_exceptions() _NOEXCEPT;
+
+class _LIBCPP_TYPE_VIS exception_ptr;
+
+_LIBCPP_FUNC_VIS exception_ptr current_exception() _NOEXCEPT;
+_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void rethrow_exception(exception_ptr);
+
+class _LIBCPP_TYPE_VIS exception_ptr
+{
+ void* __ptr_;
+public:
+ _LIBCPP_INLINE_VISIBILITY exception_ptr() _NOEXCEPT : __ptr_() {}
+ _LIBCPP_INLINE_VISIBILITY exception_ptr(nullptr_t) _NOEXCEPT : __ptr_() {}
+
+ exception_ptr(const exception_ptr&) _NOEXCEPT;
+ exception_ptr& operator=(const exception_ptr&) _NOEXCEPT;
+ ~exception_ptr() _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY explicit operator bool() const _NOEXCEPT
+ {return __ptr_ != nullptr;}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const exception_ptr& __x, const exception_ptr& __y) _NOEXCEPT
+ {return __x.__ptr_ == __y.__ptr_;}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const exception_ptr& __x, const exception_ptr& __y) _NOEXCEPT
+ {return !(__x == __y);}
+
+ friend _LIBCPP_FUNC_VIS void swap(exception_ptr& __x, exception_ptr& __y) _NOEXCEPT
+ {
+ void* __tmp = __x.__ptr_;
+ __x.__ptr_ = __y.__ptr_;
+ __y.__ptr_ = __tmp;
+ }
+
+ friend _LIBCPP_FUNC_VIS exception_ptr current_exception() _NOEXCEPT;
+ friend _LIBCPP_FUNC_VIS void rethrow_exception(exception_ptr);
+};
+
+#ifndef _LIBCPP_ABI_MICROSOFT
+
+template<class _Ep>
+_LIBCPP_INLINE_VISIBILITY exception_ptr
+make_exception_ptr(_Ep __e) _NOEXCEPT
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+ throw __e;
+ }
+ catch (...)
+ {
+ return current_exception();
+ }
+#else
+ ((void)__e);
+ _VSTD::abort();
+#endif
+}
+
+#else // _LIBCPP_ABI_MICROSOFT
+
+_LIBCPP_FUNC_VIS exception_ptr __copy_exception_ptr(void *__exception, const void* __ptr);
+
+// This is a built-in template function which automagically extracts the required
+// information.
+template <class _E> void *__GetExceptionInfo(_E);
+
+template<class _Ep>
+exception_ptr
+make_exception_ptr(_Ep __e) _NOEXCEPT
+{
+ return __copy_exception_ptr(_VSTD::addressof(__e), __GetExceptionInfo(__e));
+}
+
+#endif // _LIBCPP_ABI_MICROSOFT
+// nested_exception
+
+class _LIBCPP_EXCEPTION_ABI nested_exception
+{
+ exception_ptr __ptr_;
+public:
+ nested_exception() _NOEXCEPT;
+// nested_exception(const nested_exception&) noexcept = default;
+// nested_exception& operator=(const nested_exception&) noexcept = default;
+ virtual ~nested_exception() _NOEXCEPT;
+
+ // access functions
+ _LIBCPP_NORETURN void rethrow_nested() const;
+ _LIBCPP_INLINE_VISIBILITY exception_ptr nested_ptr() const _NOEXCEPT {return __ptr_;}
+};
+
+template <class _Tp>
+struct __nested
+ : public _Tp,
+ public nested_exception
+{
+ _LIBCPP_INLINE_VISIBILITY explicit __nested(const _Tp& __t) : _Tp(__t) {}
+};
+
+#ifndef _LIBCPP_NO_EXCEPTIONS
+template <class _Tp, class _Up, bool>
+struct __throw_with_nested;
+
+template <class _Tp, class _Up>
+struct __throw_with_nested<_Tp, _Up, true> {
+ _LIBCPP_NORETURN static inline _LIBCPP_INLINE_VISIBILITY void
+ __do_throw(_Tp&& __t)
+ {
+ throw __nested<_Up>(static_cast<_Tp&&>(__t));
+ }
+};
+
+template <class _Tp, class _Up>
+struct __throw_with_nested<_Tp, _Up, false> {
+ _LIBCPP_NORETURN static inline _LIBCPP_INLINE_VISIBILITY void
+#ifndef _LIBCPP_CXX03_LANG
+ __do_throw(_Tp&& __t)
+#else
+ __do_throw (_Tp& __t)
+#endif // _LIBCPP_CXX03_LANG
+ {
+ throw static_cast<_Tp&&>(__t);
+ }
+};
+#endif
+
+template <class _Tp>
+_LIBCPP_NORETURN
+void
+throw_with_nested(_Tp&& __t)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ typedef typename decay<_Tp>::type _Up;
+ static_assert( is_copy_constructible<_Up>::value, "type thrown must be CopyConstructible");
+ __throw_with_nested<_Tp, _Up,
+ is_class<_Up>::value &&
+ !is_base_of<nested_exception, _Up>::value &&
+ !__libcpp_is_final<_Up>::value>::
+ __do_throw(static_cast<_Tp&&>(__t));
+#else
+ ((void)__t);
+ // FIXME: Make this abort
+#endif
+}
+
+template <class _From, class _To>
+struct __can_dynamic_cast : public _LIBCPP_BOOL_CONSTANT(
+ is_polymorphic<_From>::value &&
+ (!is_base_of<_To, _From>::value ||
+ is_convertible<const _From*, const _To*>::value)) {};
+
+template <class _Ep>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+rethrow_if_nested(const _Ep& __e,
+ typename enable_if< __can_dynamic_cast<_Ep, nested_exception>::value>::type* = 0)
+{
+ const nested_exception* __nep = dynamic_cast<const nested_exception*>(_VSTD::addressof(__e));
+ if (__nep)
+ __nep->rethrow_nested();
+}
+
+template <class _Ep>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+rethrow_if_nested(const _Ep&,
+ typename enable_if<!__can_dynamic_cast<_Ep, nested_exception>::value>::type* = 0)
+{
+}
+
+} // namespace std
+
+#endif // _LIBCPP_EXCEPTION
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/experimental/__config b/contrib/libs/cxxsupp/libcxxmsvc/include/experimental/__config
new file mode 100644
index 0000000000..a71b348c04
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/experimental/__config
@@ -0,0 +1,66 @@
+// -*- 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_EXPERIMENTAL_CONFIG
+#define _LIBCPP_EXPERIMENTAL_CONFIG
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace std { namespace experimental {
+#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL } }
+#define _VSTD_EXPERIMENTAL std::experimental
+
+#define _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v1 {
+#define _LIBCPP_END_NAMESPACE_LFTS } } }
+#define _VSTD_LFTS _VSTD_EXPERIMENTAL::fundamentals_v1
+
+#define _LIBCPP_BEGIN_NAMESPACE_LFTS_V2 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v2 {
+#define _LIBCPP_END_NAMESPACE_LFTS_V2 } } }
+#define _VSTD_LFTS_V2 _VSTD_EXPERIMENTAL::fundamentals_v2
+
+#define _LIBCPP_BEGIN_NAMESPACE_LFTS_PMR _LIBCPP_BEGIN_NAMESPACE_LFTS namespace pmr {
+#define _LIBCPP_END_NAMESPACE_LFTS_PMR _LIBCPP_END_NAMESPACE_LFTS }
+#define _VSTD_LFTS_PMR _VSTD_LFTS::pmr
+
+#if !defined(__cpp_coroutines) || __cpp_coroutines < 201703L
+#define _LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES
+#endif
+
+#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_COROUTINES \
+ _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace coroutines_v1 {
+
+#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_COROUTINES \
+ } _LIBCPP_END_NAMESPACE_EXPERIMENTAL
+
+#define _VSTD_CORO _VSTD_EXPERIMENTAL::coroutines_v1
+
+#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD \
+ _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace parallelism_v2 {
+
+#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD \
+ } _LIBCPP_END_NAMESPACE_EXPERIMENTAL
+
+#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD_ABI \
+ _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD namespace simd_abi {
+
+#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD_ABI \
+ } _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD
+
+// TODO: support more targets
+#if defined(__AVX__)
+#define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 32
+#else
+#define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 16
+#endif
+
+#endif
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/fenv.h b/contrib/libs/cxxsupp/libcxxmsvc/include/fenv.h
new file mode 100644
index 0000000000..5a8cebf65f
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/fenv.h
@@ -0,0 +1,120 @@
+// -*- 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_FENV_H
+#define _LIBCPP_FENV_H
+
+
+/*
+ fenv.h synopsis
+
+This entire header is C99 / C++0X
+
+Macros:
+
+ FE_DIVBYZERO
+ FE_INEXACT
+ FE_INVALID
+ FE_OVERFLOW
+ FE_UNDERFLOW
+ FE_ALL_EXCEPT
+ FE_DOWNWARD
+ FE_TONEAREST
+ FE_TOWARDZERO
+ FE_UPWARD
+ FE_DFL_ENV
+
+Types:
+
+ fenv_t
+ fexcept_t
+
+int feclearexcept(int excepts);
+int fegetexceptflag(fexcept_t* flagp, int excepts);
+int feraiseexcept(int excepts);
+int fesetexceptflag(const fexcept_t* flagp, int excepts);
+int fetestexcept(int excepts);
+int fegetround();
+int fesetround(int round);
+int fegetenv(fenv_t* envp);
+int feholdexcept(fenv_t* envp);
+int fesetenv(const fenv_t* envp);
+int feupdateenv(const fenv_t* envp);
+
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#include Y_UCRT_INCLUDE_NEXT(fenv.h)
+#else
+#include_next <fenv.h>
+#endif
+
+#ifdef __cplusplus
+
+extern "C++" {
+
+#ifdef feclearexcept
+#undef feclearexcept
+#endif
+
+#ifdef fegetexceptflag
+#undef fegetexceptflag
+#endif
+
+
+#ifdef feraiseexcept
+#undef feraiseexcept
+#endif
+
+#ifdef fesetexceptflag
+#undef fesetexceptflag
+#endif
+
+
+#ifdef fetestexcept
+#undef fetestexcept
+#endif
+
+#ifdef fegetround
+#undef fegetround
+#endif
+
+#ifdef fesetround
+#undef fesetround
+#endif
+
+#ifdef fegetenv
+#undef fegetenv
+#endif
+
+#ifdef feholdexcept
+#undef feholdexcept
+#endif
+
+
+#ifdef fesetenv
+#undef fesetenv
+#endif
+
+#ifdef feupdateenv
+#undef feupdateenv
+#endif
+
+} // extern "C++"
+
+#endif // defined(__cplusplus)
+
+#endif // _LIBCPP_FENV_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/filesystem b/contrib/libs/cxxsupp/libcxxmsvc/include/filesystem
new file mode 100644
index 0000000000..afb75df574
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/filesystem
@@ -0,0 +1,269 @@
+// -*- 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_FILESYSTEM
+#define _LIBCPP_FILESYSTEM
+/*
+ filesystem synopsis
+
+ namespace std::filesystem {
+
+ class path;
+
+ void swap(path& lhs, path& rhs) noexcept;
+ size_t hash_value(const path& p) noexcept;
+
+ bool operator==(const path& lhs, const path& rhs) noexcept;
+ bool operator!=(const path& lhs, const path& rhs) noexcept;
+ bool operator< (const path& lhs, const path& rhs) noexcept;
+ bool operator<=(const path& lhs, const path& rhs) noexcept;
+ bool operator> (const path& lhs, const path& rhs) noexcept;
+ bool operator>=(const path& lhs, const path& rhs) noexcept;
+
+ path operator/ (const path& lhs, const path& rhs);
+
+ // fs.path.io operators are friends of path.
+ template <class charT, class traits>
+ friend basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os, const path& p);
+
+ template <class charT, class traits>
+ friend basic_istream<charT, traits>&
+ operator>>(basic_istream<charT, traits>& is, path& p);
+
+ template <class Source>
+ path u8path(const Source& source);
+ template <class InputIterator>
+ path u8path(InputIterator first, InputIterator last);
+
+ class filesystem_error;
+ class directory_entry;
+
+ class directory_iterator;
+
+ // enable directory_iterator range-based for statements
+ directory_iterator begin(directory_iterator iter) noexcept;
+ directory_iterator end(directory_iterator) noexcept;
+
+ class recursive_directory_iterator;
+
+ // enable recursive_directory_iterator range-based for statements
+ recursive_directory_iterator begin(recursive_directory_iterator iter) noexcept;
+ recursive_directory_iterator end(recursive_directory_iterator) noexcept;
+
+ class file_status;
+
+ struct space_info
+ {
+ uintmax_t capacity;
+ uintmax_t free;
+ uintmax_t available;
+ };
+
+ enum class file_type;
+ enum class perms;
+ enum class perm_options;
+ enum class copy_options;
+ enum class directory_options;
+
+ typedef chrono::time_point<trivial-clock> file_time_type;
+
+ // operational functions
+
+ path absolute(const path& p);
+ path absolute(const path& p, error_code &ec);
+
+ path canonical(const path& p);
+ path canonical(const path& p, error_code& ec);
+
+ void copy(const path& from, const path& to);
+ void copy(const path& from, const path& to, error_code& ec);
+ void copy(const path& from, const path& to, copy_options options);
+ void copy(const path& from, const path& to, copy_options options,
+ error_code& ec);
+
+ bool copy_file(const path& from, const path& to);
+ bool copy_file(const path& from, const path& to, error_code& ec);
+ bool copy_file(const path& from, const path& to, copy_options option);
+ bool copy_file(const path& from, const path& to, copy_options option,
+ error_code& ec);
+
+ void copy_symlink(const path& existing_symlink, const path& new_symlink);
+ void copy_symlink(const path& existing_symlink, const path& new_symlink,
+ error_code& ec) noexcept;
+
+ bool create_directories(const path& p);
+ bool create_directories(const path& p, error_code& ec);
+
+ bool create_directory(const path& p);
+ bool create_directory(const path& p, error_code& ec) noexcept;
+
+ bool create_directory(const path& p, const path& attributes);
+ bool create_directory(const path& p, const path& attributes,
+ error_code& ec) noexcept;
+
+ void create_directory_symlink(const path& to, const path& new_symlink);
+ void create_directory_symlink(const path& to, const path& new_symlink,
+ error_code& ec) noexcept;
+
+ void create_hard_link(const path& to, const path& new_hard_link);
+ void create_hard_link(const path& to, const path& new_hard_link,
+ error_code& ec) noexcept;
+
+ void create_symlink(const path& to, const path& new_symlink);
+ void create_symlink(const path& to, const path& new_symlink,
+ error_code& ec) noexcept;
+
+ path current_path();
+ path current_path(error_code& ec);
+ void current_path(const path& p);
+ void current_path(const path& p, error_code& ec) noexcept;
+
+ bool exists(file_status s) noexcept;
+ bool exists(const path& p);
+ bool exists(const path& p, error_code& ec) noexcept;
+
+ bool equivalent(const path& p1, const path& p2);
+ bool equivalent(const path& p1, const path& p2, error_code& ec) noexcept;
+
+ uintmax_t file_size(const path& p);
+ uintmax_t file_size(const path& p, error_code& ec) noexcept;
+
+ uintmax_t hard_link_count(const path& p);
+ uintmax_t hard_link_count(const path& p, error_code& ec) noexcept;
+
+ bool is_block_file(file_status s) noexcept;
+ bool is_block_file(const path& p);
+ bool is_block_file(const path& p, error_code& ec) noexcept;
+
+ bool is_character_file(file_status s) noexcept;
+ bool is_character_file(const path& p);
+ bool is_character_file(const path& p, error_code& ec) noexcept;
+
+ bool is_directory(file_status s) noexcept;
+ bool is_directory(const path& p);
+ bool is_directory(const path& p, error_code& ec) noexcept;
+
+ bool is_empty(const path& p);
+ bool is_empty(const path& p, error_code& ec) noexcept;
+
+ bool is_fifo(file_status s) noexcept;
+ bool is_fifo(const path& p);
+ bool is_fifo(const path& p, error_code& ec) noexcept;
+
+ bool is_other(file_status s) noexcept;
+ bool is_other(const path& p);
+ bool is_other(const path& p, error_code& ec) noexcept;
+
+ bool is_regular_file(file_status s) noexcept;
+ bool is_regular_file(const path& p);
+ bool is_regular_file(const path& p, error_code& ec) noexcept;
+
+ bool is_socket(file_status s) noexcept;
+ bool is_socket(const path& p);
+ bool is_socket(const path& p, error_code& ec) noexcept;
+
+ bool is_symlink(file_status s) noexcept;
+ bool is_symlink(const path& p);
+ bool is_symlink(const path& p, error_code& ec) noexcept;
+
+ file_time_type last_write_time(const path& p);
+ file_time_type last_write_time(const path& p, error_code& ec) noexcept;
+ void last_write_time(const path& p, file_time_type new_time);
+ void last_write_time(const path& p, file_time_type new_time,
+ error_code& ec) noexcept;
+
+ void permissions(const path& p, perms prms,
+ perm_options opts=perm_options::replace);
+ void permissions(const path& p, perms prms, error_code& ec) noexcept;
+ void permissions(const path& p, perms prms, perm_options opts,
+ error_code& ec);
+
+ path proximate(const path& p, error_code& ec);
+ path proximate(const path& p, const path& base = current_path());
+ path proximate(const path& p, const path& base, error_code &ec);
+
+ path read_symlink(const path& p);
+ path read_symlink(const path& p, error_code& ec);
+
+ path relative(const path& p, error_code& ec);
+ path relative(const path& p, const path& base=current_path());
+ path relative(const path& p, const path& base, error_code& ec);
+
+ bool remove(const path& p);
+ bool remove(const path& p, error_code& ec) noexcept;
+
+ uintmax_t remove_all(const path& p);
+ uintmax_t remove_all(const path& p, error_code& ec);
+
+ void rename(const path& from, const path& to);
+ void rename(const path& from, const path& to, error_code& ec) noexcept;
+
+ void resize_file(const path& p, uintmax_t size);
+ void resize_file(const path& p, uintmax_t size, error_code& ec) noexcept;
+
+ space_info space(const path& p);
+ space_info space(const path& p, error_code& ec) noexcept;
+
+ file_status status(const path& p);
+ file_status status(const path& p, error_code& ec) noexcept;
+
+ bool status_known(file_status s) noexcept;
+
+ file_status symlink_status(const path& p);
+ file_status symlink_status(const path& p, error_code& ec) noexcept;
+
+ path temp_directory_path();
+ path temp_directory_path(error_code& ec);
+
+ path weakly_canonical(path const& p);
+ path weakly_canonical(path const& p, error_code& ec);
+
+} // namespace std::filesystem
+
+template <>
+inline constexpr bool std::ranges::enable_borrowed_range<std::filesystem::directory_iterator> = true;
+template <>
+inline constexpr bool std::ranges::enable_borrowed_range<std::filesystem::recursive_directory_iterator> = true;
+
+template <>
+inline constexpr bool std::ranges::enable_view<std::filesystem::directory_iterator> = true;
+template <>
+inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_directory_iterator> = true;
+
+*/
+
+#include <__config>
+#include <__filesystem/copy_options.h>
+#include <__filesystem/directory_entry.h>
+#include <__filesystem/directory_iterator.h>
+#include <__filesystem/directory_options.h>
+#include <__filesystem/file_status.h>
+#include <__filesystem/file_time_type.h>
+#include <__filesystem/file_type.h>
+#include <__filesystem/filesystem_error.h>
+#include <__filesystem/operations.h>
+#include <__filesystem/path.h>
+#include <__filesystem/path_iterator.h>
+#include <__filesystem/perm_options.h>
+#include <__filesystem/perms.h>
+#include <__filesystem/recursive_directory_iterator.h>
+#include <__filesystem/space_info.h>
+#include <__filesystem/u8path.h>
+#include <compare>
+#include <version>
+
+#if defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
+# error "The Filesystem library is not supported since libc++ has been configured with LIBCXX_ENABLE_FILESYSTEM disabled"
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#endif // _LIBCPP_FILESYSTEM
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/float.h b/contrib/libs/cxxsupp/libcxxmsvc/include/float.h
new file mode 100644
index 0000000000..6479a0107c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/float.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_FLOAT_H
+#define _LIBCPP_FLOAT_H
+
+/*
+ float.h synopsis
+
+Macros:
+
+ FLT_ROUNDS
+ FLT_EVAL_METHOD // C99
+ FLT_RADIX
+
+ FLT_MANT_DIG
+ DBL_MANT_DIG
+ LDBL_MANT_DIG
+
+ FLT_HAS_SUBNORM // C11
+ DBL_HAS_SUBNORM // C11
+ LDBL_HAS_SUBNORM // C11
+
+ DECIMAL_DIG // C99
+ FLT_DECIMAL_DIG // C11
+ DBL_DECIMAL_DIG // C11
+ LDBL_DECIMAL_DIG // C11
+
+ FLT_DIG
+ DBL_DIG
+ LDBL_DIG
+
+ FLT_MIN_EXP
+ DBL_MIN_EXP
+ LDBL_MIN_EXP
+
+ FLT_MIN_10_EXP
+ DBL_MIN_10_EXP
+ LDBL_MIN_10_EXP
+
+ FLT_MAX_EXP
+ DBL_MAX_EXP
+ LDBL_MAX_EXP
+
+ FLT_MAX_10_EXP
+ DBL_MAX_10_EXP
+ LDBL_MAX_10_EXP
+
+ FLT_MAX
+ DBL_MAX
+ LDBL_MAX
+
+ FLT_EPSILON
+ DBL_EPSILON
+ LDBL_EPSILON
+
+ FLT_MIN
+ DBL_MIN
+ LDBL_MIN
+
+ FLT_TRUE_MIN // C11
+ DBL_TRUE_MIN // C11
+ LDBL_TRUE_MIN // C11
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#include Y_UCRT_INCLUDE_NEXT(float.h)
+#else
+#include_next <float.h>
+#endif
+
+#ifdef __cplusplus
+
+#ifndef FLT_EVAL_METHOD
+#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
+#endif
+
+#ifndef DECIMAL_DIG
+#define DECIMAL_DIG __DECIMAL_DIG__
+#endif
+
+#endif // __cplusplus
+
+#endif // _LIBCPP_FLOAT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/format b/contrib/libs/cxxsupp/libcxxmsvc/include/format
new file mode 100644
index 0000000000..356a3051b9
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/format
@@ -0,0 +1,560 @@
+// -*- 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
+#define _LIBCPP_FORMAT
+
+/*
+
+namespace std {
+ // [format.context], class template basic_format_context
+ template<class Out, class charT> class basic_format_context;
+ using format_context = basic_format_context<unspecified, char>;
+ using wformat_context = basic_format_context<unspecified, wchar_t>;
+
+ // [format.args], class template basic_format_args
+ template<class Context> class basic_format_args;
+ using format_args = basic_format_args<format_context>;
+ using wformat_args = basic_format_args<wformat_context>;
+
+ // [format.functions], formatting functions
+ template<class... Args>
+ string format(string_view fmt, const Args&... args);
+ template<class... Args>
+ wstring format(wstring_view fmt, const Args&... args);
+ template<class... Args>
+ string format(const locale& loc, string_view fmt, const Args&... args);
+ template<class... Args>
+ wstring format(const locale& loc, wstring_view fmt, const Args&... args);
+
+ string vformat(string_view fmt, format_args args);
+ wstring vformat(wstring_view fmt, wformat_args args);
+ string vformat(const locale& loc, string_view fmt, format_args args);
+ wstring vformat(const locale& loc, wstring_view fmt, wformat_args args);
+
+ template<class Out, class... Args>
+ Out format_to(Out out, string_view fmt, const Args&... args);
+ template<class Out, class... Args>
+ Out format_to(Out out, wstring_view fmt, const Args&... args);
+ template<class Out, class... Args>
+ Out format_to(Out out, const locale& loc, string_view fmt, const Args&... args);
+ template<class Out, class... Args>
+ Out format_to(Out out, const locale& loc, wstring_view fmt, const Args&... args);
+
+ template<class Out>
+ Out vformat_to(Out out, string_view fmt, format_args args);
+ template<class Out>
+ Out vformat_to(Out out, wstring_view fmt, wformat_args args);
+ template<class Out>
+ Out vformat_to(Out out, const locale& loc, string_view fmt,
+ format_args char> args);
+ template<class Out>
+ Out vformat_to(Out out, const locale& loc, wstring_view fmt,
+ wformat_args args);
+
+ template<class Out> struct format_to_n_result {
+ Out out;
+ iter_difference_t<Out> size;
+ };
+ template<class Out, class... Args>
+ format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,
+ string_view fmt, const Args&... args);
+ template<class Out, class... Args>
+ format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,
+ wstring_view fmt, const Args&... args);
+ template<class Out, class... Args>
+ format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,
+ const locale& loc, string_view fmt,
+ const Args&... args);
+ template<class Out, class... Args>
+ format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,
+ const locale& loc, wstring_view fmt,
+ const Args&... args);
+
+ template<class... Args>
+ size_t formatted_size(string_view fmt, const Args&... args);
+ template<class... Args>
+ size_t formatted_size(wstring_view fmt, const Args&... args);
+ template<class... Args>
+ size_t formatted_size(const locale& loc, string_view fmt, const Args&... args);
+ template<class... Args>
+ size_t formatted_size(const locale& loc, wstring_view fmt, const Args&... args);
+
+ // [format.formatter], formatter
+ template<class T, class charT = char> struct formatter;
+
+ // [format.parse.ctx], class template basic_format_parse_context
+ template<class charT> class basic_format_parse_context;
+ using format_parse_context = basic_format_parse_context<char>;
+ using wformat_parse_context = basic_format_parse_context<wchar_t>;
+
+ // [format.arguments], arguments
+ // [format.arg], class template basic_format_arg
+ template<class Context> class basic_format_arg;
+
+ template<class Visitor, class Context>
+ see below visit_format_arg(Visitor&& vis, basic_format_arg<Context> arg);
+
+ // [format.arg.store], class template format-arg-store
+ template<class Context, class... Args> struct format-arg-store; // exposition only
+
+ template<class Context = format_context, class... Args>
+ format-arg-store<Context, Args...>
+ make_format_args(const Args&... args);
+ template<class... Args>
+ format-arg-store<wformat_context, Args...>
+ make_wformat_args(const Args&... args);
+
+ // [format.error], class format_error
+ class format_error;
+}
+
+*/
+
+// Make sure all feature-test macros are available.
+#include <version>
+// Enable the contents of the header only when libc++ was built with LIBCXX_ENABLE_INCOMPLETE_FEATURES.
+#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
+
+#include <__algorithm/clamp.h>
+#include <__config>
+#include <__debug>
+#include <__format/format_arg.h>
+#include <__format/format_args.h>
+#include <__format/format_context.h>
+#include <__format/format_error.h>
+#include <__format/format_fwd.h>
+#include <__format/format_parse_context.h>
+#include <__format/format_string.h>
+#include <__format/format_to_n_result.h>
+#include <__format/formatter.h>
+#include <__format/formatter_bool.h>
+#include <__format/formatter_char.h>
+#include <__format/formatter_floating_point.h>
+#include <__format/formatter_integer.h>
+#include <__format/formatter_pointer.h>
+#include <__format/formatter_string.h>
+#include <__format/parser_std_format_spec.h>
+#include <__variant/monostate.h>
+#include <array>
+#include <concepts>
+#include <string>
+#include <string_view>
+#include <type_traits>
+
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+#include <locale>
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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)
+
+// TODO FMT Move the implementation in this file to its own granular headers.
+
+// TODO FMT Evaluate which templates should be external templates. This
+// improves the efficiency of the header. However since the header is still
+// under heavy development and not all classes are stable it makes no sense
+// to do this optimization now.
+
+using format_args = basic_format_args<format_context>;
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+using wformat_args = basic_format_args<wformat_context>;
+#endif
+
+template <class _Context, class... _Args>
+struct _LIBCPP_TEMPLATE_VIS __format_arg_store {
+ // TODO FMT Use a built-in array.
+ array<basic_format_arg<_Context>, sizeof...(_Args)> __args;
+};
+
+template <class _Context = format_context, class... _Args>
+_LIBCPP_HIDE_FROM_ABI __format_arg_store<_Context, _Args...>
+make_format_args(const _Args&... __args) {
+ return {basic_format_arg<_Context>(__args)...};
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <class... _Args>
+_LIBCPP_HIDE_FROM_ABI __format_arg_store<wformat_context, _Args...>
+make_wformat_args(const _Args&... __args) {
+ return _VSTD::make_format_args<wformat_context>(__args...);
+}
+#endif
+
+namespace __format {
+
+template <class _CharT, class _ParseCtx, class _Ctx>
+_LIBCPP_HIDE_FROM_ABI const _CharT*
+__handle_replacement_field(const _CharT* __begin, const _CharT* __end,
+ _ParseCtx& __parse_ctx, _Ctx& __ctx) {
+ __format::__parse_number_result __r =
+ __format::__parse_arg_id(__begin, __end, __parse_ctx);
+
+ switch (*__r.__ptr) {
+ case _CharT(':'):
+ // The arg-id has a format-specifier, advance the input to the format-spec.
+ __parse_ctx.advance_to(__r.__ptr + 1);
+ break;
+ case _CharT('}'):
+ // The arg-id has no format-specifier.
+ __parse_ctx.advance_to(__r.__ptr);
+ break;
+ default:
+ __throw_format_error(
+ "The replacement field arg-id should terminate at a ':' or '}'");
+ }
+
+ _VSTD::visit_format_arg(
+ [&](auto __arg) {
+ if constexpr (same_as<decltype(__arg), monostate>)
+ __throw_format_error("Argument index out of bounds");
+ else if constexpr (same_as<decltype(__arg), typename basic_format_arg<_Ctx>::handle>)
+ __arg.format(__parse_ctx, __ctx);
+ else {
+ formatter<decltype(__arg), _CharT> __formatter;
+ __parse_ctx.advance_to(__formatter.parse(__parse_ctx));
+ __ctx.advance_to(__formatter.format(__arg, __ctx));
+ }
+ },
+ __ctx.arg(__r.__value));
+
+ __begin = __parse_ctx.begin();
+ if (__begin == __end || *__begin != _CharT('}'))
+ __throw_format_error("The replacement field misses a terminating '}'");
+
+ return ++__begin;
+}
+
+template <class _ParseCtx, class _Ctx>
+_LIBCPP_HIDE_FROM_ABI typename _Ctx::iterator
+__vformat_to(_ParseCtx&& __parse_ctx, _Ctx&& __ctx) {
+ using _CharT = typename _ParseCtx::char_type;
+ static_assert(same_as<typename _Ctx::char_type, _CharT>);
+
+ const _CharT* __begin = __parse_ctx.begin();
+ const _CharT* __end = __parse_ctx.end();
+ typename _Ctx::iterator __out_it = __ctx.out();
+ while (__begin != __end) {
+ switch (*__begin) {
+ case _CharT('{'):
+ ++__begin;
+ if (__begin == __end)
+ __throw_format_error("The format string terminates at a '{'");
+
+ if (*__begin != _CharT('{')) [[likely]] {
+ __ctx.advance_to(_VSTD::move(__out_it));
+ __begin =
+ __handle_replacement_field(__begin, __end, __parse_ctx, __ctx);
+ __out_it = __ctx.out();
+
+ // The output is written and __begin points to the next character. So
+ // start the next iteration.
+ continue;
+ }
+ // The string is an escape character.
+ break;
+
+ case _CharT('}'):
+ ++__begin;
+ if (__begin == __end || *__begin != _CharT('}'))
+ __throw_format_error(
+ "The format string contains an invalid escape sequence");
+
+ break;
+ }
+
+ // Copy the character to the output verbatim.
+ *__out_it++ = *__begin++;
+ }
+ return __out_it;
+}
+
+} // namespace __format
+
+template <class _OutIt, class _CharT, class _FormatOutIt>
+requires(output_iterator<_OutIt, const _CharT&>) _LIBCPP_HIDE_FROM_ABI _OutIt
+ __vformat_to(
+ _OutIt __out_it, basic_string_view<_CharT> __fmt,
+ basic_format_args<basic_format_context<_FormatOutIt, _CharT>> __args) {
+ if constexpr (same_as<_OutIt, _FormatOutIt>)
+ return _VSTD::__format::__vformat_to(
+ basic_format_parse_context{__fmt, __args.__size()},
+ _VSTD::__format_context_create(_VSTD::move(__out_it), __args));
+ else {
+ basic_string<_CharT> __str;
+ _VSTD::__format::__vformat_to(
+ basic_format_parse_context{__fmt, __args.__size()},
+ _VSTD::__format_context_create(_VSTD::back_inserter(__str), __args));
+ return _VSTD::copy_n(__str.begin(), __str.size(), _VSTD::move(__out_it));
+ }
+}
+
+template <output_iterator<const char&> _OutIt>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
+vformat_to(_OutIt __out_it, string_view __fmt, format_args __args) {
+ return _VSTD::__vformat_to(_VSTD::move(__out_it), __fmt, __args);
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <output_iterator<const wchar_t&> _OutIt>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
+vformat_to(_OutIt __out_it, wstring_view __fmt, wformat_args __args) {
+ return _VSTD::__vformat_to(_VSTD::move(__out_it), __fmt, __args);
+}
+#endif
+
+template <output_iterator<const char&> _OutIt, class... _Args>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
+format_to(_OutIt __out_it, string_view __fmt, const _Args&... __args) {
+ return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt,
+ _VSTD::make_format_args(__args...));
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <output_iterator<const wchar_t&> _OutIt, class... _Args>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
+format_to(_OutIt __out_it, wstring_view __fmt, const _Args&... __args) {
+ return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt,
+ _VSTD::make_wformat_args(__args...));
+}
+#endif
+
+_LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string
+vformat(string_view __fmt, format_args __args) {
+ string __res;
+ _VSTD::vformat_to(_VSTD::back_inserter(__res), __fmt, __args);
+ return __res;
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+_LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring
+vformat(wstring_view __fmt, wformat_args __args) {
+ wstring __res;
+ _VSTD::vformat_to(_VSTD::back_inserter(__res), __fmt, __args);
+ return __res;
+}
+#endif
+
+template <class... _Args>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string
+format(string_view __fmt, const _Args&... __args) {
+ return _VSTD::vformat(__fmt, _VSTD::make_format_args(__args...));
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <class... _Args>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring
+format(wstring_view __fmt, const _Args&... __args) {
+ return _VSTD::vformat(__fmt, _VSTD::make_wformat_args(__args...));
+}
+#endif
+
+template <output_iterator<const char&> _OutIt, class... _Args>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
+format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, string_view __fmt,
+ const _Args&... __args) {
+ // TODO FMT Improve PoC: using std::string is inefficient.
+ string __str = _VSTD::vformat(__fmt, _VSTD::make_format_args(__args...));
+ iter_difference_t<_OutIt> __s = __str.size();
+ iter_difference_t<_OutIt> __m =
+ _VSTD::clamp(__n, iter_difference_t<_OutIt>(0), __s);
+ __out_it = _VSTD::copy_n(__str.begin(), __m, _VSTD::move(__out_it));
+ return {_VSTD::move(__out_it), __s};
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <output_iterator<const wchar_t&> _OutIt, class... _Args>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
+format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, wstring_view __fmt,
+ const _Args&... __args) {
+ // TODO FMT Improve PoC: using std::string is inefficient.
+ wstring __str = _VSTD::vformat(__fmt, _VSTD::make_wformat_args(__args...));
+ iter_difference_t<_OutIt> __s = __str.size();
+ iter_difference_t<_OutIt> __m =
+ _VSTD::clamp(__n, iter_difference_t<_OutIt>(0), __s);
+ __out_it = _VSTD::copy_n(__str.begin(), __m, _VSTD::move(__out_it));
+ return {_VSTD::move(__out_it), __s};
+}
+#endif
+
+template <class... _Args>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
+formatted_size(string_view __fmt, const _Args&... __args) {
+ // TODO FMT Improve PoC: using std::string is inefficient.
+ return _VSTD::vformat(__fmt, _VSTD::make_format_args(__args...)).size();
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <class... _Args>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
+formatted_size(wstring_view __fmt, const _Args&... __args) {
+ // TODO FMT Improve PoC: using std::string is inefficient.
+ return _VSTD::vformat(__fmt, _VSTD::make_wformat_args(__args...)).size();
+}
+#endif
+
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+
+template <class _OutIt, class _CharT, class _FormatOutIt>
+requires(output_iterator<_OutIt, const _CharT&>) _LIBCPP_HIDE_FROM_ABI _OutIt
+ __vformat_to(
+ _OutIt __out_it, locale __loc, basic_string_view<_CharT> __fmt,
+ basic_format_args<basic_format_context<_FormatOutIt, _CharT>> __args) {
+ if constexpr (same_as<_OutIt, _FormatOutIt>)
+ return _VSTD::__format::__vformat_to(
+ basic_format_parse_context{__fmt, __args.__size()},
+ _VSTD::__format_context_create(_VSTD::move(__out_it), __args,
+ _VSTD::move(__loc)));
+ else {
+ basic_string<_CharT> __str;
+ _VSTD::__format::__vformat_to(
+ basic_format_parse_context{__fmt, __args.__size()},
+ _VSTD::__format_context_create(_VSTD::back_inserter(__str), __args,
+ _VSTD::move(__loc)));
+ return _VSTD::copy_n(__str.begin(), __str.size(), _VSTD::move(__out_it));
+ }
+}
+
+template <output_iterator<const char&> _OutIt>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt vformat_to(
+ _OutIt __out_it, locale __loc, string_view __fmt, format_args __args) {
+ return _VSTD::__vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt,
+ __args);
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <output_iterator<const wchar_t&> _OutIt>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt vformat_to(
+ _OutIt __out_it, locale __loc, wstring_view __fmt, wformat_args __args) {
+ return _VSTD::__vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt,
+ __args);
+}
+#endif
+
+template <output_iterator<const char&> _OutIt, class... _Args>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt format_to(
+ _OutIt __out_it, locale __loc, string_view __fmt, const _Args&... __args) {
+ return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt,
+ _VSTD::make_format_args(__args...));
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <output_iterator<const wchar_t&> _OutIt, class... _Args>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt format_to(
+ _OutIt __out_it, locale __loc, wstring_view __fmt, const _Args&... __args) {
+ return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt,
+ _VSTD::make_wformat_args(__args...));
+}
+#endif
+
+_LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string
+vformat(locale __loc, string_view __fmt, format_args __args) {
+ string __res;
+ _VSTD::vformat_to(_VSTD::back_inserter(__res), _VSTD::move(__loc), __fmt,
+ __args);
+ return __res;
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+_LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring
+vformat(locale __loc, wstring_view __fmt, wformat_args __args) {
+ wstring __res;
+ _VSTD::vformat_to(_VSTD::back_inserter(__res), _VSTD::move(__loc), __fmt,
+ __args);
+ return __res;
+}
+#endif
+
+template <class... _Args>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string
+format(locale __loc, string_view __fmt, const _Args&... __args) {
+ return _VSTD::vformat(_VSTD::move(__loc), __fmt,
+ _VSTD::make_format_args(__args...));
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <class... _Args>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring
+format(locale __loc, wstring_view __fmt, const _Args&... __args) {
+ return _VSTD::vformat(_VSTD::move(__loc), __fmt,
+ _VSTD::make_wformat_args(__args...));
+}
+#endif
+
+template <output_iterator<const char&> _OutIt, class... _Args>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
+format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc,
+ string_view __fmt, const _Args&... __args) {
+ // TODO FMT Improve PoC: using std::string is inefficient.
+ string __str = _VSTD::vformat(_VSTD::move(__loc), __fmt,
+ _VSTD::make_format_args(__args...));
+ iter_difference_t<_OutIt> __s = __str.size();
+ iter_difference_t<_OutIt> __m =
+ _VSTD::clamp(__n, iter_difference_t<_OutIt>(0), __s);
+ __out_it = _VSTD::copy_n(__str.begin(), __m, _VSTD::move(__out_it));
+ return {_VSTD::move(__out_it), __s};
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <output_iterator<const wchar_t&> _OutIt, class... _Args>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
+format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc,
+ wstring_view __fmt, const _Args&... __args) {
+ // TODO FMT Improve PoC: using std::string is inefficient.
+ wstring __str = _VSTD::vformat(_VSTD::move(__loc), __fmt,
+ _VSTD::make_wformat_args(__args...));
+ iter_difference_t<_OutIt> __s = __str.size();
+ iter_difference_t<_OutIt> __m =
+ _VSTD::clamp(__n, iter_difference_t<_OutIt>(0), __s);
+ __out_it = _VSTD::copy_n(__str.begin(), __m, _VSTD::move(__out_it));
+ return {_VSTD::move(__out_it), __s};
+}
+#endif
+
+template <class... _Args>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
+formatted_size(locale __loc, string_view __fmt, const _Args&... __args) {
+ // TODO FMT Improve PoC: using std::string is inefficient.
+ return _VSTD::vformat(_VSTD::move(__loc), __fmt,
+ _VSTD::make_format_args(__args...))
+ .size();
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <class... _Args>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
+formatted_size(locale __loc, wstring_view __fmt, const _Args&... __args) {
+ // TODO FMT Improve PoC: using std::string is inefficient.
+ return _VSTD::vformat(_VSTD::move(__loc), __fmt,
+ _VSTD::make_wformat_args(__args...))
+ .size();
+}
+#endif
+
+#endif // _LIBCPP_HAS_NO_LOCALIZATION
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
+
+#endif // _LIBCPP_FORMAT
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/forward_list b/contrib/libs/cxxsupp/libcxxmsvc/include/forward_list
new file mode 100644
index 0000000000..e01a8e7189
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/forward_list
@@ -0,0 +1,1791 @@
+// -*- 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_FORWARD_LIST
+#define _LIBCPP_FORWARD_LIST
+
+/*
+ forward_list synopsis
+
+namespace std
+{
+
+template <class T, class Allocator = allocator<T>>
+class forward_list
+{
+public:
+ typedef T value_type;
+ typedef Allocator allocator_type;
+
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef typename allocator_traits<allocator_type>::pointer pointer;
+ typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
+ typedef typename allocator_traits<allocator_type>::size_type size_type;
+ typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+ typedef <details> iterator;
+ typedef <details> const_iterator;
+
+ forward_list()
+ noexcept(is_nothrow_default_constructible<allocator_type>::value);
+ explicit forward_list(const allocator_type& a);
+ explicit forward_list(size_type n);
+ explicit forward_list(size_type n, const allocator_type& a); // C++14
+ forward_list(size_type n, const value_type& v);
+ forward_list(size_type n, const value_type& v, const allocator_type& a);
+ template <class InputIterator>
+ forward_list(InputIterator first, InputIterator last);
+ template <class InputIterator>
+ forward_list(InputIterator first, InputIterator last, const allocator_type& a);
+ forward_list(const forward_list& x);
+ forward_list(const forward_list& x, const allocator_type& a);
+ forward_list(forward_list&& x)
+ noexcept(is_nothrow_move_constructible<allocator_type>::value);
+ forward_list(forward_list&& x, const allocator_type& a);
+ forward_list(initializer_list<value_type> il);
+ forward_list(initializer_list<value_type> il, const allocator_type& a);
+
+ ~forward_list();
+
+ forward_list& operator=(const forward_list& x);
+ forward_list& operator=(forward_list&& x)
+ noexcept(
+ allocator_type::propagate_on_container_move_assignment::value &&
+ is_nothrow_move_assignable<allocator_type>::value);
+ forward_list& operator=(initializer_list<value_type> il);
+
+ template <class InputIterator>
+ void assign(InputIterator first, InputIterator last);
+ void assign(size_type n, const value_type& v);
+ void assign(initializer_list<value_type> il);
+
+ allocator_type get_allocator() const noexcept;
+
+ iterator begin() noexcept;
+ const_iterator begin() const noexcept;
+ iterator end() noexcept;
+ const_iterator end() const noexcept;
+
+ const_iterator cbegin() const noexcept;
+ const_iterator cend() const noexcept;
+
+ iterator before_begin() noexcept;
+ const_iterator before_begin() const noexcept;
+ const_iterator cbefore_begin() const noexcept;
+
+ bool empty() const noexcept;
+ size_type max_size() const noexcept;
+
+ reference front();
+ const_reference front() const;
+
+ template <class... Args> reference emplace_front(Args&&... args); // reference in C++17
+ void push_front(const value_type& v);
+ void push_front(value_type&& v);
+
+ void pop_front();
+
+ template <class... Args>
+ iterator emplace_after(const_iterator p, Args&&... args);
+ iterator insert_after(const_iterator p, const value_type& v);
+ iterator insert_after(const_iterator p, value_type&& v);
+ iterator insert_after(const_iterator p, size_type n, const value_type& v);
+ template <class InputIterator>
+ iterator insert_after(const_iterator p,
+ InputIterator first, InputIterator last);
+ iterator insert_after(const_iterator p, initializer_list<value_type> il);
+
+ iterator erase_after(const_iterator p);
+ iterator erase_after(const_iterator first, const_iterator last);
+
+ void swap(forward_list& x)
+ noexcept(allocator_traits<allocator_type>::is_always_equal::value); // C++17
+
+ void resize(size_type n);
+ void resize(size_type n, const value_type& v);
+ void clear() noexcept;
+
+ void splice_after(const_iterator p, forward_list& x);
+ void splice_after(const_iterator p, forward_list&& x);
+ void splice_after(const_iterator p, forward_list& x, const_iterator i);
+ void splice_after(const_iterator p, forward_list&& x, const_iterator i);
+ void splice_after(const_iterator p, forward_list& x,
+ const_iterator first, const_iterator last);
+ void splice_after(const_iterator p, forward_list&& x,
+ const_iterator first, const_iterator last);
+ size_type remove(const value_type& v); // void before C++20
+ template <class Predicate>
+ size_type remove_if(Predicate pred); // void before C++20
+ size_type unique(); // void before C++20
+ template <class BinaryPredicate>
+ size_type unique(BinaryPredicate binary_pred); // void before C++20
+ void merge(forward_list& x);
+ void merge(forward_list&& x);
+ template <class Compare> void merge(forward_list& x, Compare comp);
+ template <class Compare> void merge(forward_list&& x, Compare comp);
+ void sort();
+ template <class Compare> void sort(Compare comp);
+ void reverse() noexcept;
+};
+
+
+template <class InputIterator, class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
+ forward_list(InputIterator, InputIterator, Allocator = Allocator())
+ -> forward_list<typename iterator_traits<InputIterator>::value_type, Allocator>; // C++17
+
+template <class T, class Allocator>
+ bool operator==(const forward_list<T, Allocator>& x,
+ const forward_list<T, Allocator>& y);
+
+template <class T, class Allocator>
+ bool operator< (const forward_list<T, Allocator>& x,
+ const forward_list<T, Allocator>& y);
+
+template <class T, class Allocator>
+ bool operator!=(const forward_list<T, Allocator>& x,
+ const forward_list<T, Allocator>& y);
+
+template <class T, class Allocator>
+ bool operator> (const forward_list<T, Allocator>& x,
+ const forward_list<T, Allocator>& y);
+
+template <class T, class Allocator>
+ bool operator>=(const forward_list<T, Allocator>& x,
+ const forward_list<T, Allocator>& y);
+
+template <class T, class Allocator>
+ bool operator<=(const forward_list<T, Allocator>& x,
+ const forward_list<T, Allocator>& y);
+
+template <class T, class Allocator>
+ void swap(forward_list<T, Allocator>& x, forward_list<T, Allocator>& y)
+ noexcept(noexcept(x.swap(y)));
+
+template <class T, class Allocator, class U>
+ typename forward_list<T, Allocator>::size_type
+ erase(forward_list<T, Allocator>& c, const U& value); // C++20
+template <class T, class Allocator, class Predicate>
+ typename forward_list<T, Allocator>::size_type
+ erase_if(forward_list<T, Allocator>& c, Predicate pred); // C++20
+
+} // std
+
+*/
+
+#include <__algorithm/comp.h>
+#include <__algorithm/lexicographical_compare.h>
+#include <__algorithm/min.h>
+#include <__config>
+#include <__utility/forward.h>
+#include <initializer_list>
+#include <iterator>
+#include <limits>
+#include <memory>
+#include <type_traits>
+#include <version>
+
+#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 _VoidPtr> struct __forward_list_node;
+template <class _NodePtr> struct __forward_begin_node;
+
+
+template <class>
+struct __forward_list_node_value_type;
+
+template <class _Tp, class _VoidPtr>
+struct __forward_list_node_value_type<__forward_list_node<_Tp, _VoidPtr> > {
+ typedef _Tp type;
+};
+
+template <class _NodePtr>
+struct __forward_node_traits {
+
+ typedef typename remove_cv<
+ typename pointer_traits<_NodePtr>::element_type>::type __node;
+ typedef typename __forward_list_node_value_type<__node>::type __node_value_type;
+ typedef _NodePtr __node_pointer;
+ typedef __forward_begin_node<_NodePtr> __begin_node;
+ typedef typename __rebind_pointer<_NodePtr, __begin_node>::type
+ __begin_node_pointer;
+ typedef typename __rebind_pointer<_NodePtr, void>::type __void_pointer;
+
+#if defined(_LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB)
+ typedef __begin_node_pointer __iter_node_pointer;
+#else
+ typedef typename conditional<
+ is_pointer<__void_pointer>::value,
+ __begin_node_pointer,
+ __node_pointer
+ >::type __iter_node_pointer;
+#endif
+
+ typedef typename conditional<
+ is_same<__iter_node_pointer, __node_pointer>::value,
+ __begin_node_pointer,
+ __node_pointer
+ >::type __non_iter_node_pointer;
+
+ _LIBCPP_INLINE_VISIBILITY
+ static __iter_node_pointer __as_iter_node(__iter_node_pointer __p) {
+ return __p;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ static __iter_node_pointer __as_iter_node(__non_iter_node_pointer __p) {
+ return static_cast<__iter_node_pointer>(static_cast<__void_pointer>(__p));
+ }
+};
+
+template <class _NodePtr>
+struct __forward_begin_node
+{
+ typedef _NodePtr pointer;
+ typedef typename __rebind_pointer<_NodePtr, __forward_begin_node>::type __begin_node_pointer;
+
+ pointer __next_;
+
+ _LIBCPP_INLINE_VISIBILITY __forward_begin_node() : __next_(nullptr) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __begin_node_pointer __next_as_begin() const {
+ return static_cast<__begin_node_pointer>(__next_);
+ }
+};
+
+template <class _Tp, class _VoidPtr>
+struct _LIBCPP_HIDDEN __begin_node_of
+{
+ typedef __forward_begin_node<
+ typename __rebind_pointer<_VoidPtr, __forward_list_node<_Tp, _VoidPtr> >::type
+ > type;
+};
+
+template <class _Tp, class _VoidPtr>
+struct _LIBCPP_STANDALONE_DEBUG __forward_list_node
+ : public __begin_node_of<_Tp, _VoidPtr>::type
+{
+ typedef _Tp value_type;
+
+ value_type __value_;
+};
+
+
+template <class _Tp, class _Alloc = allocator<_Tp> > class _LIBCPP_TEMPLATE_VIS forward_list;
+template<class _NodeConstPtr> class _LIBCPP_TEMPLATE_VIS __forward_list_const_iterator;
+
+template <class _NodePtr>
+class _LIBCPP_TEMPLATE_VIS __forward_list_iterator
+{
+ typedef __forward_node_traits<_NodePtr> __traits;
+ typedef typename __traits::__node_pointer __node_pointer;
+ typedef typename __traits::__begin_node_pointer __begin_node_pointer;
+ typedef typename __traits::__iter_node_pointer __iter_node_pointer;
+ typedef typename __traits::__void_pointer __void_pointer;
+
+ __iter_node_pointer __ptr_;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __begin_node_pointer __get_begin() const {
+ return static_cast<__begin_node_pointer>(
+ static_cast<__void_pointer>(__ptr_));
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ __node_pointer __get_unsafe_node_pointer() const {
+ return static_cast<__node_pointer>(
+ static_cast<__void_pointer>(__ptr_));
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __forward_list_iterator(nullptr_t) _NOEXCEPT : __ptr_(nullptr) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __forward_list_iterator(__begin_node_pointer __p) _NOEXCEPT
+ : __ptr_(__traits::__as_iter_node(__p)) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __forward_list_iterator(__node_pointer __p) _NOEXCEPT
+ : __ptr_(__traits::__as_iter_node(__p)) {}
+
+ template<class, class> friend class _LIBCPP_TEMPLATE_VIS forward_list;
+ template<class> friend class _LIBCPP_TEMPLATE_VIS __forward_list_const_iterator;
+
+public:
+ typedef forward_iterator_tag iterator_category;
+ typedef typename __traits::__node_value_type value_type;
+ typedef value_type& reference;
+ typedef typename pointer_traits<__node_pointer>::difference_type
+ difference_type;
+ typedef typename __rebind_pointer<__node_pointer, value_type>::type pointer;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __forward_list_iterator() _NOEXCEPT : __ptr_(nullptr) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ reference operator*() const {return __get_unsafe_node_pointer()->__value_;}
+ _LIBCPP_INLINE_VISIBILITY
+ pointer operator->() const {
+ return pointer_traits<pointer>::pointer_to(__get_unsafe_node_pointer()->__value_);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __forward_list_iterator& operator++()
+ {
+ __ptr_ = __traits::__as_iter_node(__ptr_->__next_);
+ return *this;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ __forward_list_iterator operator++(int)
+ {
+ __forward_list_iterator __t(*this);
+ ++(*this);
+ return __t;
+ }
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const __forward_list_iterator& __x,
+ const __forward_list_iterator& __y)
+ {return __x.__ptr_ == __y.__ptr_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const __forward_list_iterator& __x,
+ const __forward_list_iterator& __y)
+ {return !(__x == __y);}
+};
+
+template <class _NodeConstPtr>
+class _LIBCPP_TEMPLATE_VIS __forward_list_const_iterator
+{
+ static_assert((!is_const<typename pointer_traits<_NodeConstPtr>::element_type>::value), "");
+ typedef _NodeConstPtr _NodePtr;
+
+ typedef __forward_node_traits<_NodePtr> __traits;
+ typedef typename __traits::__node __node;
+ typedef typename __traits::__node_pointer __node_pointer;
+ typedef typename __traits::__begin_node_pointer __begin_node_pointer;
+ typedef typename __traits::__iter_node_pointer __iter_node_pointer;
+ typedef typename __traits::__void_pointer __void_pointer;
+
+ __iter_node_pointer __ptr_;
+
+ __begin_node_pointer __get_begin() const {
+ return static_cast<__begin_node_pointer>(
+ static_cast<__void_pointer>(__ptr_));
+ }
+ __node_pointer __get_unsafe_node_pointer() const {
+ return static_cast<__node_pointer>(
+ static_cast<__void_pointer>(__ptr_));
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __forward_list_const_iterator(nullptr_t) _NOEXCEPT
+ : __ptr_(nullptr) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __forward_list_const_iterator(__begin_node_pointer __p) _NOEXCEPT
+ : __ptr_(__traits::__as_iter_node(__p)) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __forward_list_const_iterator(__node_pointer __p) _NOEXCEPT
+ : __ptr_(__traits::__as_iter_node(__p)) {}
+
+
+ template<class, class> friend class forward_list;
+
+public:
+ typedef forward_iterator_tag iterator_category;
+ typedef typename __traits::__node_value_type value_type;
+ typedef const value_type& reference;
+ typedef typename pointer_traits<__node_pointer>::difference_type
+ difference_type;
+ typedef typename __rebind_pointer<__node_pointer, const value_type>::type
+ pointer;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __forward_list_const_iterator() _NOEXCEPT : __ptr_(nullptr) {}
+ _LIBCPP_INLINE_VISIBILITY
+ __forward_list_const_iterator(__forward_list_iterator<__node_pointer> __p) _NOEXCEPT
+ : __ptr_(__p.__ptr_) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ reference operator*() const {return __get_unsafe_node_pointer()->__value_;}
+ _LIBCPP_INLINE_VISIBILITY
+ pointer operator->() const {return pointer_traits<pointer>::pointer_to(
+ __get_unsafe_node_pointer()->__value_);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __forward_list_const_iterator& operator++()
+ {
+ __ptr_ = __traits::__as_iter_node(__ptr_->__next_);
+ return *this;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ __forward_list_const_iterator operator++(int)
+ {
+ __forward_list_const_iterator __t(*this);
+ ++(*this);
+ return __t;
+ }
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const __forward_list_const_iterator& __x,
+ const __forward_list_const_iterator& __y)
+ {return __x.__ptr_ == __y.__ptr_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const __forward_list_const_iterator& __x,
+ const __forward_list_const_iterator& __y)
+ {return !(__x == __y);}
+};
+
+template <class _Tp, class _Alloc>
+class __forward_list_base
+{
+protected:
+ typedef _Tp value_type;
+ typedef _Alloc allocator_type;
+
+ typedef typename allocator_traits<allocator_type>::void_pointer void_pointer;
+ typedef __forward_list_node<value_type, void_pointer> __node;
+ typedef typename __begin_node_of<value_type, void_pointer>::type __begin_node;
+ typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, __node>::type __node_allocator;
+ typedef allocator_traits<__node_allocator> __node_traits;
+ typedef typename __node_traits::pointer __node_pointer;
+
+ typedef typename __rebind_alloc_helper<
+ allocator_traits<allocator_type>, __begin_node
+ >::type __begin_node_allocator;
+ typedef typename allocator_traits<__begin_node_allocator>::pointer
+ __begin_node_pointer;
+
+ static_assert((!is_same<allocator_type, __node_allocator>::value),
+ "internal allocator type must differ from user-specified "
+ "type; otherwise overload resolution breaks");
+
+ __compressed_pair<__begin_node, __node_allocator> __before_begin_;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __begin_node_pointer __before_begin() _NOEXCEPT
+ {return pointer_traits<__begin_node_pointer>::pointer_to(__before_begin_.first());}
+ _LIBCPP_INLINE_VISIBILITY
+ __begin_node_pointer __before_begin() const _NOEXCEPT
+ {return pointer_traits<__begin_node_pointer>::pointer_to(const_cast<__begin_node&>(__before_begin_.first()));}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __node_allocator& __alloc() _NOEXCEPT
+ {return __before_begin_.second();}
+ _LIBCPP_INLINE_VISIBILITY
+ const __node_allocator& __alloc() const _NOEXCEPT
+ {return __before_begin_.second();}
+
+ typedef __forward_list_iterator<__node_pointer> iterator;
+ typedef __forward_list_const_iterator<__node_pointer> const_iterator;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __forward_list_base()
+ _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)
+ : __before_begin_(__begin_node(), __default_init_tag()) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __forward_list_base(const allocator_type& __a)
+ : __before_begin_(__begin_node(), __node_allocator(__a)) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __forward_list_base(const __node_allocator& __a)
+ : __before_begin_(__begin_node(), __a) {}
+#ifndef _LIBCPP_CXX03_LANG
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ __forward_list_base(__forward_list_base&& __x)
+ _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
+
+private:
+ __forward_list_base(const __forward_list_base&);
+ __forward_list_base& operator=(const __forward_list_base&);
+
+public:
+ ~__forward_list_base();
+
+protected:
+ _LIBCPP_INLINE_VISIBILITY
+ void __copy_assign_alloc(const __forward_list_base& __x)
+ {__copy_assign_alloc(__x, integral_constant<bool,
+ __node_traits::propagate_on_container_copy_assignment::value>());}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __move_assign_alloc(__forward_list_base& __x)
+ _NOEXCEPT_(!__node_traits::propagate_on_container_move_assignment::value ||
+ is_nothrow_move_assignable<__node_allocator>::value)
+ {__move_assign_alloc(__x, integral_constant<bool,
+ __node_traits::propagate_on_container_move_assignment::value>());}
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(__forward_list_base& __x)
+#if _LIBCPP_STD_VER >= 14
+ _NOEXCEPT;
+#else
+ _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value ||
+ __is_nothrow_swappable<__node_allocator>::value);
+#endif
+protected:
+ void clear() _NOEXCEPT;
+
+private:
+ _LIBCPP_INLINE_VISIBILITY
+ void __copy_assign_alloc(const __forward_list_base&, false_type) {}
+ _LIBCPP_INLINE_VISIBILITY
+ void __copy_assign_alloc(const __forward_list_base& __x, true_type)
+ {
+ if (__alloc() != __x.__alloc())
+ clear();
+ __alloc() = __x.__alloc();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __move_assign_alloc(__forward_list_base&, false_type) _NOEXCEPT
+ {}
+ _LIBCPP_INLINE_VISIBILITY
+ void __move_assign_alloc(__forward_list_base& __x, true_type)
+ _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value)
+ {__alloc() = _VSTD::move(__x.__alloc());}
+};
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Alloc>
+inline
+__forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base&& __x)
+ _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value)
+ : __before_begin_(_VSTD::move(__x.__before_begin_))
+{
+ __x.__before_begin()->__next_ = nullptr;
+}
+
+template <class _Tp, class _Alloc>
+inline
+__forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base&& __x,
+ const allocator_type& __a)
+ : __before_begin_(__begin_node(), __node_allocator(__a))
+{
+ if (__alloc() == __x.__alloc())
+ {
+ __before_begin()->__next_ = __x.__before_begin()->__next_;
+ __x.__before_begin()->__next_ = nullptr;
+ }
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Alloc>
+__forward_list_base<_Tp, _Alloc>::~__forward_list_base()
+{
+ clear();
+}
+
+template <class _Tp, class _Alloc>
+inline
+void
+__forward_list_base<_Tp, _Alloc>::swap(__forward_list_base& __x)
+#if _LIBCPP_STD_VER >= 14
+ _NOEXCEPT
+#else
+ _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value ||
+ __is_nothrow_swappable<__node_allocator>::value)
+#endif
+{
+ _VSTD::__swap_allocator(__alloc(), __x.__alloc(),
+ integral_constant<bool, __node_traits::propagate_on_container_swap::value>());
+ using _VSTD::swap;
+ swap(__before_begin()->__next_, __x.__before_begin()->__next_);
+}
+
+template <class _Tp, class _Alloc>
+void
+__forward_list_base<_Tp, _Alloc>::clear() _NOEXCEPT
+{
+ __node_allocator& __a = __alloc();
+ for (__node_pointer __p = __before_begin()->__next_; __p != nullptr;)
+ {
+ __node_pointer __next = __p->__next_;
+ __node_traits::destroy(__a, _VSTD::addressof(__p->__value_));
+ __node_traits::deallocate(__a, __p, 1);
+ __p = __next;
+ }
+ __before_begin()->__next_ = nullptr;
+}
+
+template <class _Tp, class _Alloc /*= allocator<_Tp>*/>
+class _LIBCPP_TEMPLATE_VIS forward_list
+ : private __forward_list_base<_Tp, _Alloc>
+{
+ typedef __forward_list_base<_Tp, _Alloc> base;
+ typedef typename base::__node_allocator __node_allocator;
+ typedef typename base::__node __node;
+ typedef typename base::__node_traits __node_traits;
+ typedef typename base::__node_pointer __node_pointer;
+ typedef typename base::__begin_node_pointer __begin_node_pointer;
+
+public:
+ typedef _Tp value_type;
+ typedef _Alloc allocator_type;
+
+ static_assert((is_same<typename allocator_type::value_type, value_type>::value),
+ "Allocator::value_type must be same type as value_type");
+
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef typename allocator_traits<allocator_type>::pointer pointer;
+ typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
+ typedef typename allocator_traits<allocator_type>::size_type size_type;
+ typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+ typedef typename base::iterator iterator;
+ typedef typename base::const_iterator const_iterator;
+#if _LIBCPP_STD_VER > 17
+ typedef size_type __remove_return_type;
+#else
+ typedef void __remove_return_type;
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ forward_list()
+ _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)
+ {} // = default;
+ _LIBCPP_INLINE_VISIBILITY
+ explicit forward_list(const allocator_type& __a);
+ explicit forward_list(size_type __n);
+#if _LIBCPP_STD_VER > 11
+ explicit forward_list(size_type __n, const allocator_type& __a);
+#endif
+ forward_list(size_type __n, const value_type& __v);
+
+ template <class = __enable_if_t<__is_allocator<_Alloc>::value> >
+ forward_list(size_type __n, const value_type& __v, const allocator_type& __a) : base(__a)
+ {
+ insert_after(cbefore_begin(), __n, __v);
+ }
+
+ template <class _InputIterator>
+ forward_list(_InputIterator __f, _InputIterator __l,
+ typename enable_if<
+ __is_cpp17_input_iterator<_InputIterator>::value
+ >::type* = nullptr);
+ template <class _InputIterator>
+ forward_list(_InputIterator __f, _InputIterator __l,
+ const allocator_type& __a,
+ typename enable_if<
+ __is_cpp17_input_iterator<_InputIterator>::value
+ >::type* = nullptr);
+ forward_list(const forward_list& __x);
+ forward_list(const forward_list& __x, const __identity_t<allocator_type>& __a);
+
+ forward_list& operator=(const forward_list& __x);
+
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ forward_list(forward_list&& __x)
+ _NOEXCEPT_(is_nothrow_move_constructible<base>::value)
+ : base(_VSTD::move(__x)) {}
+ 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);
+
+ _LIBCPP_INLINE_VISIBILITY
+ forward_list& operator=(forward_list&& __x)
+ _NOEXCEPT_(
+ __node_traits::propagate_on_container_move_assignment::value &&
+ is_nothrow_move_assignable<allocator_type>::value);
+
+ _LIBCPP_INLINE_VISIBILITY
+ forward_list& operator=(initializer_list<value_type> __il);
+
+ _LIBCPP_INLINE_VISIBILITY
+ void assign(initializer_list<value_type> __il);
+#endif // _LIBCPP_CXX03_LANG
+
+ // ~forward_list() = default;
+
+ template <class _InputIterator>
+ typename enable_if
+ <
+ __is_cpp17_input_iterator<_InputIterator>::value,
+ void
+ >::type
+ assign(_InputIterator __f, _InputIterator __l);
+ void assign(size_type __n, const value_type& __v);
+
+ _LIBCPP_INLINE_VISIBILITY
+ allocator_type get_allocator() const _NOEXCEPT
+ {return allocator_type(base::__alloc());}
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator begin() _NOEXCEPT
+ {return iterator(base::__before_begin()->__next_);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator begin() const _NOEXCEPT
+ {return const_iterator(base::__before_begin()->__next_);}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator end() _NOEXCEPT
+ {return iterator(nullptr);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator end() const _NOEXCEPT
+ {return const_iterator(nullptr);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator cbegin() const _NOEXCEPT
+ {return const_iterator(base::__before_begin()->__next_);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator cend() const _NOEXCEPT
+ {return const_iterator(nullptr);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator before_begin() _NOEXCEPT
+ {return iterator(base::__before_begin());}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator before_begin() const _NOEXCEPT
+ {return const_iterator(base::__before_begin());}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator cbefore_begin() const _NOEXCEPT
+ {return const_iterator(base::__before_begin());}
+
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+ bool empty() const _NOEXCEPT
+ {return base::__before_begin()->__next_ == nullptr;}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type max_size() const _NOEXCEPT {
+ return _VSTD::min<size_type>(
+ __node_traits::max_size(base::__alloc()),
+ numeric_limits<difference_type>::max());
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ reference front() {return base::__before_begin()->__next_->__value_;}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reference front() const {return base::__before_begin()->__next_->__value_;}
+
+#ifndef _LIBCPP_CXX03_LANG
+#if _LIBCPP_STD_VER > 14
+ template <class... _Args> reference emplace_front(_Args&&... __args);
+#else
+ template <class... _Args> void emplace_front(_Args&&... __args);
+#endif
+ void push_front(value_type&& __v);
+#endif // _LIBCPP_CXX03_LANG
+ void push_front(const value_type& __v);
+
+ void pop_front();
+
+#ifndef _LIBCPP_CXX03_LANG
+ template <class... _Args>
+ iterator emplace_after(const_iterator __p, _Args&&... __args);
+
+ 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
+ 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>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if
+ <
+ __is_cpp17_input_iterator<_InputIterator>::value,
+ iterator
+ >::type
+ insert_after(const_iterator __p, _InputIterator __f, _InputIterator __l);
+
+ iterator erase_after(const_iterator __p);
+ iterator erase_after(const_iterator __f, const_iterator __l);
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(forward_list& __x)
+#if _LIBCPP_STD_VER >= 14
+ _NOEXCEPT
+#else
+ _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value ||
+ __is_nothrow_swappable<__node_allocator>::value)
+#endif
+ {base::swap(__x);}
+
+ void resize(size_type __n);
+ void resize(size_type __n, const value_type& __v);
+ _LIBCPP_INLINE_VISIBILITY
+ void clear() _NOEXCEPT {base::clear();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void splice_after(const_iterator __p, forward_list&& __x);
+ _LIBCPP_INLINE_VISIBILITY
+ void splice_after(const_iterator __p, forward_list&& __x, const_iterator __i);
+ _LIBCPP_INLINE_VISIBILITY
+ void splice_after(const_iterator __p, forward_list&& __x,
+ const_iterator __f, const_iterator __l);
+ void splice_after(const_iterator __p, forward_list& __x);
+ void splice_after(const_iterator __p, forward_list& __x, const_iterator __i);
+ void splice_after(const_iterator __p, forward_list& __x,
+ const_iterator __f, const_iterator __l);
+ __remove_return_type remove(const value_type& __v);
+ template <class _Predicate> __remove_return_type remove_if(_Predicate __pred);
+ _LIBCPP_INLINE_VISIBILITY
+ __remove_return_type unique() {return unique(__equal_to<value_type>());}
+ template <class _BinaryPredicate> __remove_return_type unique(_BinaryPredicate __binary_pred);
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(forward_list&& __x) {merge(__x, __less<value_type>());}
+ template <class _Compare>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(forward_list&& __x, _Compare __comp)
+ {merge(__x, _VSTD::move(__comp));}
+#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);
+ _LIBCPP_INLINE_VISIBILITY
+ void sort() {sort(__less<value_type>());}
+ template <class _Compare> _LIBCPP_INLINE_VISIBILITY void sort(_Compare __comp);
+ void reverse() _NOEXCEPT;
+
+private:
+
+#ifndef _LIBCPP_CXX03_LANG
+ 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
+
+ template <class _Compare>
+ static
+ __node_pointer
+ __merge(__node_pointer __f1, __node_pointer __f2, _Compare& __comp);
+
+ template <class _Compare>
+ static
+ __node_pointer
+ __sort(__node_pointer __f, difference_type __sz, _Compare& __comp);
+};
+
+
+#if _LIBCPP_STD_VER >= 17
+template<class _InputIterator,
+ class _Alloc = allocator<__iter_value_type<_InputIterator>>,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = enable_if_t<__is_allocator<_Alloc>::value>
+ >
+forward_list(_InputIterator, _InputIterator)
+ -> forward_list<__iter_value_type<_InputIterator>, _Alloc>;
+
+template<class _InputIterator,
+ class _Alloc,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = enable_if_t<__is_allocator<_Alloc>::value>
+ >
+forward_list(_InputIterator, _InputIterator, _Alloc)
+ -> forward_list<__iter_value_type<_InputIterator>, _Alloc>;
+#endif
+
+template <class _Tp, class _Alloc>
+inline
+forward_list<_Tp, _Alloc>::forward_list(const allocator_type& __a)
+ : base(__a)
+{
+}
+
+template <class _Tp, class _Alloc>
+forward_list<_Tp, _Alloc>::forward_list(size_type __n)
+{
+ if (__n > 0)
+ {
+ __node_allocator& __a = base::__alloc();
+ typedef __allocator_destructor<__node_allocator> _Dp;
+ unique_ptr<__node, _Dp> __h(nullptr, _Dp(__a, 1));
+ for (__begin_node_pointer __p = base::__before_begin(); __n > 0; --__n,
+ __p = __p->__next_as_begin())
+ {
+ __h.reset(__node_traits::allocate(__a, 1));
+ __node_traits::construct(__a, _VSTD::addressof(__h->__value_));
+ __h->__next_ = nullptr;
+ __p->__next_ = __h.release();
+ }
+ }
+}
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp, class _Alloc>
+forward_list<_Tp, _Alloc>::forward_list(size_type __n,
+ const allocator_type& __base_alloc)
+ : base ( __base_alloc )
+{
+ if (__n > 0)
+ {
+ __node_allocator& __a = base::__alloc();
+ typedef __allocator_destructor<__node_allocator> _Dp;
+ unique_ptr<__node, _Dp> __h(nullptr, _Dp(__a, 1));
+ for (__begin_node_pointer __p = base::__before_begin(); __n > 0; --__n,
+ __p = __p->__next_as_begin())
+ {
+ __h.reset(__node_traits::allocate(__a, 1));
+ __node_traits::construct(__a, _VSTD::addressof(__h->__value_));
+ __h->__next_ = nullptr;
+ __p->__next_ = __h.release();
+ }
+ }
+}
+#endif
+
+template <class _Tp, class _Alloc>
+forward_list<_Tp, _Alloc>::forward_list(size_type __n, const value_type& __v)
+{
+ insert_after(cbefore_begin(), __n, __v);
+}
+
+template <class _Tp, class _Alloc>
+template <class _InputIterator>
+forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l,
+ typename enable_if<
+ __is_cpp17_input_iterator<_InputIterator>::value
+ >::type*)
+{
+ insert_after(cbefore_begin(), __f, __l);
+}
+
+template <class _Tp, class _Alloc>
+template <class _InputIterator>
+forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l,
+ const allocator_type& __a,
+ typename enable_if<
+ __is_cpp17_input_iterator<_InputIterator>::value
+ >::type*)
+ : base(__a)
+{
+ insert_after(cbefore_begin(), __f, __l);
+}
+
+template <class _Tp, class _Alloc>
+forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x)
+ : base(
+ __node_traits::select_on_container_copy_construction(__x.__alloc())) {
+ insert_after(cbefore_begin(), __x.begin(), __x.end());
+}
+
+template <class _Tp, class _Alloc>
+forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x,
+ const __identity_t<allocator_type>& __a)
+ : base(__a)
+{
+ insert_after(cbefore_begin(), __x.begin(), __x.end());
+}
+
+template <class _Tp, class _Alloc>
+forward_list<_Tp, _Alloc>&
+forward_list<_Tp, _Alloc>::operator=(const forward_list& __x)
+{
+ if (this != _VSTD::addressof(__x))
+ {
+ base::__copy_assign_alloc(__x);
+ assign(__x.begin(), __x.end());
+ }
+ return *this;
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+template <class _Tp, class _Alloc>
+forward_list<_Tp, _Alloc>::forward_list(forward_list&& __x,
+ const __identity_t<allocator_type>& __a)
+ : base(_VSTD::move(__x), __a)
+{
+ if (base::__alloc() != __x.__alloc())
+ {
+ typedef move_iterator<iterator> _Ip;
+ insert_after(cbefore_begin(), _Ip(__x.begin()), _Ip(__x.end()));
+ }
+}
+
+template <class _Tp, class _Alloc>
+forward_list<_Tp, _Alloc>::forward_list(initializer_list<value_type> __il)
+{
+ insert_after(cbefore_begin(), __il.begin(), __il.end());
+}
+
+template <class _Tp, class _Alloc>
+forward_list<_Tp, _Alloc>::forward_list(initializer_list<value_type> __il,
+ const allocator_type& __a)
+ : base(__a)
+{
+ insert_after(cbefore_begin(), __il.begin(), __il.end());
+}
+
+template <class _Tp, class _Alloc>
+void
+forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, true_type)
+ _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
+{
+ clear();
+ base::__move_assign_alloc(__x);
+ base::__before_begin()->__next_ = __x.__before_begin()->__next_;
+ __x.__before_begin()->__next_ = nullptr;
+}
+
+template <class _Tp, class _Alloc>
+void
+forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, false_type)
+{
+ if (base::__alloc() == __x.__alloc())
+ __move_assign(__x, true_type());
+ else
+ {
+ typedef move_iterator<iterator> _Ip;
+ assign(_Ip(__x.begin()), _Ip(__x.end()));
+ }
+}
+
+template <class _Tp, class _Alloc>
+inline
+forward_list<_Tp, _Alloc>&
+forward_list<_Tp, _Alloc>::operator=(forward_list&& __x)
+ _NOEXCEPT_(
+ __node_traits::propagate_on_container_move_assignment::value &&
+ is_nothrow_move_assignable<allocator_type>::value)
+{
+ __move_assign(__x, integral_constant<bool,
+ __node_traits::propagate_on_container_move_assignment::value>());
+ return *this;
+}
+
+template <class _Tp, class _Alloc>
+inline
+forward_list<_Tp, _Alloc>&
+forward_list<_Tp, _Alloc>::operator=(initializer_list<value_type> __il)
+{
+ assign(__il.begin(), __il.end());
+ return *this;
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Alloc>
+template <class _InputIterator>
+typename enable_if
+<
+ __is_cpp17_input_iterator<_InputIterator>::value,
+ void
+>::type
+forward_list<_Tp, _Alloc>::assign(_InputIterator __f, _InputIterator __l)
+{
+ iterator __i = before_begin();
+ iterator __j = _VSTD::next(__i);
+ iterator __e = end();
+ for (; __j != __e && __f != __l; ++__i, (void) ++__j, ++__f)
+ *__j = *__f;
+ if (__j == __e)
+ insert_after(__i, __f, __l);
+ else
+ erase_after(__i, __e);
+}
+
+template <class _Tp, class _Alloc>
+void
+forward_list<_Tp, _Alloc>::assign(size_type __n, const value_type& __v)
+{
+ iterator __i = before_begin();
+ iterator __j = _VSTD::next(__i);
+ iterator __e = end();
+ for (; __j != __e && __n > 0; --__n, ++__i, ++__j)
+ *__j = __v;
+ if (__j == __e)
+ insert_after(__i, __n, __v);
+ else
+ erase_after(__i, __e);
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Alloc>
+inline
+void
+forward_list<_Tp, _Alloc>::assign(initializer_list<value_type> __il)
+{
+ assign(__il.begin(), __il.end());
+}
+
+template <class _Tp, class _Alloc>
+template <class... _Args>
+#if _LIBCPP_STD_VER > 14
+typename forward_list<_Tp, _Alloc>::reference
+#else
+void
+#endif
+forward_list<_Tp, _Alloc>::emplace_front(_Args&&... __args)
+{
+ __node_allocator& __a = base::__alloc();
+ typedef __allocator_destructor<__node_allocator> _Dp;
+ unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1));
+ __node_traits::construct(__a, _VSTD::addressof(__h->__value_),
+ _VSTD::forward<_Args>(__args)...);
+ __h->__next_ = base::__before_begin()->__next_;
+ base::__before_begin()->__next_ = __h.release();
+#if _LIBCPP_STD_VER > 14
+ return base::__before_begin()->__next_->__value_;
+#endif
+}
+
+template <class _Tp, class _Alloc>
+void
+forward_list<_Tp, _Alloc>::push_front(value_type&& __v)
+{
+ __node_allocator& __a = base::__alloc();
+ typedef __allocator_destructor<__node_allocator> _Dp;
+ unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1));
+ __node_traits::construct(__a, _VSTD::addressof(__h->__value_), _VSTD::move(__v));
+ __h->__next_ = base::__before_begin()->__next_;
+ base::__before_begin()->__next_ = __h.release();
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Alloc>
+void
+forward_list<_Tp, _Alloc>::push_front(const value_type& __v)
+{
+ __node_allocator& __a = base::__alloc();
+ typedef __allocator_destructor<__node_allocator> _Dp;
+ unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1));
+ __node_traits::construct(__a, _VSTD::addressof(__h->__value_), __v);
+ __h->__next_ = base::__before_begin()->__next_;
+ base::__before_begin()->__next_ = __h.release();
+}
+
+template <class _Tp, class _Alloc>
+void
+forward_list<_Tp, _Alloc>::pop_front()
+{
+ __node_allocator& __a = base::__alloc();
+ __node_pointer __p = base::__before_begin()->__next_;
+ base::__before_begin()->__next_ = __p->__next_;
+ __node_traits::destroy(__a, _VSTD::addressof(__p->__value_));
+ __node_traits::deallocate(__a, __p, 1);
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Alloc>
+template <class... _Args>
+typename forward_list<_Tp, _Alloc>::iterator
+forward_list<_Tp, _Alloc>::emplace_after(const_iterator __p, _Args&&... __args)
+{
+ __begin_node_pointer const __r = __p.__get_begin();
+ __node_allocator& __a = base::__alloc();
+ typedef __allocator_destructor<__node_allocator> _Dp;
+ unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1));
+ __node_traits::construct(__a, _VSTD::addressof(__h->__value_),
+ _VSTD::forward<_Args>(__args)...);
+ __h->__next_ = __r->__next_;
+ __r->__next_ = __h.release();
+ return iterator(__r->__next_);
+}
+
+template <class _Tp, class _Alloc>
+typename forward_list<_Tp, _Alloc>::iterator
+forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, value_type&& __v)
+{
+ __begin_node_pointer const __r = __p.__get_begin();
+ __node_allocator& __a = base::__alloc();
+ typedef __allocator_destructor<__node_allocator> _Dp;
+ unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1));
+ __node_traits::construct(__a, _VSTD::addressof(__h->__value_), _VSTD::move(__v));
+ __h->__next_ = __r->__next_;
+ __r->__next_ = __h.release();
+ return iterator(__r->__next_);
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Alloc>
+typename forward_list<_Tp, _Alloc>::iterator
+forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, const value_type& __v)
+{
+ __begin_node_pointer const __r = __p.__get_begin();
+ __node_allocator& __a = base::__alloc();
+ typedef __allocator_destructor<__node_allocator> _Dp;
+ unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1));
+ __node_traits::construct(__a, _VSTD::addressof(__h->__value_), __v);
+ __h->__next_ = __r->__next_;
+ __r->__next_ = __h.release();
+ return iterator(__r->__next_);
+}
+
+template <class _Tp, class _Alloc>
+typename forward_list<_Tp, _Alloc>::iterator
+forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n,
+ const value_type& __v)
+{
+ __begin_node_pointer __r = __p.__get_begin();
+ if (__n > 0)
+ {
+ __node_allocator& __a = base::__alloc();
+ typedef __allocator_destructor<__node_allocator> _Dp;
+ unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1));
+ __node_traits::construct(__a, _VSTD::addressof(__h->__value_), __v);
+ __node_pointer __first = __h.release();
+ __node_pointer __last = __first;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ for (--__n; __n != 0; --__n, __last = __last->__next_)
+ {
+ __h.reset(__node_traits::allocate(__a, 1));
+ __node_traits::construct(__a, _VSTD::addressof(__h->__value_), __v);
+ __last->__next_ = __h.release();
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ while (__first != nullptr)
+ {
+ __node_pointer __next = __first->__next_;
+ __node_traits::destroy(__a, _VSTD::addressof(__first->__value_));
+ __node_traits::deallocate(__a, __first, 1);
+ __first = __next;
+ }
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ __last->__next_ = __r->__next_;
+ __r->__next_ = __first;
+ __r = static_cast<__begin_node_pointer>(__last);
+ }
+ return iterator(__r);
+}
+
+template <class _Tp, class _Alloc>
+template <class _InputIterator>
+typename enable_if
+<
+ __is_cpp17_input_iterator<_InputIterator>::value,
+ typename forward_list<_Tp, _Alloc>::iterator
+>::type
+forward_list<_Tp, _Alloc>::insert_after(const_iterator __p,
+ _InputIterator __f, _InputIterator __l)
+{
+ __begin_node_pointer __r = __p.__get_begin();
+ if (__f != __l)
+ {
+ __node_allocator& __a = base::__alloc();
+ typedef __allocator_destructor<__node_allocator> _Dp;
+ unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1));
+ __node_traits::construct(__a, _VSTD::addressof(__h->__value_), *__f);
+ __node_pointer __first = __h.release();
+ __node_pointer __last = __first;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ for (++__f; __f != __l; ++__f, ((void)(__last = __last->__next_)))
+ {
+ __h.reset(__node_traits::allocate(__a, 1));
+ __node_traits::construct(__a, _VSTD::addressof(__h->__value_), *__f);
+ __last->__next_ = __h.release();
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ while (__first != nullptr)
+ {
+ __node_pointer __next = __first->__next_;
+ __node_traits::destroy(__a, _VSTD::addressof(__first->__value_));
+ __node_traits::deallocate(__a, __first, 1);
+ __first = __next;
+ }
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ __last->__next_ = __r->__next_;
+ __r->__next_ = __first;
+ __r = static_cast<__begin_node_pointer>(__last);
+ }
+ return iterator(__r);
+}
+
+template <class _Tp, class _Alloc>
+typename forward_list<_Tp, _Alloc>::iterator
+forward_list<_Tp, _Alloc>::erase_after(const_iterator __f)
+{
+ __begin_node_pointer __p = __f.__get_begin();
+ __node_pointer __n = __p->__next_;
+ __p->__next_ = __n->__next_;
+ __node_allocator& __a = base::__alloc();
+ __node_traits::destroy(__a, _VSTD::addressof(__n->__value_));
+ __node_traits::deallocate(__a, __n, 1);
+ return iterator(__p->__next_);
+}
+
+template <class _Tp, class _Alloc>
+typename forward_list<_Tp, _Alloc>::iterator
+forward_list<_Tp, _Alloc>::erase_after(const_iterator __f, const_iterator __l)
+{
+ __node_pointer __e = __l.__get_unsafe_node_pointer();
+ if (__f != __l)
+ {
+ __begin_node_pointer __bp = __f.__get_begin();
+
+ __node_pointer __n = __bp->__next_;
+ if (__n != __e)
+ {
+ __bp->__next_ = __e;
+ __node_allocator& __a = base::__alloc();
+ do
+ {
+ __node_pointer __tmp = __n->__next_;
+ __node_traits::destroy(__a, _VSTD::addressof(__n->__value_));
+ __node_traits::deallocate(__a, __n, 1);
+ __n = __tmp;
+ } while (__n != __e);
+ }
+ }
+ return iterator(__e);
+}
+
+template <class _Tp, class _Alloc>
+void
+forward_list<_Tp, _Alloc>::resize(size_type __n)
+{
+ size_type __sz = 0;
+ iterator __p = before_begin();
+ iterator __i = begin();
+ iterator __e = end();
+ for (; __i != __e && __sz < __n; ++__p, ++__i, ++__sz)
+ ;
+ if (__i != __e)
+ erase_after(__p, __e);
+ else
+ {
+ __n -= __sz;
+ if (__n > 0)
+ {
+ __node_allocator& __a = base::__alloc();
+ typedef __allocator_destructor<__node_allocator> _Dp;
+ unique_ptr<__node, _Dp> __h(nullptr, _Dp(__a, 1));
+ for (__begin_node_pointer __ptr = __p.__get_begin(); __n > 0; --__n,
+ __ptr = __ptr->__next_as_begin())
+ {
+ __h.reset(__node_traits::allocate(__a, 1));
+ __node_traits::construct(__a, _VSTD::addressof(__h->__value_));
+ __h->__next_ = nullptr;
+ __ptr->__next_ = __h.release();
+ }
+ }
+ }
+}
+
+template <class _Tp, class _Alloc>
+void
+forward_list<_Tp, _Alloc>::resize(size_type __n, const value_type& __v)
+{
+ size_type __sz = 0;
+ iterator __p = before_begin();
+ iterator __i = begin();
+ iterator __e = end();
+ for (; __i != __e && __sz < __n; ++__p, ++__i, ++__sz)
+ ;
+ if (__i != __e)
+ erase_after(__p, __e);
+ else
+ {
+ __n -= __sz;
+ if (__n > 0)
+ {
+ __node_allocator& __a = base::__alloc();
+ typedef __allocator_destructor<__node_allocator> _Dp;
+ unique_ptr<__node, _Dp> __h(nullptr, _Dp(__a, 1));
+ for (__begin_node_pointer __ptr = __p.__get_begin(); __n > 0; --__n,
+ __ptr = __ptr->__next_as_begin())
+ {
+ __h.reset(__node_traits::allocate(__a, 1));
+ __node_traits::construct(__a, _VSTD::addressof(__h->__value_), __v);
+ __h->__next_ = nullptr;
+ __ptr->__next_ = __h.release();
+ }
+ }
+ }
+}
+
+template <class _Tp, class _Alloc>
+void
+forward_list<_Tp, _Alloc>::splice_after(const_iterator __p,
+ forward_list& __x)
+{
+ if (!__x.empty())
+ {
+ if (__p.__get_begin()->__next_ != nullptr)
+ {
+ const_iterator __lm1 = __x.before_begin();
+ while (__lm1.__get_begin()->__next_ != nullptr)
+ ++__lm1;
+ __lm1.__get_begin()->__next_ = __p.__get_begin()->__next_;
+ }
+ __p.__get_begin()->__next_ = __x.__before_begin()->__next_;
+ __x.__before_begin()->__next_ = nullptr;
+ }
+}
+
+template <class _Tp, class _Alloc>
+void
+forward_list<_Tp, _Alloc>::splice_after(const_iterator __p,
+ forward_list& /*__other*/,
+ const_iterator __i)
+{
+ const_iterator __lm1 = _VSTD::next(__i);
+ if (__p != __i && __p != __lm1)
+ {
+ __i.__get_begin()->__next_ = __lm1.__get_begin()->__next_;
+ __lm1.__get_begin()->__next_ = __p.__get_begin()->__next_;
+ __p.__get_begin()->__next_ = __lm1.__get_unsafe_node_pointer();
+ }
+}
+
+template <class _Tp, class _Alloc>
+void
+forward_list<_Tp, _Alloc>::splice_after(const_iterator __p,
+ forward_list& /*__other*/,
+ const_iterator __f, const_iterator __l)
+{
+ if (__f != __l && __p != __f)
+ {
+ const_iterator __lm1 = __f;
+ while (__lm1.__get_begin()->__next_ != __l.__get_begin())
+ ++__lm1;
+ if (__f != __lm1)
+ {
+ __lm1.__get_begin()->__next_ = __p.__get_begin()->__next_;
+ __p.__get_begin()->__next_ = __f.__get_begin()->__next_;
+ __f.__get_begin()->__next_ = __l.__get_unsafe_node_pointer();
+ }
+ }
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+forward_list<_Tp, _Alloc>::splice_after(const_iterator __p,
+ forward_list&& __x)
+{
+ splice_after(__p, __x);
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+forward_list<_Tp, _Alloc>::splice_after(const_iterator __p,
+ forward_list&& __x,
+ const_iterator __i)
+{
+ splice_after(__p, __x, __i);
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+forward_list<_Tp, _Alloc>::splice_after(const_iterator __p,
+ forward_list&& __x,
+ const_iterator __f, const_iterator __l)
+{
+ splice_after(__p, __x, __f, __l);
+}
+
+template <class _Tp, class _Alloc>
+typename forward_list<_Tp, _Alloc>::__remove_return_type
+forward_list<_Tp, _Alloc>::remove(const value_type& __v)
+{
+ forward_list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing
+ typename forward_list<_Tp, _Alloc>::size_type __count_removed = 0;
+ const iterator __e = end();
+ for (iterator __i = before_begin(); __i.__get_begin()->__next_ != nullptr;)
+ {
+ if (__i.__get_begin()->__next_->__value_ == __v)
+ {
+ ++__count_removed;
+ iterator __j = _VSTD::next(__i, 2);
+ for (; __j != __e && *__j == __v; ++__j)
+ ++__count_removed;
+ __deleted_nodes.splice_after(__deleted_nodes.before_begin(), *this, __i, __j);
+ if (__j == __e)
+ break;
+ __i = __j;
+ }
+ else
+ ++__i;
+ }
+
+ return (__remove_return_type) __count_removed;
+}
+
+template <class _Tp, class _Alloc>
+template <class _Predicate>
+typename forward_list<_Tp, _Alloc>::__remove_return_type
+forward_list<_Tp, _Alloc>::remove_if(_Predicate __pred)
+{
+ forward_list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing
+ typename forward_list<_Tp, _Alloc>::size_type __count_removed = 0;
+ const iterator __e = end();
+ for (iterator __i = before_begin(); __i.__get_begin()->__next_ != nullptr;)
+ {
+ if (__pred(__i.__get_begin()->__next_->__value_))
+ {
+ ++__count_removed;
+ iterator __j = _VSTD::next(__i, 2);
+ for (; __j != __e && __pred(*__j); ++__j)
+ ++__count_removed;
+ __deleted_nodes.splice_after(__deleted_nodes.before_begin(), *this, __i, __j);
+ if (__j == __e)
+ break;
+ __i = __j;
+ }
+ else
+ ++__i;
+ }
+
+ return (__remove_return_type) __count_removed;
+}
+
+template <class _Tp, class _Alloc>
+template <class _BinaryPredicate>
+typename forward_list<_Tp, _Alloc>::__remove_return_type
+forward_list<_Tp, _Alloc>::unique(_BinaryPredicate __binary_pred)
+{
+ forward_list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing
+ typename forward_list<_Tp, _Alloc>::size_type __count_removed = 0;
+ for (iterator __i = begin(), __e = end(); __i != __e;)
+ {
+ iterator __j = _VSTD::next(__i);
+ for (; __j != __e && __binary_pred(*__i, *__j); ++__j)
+ ++__count_removed;
+ if (__i.__get_begin()->__next_ != __j.__get_unsafe_node_pointer())
+ __deleted_nodes.splice_after(__deleted_nodes.before_begin(), *this, __i, __j);
+ __i = __j;
+ }
+
+ return (__remove_return_type) __count_removed;
+}
+
+template <class _Tp, class _Alloc>
+template <class _Compare>
+void
+forward_list<_Tp, _Alloc>::merge(forward_list& __x, _Compare __comp)
+{
+ if (this != _VSTD::addressof(__x))
+ {
+ base::__before_begin()->__next_ = __merge(base::__before_begin()->__next_,
+ __x.__before_begin()->__next_,
+ __comp);
+ __x.__before_begin()->__next_ = nullptr;
+ }
+}
+
+template <class _Tp, class _Alloc>
+template <class _Compare>
+typename forward_list<_Tp, _Alloc>::__node_pointer
+forward_list<_Tp, _Alloc>::__merge(__node_pointer __f1, __node_pointer __f2,
+ _Compare& __comp)
+{
+ if (__f1 == nullptr)
+ return __f2;
+ if (__f2 == nullptr)
+ return __f1;
+ __node_pointer __r;
+ if (__comp(__f2->__value_, __f1->__value_))
+ {
+ __node_pointer __t = __f2;
+ while (__t->__next_ != nullptr &&
+ __comp(__t->__next_->__value_, __f1->__value_))
+ __t = __t->__next_;
+ __r = __f2;
+ __f2 = __t->__next_;
+ __t->__next_ = __f1;
+ }
+ else
+ __r = __f1;
+ __node_pointer __p = __f1;
+ __f1 = __f1->__next_;
+ while (__f1 != nullptr && __f2 != nullptr)
+ {
+ if (__comp(__f2->__value_, __f1->__value_))
+ {
+ __node_pointer __t = __f2;
+ while (__t->__next_ != nullptr &&
+ __comp(__t->__next_->__value_, __f1->__value_))
+ __t = __t->__next_;
+ __p->__next_ = __f2;
+ __f2 = __t->__next_;
+ __t->__next_ = __f1;
+ }
+ __p = __f1;
+ __f1 = __f1->__next_;
+ }
+ if (__f2 != nullptr)
+ __p->__next_ = __f2;
+ return __r;
+}
+
+template <class _Tp, class _Alloc>
+template <class _Compare>
+inline
+void
+forward_list<_Tp, _Alloc>::sort(_Compare __comp)
+{
+ base::__before_begin()->__next_ = __sort(base::__before_begin()->__next_,
+ _VSTD::distance(begin(), end()), __comp);
+}
+
+template <class _Tp, class _Alloc>
+template <class _Compare>
+typename forward_list<_Tp, _Alloc>::__node_pointer
+forward_list<_Tp, _Alloc>::__sort(__node_pointer __f1, difference_type __sz,
+ _Compare& __comp)
+{
+ switch (__sz)
+ {
+ case 0:
+ case 1:
+ return __f1;
+ case 2:
+ if (__comp(__f1->__next_->__value_, __f1->__value_))
+ {
+ __node_pointer __t = __f1->__next_;
+ __t->__next_ = __f1;
+ __f1->__next_ = nullptr;
+ __f1 = __t;
+ }
+ return __f1;
+ }
+ difference_type __sz1 = __sz / 2;
+ difference_type __sz2 = __sz - __sz1;
+ __node_pointer __t = _VSTD::next(iterator(__f1), __sz1 - 1).__get_unsafe_node_pointer();
+ __node_pointer __f2 = __t->__next_;
+ __t->__next_ = nullptr;
+ return __merge(__sort(__f1, __sz1, __comp),
+ __sort(__f2, __sz2, __comp), __comp);
+}
+
+template <class _Tp, class _Alloc>
+void
+forward_list<_Tp, _Alloc>::reverse() _NOEXCEPT
+{
+ __node_pointer __p = base::__before_begin()->__next_;
+ if (__p != nullptr)
+ {
+ __node_pointer __f = __p->__next_;
+ __p->__next_ = nullptr;
+ while (__f != nullptr)
+ {
+ __node_pointer __t = __f->__next_;
+ __f->__next_ = __p;
+ __p = __f;
+ __f = __t;
+ }
+ base::__before_begin()->__next_ = __p;
+ }
+}
+
+template <class _Tp, class _Alloc>
+bool operator==(const forward_list<_Tp, _Alloc>& __x,
+ const forward_list<_Tp, _Alloc>& __y)
+{
+ typedef forward_list<_Tp, _Alloc> _Cp;
+ typedef typename _Cp::const_iterator _Ip;
+ _Ip __ix = __x.begin();
+ _Ip __ex = __x.end();
+ _Ip __iy = __y.begin();
+ _Ip __ey = __y.end();
+ for (; __ix != __ex && __iy != __ey; ++__ix, ++__iy)
+ if (!(*__ix == *__iy))
+ return false;
+ return (__ix == __ex) == (__iy == __ey);
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool operator!=(const forward_list<_Tp, _Alloc>& __x,
+ const forward_list<_Tp, _Alloc>& __y)
+{
+ return !(__x == __y);
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool operator< (const forward_list<_Tp, _Alloc>& __x,
+ const forward_list<_Tp, _Alloc>& __y)
+{
+ return _VSTD::lexicographical_compare(__x.begin(), __x.end(),
+ __y.begin(), __y.end());
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool operator> (const forward_list<_Tp, _Alloc>& __x,
+ const forward_list<_Tp, _Alloc>& __y)
+{
+ return __y < __x;
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool operator>=(const forward_list<_Tp, _Alloc>& __x,
+ const forward_list<_Tp, _Alloc>& __y)
+{
+ return !(__x < __y);
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool operator<=(const forward_list<_Tp, _Alloc>& __x,
+ const forward_list<_Tp, _Alloc>& __y)
+{
+ return !(__y < __x);
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(forward_list<_Tp, _Alloc>& __x, forward_list<_Tp, _Alloc>& __y)
+ _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+ __x.swap(__y);
+}
+
+#if _LIBCPP_STD_VER > 17
+template <class _Tp, class _Allocator, class _Predicate>
+inline _LIBCPP_INLINE_VISIBILITY
+ typename forward_list<_Tp, _Allocator>::size_type
+ erase_if(forward_list<_Tp, _Allocator>& __c, _Predicate __pred) {
+ return __c.remove_if(__pred);
+}
+
+template <class _Tp, class _Allocator, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+ typename forward_list<_Tp, _Allocator>::size_type
+ erase(forward_list<_Tp, _Allocator>& __c, const _Up& __v) {
+ return _VSTD::erase_if(__c, [&](auto& __elem) { return __elem == __v; });
+}
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_FORWARD_LIST
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/fstream b/contrib/libs/cxxsupp/libcxxmsvc/include/fstream
new file mode 100644
index 0000000000..80bda63755
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/fstream
@@ -0,0 +1,1730 @@
+// -*- 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_FSTREAM
+#define _LIBCPP_FSTREAM
+
+/*
+ fstream synopsis
+
+template <class charT, class traits = char_traits<charT> >
+class basic_filebuf
+ : public basic_streambuf<charT, traits>
+{
+public:
+ typedef charT char_type;
+ typedef traits traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+
+ // 27.9.1.2 Constructors/destructor:
+ basic_filebuf();
+ basic_filebuf(basic_filebuf&& rhs);
+ virtual ~basic_filebuf();
+
+ // 27.9.1.3 Assign/swap:
+ basic_filebuf& operator=(basic_filebuf&& rhs);
+ void swap(basic_filebuf& rhs);
+
+ // 27.9.1.4 Members:
+ bool is_open() const;
+ basic_filebuf* open(const char* s, ios_base::openmode mode);
+ basic_filebuf* open(const string& s, ios_base::openmode mode);
+ basic_filebuf* open(const filesystem::path& p, ios_base::openmode mode); // C++17
+ basic_filebuf* close();
+
+protected:
+ // 27.9.1.5 Overridden virtual functions:
+ virtual streamsize showmanyc();
+ virtual int_type underflow();
+ virtual int_type uflow();
+ virtual int_type pbackfail(int_type c = traits_type::eof());
+ virtual int_type overflow (int_type c = traits_type::eof());
+ virtual basic_streambuf<char_type, traits_type>* setbuf(char_type* s, streamsize n);
+ virtual pos_type seekoff(off_type off, ios_base::seekdir way,
+ ios_base::openmode which = ios_base::in | ios_base::out);
+ virtual pos_type seekpos(pos_type sp,
+ ios_base::openmode which = ios_base::in | ios_base::out);
+ virtual int sync();
+ virtual void imbue(const locale& loc);
+};
+
+template <class charT, class traits>
+ void
+ swap(basic_filebuf<charT, traits>& x, basic_filebuf<charT, traits>& y);
+
+typedef basic_filebuf<char> filebuf;
+typedef basic_filebuf<wchar_t> wfilebuf;
+
+template <class charT, class traits = char_traits<charT> >
+class basic_ifstream
+ : public basic_istream<charT,traits>
+{
+public:
+ typedef charT char_type;
+ typedef traits traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+
+ basic_ifstream();
+ explicit basic_ifstream(const char* s, ios_base::openmode mode = ios_base::in);
+ explicit basic_ifstream(const string& s, ios_base::openmode mode = ios_base::in);
+ explicit basic_ifstream(const filesystem::path& p,
+ ios_base::openmode mode = ios_base::in); // C++17
+ basic_ifstream(basic_ifstream&& rhs);
+
+ basic_ifstream& operator=(basic_ifstream&& rhs);
+ void swap(basic_ifstream& rhs);
+
+ basic_filebuf<char_type, traits_type>* rdbuf() const;
+ bool is_open() const;
+ void open(const char* s, ios_base::openmode mode = ios_base::in);
+ void open(const string& s, ios_base::openmode mode = ios_base::in);
+ void open(const filesystem::path& s, ios_base::openmode mode = ios_base::in); // C++17
+
+ void close();
+};
+
+template <class charT, class traits>
+ void
+ swap(basic_ifstream<charT, traits>& x, basic_ifstream<charT, traits>& y);
+
+typedef basic_ifstream<char> ifstream;
+typedef basic_ifstream<wchar_t> wifstream;
+
+template <class charT, class traits = char_traits<charT> >
+class basic_ofstream
+ : public basic_ostream<charT,traits>
+{
+public:
+ typedef charT char_type;
+ typedef traits traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+
+ basic_ofstream();
+ explicit basic_ofstream(const char* s, ios_base::openmode mode = ios_base::out);
+ explicit basic_ofstream(const string& s, ios_base::openmode mode = ios_base::out);
+ explicit basic_ofstream(const filesystem::path& p,
+ ios_base::openmode mode = ios_base::out); // C++17
+ basic_ofstream(basic_ofstream&& rhs);
+
+ basic_ofstream& operator=(basic_ofstream&& rhs);
+ void swap(basic_ofstream& rhs);
+
+ basic_filebuf<char_type, traits_type>* rdbuf() const;
+ bool is_open() const;
+ void open(const char* s, ios_base::openmode mode = ios_base::out);
+ void open(const string& s, ios_base::openmode mode = ios_base::out);
+ void open(const filesystem::path& p,
+ ios_base::openmode mode = ios_base::out); // C++17
+
+ void close();
+};
+
+template <class charT, class traits>
+ void
+ swap(basic_ofstream<charT, traits>& x, basic_ofstream<charT, traits>& y);
+
+typedef basic_ofstream<char> ofstream;
+typedef basic_ofstream<wchar_t> wofstream;
+
+template <class charT, class traits=char_traits<charT> >
+class basic_fstream
+ : public basic_iostream<charT,traits>
+{
+public:
+ typedef charT char_type;
+ typedef traits traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+
+ basic_fstream();
+ explicit basic_fstream(const char* s, ios_base::openmode mode = ios_base::in|ios_base::out);
+ explicit basic_fstream(const string& s, ios_base::openmode mode = ios_base::in|ios_base::out);
+ explicit basic_fstream(const filesystem::path& p,
+ ios_base::openmode mode = ios_base::in|ios_base::out); C++17
+ basic_fstream(basic_fstream&& rhs);
+
+ basic_fstream& operator=(basic_fstream&& rhs);
+ void swap(basic_fstream& rhs);
+
+ basic_filebuf<char_type, traits_type>* rdbuf() const;
+ bool is_open() const;
+ void open(const char* s, ios_base::openmode mode = ios_base::in|ios_base::out);
+ void open(const string& s, ios_base::openmode mode = ios_base::in|ios_base::out);
+ void open(const filesystem::path& s,
+ ios_base::openmode mode = ios_base::in|ios_base::out); // C++17
+
+ void close();
+};
+
+template <class charT, class traits>
+ void swap(basic_fstream<charT, traits>& x, basic_fstream<charT, traits>& y);
+
+typedef basic_fstream<char> fstream;
+typedef basic_fstream<wchar_t> wfstream;
+
+} // std
+
+*/
+
+#include <__algorithm/max.h>
+#include <__assert>
+#include <__availability>
+#include <__config>
+#include <__locale>
+#include <__utility/unreachable.h>
+#include <cstdio>
+#include <cstdlib>
+#include <istream>
+#include <ostream>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
+# include <filesystem>
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_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
+
+template <class _CharT, class _Traits>
+class _LIBCPP_TEMPLATE_VIS basic_filebuf
+ : public basic_streambuf<_CharT, _Traits>
+{
+public:
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+ typedef typename traits_type::state_type state_type;
+
+ // 27.9.1.2 Constructors/destructor:
+ basic_filebuf();
+ basic_filebuf(basic_filebuf&& __rhs);
+ virtual ~basic_filebuf();
+
+ // 27.9.1.3 Assign/swap:
+ _LIBCPP_INLINE_VISIBILITY
+ basic_filebuf& operator=(basic_filebuf&& __rhs);
+ void swap(basic_filebuf& __rhs);
+
+ // 27.9.1.4 Members:
+ _LIBCPP_INLINE_VISIBILITY
+ bool is_open() const;
+ basic_filebuf* open(const char* __s, ios_base::openmode __mode);
+#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
+ basic_filebuf* open(const wchar_t* __s, ios_base::openmode __mode);
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ basic_filebuf* open(const string& __s, ios_base::openmode __mode);
+
+#if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
+ _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_INLINE_VISIBILITY
+ basic_filebuf* open(const _VSTD_FS::path& __p, ios_base::openmode __mode) {
+ return open(__p.c_str(), __mode);
+ }
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ basic_filebuf* __open(int __fd, ios_base::openmode __mode);
+ basic_filebuf* close();
+
+ _LIBCPP_INLINE_VISIBILITY
+ inline static const char*
+ __make_mdstring(ios_base::openmode __mode) _NOEXCEPT;
+
+ protected:
+ // 27.9.1.5 Overridden virtual functions:
+ virtual int_type underflow();
+ virtual int_type pbackfail(int_type __c = traits_type::eof());
+ virtual int_type overflow (int_type __c = traits_type::eof());
+ virtual basic_streambuf<char_type, traits_type>* setbuf(char_type* __s, streamsize __n);
+ virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,
+ ios_base::openmode __wch = ios_base::in | ios_base::out);
+ virtual pos_type seekpos(pos_type __sp,
+ ios_base::openmode __wch = ios_base::in | ios_base::out);
+ virtual int sync();
+ virtual void imbue(const locale& __loc);
+
+private:
+ char* __extbuf_;
+ const char* __extbufnext_;
+ const char* __extbufend_;
+ char __extbuf_min_[8];
+ size_t __ebs_;
+ char_type* __intbuf_;
+ size_t __ibs_;
+ FILE* __file_;
+ const codecvt<char_type, char, state_type>* __cv_;
+ state_type __st_;
+ state_type __st_last_;
+ ios_base::openmode __om_;
+ ios_base::openmode __cm_;
+ bool __owns_eb_;
+ bool __owns_ib_;
+ bool __always_noconv_;
+
+ bool __read_mode();
+ void __write_mode();
+};
+
+template <class _CharT, class _Traits>
+basic_filebuf<_CharT, _Traits>::basic_filebuf()
+ : __extbuf_(nullptr),
+ __extbufnext_(nullptr),
+ __extbufend_(nullptr),
+ __ebs_(0),
+ __intbuf_(nullptr),
+ __ibs_(0),
+ __file_(nullptr),
+ __cv_(nullptr),
+ __st_(),
+ __st_last_(),
+ __om_(0),
+ __cm_(0),
+ __owns_eb_(false),
+ __owns_ib_(false),
+ __always_noconv_(false)
+{
+ if (has_facet<codecvt<char_type, char, state_type> >(this->getloc()))
+ {
+ __cv_ = &use_facet<codecvt<char_type, char, state_type> >(this->getloc());
+ __always_noconv_ = __cv_->always_noconv();
+ }
+ setbuf(nullptr, 4096);
+}
+
+template <class _CharT, class _Traits>
+basic_filebuf<_CharT, _Traits>::basic_filebuf(basic_filebuf&& __rhs)
+ : basic_streambuf<_CharT, _Traits>(__rhs)
+{
+ if (__rhs.__extbuf_ == __rhs.__extbuf_min_)
+ {
+ __extbuf_ = __extbuf_min_;
+ __extbufnext_ = __extbuf_ + (__rhs.__extbufnext_ - __rhs.__extbuf_);
+ __extbufend_ = __extbuf_ + (__rhs.__extbufend_ - __rhs.__extbuf_);
+ }
+ else
+ {
+ __extbuf_ = __rhs.__extbuf_;
+ __extbufnext_ = __rhs.__extbufnext_;
+ __extbufend_ = __rhs.__extbufend_;
+ }
+ __ebs_ = __rhs.__ebs_;
+ __intbuf_ = __rhs.__intbuf_;
+ __ibs_ = __rhs.__ibs_;
+ __file_ = __rhs.__file_;
+ __cv_ = __rhs.__cv_;
+ __st_ = __rhs.__st_;
+ __st_last_ = __rhs.__st_last_;
+ __om_ = __rhs.__om_;
+ __cm_ = __rhs.__cm_;
+ __owns_eb_ = __rhs.__owns_eb_;
+ __owns_ib_ = __rhs.__owns_ib_;
+ __always_noconv_ = __rhs.__always_noconv_;
+ if (__rhs.pbase())
+ {
+ if (__rhs.pbase() == __rhs.__intbuf_)
+ this->setp(__intbuf_, __intbuf_ + (__rhs. epptr() - __rhs.pbase()));
+ else
+ this->setp((char_type*)__extbuf_,
+ (char_type*)__extbuf_ + (__rhs. epptr() - __rhs.pbase()));
+ this->__pbump(__rhs. pptr() - __rhs.pbase());
+ }
+ else if (__rhs.eback())
+ {
+ if (__rhs.eback() == __rhs.__intbuf_)
+ this->setg(__intbuf_, __intbuf_ + (__rhs.gptr() - __rhs.eback()),
+ __intbuf_ + (__rhs.egptr() - __rhs.eback()));
+ else
+ this->setg((char_type*)__extbuf_,
+ (char_type*)__extbuf_ + (__rhs.gptr() - __rhs.eback()),
+ (char_type*)__extbuf_ + (__rhs.egptr() - __rhs.eback()));
+ }
+ __rhs.__extbuf_ = nullptr;
+ __rhs.__extbufnext_ = nullptr;
+ __rhs.__extbufend_ = nullptr;
+ __rhs.__ebs_ = 0;
+ __rhs.__intbuf_ = 0;
+ __rhs.__ibs_ = 0;
+ __rhs.__file_ = nullptr;
+ __rhs.__st_ = state_type();
+ __rhs.__st_last_ = state_type();
+ __rhs.__om_ = 0;
+ __rhs.__cm_ = 0;
+ __rhs.__owns_eb_ = false;
+ __rhs.__owns_ib_ = false;
+ __rhs.setg(0, 0, 0);
+ __rhs.setp(0, 0);
+}
+
+template <class _CharT, class _Traits>
+inline
+basic_filebuf<_CharT, _Traits>&
+basic_filebuf<_CharT, _Traits>::operator=(basic_filebuf&& __rhs)
+{
+ close();
+ swap(__rhs);
+ return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_filebuf<_CharT, _Traits>::~basic_filebuf()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ close();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ if (__owns_eb_)
+ delete [] __extbuf_;
+ if (__owns_ib_)
+ delete [] __intbuf_;
+}
+
+template <class _CharT, class _Traits>
+void
+basic_filebuf<_CharT, _Traits>::swap(basic_filebuf& __rhs)
+{
+ basic_streambuf<char_type, traits_type>::swap(__rhs);
+ if (__extbuf_ != __extbuf_min_ && __rhs.__extbuf_ != __rhs.__extbuf_min_)
+ {
+ _VSTD::swap(__extbuf_, __rhs.__extbuf_);
+ _VSTD::swap(__extbufnext_, __rhs.__extbufnext_);
+ _VSTD::swap(__extbufend_, __rhs.__extbufend_);
+ }
+ else
+ {
+ ptrdiff_t __ln = __extbufnext_ - __extbuf_;
+ ptrdiff_t __le = __extbufend_ - __extbuf_;
+ ptrdiff_t __rn = __rhs.__extbufnext_ - __rhs.__extbuf_;
+ ptrdiff_t __re = __rhs.__extbufend_ - __rhs.__extbuf_;
+ if (__extbuf_ == __extbuf_min_ && __rhs.__extbuf_ != __rhs.__extbuf_min_)
+ {
+ __extbuf_ = __rhs.__extbuf_;
+ __rhs.__extbuf_ = __rhs.__extbuf_min_;
+ }
+ else if (__extbuf_ != __extbuf_min_ && __rhs.__extbuf_ == __rhs.__extbuf_min_)
+ {
+ __rhs.__extbuf_ = __extbuf_;
+ __extbuf_ = __extbuf_min_;
+ }
+ __extbufnext_ = __extbuf_ + __rn;
+ __extbufend_ = __extbuf_ + __re;
+ __rhs.__extbufnext_ = __rhs.__extbuf_ + __ln;
+ __rhs.__extbufend_ = __rhs.__extbuf_ + __le;
+ }
+ _VSTD::swap(__ebs_, __rhs.__ebs_);
+ _VSTD::swap(__intbuf_, __rhs.__intbuf_);
+ _VSTD::swap(__ibs_, __rhs.__ibs_);
+ _VSTD::swap(__file_, __rhs.__file_);
+ _VSTD::swap(__cv_, __rhs.__cv_);
+ _VSTD::swap(__st_, __rhs.__st_);
+ _VSTD::swap(__st_last_, __rhs.__st_last_);
+ _VSTD::swap(__om_, __rhs.__om_);
+ _VSTD::swap(__cm_, __rhs.__cm_);
+ _VSTD::swap(__owns_eb_, __rhs.__owns_eb_);
+ _VSTD::swap(__owns_ib_, __rhs.__owns_ib_);
+ _VSTD::swap(__always_noconv_, __rhs.__always_noconv_);
+ if (this->eback() == (char_type*)__rhs.__extbuf_min_)
+ {
+ ptrdiff_t __n = this->gptr() - this->eback();
+ ptrdiff_t __e = this->egptr() - this->eback();
+ this->setg((char_type*)__extbuf_min_,
+ (char_type*)__extbuf_min_ + __n,
+ (char_type*)__extbuf_min_ + __e);
+ }
+ else if (this->pbase() == (char_type*)__rhs.__extbuf_min_)
+ {
+ ptrdiff_t __n = this->pptr() - this->pbase();
+ ptrdiff_t __e = this->epptr() - this->pbase();
+ this->setp((char_type*)__extbuf_min_,
+ (char_type*)__extbuf_min_ + __e);
+ this->__pbump(__n);
+ }
+ if (__rhs.eback() == (char_type*)__extbuf_min_)
+ {
+ ptrdiff_t __n = __rhs.gptr() - __rhs.eback();
+ ptrdiff_t __e = __rhs.egptr() - __rhs.eback();
+ __rhs.setg((char_type*)__rhs.__extbuf_min_,
+ (char_type*)__rhs.__extbuf_min_ + __n,
+ (char_type*)__rhs.__extbuf_min_ + __e);
+ }
+ else if (__rhs.pbase() == (char_type*)__extbuf_min_)
+ {
+ ptrdiff_t __n = __rhs.pptr() - __rhs.pbase();
+ ptrdiff_t __e = __rhs.epptr() - __rhs.pbase();
+ __rhs.setp((char_type*)__rhs.__extbuf_min_,
+ (char_type*)__rhs.__extbuf_min_ + __e);
+ __rhs.__pbump(__n);
+ }
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(basic_filebuf<_CharT, _Traits>& __x, basic_filebuf<_CharT, _Traits>& __y)
+{
+ __x.swap(__y);
+}
+
+template <class _CharT, class _Traits>
+inline
+bool
+basic_filebuf<_CharT, _Traits>::is_open() const
+{
+ return __file_ != nullptr;
+}
+
+template <class _CharT, class _Traits>
+const char* basic_filebuf<_CharT, _Traits>::__make_mdstring(
+ ios_base::openmode __mode) _NOEXCEPT {
+ switch (__mode & ~ios_base::ate) {
+ case ios_base::out:
+ case ios_base::out | ios_base::trunc:
+ return "w" _LIBCPP_FOPEN_CLOEXEC_MODE;
+ case ios_base::out | ios_base::app:
+ case ios_base::app:
+ return "a" _LIBCPP_FOPEN_CLOEXEC_MODE;
+ case ios_base::in:
+ return "r" _LIBCPP_FOPEN_CLOEXEC_MODE;
+ case ios_base::in | ios_base::out:
+ return "r+" _LIBCPP_FOPEN_CLOEXEC_MODE;
+ case ios_base::in | ios_base::out | ios_base::trunc:
+ return "w+" _LIBCPP_FOPEN_CLOEXEC_MODE;
+ case ios_base::in | ios_base::out | ios_base::app:
+ case ios_base::in | ios_base::app:
+ return "a+" _LIBCPP_FOPEN_CLOEXEC_MODE;
+ case ios_base::out | ios_base::binary:
+ case ios_base::out | ios_base::trunc | ios_base::binary:
+ return "wb" _LIBCPP_FOPEN_CLOEXEC_MODE;
+ case ios_base::out | ios_base::app | ios_base::binary:
+ case ios_base::app | ios_base::binary:
+ return "ab" _LIBCPP_FOPEN_CLOEXEC_MODE;
+ case ios_base::in | ios_base::binary:
+ return "rb" _LIBCPP_FOPEN_CLOEXEC_MODE;
+ case ios_base::in | ios_base::out | ios_base::binary:
+ return "r+b" _LIBCPP_FOPEN_CLOEXEC_MODE;
+ case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary:
+ return "w+b" _LIBCPP_FOPEN_CLOEXEC_MODE;
+ case ios_base::in | ios_base::out | ios_base::app | ios_base::binary:
+ case ios_base::in | ios_base::app | ios_base::binary:
+ return "a+b" _LIBCPP_FOPEN_CLOEXEC_MODE;
+ default:
+ return nullptr;
+ }
+ __libcpp_unreachable();
+}
+
+template <class _CharT, class _Traits>
+basic_filebuf<_CharT, _Traits>*
+basic_filebuf<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
+{
+ basic_filebuf<_CharT, _Traits>* __rt = nullptr;
+ if (__file_ == nullptr)
+ {
+ if (const char* __mdstr = __make_mdstring(__mode)) {
+ __rt = this;
+ __file_ = fopen(__s, __mdstr);
+ if (__file_) {
+ __om_ = __mode;
+ if (__mode & ios_base::ate) {
+ if (fseek(__file_, 0, SEEK_END)) {
+ fclose(__file_);
+ __file_ = nullptr;
+ __rt = nullptr;
+ }
+ }
+ } else
+ __rt = nullptr;
+ }
+ }
+ return __rt;
+}
+
+template <class _CharT, class _Traits>
+inline
+basic_filebuf<_CharT, _Traits>*
+basic_filebuf<_CharT, _Traits>::__open(int __fd, ios_base::openmode __mode) {
+ basic_filebuf<_CharT, _Traits>* __rt = nullptr;
+ if (__file_ == nullptr) {
+ if (const char* __mdstr = __make_mdstring(__mode)) {
+ __rt = this;
+ __file_ = fdopen(__fd, __mdstr);
+ if (__file_) {
+ __om_ = __mode;
+ if (__mode & ios_base::ate) {
+ if (fseek(__file_, 0, SEEK_END)) {
+ fclose(__file_);
+ __file_ = nullptr;
+ __rt = nullptr;
+ }
+ }
+ } else
+ __rt = nullptr;
+ }
+ }
+ return __rt;
+}
+
+#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
+// This is basically the same as the char* overload except that it uses _wfopen
+// and long mode strings.
+template <class _CharT, class _Traits>
+basic_filebuf<_CharT, _Traits>*
+basic_filebuf<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode)
+{
+ basic_filebuf<_CharT, _Traits>* __rt = nullptr;
+ if (__file_ == nullptr)
+ {
+ __rt = this;
+ const wchar_t* __mdstr;
+ switch (__mode & ~ios_base::ate)
+ {
+ case ios_base::out:
+ case ios_base::out | ios_base::trunc:
+ __mdstr = L"w";
+ break;
+ case ios_base::out | ios_base::app:
+ case ios_base::app:
+ __mdstr = L"a";
+ break;
+ case ios_base::in:
+ __mdstr = L"r";
+ break;
+ case ios_base::in | ios_base::out:
+ __mdstr = L"r+";
+ break;
+ case ios_base::in | ios_base::out | ios_base::trunc:
+ __mdstr = L"w+";
+ break;
+ case ios_base::in | ios_base::out | ios_base::app:
+ case ios_base::in | ios_base::app:
+ __mdstr = L"a+";
+ break;
+ case ios_base::out | ios_base::binary:
+ case ios_base::out | ios_base::trunc | ios_base::binary:
+ __mdstr = L"wb";
+ break;
+ case ios_base::out | ios_base::app | ios_base::binary:
+ case ios_base::app | ios_base::binary:
+ __mdstr = L"ab";
+ break;
+ case ios_base::in | ios_base::binary:
+ __mdstr = L"rb";
+ break;
+ case ios_base::in | ios_base::out | ios_base::binary:
+ __mdstr = L"r+b";
+ break;
+ case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary:
+ __mdstr = L"w+b";
+ break;
+ case ios_base::in | ios_base::out | ios_base::app | ios_base::binary:
+ case ios_base::in | ios_base::app | ios_base::binary:
+ __mdstr = L"a+b";
+ break;
+ default:
+ __rt = nullptr;
+ break;
+ }
+ if (__rt)
+ {
+ __file_ = _wfopen(__s, __mdstr);
+ if (__file_)
+ {
+ __om_ = __mode;
+ if (__mode & ios_base::ate)
+ {
+ if (fseek(__file_, 0, SEEK_END))
+ {
+ fclose(__file_);
+ __file_ = nullptr;
+ __rt = nullptr;
+ }
+ }
+ }
+ else
+ __rt = nullptr;
+ }
+ }
+ return __rt;
+}
+#endif
+
+template <class _CharT, class _Traits>
+inline
+basic_filebuf<_CharT, _Traits>*
+basic_filebuf<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode)
+{
+ return open(__s.c_str(), __mode);
+}
+
+template <class _CharT, class _Traits>
+basic_filebuf<_CharT, _Traits>*
+basic_filebuf<_CharT, _Traits>::close()
+{
+ basic_filebuf<_CharT, _Traits>* __rt = nullptr;
+ if (__file_)
+ {
+ __rt = this;
+ unique_ptr<FILE, int(*)(FILE*)> __h(__file_, fclose);
+ if (sync())
+ __rt = nullptr;
+ if (fclose(__h.release()))
+ __rt = nullptr;
+ __file_ = nullptr;
+ setbuf(0, 0);
+ }
+ return __rt;
+}
+
+template <class _CharT, class _Traits>
+typename basic_filebuf<_CharT, _Traits>::int_type
+basic_filebuf<_CharT, _Traits>::underflow()
+{
+ if (__file_ == nullptr)
+ return traits_type::eof();
+ bool __initial = __read_mode();
+ char_type __1buf;
+ if (this->gptr() == nullptr)
+ this->setg(&__1buf, &__1buf+1, &__1buf+1);
+ const size_t __unget_sz = __initial ? 0 : min<size_t>((this->egptr() - this->eback()) / 2, 4);
+ int_type __c = traits_type::eof();
+ if (this->gptr() == this->egptr())
+ {
+ _VSTD::memmove(this->eback(), this->egptr() - __unget_sz, __unget_sz * sizeof(char_type));
+ if (__always_noconv_)
+ {
+ size_t __nmemb = static_cast<size_t>(this->egptr() - this->eback() - __unget_sz);
+ __nmemb = fread(this->eback() + __unget_sz, 1, __nmemb, __file_);
+ if (__nmemb != 0)
+ {
+ this->setg(this->eback(),
+ this->eback() + __unget_sz,
+ this->eback() + __unget_sz + __nmemb);
+ __c = traits_type::to_int_type(*this->gptr());
+ }
+ }
+ else
+ {
+ _LIBCPP_ASSERT ( !(__extbufnext_ == NULL && (__extbufend_ != __extbufnext_)), "underflow moving from NULL" );
+ if (__extbufend_ != __extbufnext_)
+ _VSTD::memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
+ __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);
+ __extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_);
+ size_t __nmemb = _VSTD::min(static_cast<size_t>(__ibs_ - __unget_sz),
+ static_cast<size_t>(__extbufend_ - __extbufnext_));
+ codecvt_base::result __r;
+ __st_last_ = __st_;
+ size_t __nr = fread((void*) const_cast<char *>(__extbufnext_), 1, __nmemb, __file_);
+ if (__nr != 0)
+ {
+ if (!__cv_)
+ __throw_bad_cast();
+
+ __extbufend_ = __extbufnext_ + __nr;
+ char_type* __inext;
+ __r = __cv_->in(__st_, __extbuf_, __extbufend_, __extbufnext_,
+ this->eback() + __unget_sz,
+ this->eback() + __ibs_, __inext);
+ if (__r == codecvt_base::noconv)
+ {
+ this->setg((char_type*)__extbuf_, (char_type*)__extbuf_,
+ (char_type*)const_cast<char *>(__extbufend_));
+ __c = traits_type::to_int_type(*this->gptr());
+ }
+ else if (__inext != this->eback() + __unget_sz)
+ {
+ this->setg(this->eback(), this->eback() + __unget_sz, __inext);
+ __c = traits_type::to_int_type(*this->gptr());
+ }
+ }
+ }
+ }
+ else
+ __c = traits_type::to_int_type(*this->gptr());
+ if (this->eback() == &__1buf)
+ this->setg(nullptr, nullptr, nullptr);
+ return __c;
+}
+
+template <class _CharT, class _Traits>
+typename basic_filebuf<_CharT, _Traits>::int_type
+basic_filebuf<_CharT, _Traits>::pbackfail(int_type __c)
+{
+ if (__file_ && this->eback() < this->gptr())
+ {
+ if (traits_type::eq_int_type(__c, traits_type::eof()))
+ {
+ this->gbump(-1);
+ return traits_type::not_eof(__c);
+ }
+ if ((__om_ & ios_base::out) ||
+ traits_type::eq(traits_type::to_char_type(__c), this->gptr()[-1]))
+ {
+ this->gbump(-1);
+ *this->gptr() = traits_type::to_char_type(__c);
+ return __c;
+ }
+ }
+ return traits_type::eof();
+}
+
+template <class _CharT, class _Traits>
+typename basic_filebuf<_CharT, _Traits>::int_type
+basic_filebuf<_CharT, _Traits>::overflow(int_type __c)
+{
+ if (__file_ == nullptr)
+ return traits_type::eof();
+ __write_mode();
+ char_type __1buf;
+ char_type* __pb_save = this->pbase();
+ char_type* __epb_save = this->epptr();
+ if (!traits_type::eq_int_type(__c, traits_type::eof()))
+ {
+ if (this->pptr() == nullptr)
+ this->setp(&__1buf, &__1buf+1);
+ *this->pptr() = traits_type::to_char_type(__c);
+ this->pbump(1);
+ }
+ if (this->pptr() != this->pbase())
+ {
+ if (__always_noconv_)
+ {
+ size_t __nmemb = static_cast<size_t>(this->pptr() - this->pbase());
+ if (fwrite(this->pbase(), sizeof(char_type), __nmemb, __file_) != __nmemb)
+ return traits_type::eof();
+ }
+ else
+ {
+ char* __extbe = __extbuf_;
+ codecvt_base::result __r;
+ do
+ {
+ if (!__cv_)
+ __throw_bad_cast();
+
+ const char_type* __e;
+ __r = __cv_->out(__st_, this->pbase(), this->pptr(), __e,
+ __extbuf_, __extbuf_ + __ebs_, __extbe);
+ if (__e == this->pbase())
+ return traits_type::eof();
+ if (__r == codecvt_base::noconv)
+ {
+ size_t __nmemb = static_cast<size_t>(this->pptr() - this->pbase());
+ if (fwrite(this->pbase(), 1, __nmemb, __file_) != __nmemb)
+ return traits_type::eof();
+ }
+ else if (__r == codecvt_base::ok || __r == codecvt_base::partial)
+ {
+ size_t __nmemb = static_cast<size_t>(__extbe - __extbuf_);
+ if (fwrite(__extbuf_, 1, __nmemb, __file_) != __nmemb)
+ return traits_type::eof();
+ if (__r == codecvt_base::partial)
+ {
+ this->setp(const_cast<char_type*>(__e), this->pptr());
+ this->__pbump(this->epptr() - this->pbase());
+ }
+ }
+ else
+ return traits_type::eof();
+ } while (__r == codecvt_base::partial);
+ }
+ this->setp(__pb_save, __epb_save);
+ }
+ return traits_type::not_eof(__c);
+}
+
+template <class _CharT, class _Traits>
+basic_streambuf<_CharT, _Traits>*
+basic_filebuf<_CharT, _Traits>::setbuf(char_type* __s, streamsize __n)
+{
+ this->setg(nullptr, nullptr, nullptr);
+ this->setp(nullptr, nullptr);
+ if (__owns_eb_)
+ delete [] __extbuf_;
+ if (__owns_ib_)
+ delete [] __intbuf_;
+ __ebs_ = __n;
+ if (__ebs_ > sizeof(__extbuf_min_))
+ {
+ if (__always_noconv_ && __s)
+ {
+ __extbuf_ = (char*)__s;
+ __owns_eb_ = false;
+ }
+ else
+ {
+ __extbuf_ = new char[__ebs_];
+ __owns_eb_ = true;
+ }
+ }
+ else
+ {
+ __extbuf_ = __extbuf_min_;
+ __ebs_ = sizeof(__extbuf_min_);
+ __owns_eb_ = false;
+ }
+ if (!__always_noconv_)
+ {
+ __ibs_ = max<streamsize>(__n, sizeof(__extbuf_min_));
+ if (__s && __ibs_ >= sizeof(__extbuf_min_))
+ {
+ __intbuf_ = __s;
+ __owns_ib_ = false;
+ }
+ else
+ {
+ __intbuf_ = new char_type[__ibs_];
+ __owns_ib_ = true;
+ }
+ }
+ else
+ {
+ __ibs_ = 0;
+ __intbuf_ = nullptr;
+ __owns_ib_ = false;
+ }
+ return this;
+}
+
+template <class _CharT, class _Traits>
+typename basic_filebuf<_CharT, _Traits>::pos_type
+basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way,
+ ios_base::openmode)
+{
+ if (!__cv_)
+ __throw_bad_cast();
+
+ int __width = __cv_->encoding();
+ if (__file_ == nullptr || (__width <= 0 && __off != 0) || sync())
+ return pos_type(off_type(-1));
+ // __width > 0 || __off == 0
+ int __whence;
+ switch (__way)
+ {
+ case ios_base::beg:
+ __whence = SEEK_SET;
+ break;
+ case ios_base::cur:
+ __whence = SEEK_CUR;
+ break;
+ case ios_base::end:
+ __whence = SEEK_END;
+ break;
+ default:
+ return pos_type(off_type(-1));
+ }
+#if defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)
+ if (fseek(__file_, __width > 0 ? __width * __off : 0, __whence))
+ return pos_type(off_type(-1));
+ pos_type __r = ftell(__file_);
+#else
+ if (fseeko(__file_, __width > 0 ? __width * __off : 0, __whence))
+ return pos_type(off_type(-1));
+ pos_type __r = ftello(__file_);
+#endif
+ __r.state(__st_);
+ return __r;
+}
+
+template <class _CharT, class _Traits>
+typename basic_filebuf<_CharT, _Traits>::pos_type
+basic_filebuf<_CharT, _Traits>::seekpos(pos_type __sp, ios_base::openmode)
+{
+ if (__file_ == nullptr || sync())
+ return pos_type(off_type(-1));
+#if defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)
+ if (fseek(__file_, __sp, SEEK_SET))
+ return pos_type(off_type(-1));
+#else
+ if (fseeko(__file_, __sp, SEEK_SET))
+ return pos_type(off_type(-1));
+#endif
+ __st_ = __sp.state();
+ return __sp;
+}
+
+template <class _CharT, class _Traits>
+int
+basic_filebuf<_CharT, _Traits>::sync()
+{
+ if (__file_ == nullptr)
+ return 0;
+ if (!__cv_)
+ __throw_bad_cast();
+
+ if (__cm_ & ios_base::out)
+ {
+ if (this->pptr() != this->pbase())
+ if (overflow() == traits_type::eof())
+ return -1;
+ codecvt_base::result __r;
+ do
+ {
+ char* __extbe;
+ __r = __cv_->unshift(__st_, __extbuf_, __extbuf_ + __ebs_, __extbe);
+ size_t __nmemb = static_cast<size_t>(__extbe - __extbuf_);
+ if (fwrite(__extbuf_, 1, __nmemb, __file_) != __nmemb)
+ return -1;
+ } while (__r == codecvt_base::partial);
+ if (__r == codecvt_base::error)
+ return -1;
+ if (fflush(__file_))
+ return -1;
+ }
+ else if (__cm_ & ios_base::in)
+ {
+ off_type __c;
+ state_type __state = __st_last_;
+ bool __update_st = false;
+ if (__always_noconv_)
+ __c = this->egptr() - this->gptr();
+ else
+ {
+ int __width = __cv_->encoding();
+ __c = __extbufend_ - __extbufnext_;
+ if (__width > 0)
+ __c += __width * (this->egptr() - this->gptr());
+ else
+ {
+ if (this->gptr() != this->egptr())
+ {
+ const int __off = __cv_->length(__state, __extbuf_,
+ __extbufnext_,
+ this->gptr() - this->eback());
+ __c += __extbufnext_ - __extbuf_ - __off;
+ __update_st = true;
+ }
+ }
+ }
+#if defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)
+ if (fseek(__file_, -__c, SEEK_CUR))
+ return -1;
+#else
+ if (fseeko(__file_, -__c, SEEK_CUR))
+ return -1;
+#endif
+ if (__update_st)
+ __st_ = __state;
+ __extbufnext_ = __extbufend_ = __extbuf_;
+ this->setg(nullptr, nullptr, nullptr);
+ __cm_ = 0;
+ }
+ return 0;
+}
+
+template <class _CharT, class _Traits>
+void
+basic_filebuf<_CharT, _Traits>::imbue(const locale& __loc)
+{
+ sync();
+ __cv_ = &use_facet<codecvt<char_type, char, state_type> >(__loc);
+ bool __old_anc = __always_noconv_;
+ __always_noconv_ = __cv_->always_noconv();
+ if (__old_anc != __always_noconv_)
+ {
+ this->setg(nullptr, nullptr, nullptr);
+ this->setp(nullptr, nullptr);
+ // invariant, char_type is char, else we couldn't get here
+ if (__always_noconv_) // need to dump __intbuf_
+ {
+ if (__owns_eb_)
+ delete [] __extbuf_;
+ __owns_eb_ = __owns_ib_;
+ __ebs_ = __ibs_;
+ __extbuf_ = (char*)__intbuf_;
+ __ibs_ = 0;
+ __intbuf_ = nullptr;
+ __owns_ib_ = false;
+ }
+ else // need to obtain an __intbuf_.
+ { // If __extbuf_ is user-supplied, use it, else new __intbuf_
+ if (!__owns_eb_ && __extbuf_ != __extbuf_min_)
+ {
+ __ibs_ = __ebs_;
+ __intbuf_ = (char_type*)__extbuf_;
+ __owns_ib_ = false;
+ __extbuf_ = new char[__ebs_];
+ __owns_eb_ = true;
+ }
+ else
+ {
+ __ibs_ = __ebs_;
+ __intbuf_ = new char_type[__ibs_];
+ __owns_ib_ = true;
+ }
+ }
+ }
+}
+
+template <class _CharT, class _Traits>
+bool
+basic_filebuf<_CharT, _Traits>::__read_mode()
+{
+ if (!(__cm_ & ios_base::in))
+ {
+ this->setp(nullptr, nullptr);
+ if (__always_noconv_)
+ this->setg((char_type*)__extbuf_,
+ (char_type*)__extbuf_ + __ebs_,
+ (char_type*)__extbuf_ + __ebs_);
+ else
+ this->setg(__intbuf_, __intbuf_ + __ibs_, __intbuf_ + __ibs_);
+ __cm_ = ios_base::in;
+ return true;
+ }
+ return false;
+}
+
+template <class _CharT, class _Traits>
+void
+basic_filebuf<_CharT, _Traits>::__write_mode()
+{
+ if (!(__cm_ & ios_base::out))
+ {
+ this->setg(nullptr, nullptr, nullptr);
+ if (__ebs_ > sizeof(__extbuf_min_))
+ {
+ if (__always_noconv_)
+ this->setp((char_type*)__extbuf_,
+ (char_type*)__extbuf_ + (__ebs_ - 1));
+ else
+ this->setp(__intbuf_, __intbuf_ + (__ibs_ - 1));
+ }
+ else
+ this->setp(nullptr, nullptr);
+ __cm_ = ios_base::out;
+ }
+}
+
+// basic_ifstream
+
+template <class _CharT, class _Traits>
+class _LIBCPP_TEMPLATE_VIS basic_ifstream
+ : public basic_istream<_CharT, _Traits>
+{
+public:
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ basic_ifstream();
+ _LIBCPP_INLINE_VISIBILITY
+ explicit basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in);
+#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
+ _LIBCPP_INLINE_VISIBILITY
+ explicit basic_ifstream(const wchar_t* __s, ios_base::openmode __mode = ios_base::in);
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ explicit basic_ifstream(const string& __s, ios_base::openmode __mode = ios_base::in);
+#if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
+ _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_INLINE_VISIBILITY
+ explicit basic_ifstream(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in)
+ : basic_ifstream(__p.c_str(), __mode) {}
+#endif // _LIBCPP_STD_VER >= 17
+ _LIBCPP_INLINE_VISIBILITY
+ basic_ifstream(basic_ifstream&& __rhs);
+ _LIBCPP_INLINE_VISIBILITY
+ basic_ifstream& operator=(basic_ifstream&& __rhs);
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(basic_ifstream& __rhs);
+
+ _LIBCPP_INLINE_VISIBILITY
+ basic_filebuf<char_type, traits_type>* rdbuf() const;
+ _LIBCPP_INLINE_VISIBILITY
+ bool is_open() const;
+ void open(const char* __s, ios_base::openmode __mode = ios_base::in);
+#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
+ void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::in);
+#endif
+ void open(const string& __s, ios_base::openmode __mode = ios_base::in);
+#if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
+ _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_INLINE_VISIBILITY
+ void open(const filesystem::path& __p,
+ ios_base::openmode __mode = ios_base::in) {
+ return open(__p.c_str(), __mode);
+ }
+#endif // _LIBCPP_STD_VER >= 17
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __open(int __fd, ios_base::openmode __mode);
+ _LIBCPP_INLINE_VISIBILITY
+ void close();
+
+private:
+ basic_filebuf<char_type, traits_type> __sb_;
+};
+
+template <class _CharT, class _Traits>
+inline
+basic_ifstream<_CharT, _Traits>::basic_ifstream()
+ : basic_istream<char_type, traits_type>(&__sb_)
+{
+}
+
+template <class _CharT, class _Traits>
+inline
+basic_ifstream<_CharT, _Traits>::basic_ifstream(const char* __s, ios_base::openmode __mode)
+ : basic_istream<char_type, traits_type>(&__sb_)
+{
+ if (__sb_.open(__s, __mode | ios_base::in) == nullptr)
+ this->setstate(ios_base::failbit);
+}
+
+#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
+template <class _CharT, class _Traits>
+inline
+basic_ifstream<_CharT, _Traits>::basic_ifstream(const wchar_t* __s, ios_base::openmode __mode)
+ : basic_istream<char_type, traits_type>(&__sb_)
+{
+ if (__sb_.open(__s, __mode | ios_base::in) == nullptr)
+ this->setstate(ios_base::failbit);
+}
+#endif
+
+template <class _CharT, class _Traits>
+inline
+basic_ifstream<_CharT, _Traits>::basic_ifstream(const string& __s, ios_base::openmode __mode)
+ : basic_istream<char_type, traits_type>(&__sb_)
+{
+ if (__sb_.open(__s, __mode | ios_base::in) == nullptr)
+ this->setstate(ios_base::failbit);
+}
+
+template <class _CharT, class _Traits>
+inline
+basic_ifstream<_CharT, _Traits>::basic_ifstream(basic_ifstream&& __rhs)
+ : basic_istream<char_type, traits_type>(_VSTD::move(__rhs)),
+ __sb_(_VSTD::move(__rhs.__sb_))
+{
+ this->set_rdbuf(&__sb_);
+}
+
+template <class _CharT, class _Traits>
+inline
+basic_ifstream<_CharT, _Traits>&
+basic_ifstream<_CharT, _Traits>::operator=(basic_ifstream&& __rhs)
+{
+ basic_istream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
+ __sb_ = _VSTD::move(__rhs.__sb_);
+ return *this;
+}
+
+template <class _CharT, class _Traits>
+inline
+void
+basic_ifstream<_CharT, _Traits>::swap(basic_ifstream& __rhs)
+{
+ basic_istream<char_type, traits_type>::swap(__rhs);
+ __sb_.swap(__rhs.__sb_);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(basic_ifstream<_CharT, _Traits>& __x, basic_ifstream<_CharT, _Traits>& __y)
+{
+ __x.swap(__y);
+}
+
+template <class _CharT, class _Traits>
+inline
+basic_filebuf<_CharT, _Traits>*
+basic_ifstream<_CharT, _Traits>::rdbuf() const
+{
+ return const_cast<basic_filebuf<char_type, traits_type>*>(&__sb_);
+}
+
+template <class _CharT, class _Traits>
+inline
+bool
+basic_ifstream<_CharT, _Traits>::is_open() const
+{
+ return __sb_.is_open();
+}
+
+template <class _CharT, class _Traits>
+void
+basic_ifstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
+{
+ if (__sb_.open(__s, __mode | ios_base::in))
+ this->clear();
+ else
+ this->setstate(ios_base::failbit);
+}
+
+#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
+template <class _CharT, class _Traits>
+void
+basic_ifstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode)
+{
+ if (__sb_.open(__s, __mode | ios_base::in))
+ this->clear();
+ else
+ this->setstate(ios_base::failbit);
+}
+#endif
+
+template <class _CharT, class _Traits>
+void
+basic_ifstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode)
+{
+ if (__sb_.open(__s, __mode | ios_base::in))
+ this->clear();
+ else
+ this->setstate(ios_base::failbit);
+}
+
+template <class _CharT, class _Traits>
+inline
+void basic_ifstream<_CharT, _Traits>::__open(int __fd,
+ ios_base::openmode __mode) {
+ if (__sb_.__open(__fd, __mode | ios_base::in))
+ this->clear();
+ else
+ this->setstate(ios_base::failbit);
+}
+
+template <class _CharT, class _Traits>
+inline
+void
+basic_ifstream<_CharT, _Traits>::close()
+{
+ if (__sb_.close() == 0)
+ this->setstate(ios_base::failbit);
+}
+
+// basic_ofstream
+
+template <class _CharT, class _Traits>
+class _LIBCPP_TEMPLATE_VIS basic_ofstream
+ : public basic_ostream<_CharT, _Traits>
+{
+public:
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ basic_ofstream();
+ _LIBCPP_INLINE_VISIBILITY
+ explicit basic_ofstream(const char* __s, ios_base::openmode __mode = ios_base::out);
+#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
+ _LIBCPP_INLINE_VISIBILITY
+ explicit basic_ofstream(const wchar_t* __s, ios_base::openmode __mode = ios_base::out);
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ explicit basic_ofstream(const string& __s, ios_base::openmode __mode = ios_base::out);
+
+#if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
+ _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_INLINE_VISIBILITY
+ explicit basic_ofstream(const filesystem::path& __p, ios_base::openmode __mode = ios_base::out)
+ : basic_ofstream(__p.c_str(), __mode) {}
+#endif // _LIBCPP_STD_VER >= 17
+
+ _LIBCPP_INLINE_VISIBILITY
+ basic_ofstream(basic_ofstream&& __rhs);
+ _LIBCPP_INLINE_VISIBILITY
+ basic_ofstream& operator=(basic_ofstream&& __rhs);
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(basic_ofstream& __rhs);
+
+ _LIBCPP_INLINE_VISIBILITY
+ basic_filebuf<char_type, traits_type>* rdbuf() const;
+ _LIBCPP_INLINE_VISIBILITY
+ bool is_open() const;
+ void open(const char* __s, ios_base::openmode __mode = ios_base::out);
+#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
+ void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::out);
+#endif
+ void open(const string& __s, ios_base::openmode __mode = ios_base::out);
+
+#if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
+ _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_INLINE_VISIBILITY
+ void open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::out)
+ { return open(__p.c_str(), __mode); }
+#endif // _LIBCPP_STD_VER >= 17
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __open(int __fd, ios_base::openmode __mode);
+ _LIBCPP_INLINE_VISIBILITY
+ void close();
+
+private:
+ basic_filebuf<char_type, traits_type> __sb_;
+};
+
+template <class _CharT, class _Traits>
+inline
+basic_ofstream<_CharT, _Traits>::basic_ofstream()
+ : basic_ostream<char_type, traits_type>(&__sb_)
+{
+}
+
+template <class _CharT, class _Traits>
+inline
+basic_ofstream<_CharT, _Traits>::basic_ofstream(const char* __s, ios_base::openmode __mode)
+ : basic_ostream<char_type, traits_type>(&__sb_)
+{
+ if (__sb_.open(__s, __mode | ios_base::out) == nullptr)
+ this->setstate(ios_base::failbit);
+}
+
+#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
+template <class _CharT, class _Traits>
+inline
+basic_ofstream<_CharT, _Traits>::basic_ofstream(const wchar_t* __s, ios_base::openmode __mode)
+ : basic_ostream<char_type, traits_type>(&__sb_)
+{
+ if (__sb_.open(__s, __mode | ios_base::out) == nullptr)
+ this->setstate(ios_base::failbit);
+}
+#endif
+
+template <class _CharT, class _Traits>
+inline
+basic_ofstream<_CharT, _Traits>::basic_ofstream(const string& __s, ios_base::openmode __mode)
+ : basic_ostream<char_type, traits_type>(&__sb_)
+{
+ if (__sb_.open(__s, __mode | ios_base::out) == nullptr)
+ this->setstate(ios_base::failbit);
+}
+
+template <class _CharT, class _Traits>
+inline
+basic_ofstream<_CharT, _Traits>::basic_ofstream(basic_ofstream&& __rhs)
+ : basic_ostream<char_type, traits_type>(_VSTD::move(__rhs)),
+ __sb_(_VSTD::move(__rhs.__sb_))
+{
+ this->set_rdbuf(&__sb_);
+}
+
+template <class _CharT, class _Traits>
+inline
+basic_ofstream<_CharT, _Traits>&
+basic_ofstream<_CharT, _Traits>::operator=(basic_ofstream&& __rhs)
+{
+ basic_ostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
+ __sb_ = _VSTD::move(__rhs.__sb_);
+ return *this;
+}
+
+template <class _CharT, class _Traits>
+inline
+void
+basic_ofstream<_CharT, _Traits>::swap(basic_ofstream& __rhs)
+{
+ basic_ostream<char_type, traits_type>::swap(__rhs);
+ __sb_.swap(__rhs.__sb_);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(basic_ofstream<_CharT, _Traits>& __x, basic_ofstream<_CharT, _Traits>& __y)
+{
+ __x.swap(__y);
+}
+
+template <class _CharT, class _Traits>
+inline
+basic_filebuf<_CharT, _Traits>*
+basic_ofstream<_CharT, _Traits>::rdbuf() const
+{
+ return const_cast<basic_filebuf<char_type, traits_type>*>(&__sb_);
+}
+
+template <class _CharT, class _Traits>
+inline
+bool
+basic_ofstream<_CharT, _Traits>::is_open() const
+{
+ return __sb_.is_open();
+}
+
+template <class _CharT, class _Traits>
+void
+basic_ofstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
+{
+ if (__sb_.open(__s, __mode | ios_base::out))
+ this->clear();
+ else
+ this->setstate(ios_base::failbit);
+}
+
+#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
+template <class _CharT, class _Traits>
+void
+basic_ofstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode)
+{
+ if (__sb_.open(__s, __mode | ios_base::out))
+ this->clear();
+ else
+ this->setstate(ios_base::failbit);
+}
+#endif
+
+template <class _CharT, class _Traits>
+void
+basic_ofstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode)
+{
+ if (__sb_.open(__s, __mode | ios_base::out))
+ this->clear();
+ else
+ this->setstate(ios_base::failbit);
+}
+
+template <class _CharT, class _Traits>
+inline
+void basic_ofstream<_CharT, _Traits>::__open(int __fd,
+ ios_base::openmode __mode) {
+ if (__sb_.__open(__fd, __mode | ios_base::out))
+ this->clear();
+ else
+ this->setstate(ios_base::failbit);
+}
+
+template <class _CharT, class _Traits>
+inline
+void
+basic_ofstream<_CharT, _Traits>::close()
+{
+ if (__sb_.close() == nullptr)
+ this->setstate(ios_base::failbit);
+}
+
+// basic_fstream
+
+template <class _CharT, class _Traits>
+class _LIBCPP_TEMPLATE_VIS basic_fstream
+ : public basic_iostream<_CharT, _Traits>
+{
+public:
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ basic_fstream();
+ _LIBCPP_INLINE_VISIBILITY
+ explicit basic_fstream(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
+#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
+ _LIBCPP_INLINE_VISIBILITY
+ explicit basic_fstream(const wchar_t* __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ explicit basic_fstream(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
+
+#if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
+ _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_INLINE_VISIBILITY
+ explicit basic_fstream(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in | ios_base::out)
+ : basic_fstream(__p.c_str(), __mode) {}
+#endif // _LIBCPP_STD_VER >= 17
+
+ _LIBCPP_INLINE_VISIBILITY
+ basic_fstream(basic_fstream&& __rhs);
+
+ _LIBCPP_INLINE_VISIBILITY
+ basic_fstream& operator=(basic_fstream&& __rhs);
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(basic_fstream& __rhs);
+
+ _LIBCPP_INLINE_VISIBILITY
+ basic_filebuf<char_type, traits_type>* rdbuf() const;
+ _LIBCPP_INLINE_VISIBILITY
+ bool is_open() const;
+ void open(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
+#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
+ void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
+#endif
+ void open(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
+
+#if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
+ _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_INLINE_VISIBILITY
+ void open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in|ios_base::out)
+ { return open(__p.c_str(), __mode); }
+#endif // _LIBCPP_STD_VER >= 17
+
+ _LIBCPP_INLINE_VISIBILITY
+ void close();
+
+private:
+ basic_filebuf<char_type, traits_type> __sb_;
+};
+
+template <class _CharT, class _Traits>
+inline
+basic_fstream<_CharT, _Traits>::basic_fstream()
+ : basic_iostream<char_type, traits_type>(&__sb_)
+{
+}
+
+template <class _CharT, class _Traits>
+inline
+basic_fstream<_CharT, _Traits>::basic_fstream(const char* __s, ios_base::openmode __mode)
+ : basic_iostream<char_type, traits_type>(&__sb_)
+{
+ if (__sb_.open(__s, __mode) == nullptr)
+ this->setstate(ios_base::failbit);
+}
+
+#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
+template <class _CharT, class _Traits>
+inline
+basic_fstream<_CharT, _Traits>::basic_fstream(const wchar_t* __s, ios_base::openmode __mode)
+ : basic_iostream<char_type, traits_type>(&__sb_)
+{
+ if (__sb_.open(__s, __mode) == nullptr)
+ this->setstate(ios_base::failbit);
+}
+#endif
+
+template <class _CharT, class _Traits>
+inline
+basic_fstream<_CharT, _Traits>::basic_fstream(const string& __s, ios_base::openmode __mode)
+ : basic_iostream<char_type, traits_type>(&__sb_)
+{
+ if (__sb_.open(__s, __mode) == nullptr)
+ this->setstate(ios_base::failbit);
+}
+
+template <class _CharT, class _Traits>
+inline
+basic_fstream<_CharT, _Traits>::basic_fstream(basic_fstream&& __rhs)
+ : basic_iostream<char_type, traits_type>(_VSTD::move(__rhs)),
+ __sb_(_VSTD::move(__rhs.__sb_))
+{
+ this->set_rdbuf(&__sb_);
+}
+
+template <class _CharT, class _Traits>
+inline
+basic_fstream<_CharT, _Traits>&
+basic_fstream<_CharT, _Traits>::operator=(basic_fstream&& __rhs)
+{
+ basic_iostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
+ __sb_ = _VSTD::move(__rhs.__sb_);
+ return *this;
+}
+
+template <class _CharT, class _Traits>
+inline
+void
+basic_fstream<_CharT, _Traits>::swap(basic_fstream& __rhs)
+{
+ basic_iostream<char_type, traits_type>::swap(__rhs);
+ __sb_.swap(__rhs.__sb_);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(basic_fstream<_CharT, _Traits>& __x, basic_fstream<_CharT, _Traits>& __y)
+{
+ __x.swap(__y);
+}
+
+template <class _CharT, class _Traits>
+inline
+basic_filebuf<_CharT, _Traits>*
+basic_fstream<_CharT, _Traits>::rdbuf() const
+{
+ return const_cast<basic_filebuf<char_type, traits_type>*>(&__sb_);
+}
+
+template <class _CharT, class _Traits>
+inline
+bool
+basic_fstream<_CharT, _Traits>::is_open() const
+{
+ return __sb_.is_open();
+}
+
+template <class _CharT, class _Traits>
+void
+basic_fstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
+{
+ if (__sb_.open(__s, __mode))
+ this->clear();
+ else
+ this->setstate(ios_base::failbit);
+}
+
+#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
+template <class _CharT, class _Traits>
+void
+basic_fstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode)
+{
+ if (__sb_.open(__s, __mode))
+ this->clear();
+ else
+ this->setstate(ios_base::failbit);
+}
+#endif
+
+template <class _CharT, class _Traits>
+void
+basic_fstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode)
+{
+ if (__sb_.open(__s, __mode))
+ this->clear();
+ else
+ this->setstate(ios_base::failbit);
+}
+
+template <class _CharT, class _Traits>
+inline
+void
+basic_fstream<_CharT, _Traits>::close()
+{
+ if (__sb_.close() == nullptr)
+ this->setstate(ios_base::failbit);
+}
+
+#if defined(_LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1)
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ifstream<char>)
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ofstream<char>)
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_filebuf<char>)
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_FSTREAM
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/functional b/contrib/libs/cxxsupp/libcxxmsvc/include/functional
new file mode 100644
index 0000000000..d4889294f7
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/functional
@@ -0,0 +1,535 @@
+// -*- 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
+#define _LIBCPP_FUNCTIONAL
+
+/*
+ functional synopsis
+
+namespace std
+{
+
+template <class Arg, class Result>
+struct unary_function
+{
+ typedef Arg argument_type;
+ typedef Result result_type;
+};
+
+template <class Arg1, class Arg2, class Result>
+struct binary_function
+{
+ typedef Arg1 first_argument_type;
+ typedef Arg2 second_argument_type;
+ typedef Result result_type;
+};
+
+template <class T>
+class reference_wrapper
+ : public unary_function<T1, R> // if wrapping a unary functor
+ : public binary_function<T1, T2, R> // if wraping a binary functor
+{
+public:
+ // types
+ typedef T type;
+ typedef see below result_type; // Not always defined
+
+ // construct/copy/destroy
+ template<class U>
+ reference_wrapper(U&&);
+ reference_wrapper(const reference_wrapper<T>& x) noexcept;
+
+ // assignment
+ reference_wrapper& operator=(const reference_wrapper<T>& x) noexcept;
+
+ // access
+ operator T& () const noexcept;
+ T& get() const noexcept;
+
+ // invoke
+ template <class... ArgTypes>
+ typename result_of<T&(ArgTypes&&...)>::type
+ 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;
+
+template <class T> reference_wrapper<const T> cref(const T& t) noexcept;
+template <class T> void cref(const T&& t) = delete;
+template <class T> reference_wrapper<const T> cref(reference_wrapper<T> t) noexcept;
+
+template <class T> struct unwrap_reference; // since C++20
+template <class T> struct unwrap_ref_decay : unwrap_reference<decay_t<T>> { }; // since C++20
+template <class T> using unwrap_reference_t = typename unwrap_reference<T>::type; // since C++20
+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 {
+ T operator()(const T& x, const T& y) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct minus {
+ T operator()(const T& x, const T& y) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct multiplies {
+ T operator()(const T& x, const T& y) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct divides {
+ T operator()(const T& x, const T& y) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct modulus {
+ T operator()(const T& x, const T& y) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct negate {
+ T operator()(const T& x) const;
+};
+
+template <class T> // <class T=void> in C++14
+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 {
+ bool operator()(const T& x, const T& y) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct greater {
+ bool operator()(const T& x, const T& y) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct less {
+ bool operator()(const T& x, const T& y) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct greater_equal {
+ bool operator()(const T& x, const T& y) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct less_equal {
+ bool operator()(const T& x, const T& y) const;
+};
+
+// [comparisons.three.way], class compare_three_way
+struct compare_three_way;
+
+template <class T> // <class T=void> in C++14
+struct logical_and {
+ bool operator()(const T& x, const T& y) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct logical_or {
+ bool operator()(const T& x, const T& y) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct logical_not {
+ bool operator()(const T& x) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct bit_and {
+ T operator()(const T& x, const T& y) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct bit_or {
+ T operator()(const T& x, const T& y) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct bit_xor {
+ T operator()(const T& x, const T& y) const;
+};
+
+template <class T=void> // C++14
+struct bit_not {
+ T operator()(const T& x) const;
+};
+
+struct identity; // C++20
+
+template <class Predicate>
+class unary_negate // deprecated in C++17, removed in C++20
+ : public unary_function<typename Predicate::argument_type, bool>
+{
+public:
+ explicit unary_negate(const Predicate& pred);
+ bool operator()(const typename Predicate::argument_type& x) const;
+};
+
+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, removed in C++20
+ : public binary_function<typename Predicate::first_argument_type,
+ typename Predicate::second_argument_type,
+ bool>
+{
+public:
+ explicit binary_negate(const Predicate& pred);
+ bool operator()(const typename Predicate::first_argument_type& x,
+ const typename Predicate::second_argument_type& y) const;
+};
+
+template <class Predicate> // deprecated in C++17, removed in C++20
+binary_negate<Predicate> not2(const Predicate& pred);
+
+template <class F>
+constexpr unspecified not_fn(F&& f); // C++17, constexpr in C++20
+
+template<class T> struct is_bind_expression;
+template<class T> struct is_placeholder;
+
+ // See C++14 20.9.9, Function object binders
+template <class T> inline constexpr bool is_bind_expression_v
+ = is_bind_expression<T>::value; // C++17
+template <class T> inline constexpr int is_placeholder_v
+ = is_placeholder<T>::value; // C++17
+
+
+template<class Fn, class... BoundArgs>
+ constexpr unspecified bind(Fn&&, BoundArgs&&...); // constexpr in C++20
+template<class R, class Fn, class... BoundArgs>
+ constexpr unspecified bind(Fn&&, BoundArgs&&...); // constexpr in C++20
+
+template<class F, class... Args>
+ constexpr // constexpr in C++20
+ invoke_result_t<F, Args...> invoke(F&& f, Args&&... args) // C++17
+ noexcept(is_nothrow_invocable_v<F, Args...>);
+
+namespace placeholders {
+ // M is the implementation-defined number of placeholders
+ extern unspecified _1;
+ extern unspecified _2;
+ .
+ .
+ .
+ extern unspecified _Mp;
+}
+
+template <class Operation>
+class binder1st // deprecated in C++11, removed in C++17
+ : public unary_function<typename Operation::second_argument_type,
+ typename Operation::result_type>
+{
+protected:
+ Operation op;
+ typename Operation::first_argument_type value;
+public:
+ binder1st(const Operation& x, const typename Operation::first_argument_type y);
+ typename Operation::result_type operator()( typename Operation::second_argument_type& x) const;
+ typename Operation::result_type operator()(const typename Operation::second_argument_type& x) const;
+};
+
+template <class Operation, class T>
+binder1st<Operation> bind1st(const Operation& op, const T& x); // deprecated in C++11, removed in C++17
+
+template <class Operation>
+class binder2nd // deprecated in C++11, removed in C++17
+ : public unary_function<typename Operation::first_argument_type,
+ typename Operation::result_type>
+{
+protected:
+ Operation op;
+ typename Operation::second_argument_type value;
+public:
+ binder2nd(const Operation& x, const typename Operation::second_argument_type y);
+ typename Operation::result_type operator()( typename Operation::first_argument_type& x) const;
+ typename Operation::result_type operator()(const typename Operation::first_argument_type& x) const;
+};
+
+template <class Operation, class T>
+binder2nd<Operation> bind2nd(const Operation& op, const T& x); // deprecated in C++11, removed in C++17
+
+template <class Arg, class Result> // deprecated in C++11, removed in C++17
+class pointer_to_unary_function : public unary_function<Arg, Result>
+{
+public:
+ explicit pointer_to_unary_function(Result (*f)(Arg));
+ Result operator()(Arg x) const;
+};
+
+template <class Arg, class Result>
+pointer_to_unary_function<Arg,Result> ptr_fun(Result (*f)(Arg)); // deprecated in C++11, removed in C++17
+
+template <class Arg1, class Arg2, class Result> // deprecated in C++11, removed in C++17
+class pointer_to_binary_function : public binary_function<Arg1, Arg2, Result>
+{
+public:
+ explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2));
+ Result operator()(Arg1 x, Arg2 y) const;
+};
+
+template <class Arg1, class Arg2, class Result>
+pointer_to_binary_function<Arg1,Arg2,Result> ptr_fun(Result (*f)(Arg1,Arg2)); // deprecated in C++11, removed in C++17
+
+template<class S, class T> // deprecated in C++11, removed in C++17
+class mem_fun_t : public unary_function<T*, S>
+{
+public:
+ explicit mem_fun_t(S (T::*p)());
+ S operator()(T* p) const;
+};
+
+template<class S, class T, class A>
+class mem_fun1_t : public binary_function<T*, A, S> // deprecated in C++11, removed in C++17
+{
+public:
+ explicit mem_fun1_t(S (T::*p)(A));
+ S operator()(T* p, A x) const;
+};
+
+template<class S, class T> mem_fun_t<S,T> mem_fun(S (T::*f)()); // deprecated in C++11, removed in C++17
+template<class S, class T, class A> mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A)); // deprecated in C++11, removed in C++17
+
+template<class S, class T>
+class mem_fun_ref_t : public unary_function<T, S> // deprecated in C++11, removed in C++17
+{
+public:
+ explicit mem_fun_ref_t(S (T::*p)());
+ S operator()(T& p) const;
+};
+
+template<class S, class T, class A>
+class mem_fun1_ref_t : public binary_function<T, A, S> // deprecated in C++11, removed in C++17
+{
+public:
+ explicit mem_fun1_ref_t(S (T::*p)(A));
+ S operator()(T& p, A x) const;
+};
+
+template<class S, class T> mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)()); // deprecated in C++11, removed in C++17
+template<class S, class T, class A> mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A)); // deprecated in C++11, removed in C++17
+
+template <class S, class T>
+class const_mem_fun_t : public unary_function<const T*, S> // deprecated in C++11, removed in C++17
+{
+public:
+ explicit const_mem_fun_t(S (T::*p)() const);
+ S operator()(const T* p) const;
+};
+
+template <class S, class T, class A>
+class const_mem_fun1_t : public binary_function<const T*, A, S> // deprecated in C++11, removed in C++17
+{
+public:
+ explicit const_mem_fun1_t(S (T::*p)(A) const);
+ S operator()(const T* p, A x) const;
+};
+
+template <class S, class T> const_mem_fun_t<S,T> mem_fun(S (T::*f)() const); // deprecated in C++11, removed in C++17
+template <class S, class T, class A> const_mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A) const); // deprecated in C++11, removed in C++17
+
+template <class S, class T>
+class const_mem_fun_ref_t : public unary_function<T, S> // deprecated in C++11, removed in C++17
+{
+public:
+ explicit const_mem_fun_ref_t(S (T::*p)() const);
+ S operator()(const T& p) const;
+};
+
+template <class S, class T, class A>
+class const_mem_fun1_ref_t : public binary_function<T, A, S> // deprecated in C++11, removed in C++17
+{
+public:
+ explicit const_mem_fun1_ref_t(S (T::*p)(A) const);
+ S operator()(const T& p, A x) const;
+};
+
+template <class S, class T> const_mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)() const); // deprecated in C++11, removed in C++17
+template <class S, class T, class A> const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const); // deprecated in C++11, removed in C++17
+
+template<class R, class T>
+constexpr unspecified mem_fn(R T::*); // constexpr in C++20
+
+class bad_function_call
+ : public exception
+{
+};
+
+template<class> class function; // undefined
+
+template<class R, class... ArgTypes>
+class function<R(ArgTypes...)>
+ : public unary_function<T1, R> // iff sizeof...(ArgTypes) == 1 and
+ // ArgTypes contains T1
+ : public binary_function<T1, T2, R> // iff sizeof...(ArgTypes) == 2 and
+ // ArgTypes contains T1 and T2
+{
+public:
+ typedef R result_type;
+
+ // construct/copy/destroy:
+ function() noexcept;
+ function(nullptr_t) noexcept;
+ function(const function&);
+ function(function&&) noexcept;
+ template<class F>
+ function(F);
+ template<Allocator Alloc>
+ function(allocator_arg_t, const Alloc&) noexcept; // removed in C++17
+ template<Allocator Alloc>
+ function(allocator_arg_t, const Alloc&, nullptr_t) noexcept; // removed in C++17
+ template<Allocator Alloc>
+ function(allocator_arg_t, const Alloc&, const function&); // removed in C++17
+ template<Allocator Alloc>
+ function(allocator_arg_t, const Alloc&, function&&); // removed in C++17
+ template<class F, Allocator Alloc>
+ function(allocator_arg_t, const Alloc&, F); // removed in C++17
+
+ function& operator=(const function&);
+ function& operator=(function&&) noexcept;
+ function& operator=(nullptr_t) noexcept;
+ template<class F>
+ function& operator=(F&&);
+ template<class F>
+ function& operator=(reference_wrapper<F>) noexcept;
+
+ ~function();
+
+ // function modifiers:
+ void swap(function&) noexcept;
+ template<class F, class Alloc>
+ void assign(F&&, const Alloc&); // Removed in C++17
+
+ // function capacity:
+ explicit operator bool() const noexcept;
+
+ // function invocation:
+ R operator()(ArgTypes...) const;
+
+ // function target access:
+ const std::type_info& target_type() const noexcept;
+ template <typename T> T* target() noexcept;
+ template <typename T> const T* target() const noexcept;
+};
+
+// Deduction guides
+template<class R, class ...Args>
+function(R(*)(Args...)) -> function<R(Args...)>; // since C++17
+
+template<class F>
+function(F) -> function<see-below>; // since C++17
+
+// Null pointer comparisons:
+template <class R, class ... ArgTypes>
+ bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
+
+template <class R, class ... ArgTypes>
+ bool operator==(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
+
+template <class R, class ... ArgTypes>
+ bool operator!=(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
+
+template <class R, class ... ArgTypes>
+ bool operator!=(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
+
+// specialized algorithms:
+template <class R, class ... ArgTypes>
+ void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;
+
+template <class T> struct hash;
+
+template <> struct hash<bool>;
+template <> struct hash<char>;
+template <> struct hash<signed char>;
+template <> struct hash<unsigned char>;
+template <> struct hash<char8_t>; // since C++20
+template <> struct hash<char16_t>;
+template <> struct hash<char32_t>;
+template <> struct hash<wchar_t>;
+template <> struct hash<short>;
+template <> struct hash<unsigned short>;
+template <> struct hash<int>;
+template <> struct hash<unsigned int>;
+template <> struct hash<long>;
+template <> struct hash<long long>;
+template <> struct hash<unsigned long>;
+template <> struct hash<unsigned long long>;
+
+template <> struct hash<float>;
+template <> struct hash<double>;
+template <> struct hash<long double>;
+
+template<class T> struct hash<T*>;
+template <> struct hash<nullptr_t>; // C++17
+
+} // std
+
+POLICY: For non-variadic implementations, the number of arguments is limited
+ to 3. It is hoped that the need for non-variadic implementations
+ will be minimal.
+
+*/
+
+#include <__algorithm/search.h>
+#include <__compare/compare_three_way.h>
+#include <__config>
+#include <__debug>
+#include <__functional/binary_function.h> // TODO: deprecate
+#include <__functional/binary_negate.h>
+#include <__functional/bind.h>
+#include <__functional/bind_back.h>
+#include <__functional/bind_front.h>
+#include <__functional/binder1st.h>
+#include <__functional/binder2nd.h>
+#include <__functional/compose.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>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#endif // _LIBCPP_FUNCTIONAL
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/future b/contrib/libs/cxxsupp/libcxxmsvc/include/future
new file mode 100644
index 0000000000..15685dfb22
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/future
@@ -0,0 +1,2435 @@
+// -*- 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_FUTURE
+#define _LIBCPP_FUTURE
+
+/*
+ future synopsis
+
+namespace std
+{
+
+enum class future_errc
+{
+ future_already_retrieved = 1,
+ promise_already_satisfied,
+ no_state,
+ broken_promise
+};
+
+enum class launch
+{
+ async = 1,
+ deferred = 2,
+ any = async | deferred
+};
+
+enum class future_status
+{
+ ready,
+ timeout,
+ deferred
+};
+
+template <> struct is_error_code_enum<future_errc> : public true_type { };
+error_code make_error_code(future_errc e) noexcept;
+error_condition make_error_condition(future_errc e) noexcept;
+
+const error_category& future_category() noexcept;
+
+class future_error
+ : public logic_error
+{
+public:
+ future_error(error_code ec); // exposition only
+ explicit future_error(future_errc); // C++17
+ const error_code& code() const noexcept;
+ const char* what() const noexcept;
+};
+
+template <class R>
+class promise
+{
+public:
+ promise();
+ template <class Allocator>
+ promise(allocator_arg_t, const Allocator& a);
+ promise(promise&& rhs) noexcept;
+ promise(const promise& rhs) = delete;
+ ~promise();
+
+ // assignment
+ promise& operator=(promise&& rhs) noexcept;
+ promise& operator=(const promise& rhs) = delete;
+ void swap(promise& other) noexcept;
+
+ // retrieving the result
+ future<R> get_future();
+
+ // setting the result
+ void set_value(const R& r);
+ void set_value(R&& r);
+ void set_exception(exception_ptr p);
+
+ // setting the result with deferred notification
+ void set_value_at_thread_exit(const R& r);
+ void set_value_at_thread_exit(R&& r);
+ void set_exception_at_thread_exit(exception_ptr p);
+};
+
+template <class R>
+class promise<R&>
+{
+public:
+ promise();
+ template <class Allocator>
+ promise(allocator_arg_t, const Allocator& a);
+ promise(promise&& rhs) noexcept;
+ promise(const promise& rhs) = delete;
+ ~promise();
+
+ // assignment
+ promise& operator=(promise&& rhs) noexcept;
+ promise& operator=(const promise& rhs) = delete;
+ void swap(promise& other) noexcept;
+
+ // retrieving the result
+ future<R&> get_future();
+
+ // setting the result
+ void set_value(R& r);
+ void set_exception(exception_ptr p);
+
+ // setting the result with deferred notification
+ void set_value_at_thread_exit(R&);
+ void set_exception_at_thread_exit(exception_ptr p);
+};
+
+template <>
+class promise<void>
+{
+public:
+ promise();
+ template <class Allocator>
+ promise(allocator_arg_t, const Allocator& a);
+ promise(promise&& rhs) noexcept;
+ promise(const promise& rhs) = delete;
+ ~promise();
+
+ // assignment
+ promise& operator=(promise&& rhs) noexcept;
+ promise& operator=(const promise& rhs) = delete;
+ void swap(promise& other) noexcept;
+
+ // retrieving the result
+ future<void> get_future();
+
+ // setting the result
+ void set_value();
+ void set_exception(exception_ptr p);
+
+ // setting the result with deferred notification
+ void set_value_at_thread_exit();
+ void set_exception_at_thread_exit(exception_ptr p);
+};
+
+template <class R> void swap(promise<R>& x, promise<R>& y) noexcept;
+
+template <class R, class Alloc>
+ struct uses_allocator<promise<R>, Alloc> : public true_type {};
+
+template <class R>
+class future
+{
+public:
+ future() noexcept;
+ future(future&&) noexcept;
+ future(const future& rhs) = delete;
+ ~future();
+ future& operator=(const future& rhs) = delete;
+ future& operator=(future&&) noexcept;
+ shared_future<R> share() noexcept;
+
+ // retrieving the value
+ R get();
+
+ // functions to check state
+ bool valid() const noexcept;
+
+ void wait() const;
+ template <class Rep, class Period>
+ future_status
+ wait_for(const chrono::duration<Rep, Period>& rel_time) const;
+ template <class Clock, class Duration>
+ future_status
+ wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
+};
+
+template <class R>
+class future<R&>
+{
+public:
+ future() noexcept;
+ future(future&&) noexcept;
+ future(const future& rhs) = delete;
+ ~future();
+ future& operator=(const future& rhs) = delete;
+ future& operator=(future&&) noexcept;
+ shared_future<R&> share() noexcept;
+
+ // retrieving the value
+ R& get();
+
+ // functions to check state
+ bool valid() const noexcept;
+
+ void wait() const;
+ template <class Rep, class Period>
+ future_status
+ wait_for(const chrono::duration<Rep, Period>& rel_time) const;
+ template <class Clock, class Duration>
+ future_status
+ wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
+};
+
+template <>
+class future<void>
+{
+public:
+ future() noexcept;
+ future(future&&) noexcept;
+ future(const future& rhs) = delete;
+ ~future();
+ future& operator=(const future& rhs) = delete;
+ future& operator=(future&&) noexcept;
+ shared_future<void> share() noexcept;
+
+ // retrieving the value
+ void get();
+
+ // functions to check state
+ bool valid() const noexcept;
+
+ void wait() const;
+ template <class Rep, class Period>
+ future_status
+ wait_for(const chrono::duration<Rep, Period>& rel_time) const;
+ template <class Clock, class Duration>
+ future_status
+ wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
+};
+
+template <class R>
+class shared_future
+{
+public:
+ shared_future() noexcept;
+ shared_future(const shared_future& rhs);
+ shared_future(future<R>&&) noexcept;
+ shared_future(shared_future&& rhs) noexcept;
+ ~shared_future();
+ shared_future& operator=(const shared_future& rhs);
+ shared_future& operator=(shared_future&& rhs) noexcept;
+
+ // retrieving the value
+ const R& get() const;
+
+ // functions to check state
+ bool valid() const noexcept;
+
+ void wait() const;
+ template <class Rep, class Period>
+ future_status
+ wait_for(const chrono::duration<Rep, Period>& rel_time) const;
+ template <class Clock, class Duration>
+ future_status
+ wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
+};
+
+template <class R>
+class shared_future<R&>
+{
+public:
+ shared_future() noexcept;
+ shared_future(const shared_future& rhs);
+ shared_future(future<R&>&&) noexcept;
+ shared_future(shared_future&& rhs) noexcept;
+ ~shared_future();
+ shared_future& operator=(const shared_future& rhs);
+ shared_future& operator=(shared_future&& rhs) noexcept;
+
+ // retrieving the value
+ R& get() const;
+
+ // functions to check state
+ bool valid() const noexcept;
+
+ void wait() const;
+ template <class Rep, class Period>
+ future_status
+ wait_for(const chrono::duration<Rep, Period>& rel_time) const;
+ template <class Clock, class Duration>
+ future_status
+ wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
+};
+
+template <>
+class shared_future<void>
+{
+public:
+ shared_future() noexcept;
+ shared_future(const shared_future& rhs);
+ shared_future(future<void>&&) noexcept;
+ shared_future(shared_future&& rhs) noexcept;
+ ~shared_future();
+ shared_future& operator=(const shared_future& rhs);
+ shared_future& operator=(shared_future&& rhs) noexcept;
+
+ // retrieving the value
+ void get() const;
+
+ // functions to check state
+ bool valid() const noexcept;
+
+ void wait() const;
+ template <class Rep, class Period>
+ future_status
+ wait_for(const chrono::duration<Rep, Period>& rel_time) const;
+ template <class Clock, class Duration>
+ future_status
+ wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
+};
+
+template <class F, class... Args>
+ future<typename result_of<typename decay<F>::type(typename decay<Args>::type...)>::type>
+ async(F&& f, Args&&... args);
+
+template <class F, class... Args>
+ future<typename result_of<typename decay<F>::type(typename decay<Args>::type...)>::type>
+ async(launch policy, F&& f, Args&&... args);
+
+template <class> class packaged_task; // undefined
+
+template <class R, class... ArgTypes>
+class packaged_task<R(ArgTypes...)>
+{
+public:
+ typedef R result_type; // extension
+
+ // construction and destruction
+ packaged_task() noexcept;
+ template <class F>
+ explicit packaged_task(F&& f);
+ template <class F, class Allocator>
+ packaged_task(allocator_arg_t, const Allocator& a, F&& f);
+ ~packaged_task();
+
+ // no copy
+ packaged_task(const packaged_task&) = delete;
+ packaged_task& operator=(const packaged_task&) = delete;
+
+ // move support
+ packaged_task(packaged_task&& other) noexcept;
+ packaged_task& operator=(packaged_task&& other) noexcept;
+ void swap(packaged_task& other) noexcept;
+
+ bool valid() const noexcept;
+
+ // result retrieval
+ future<R> get_future();
+
+ // execution
+ void operator()(ArgTypes... );
+ void make_ready_at_thread_exit(ArgTypes...);
+
+ void reset();
+};
+
+template <class R>
+ void swap(packaged_task<R(ArgTypes...)&, packaged_task<R(ArgTypes...)>&) noexcept;
+
+template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;
+
+} // std
+
+*/
+
+#include <__assert>
+#include <__availability>
+#include <__config>
+#include <__memory/allocator_arg_t.h>
+#include <__memory/uses_allocator.h>
+#include <__utility/auto_cast.h>
+#include <__utility/forward.h>
+#include <chrono>
+#include <exception>
+#include <memory>
+#include <mutex>
+#include <system_error>
+#include <thread>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifdef _LIBCPP_HAS_NO_THREADS
+#error <future> is not supported on this single threaded system
+#else // !_LIBCPP_HAS_NO_THREADS
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+//enum class future_errc
+_LIBCPP_DECLARE_STRONG_ENUM(future_errc)
+{
+ future_already_retrieved = 1,
+ promise_already_satisfied,
+ no_state,
+ broken_promise
+};
+_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_errc)
+
+template <>
+struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc> : public true_type {};
+
+#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
+template <>
+struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc::__lx> : public true_type { };
+#endif
+
+//enum class launch
+_LIBCPP_DECLARE_STRONG_ENUM(launch)
+{
+ async = 1,
+ deferred = 2,
+ any = async | deferred
+};
+_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(launch)
+
+#ifndef _LIBCPP_HAS_NO_STRONG_ENUMS
+
+typedef underlying_type<launch>::type __launch_underlying_type;
+
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+launch
+operator&(launch __x, launch __y)
+{
+ return static_cast<launch>(static_cast<__launch_underlying_type>(__x) &
+ static_cast<__launch_underlying_type>(__y));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+launch
+operator|(launch __x, launch __y)
+{
+ return static_cast<launch>(static_cast<__launch_underlying_type>(__x) |
+ static_cast<__launch_underlying_type>(__y));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+launch
+operator^(launch __x, launch __y)
+{
+ return static_cast<launch>(static_cast<__launch_underlying_type>(__x) ^
+ static_cast<__launch_underlying_type>(__y));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+launch
+operator~(launch __x)
+{
+ return static_cast<launch>(~static_cast<__launch_underlying_type>(__x) & 3);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+launch&
+operator&=(launch& __x, launch __y)
+{
+ __x = __x & __y; return __x;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+launch&
+operator|=(launch& __x, launch __y)
+{
+ __x = __x | __y; return __x;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+launch&
+operator^=(launch& __x, launch __y)
+{
+ __x = __x ^ __y; return __x;
+}
+
+#endif // !_LIBCPP_HAS_NO_STRONG_ENUMS
+
+//enum class future_status
+_LIBCPP_DECLARE_STRONG_ENUM(future_status)
+{
+ ready,
+ timeout,
+ deferred
+};
+_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_status)
+
+_LIBCPP_FUNC_VIS
+const error_category& future_category() _NOEXCEPT;
+
+inline _LIBCPP_INLINE_VISIBILITY
+error_code
+make_error_code(future_errc __e) _NOEXCEPT
+{
+ return error_code(static_cast<int>(__e), future_category());
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+error_condition
+make_error_condition(future_errc __e) _NOEXCEPT
+{
+ return error_condition(static_cast<int>(__e), future_category());
+}
+
+class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_FUTURE_ERROR future_error
+ : public logic_error
+{
+ error_code __ec_;
+public:
+ future_error(error_code __ec);
+
+ _LIBCPP_INLINE_VISIBILITY
+ const error_code& code() const _NOEXCEPT {return __ec_;}
+
+ future_error(const future_error&) _NOEXCEPT = default;
+ virtual ~future_error() _NOEXCEPT;
+};
+
+_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
+#ifndef _LIBCPP_NO_EXCEPTIONS
+_LIBCPP_AVAILABILITY_FUTURE_ERROR
+#endif
+void __throw_future_error(future_errc _Ev)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw future_error(make_error_code(_Ev));
+#else
+ ((void)_Ev);
+ _VSTD::abort();
+#endif
+}
+
+class _LIBCPP_TYPE_VIS _LIBCPP_AVAILABILITY_FUTURE __assoc_sub_state
+ : public __shared_count
+{
+protected:
+ exception_ptr __exception_;
+ mutable mutex __mut_;
+ mutable condition_variable __cv_;
+ unsigned __state_;
+
+ virtual void __on_zero_shared() _NOEXCEPT;
+ void __sub_wait(unique_lock<mutex>& __lk);
+public:
+ enum
+ {
+ __constructed = 1,
+ __future_attached = 2,
+ ready = 4,
+ deferred = 8
+ };
+
+ _LIBCPP_INLINE_VISIBILITY
+ __assoc_sub_state() : __state_(0) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool __has_value() const
+ {return (__state_ & __constructed) || (__exception_ != nullptr);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __attach_future() {
+ lock_guard<mutex> __lk(__mut_);
+ bool __has_future_attached = (__state_ & __future_attached) != 0;
+ if (__has_future_attached)
+ __throw_future_error(future_errc::future_already_retrieved);
+ this->__add_shared();
+ __state_ |= __future_attached;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __set_deferred() {__state_ |= deferred;}
+
+ void __make_ready();
+ _LIBCPP_INLINE_VISIBILITY
+ bool __is_ready() const {return (__state_ & ready) != 0;}
+
+ void set_value();
+ void set_value_at_thread_exit();
+
+ void set_exception(exception_ptr __p);
+ void set_exception_at_thread_exit(exception_ptr __p);
+
+ void copy();
+
+ void wait();
+ template <class _Rep, class _Period>
+ future_status
+ _LIBCPP_INLINE_VISIBILITY
+ wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const;
+ template <class _Clock, class _Duration>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ future_status
+ wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const;
+
+ virtual void __execute();
+};
+
+template <class _Clock, class _Duration>
+future_status
+__assoc_sub_state::wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const
+{
+ unique_lock<mutex> __lk(__mut_);
+ if (__state_ & deferred)
+ return future_status::deferred;
+ while (!(__state_ & ready) && _Clock::now() < __abs_time)
+ __cv_.wait_until(__lk, __abs_time);
+ if (__state_ & ready)
+ return future_status::ready;
+ return future_status::timeout;
+}
+
+template <class _Rep, class _Period>
+inline
+future_status
+__assoc_sub_state::wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const
+{
+ return wait_until(chrono::steady_clock::now() + __rel_time);
+}
+
+template <class _Rp>
+class _LIBCPP_AVAILABILITY_FUTURE _LIBCPP_HIDDEN __assoc_state
+ : public __assoc_sub_state
+{
+ typedef __assoc_sub_state base;
+ typedef typename aligned_storage<sizeof(_Rp), alignment_of<_Rp>::value>::type _Up;
+protected:
+ _Up __value_;
+
+ virtual void __on_zero_shared() _NOEXCEPT;
+public:
+
+ template <class _Arg>
+ void set_value(_Arg&& __arg);
+
+ template <class _Arg>
+ void set_value_at_thread_exit(_Arg&& __arg);
+
+ _Rp move();
+ typename add_lvalue_reference<_Rp>::type copy();
+};
+
+template <class _Rp>
+void
+__assoc_state<_Rp>::__on_zero_shared() _NOEXCEPT
+{
+ if (this->__state_ & base::__constructed)
+ reinterpret_cast<_Rp*>(&__value_)->~_Rp();
+ delete this;
+}
+
+template <class _Rp>
+template <class _Arg>
+_LIBCPP_AVAILABILITY_FUTURE
+void
+__assoc_state<_Rp>::set_value(_Arg&& __arg)
+{
+ unique_lock<mutex> __lk(this->__mut_);
+ if (this->__has_value())
+ __throw_future_error(future_errc::promise_already_satisfied);
+ ::new ((void*)&__value_) _Rp(_VSTD::forward<_Arg>(__arg));
+ this->__state_ |= base::__constructed | base::ready;
+ __cv_.notify_all();
+}
+
+template <class _Rp>
+template <class _Arg>
+void
+__assoc_state<_Rp>::set_value_at_thread_exit(_Arg&& __arg)
+{
+ unique_lock<mutex> __lk(this->__mut_);
+ if (this->__has_value())
+ __throw_future_error(future_errc::promise_already_satisfied);
+ ::new ((void*)&__value_) _Rp(_VSTD::forward<_Arg>(__arg));
+ this->__state_ |= base::__constructed;
+ __thread_local_data()->__make_ready_at_thread_exit(this);
+}
+
+template <class _Rp>
+_Rp
+__assoc_state<_Rp>::move()
+{
+ unique_lock<mutex> __lk(this->__mut_);
+ this->__sub_wait(__lk);
+ if (this->__exception_ != nullptr)
+ rethrow_exception(this->__exception_);
+ return _VSTD::move(*reinterpret_cast<_Rp*>(&__value_));
+}
+
+template <class _Rp>
+typename add_lvalue_reference<_Rp>::type
+__assoc_state<_Rp>::copy()
+{
+ unique_lock<mutex> __lk(this->__mut_);
+ this->__sub_wait(__lk);
+ if (this->__exception_ != nullptr)
+ rethrow_exception(this->__exception_);
+ return *reinterpret_cast<_Rp*>(&__value_);
+}
+
+template <class _Rp>
+class _LIBCPP_AVAILABILITY_FUTURE __assoc_state<_Rp&>
+ : public __assoc_sub_state
+{
+ typedef __assoc_sub_state base;
+ typedef _Rp* _Up;
+protected:
+ _Up __value_;
+
+ virtual void __on_zero_shared() _NOEXCEPT;
+public:
+
+ void set_value(_Rp& __arg);
+ void set_value_at_thread_exit(_Rp& __arg);
+
+ _Rp& copy();
+};
+
+template <class _Rp>
+void
+__assoc_state<_Rp&>::__on_zero_shared() _NOEXCEPT
+{
+ delete this;
+}
+
+template <class _Rp>
+void
+__assoc_state<_Rp&>::set_value(_Rp& __arg)
+{
+ unique_lock<mutex> __lk(this->__mut_);
+ if (this->__has_value())
+ __throw_future_error(future_errc::promise_already_satisfied);
+ __value_ = _VSTD::addressof(__arg);
+ this->__state_ |= base::__constructed | base::ready;
+ __cv_.notify_all();
+}
+
+template <class _Rp>
+void
+__assoc_state<_Rp&>::set_value_at_thread_exit(_Rp& __arg)
+{
+ unique_lock<mutex> __lk(this->__mut_);
+ if (this->__has_value())
+ __throw_future_error(future_errc::promise_already_satisfied);
+ __value_ = _VSTD::addressof(__arg);
+ this->__state_ |= base::__constructed;
+ __thread_local_data()->__make_ready_at_thread_exit(this);
+}
+
+template <class _Rp>
+_Rp&
+__assoc_state<_Rp&>::copy()
+{
+ unique_lock<mutex> __lk(this->__mut_);
+ this->__sub_wait(__lk);
+ if (this->__exception_ != nullptr)
+ rethrow_exception(this->__exception_);
+ return *__value_;
+}
+
+template <class _Rp, class _Alloc>
+class _LIBCPP_AVAILABILITY_FUTURE __assoc_state_alloc
+ : public __assoc_state<_Rp>
+{
+ typedef __assoc_state<_Rp> base;
+ _Alloc __alloc_;
+
+ virtual void __on_zero_shared() _NOEXCEPT;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __assoc_state_alloc(const _Alloc& __a)
+ : __alloc_(__a) {}
+};
+
+template <class _Rp, class _Alloc>
+void
+__assoc_state_alloc<_Rp, _Alloc>::__on_zero_shared() _NOEXCEPT
+{
+ if (this->__state_ & base::__constructed)
+ reinterpret_cast<_Rp*>(_VSTD::addressof(this->__value_))->~_Rp();
+ typedef typename __allocator_traits_rebind<_Alloc, __assoc_state_alloc>::type _Al;
+ typedef allocator_traits<_Al> _ATraits;
+ typedef pointer_traits<typename _ATraits::pointer> _PTraits;
+ _Al __a(__alloc_);
+ this->~__assoc_state_alloc();
+ __a.deallocate(_PTraits::pointer_to(*this), 1);
+}
+
+template <class _Rp, class _Alloc>
+class _LIBCPP_AVAILABILITY_FUTURE __assoc_state_alloc<_Rp&, _Alloc>
+ : public __assoc_state<_Rp&>
+{
+ typedef __assoc_state<_Rp&> base;
+ _Alloc __alloc_;
+
+ virtual void __on_zero_shared() _NOEXCEPT;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __assoc_state_alloc(const _Alloc& __a)
+ : __alloc_(__a) {}
+};
+
+template <class _Rp, class _Alloc>
+void
+__assoc_state_alloc<_Rp&, _Alloc>::__on_zero_shared() _NOEXCEPT
+{
+ typedef typename __allocator_traits_rebind<_Alloc, __assoc_state_alloc>::type _Al;
+ typedef allocator_traits<_Al> _ATraits;
+ typedef pointer_traits<typename _ATraits::pointer> _PTraits;
+ _Al __a(__alloc_);
+ this->~__assoc_state_alloc();
+ __a.deallocate(_PTraits::pointer_to(*this), 1);
+}
+
+template <class _Alloc>
+class _LIBCPP_AVAILABILITY_FUTURE __assoc_sub_state_alloc
+ : public __assoc_sub_state
+{
+ typedef __assoc_sub_state base;
+ _Alloc __alloc_;
+
+ virtual void __on_zero_shared() _NOEXCEPT;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __assoc_sub_state_alloc(const _Alloc& __a)
+ : __alloc_(__a) {}
+};
+
+template <class _Alloc>
+void
+__assoc_sub_state_alloc<_Alloc>::__on_zero_shared() _NOEXCEPT
+{
+ typedef typename __allocator_traits_rebind<_Alloc, __assoc_sub_state_alloc>::type _Al;
+ typedef allocator_traits<_Al> _ATraits;
+ typedef pointer_traits<typename _ATraits::pointer> _PTraits;
+ _Al __a(__alloc_);
+ this->~__assoc_sub_state_alloc();
+ __a.deallocate(_PTraits::pointer_to(*this), 1);
+}
+
+template <class _Rp, class _Fp>
+class _LIBCPP_AVAILABILITY_FUTURE __deferred_assoc_state
+ : public __assoc_state<_Rp>
+{
+ typedef __assoc_state<_Rp> base;
+
+ _Fp __func_;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __deferred_assoc_state(_Fp&& __f);
+
+ virtual void __execute();
+};
+
+template <class _Rp, class _Fp>
+inline
+__deferred_assoc_state<_Rp, _Fp>::__deferred_assoc_state(_Fp&& __f)
+ : __func_(_VSTD::forward<_Fp>(__f))
+{
+ this->__set_deferred();
+}
+
+template <class _Rp, class _Fp>
+void
+__deferred_assoc_state<_Rp, _Fp>::__execute()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ this->set_value(__func_());
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ this->set_exception(current_exception());
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+}
+
+template <class _Fp>
+class _LIBCPP_AVAILABILITY_FUTURE __deferred_assoc_state<void, _Fp>
+ : public __assoc_sub_state
+{
+ typedef __assoc_sub_state base;
+
+ _Fp __func_;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __deferred_assoc_state(_Fp&& __f);
+
+ virtual void __execute();
+};
+
+template <class _Fp>
+inline
+__deferred_assoc_state<void, _Fp>::__deferred_assoc_state(_Fp&& __f)
+ : __func_(_VSTD::forward<_Fp>(__f))
+{
+ this->__set_deferred();
+}
+
+template <class _Fp>
+void
+__deferred_assoc_state<void, _Fp>::__execute()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ __func_();
+ this->set_value();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ this->set_exception(current_exception());
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+}
+
+template <class _Rp, class _Fp>
+class _LIBCPP_AVAILABILITY_FUTURE __async_assoc_state
+ : public __assoc_state<_Rp>
+{
+ typedef __assoc_state<_Rp> base;
+
+ _Fp __func_;
+
+ virtual void __on_zero_shared() _NOEXCEPT;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __async_assoc_state(_Fp&& __f);
+
+ virtual void __execute();
+};
+
+template <class _Rp, class _Fp>
+inline
+__async_assoc_state<_Rp, _Fp>::__async_assoc_state(_Fp&& __f)
+ : __func_(_VSTD::forward<_Fp>(__f))
+{
+}
+
+template <class _Rp, class _Fp>
+void
+__async_assoc_state<_Rp, _Fp>::__execute()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ this->set_value(__func_());
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ this->set_exception(current_exception());
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+}
+
+template <class _Rp, class _Fp>
+void
+__async_assoc_state<_Rp, _Fp>::__on_zero_shared() _NOEXCEPT
+{
+ this->wait();
+ base::__on_zero_shared();
+}
+
+template <class _Fp>
+class _LIBCPP_AVAILABILITY_FUTURE __async_assoc_state<void, _Fp>
+ : public __assoc_sub_state
+{
+ typedef __assoc_sub_state base;
+
+ _Fp __func_;
+
+ virtual void __on_zero_shared() _NOEXCEPT;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __async_assoc_state(_Fp&& __f);
+
+ virtual void __execute();
+};
+
+template <class _Fp>
+inline
+__async_assoc_state<void, _Fp>::__async_assoc_state(_Fp&& __f)
+ : __func_(_VSTD::forward<_Fp>(__f))
+{
+}
+
+template <class _Fp>
+void
+__async_assoc_state<void, _Fp>::__execute()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ __func_();
+ this->set_value();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ this->set_exception(current_exception());
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+}
+
+template <class _Fp>
+void
+__async_assoc_state<void, _Fp>::__on_zero_shared() _NOEXCEPT
+{
+ this->wait();
+ base::__on_zero_shared();
+}
+
+template <class _Rp> class _LIBCPP_TEMPLATE_VIS promise;
+template <class _Rp> class _LIBCPP_TEMPLATE_VIS shared_future;
+
+// future
+
+template <class _Rp> class _LIBCPP_TEMPLATE_VIS future;
+
+template <class _Rp, class _Fp>
+_LIBCPP_INLINE_VISIBILITY future<_Rp>
+__make_deferred_assoc_state(_Fp&& __f);
+
+template <class _Rp, class _Fp>
+_LIBCPP_INLINE_VISIBILITY future<_Rp>
+__make_async_assoc_state(_Fp&& __f);
+
+template <class _Rp>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FUTURE future
+{
+ __assoc_state<_Rp>* __state_;
+
+ explicit future(__assoc_state<_Rp>* __state);
+
+ template <class> friend class promise;
+ template <class> friend class shared_future;
+
+ template <class _R1, class _Fp>
+ friend future<_R1> __make_deferred_assoc_state(_Fp&& __f);
+ template <class _R1, class _Fp>
+ friend future<_R1> __make_async_assoc_state(_Fp&& __f);
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ future() _NOEXCEPT : __state_(nullptr) {}
+ _LIBCPP_INLINE_VISIBILITY
+ future(future&& __rhs) _NOEXCEPT
+ : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;}
+ future(const future&) = delete;
+ future& operator=(const future&) = delete;
+ _LIBCPP_INLINE_VISIBILITY
+ future& operator=(future&& __rhs) _NOEXCEPT
+ {
+ future(_VSTD::move(__rhs)).swap(*this);
+ return *this;
+ }
+
+ ~future();
+ _LIBCPP_INLINE_VISIBILITY
+ shared_future<_Rp> share() _NOEXCEPT;
+
+ // retrieving the value
+ _Rp get();
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(future& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);}
+
+ // functions to check state
+ _LIBCPP_INLINE_VISIBILITY
+ bool valid() const _NOEXCEPT {return __state_ != nullptr;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void wait() const {__state_->wait();}
+ template <class _Rep, class _Period>
+ _LIBCPP_INLINE_VISIBILITY
+ future_status
+ wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const
+ {return __state_->wait_for(__rel_time);}
+ template <class _Clock, class _Duration>
+ _LIBCPP_INLINE_VISIBILITY
+ future_status
+ wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const
+ {return __state_->wait_until(__abs_time);}
+};
+
+template <class _Rp>
+future<_Rp>::future(__assoc_state<_Rp>* __state)
+ : __state_(__state)
+{
+ __state_->__attach_future();
+}
+
+struct __release_shared_count
+{
+ void operator()(__shared_count* p) {p->__release_shared();}
+};
+
+template <class _Rp>
+future<_Rp>::~future()
+{
+ if (__state_)
+ __state_->__release_shared();
+}
+
+template <class _Rp>
+_Rp
+future<_Rp>::get()
+{
+ unique_ptr<__shared_count, __release_shared_count> __(__state_);
+ __assoc_state<_Rp>* __s = __state_;
+ __state_ = nullptr;
+ return __s->move();
+}
+
+template <class _Rp>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FUTURE future<_Rp&>
+{
+ __assoc_state<_Rp&>* __state_;
+
+ explicit future(__assoc_state<_Rp&>* __state);
+
+ template <class> friend class promise;
+ template <class> friend class shared_future;
+
+ template <class _R1, class _Fp>
+ friend future<_R1> __make_deferred_assoc_state(_Fp&& __f);
+ template <class _R1, class _Fp>
+ friend future<_R1> __make_async_assoc_state(_Fp&& __f);
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ future() _NOEXCEPT : __state_(nullptr) {}
+ _LIBCPP_INLINE_VISIBILITY
+ future(future&& __rhs) _NOEXCEPT
+ : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;}
+ future(const future&) = delete;
+ future& operator=(const future&) = delete;
+ _LIBCPP_INLINE_VISIBILITY
+ future& operator=(future&& __rhs) _NOEXCEPT
+ {
+ future(_VSTD::move(__rhs)).swap(*this);
+ return *this;
+ }
+
+ ~future();
+ _LIBCPP_INLINE_VISIBILITY
+ shared_future<_Rp&> share() _NOEXCEPT;
+
+ // retrieving the value
+ _Rp& get();
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(future& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);}
+
+ // functions to check state
+ _LIBCPP_INLINE_VISIBILITY
+ bool valid() const _NOEXCEPT {return __state_ != nullptr;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void wait() const {__state_->wait();}
+ template <class _Rep, class _Period>
+ _LIBCPP_INLINE_VISIBILITY
+ future_status
+ wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const
+ {return __state_->wait_for(__rel_time);}
+ template <class _Clock, class _Duration>
+ _LIBCPP_INLINE_VISIBILITY
+ future_status
+ wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const
+ {return __state_->wait_until(__abs_time);}
+};
+
+template <class _Rp>
+future<_Rp&>::future(__assoc_state<_Rp&>* __state)
+ : __state_(__state)
+{
+ __state_->__attach_future();
+}
+
+template <class _Rp>
+future<_Rp&>::~future()
+{
+ if (__state_)
+ __state_->__release_shared();
+}
+
+template <class _Rp>
+_Rp&
+future<_Rp&>::get()
+{
+ unique_ptr<__shared_count, __release_shared_count> __(__state_);
+ __assoc_state<_Rp&>* __s = __state_;
+ __state_ = nullptr;
+ return __s->copy();
+}
+
+template <>
+class _LIBCPP_TYPE_VIS _LIBCPP_AVAILABILITY_FUTURE future<void>
+{
+ __assoc_sub_state* __state_;
+
+ explicit future(__assoc_sub_state* __state);
+
+ template <class> friend class promise;
+ template <class> friend class shared_future;
+
+ template <class _R1, class _Fp>
+ friend future<_R1> __make_deferred_assoc_state(_Fp&& __f);
+ template <class _R1, class _Fp>
+ friend future<_R1> __make_async_assoc_state(_Fp&& __f);
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ future() _NOEXCEPT : __state_(nullptr) {}
+ _LIBCPP_INLINE_VISIBILITY
+ future(future&& __rhs) _NOEXCEPT
+ : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;}
+ future(const future&) = delete;
+ future& operator=(const future&) = delete;
+ _LIBCPP_INLINE_VISIBILITY
+ future& operator=(future&& __rhs) _NOEXCEPT
+ {
+ future(_VSTD::move(__rhs)).swap(*this);
+ return *this;
+ }
+
+ ~future();
+ _LIBCPP_INLINE_VISIBILITY
+ shared_future<void> share() _NOEXCEPT;
+
+ // retrieving the value
+ void get();
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(future& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);}
+
+ // functions to check state
+ _LIBCPP_INLINE_VISIBILITY
+ bool valid() const _NOEXCEPT {return __state_ != nullptr;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void wait() const {__state_->wait();}
+ template <class _Rep, class _Period>
+ _LIBCPP_INLINE_VISIBILITY
+ future_status
+ wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const
+ {return __state_->wait_for(__rel_time);}
+ template <class _Clock, class _Duration>
+ _LIBCPP_INLINE_VISIBILITY
+ future_status
+ wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const
+ {return __state_->wait_until(__abs_time);}
+};
+
+template <class _Rp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(future<_Rp>& __x, future<_Rp>& __y) _NOEXCEPT
+{
+ __x.swap(__y);
+}
+
+// promise<R>
+
+template <class _Callable> class packaged_task;
+
+template <class _Rp>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FUTURE promise
+{
+ __assoc_state<_Rp>* __state_;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit promise(nullptr_t) _NOEXCEPT : __state_(nullptr) {}
+
+ template <class> friend class packaged_task;
+public:
+ promise();
+ template <class _Alloc>
+ promise(allocator_arg_t, const _Alloc& __a);
+ _LIBCPP_INLINE_VISIBILITY
+ promise(promise&& __rhs) _NOEXCEPT
+ : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;}
+ promise(const promise& __rhs) = delete;
+ ~promise();
+
+ // assignment
+ _LIBCPP_INLINE_VISIBILITY
+ promise& operator=(promise&& __rhs) _NOEXCEPT
+ {
+ promise(_VSTD::move(__rhs)).swap(*this);
+ return *this;
+ }
+ promise& operator=(const promise& __rhs) = delete;
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(promise& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);}
+
+ // retrieving the result
+ future<_Rp> get_future();
+
+ // setting the result
+ void set_value(const _Rp& __r);
+ void set_value(_Rp&& __r);
+ void set_exception(exception_ptr __p);
+
+ // setting the result with deferred notification
+ void set_value_at_thread_exit(const _Rp& __r);
+ void set_value_at_thread_exit(_Rp&& __r);
+ void set_exception_at_thread_exit(exception_ptr __p);
+};
+
+template <class _Rp>
+promise<_Rp>::promise()
+ : __state_(new __assoc_state<_Rp>)
+{
+}
+
+template <class _Rp>
+template <class _Alloc>
+promise<_Rp>::promise(allocator_arg_t, const _Alloc& __a0)
+{
+ typedef __assoc_state_alloc<_Rp, _Alloc> _State;
+ typedef typename __allocator_traits_rebind<_Alloc, _State>::type _A2;
+ typedef __allocator_destructor<_A2> _D2;
+ _A2 __a(__a0);
+ unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1));
+ ::new ((void*)_VSTD::addressof(*__hold.get())) _State(__a0);
+ __state_ = _VSTD::addressof(*__hold.release());
+}
+
+template <class _Rp>
+promise<_Rp>::~promise()
+{
+ if (__state_)
+ {
+ if (!__state_->__has_value() && __state_->use_count() > 1)
+ __state_->set_exception(make_exception_ptr(
+ future_error(make_error_code(future_errc::broken_promise))
+ ));
+ __state_->__release_shared();
+ }
+}
+
+template <class _Rp>
+future<_Rp>
+promise<_Rp>::get_future()
+{
+ if (__state_ == nullptr)
+ __throw_future_error(future_errc::no_state);
+ return future<_Rp>(__state_);
+}
+
+template <class _Rp>
+void
+promise<_Rp>::set_value(const _Rp& __r)
+{
+ if (__state_ == nullptr)
+ __throw_future_error(future_errc::no_state);
+ __state_->set_value(__r);
+}
+
+template <class _Rp>
+void
+promise<_Rp>::set_value(_Rp&& __r)
+{
+ if (__state_ == nullptr)
+ __throw_future_error(future_errc::no_state);
+ __state_->set_value(_VSTD::move(__r));
+}
+
+template <class _Rp>
+void
+promise<_Rp>::set_exception(exception_ptr __p)
+{
+ _LIBCPP_ASSERT( __p != nullptr, "promise::set_exception: received nullptr" );
+ if (__state_ == nullptr)
+ __throw_future_error(future_errc::no_state);
+ __state_->set_exception(__p);
+}
+
+template <class _Rp>
+void
+promise<_Rp>::set_value_at_thread_exit(const _Rp& __r)
+{
+ if (__state_ == nullptr)
+ __throw_future_error(future_errc::no_state);
+ __state_->set_value_at_thread_exit(__r);
+}
+
+template <class _Rp>
+void
+promise<_Rp>::set_value_at_thread_exit(_Rp&& __r)
+{
+ if (__state_ == nullptr)
+ __throw_future_error(future_errc::no_state);
+ __state_->set_value_at_thread_exit(_VSTD::move(__r));
+}
+
+template <class _Rp>
+void
+promise<_Rp>::set_exception_at_thread_exit(exception_ptr __p)
+{
+ _LIBCPP_ASSERT( __p != nullptr, "promise::set_exception_at_thread_exit: received nullptr" );
+ if (__state_ == nullptr)
+ __throw_future_error(future_errc::no_state);
+ __state_->set_exception_at_thread_exit(__p);
+}
+
+// promise<R&>
+
+template <class _Rp>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FUTURE promise<_Rp&>
+{
+ __assoc_state<_Rp&>* __state_;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit promise(nullptr_t) _NOEXCEPT : __state_(nullptr) {}
+
+ template <class> friend class packaged_task;
+
+public:
+ promise();
+ template <class _Allocator>
+ promise(allocator_arg_t, const _Allocator& __a);
+ _LIBCPP_INLINE_VISIBILITY
+ promise(promise&& __rhs) _NOEXCEPT
+ : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;}
+ promise(const promise& __rhs) = delete;
+ ~promise();
+
+ // assignment
+ _LIBCPP_INLINE_VISIBILITY
+ promise& operator=(promise&& __rhs) _NOEXCEPT
+ {
+ promise(_VSTD::move(__rhs)).swap(*this);
+ return *this;
+ }
+ promise& operator=(const promise& __rhs) = delete;
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(promise& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);}
+
+ // retrieving the result
+ future<_Rp&> get_future();
+
+ // setting the result
+ void set_value(_Rp& __r);
+ void set_exception(exception_ptr __p);
+
+ // setting the result with deferred notification
+ void set_value_at_thread_exit(_Rp&);
+ void set_exception_at_thread_exit(exception_ptr __p);
+};
+
+template <class _Rp>
+promise<_Rp&>::promise()
+ : __state_(new __assoc_state<_Rp&>)
+{
+}
+
+template <class _Rp>
+template <class _Alloc>
+promise<_Rp&>::promise(allocator_arg_t, const _Alloc& __a0)
+{
+ typedef __assoc_state_alloc<_Rp&, _Alloc> _State;
+ typedef typename __allocator_traits_rebind<_Alloc, _State>::type _A2;
+ typedef __allocator_destructor<_A2> _D2;
+ _A2 __a(__a0);
+ unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1));
+ ::new ((void*)_VSTD::addressof(*__hold.get())) _State(__a0);
+ __state_ = _VSTD::addressof(*__hold.release());
+}
+
+template <class _Rp>
+promise<_Rp&>::~promise()
+{
+ if (__state_)
+ {
+ if (!__state_->__has_value() && __state_->use_count() > 1)
+ __state_->set_exception(make_exception_ptr(
+ future_error(make_error_code(future_errc::broken_promise))
+ ));
+ __state_->__release_shared();
+ }
+}
+
+template <class _Rp>
+future<_Rp&>
+promise<_Rp&>::get_future()
+{
+ if (__state_ == nullptr)
+ __throw_future_error(future_errc::no_state);
+ return future<_Rp&>(__state_);
+}
+
+template <class _Rp>
+void
+promise<_Rp&>::set_value(_Rp& __r)
+{
+ if (__state_ == nullptr)
+ __throw_future_error(future_errc::no_state);
+ __state_->set_value(__r);
+}
+
+template <class _Rp>
+void
+promise<_Rp&>::set_exception(exception_ptr __p)
+{
+ _LIBCPP_ASSERT( __p != nullptr, "promise::set_exception: received nullptr" );
+ if (__state_ == nullptr)
+ __throw_future_error(future_errc::no_state);
+ __state_->set_exception(__p);
+}
+
+template <class _Rp>
+void
+promise<_Rp&>::set_value_at_thread_exit(_Rp& __r)
+{
+ if (__state_ == nullptr)
+ __throw_future_error(future_errc::no_state);
+ __state_->set_value_at_thread_exit(__r);
+}
+
+template <class _Rp>
+void
+promise<_Rp&>::set_exception_at_thread_exit(exception_ptr __p)
+{
+ _LIBCPP_ASSERT( __p != nullptr, "promise::set_exception_at_thread_exit: received nullptr" );
+ if (__state_ == nullptr)
+ __throw_future_error(future_errc::no_state);
+ __state_->set_exception_at_thread_exit(__p);
+}
+
+// promise<void>
+
+template <>
+class _LIBCPP_TYPE_VIS _LIBCPP_AVAILABILITY_FUTURE promise<void>
+{
+ __assoc_sub_state* __state_;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit promise(nullptr_t) _NOEXCEPT : __state_(nullptr) {}
+
+ template <class> friend class packaged_task;
+
+public:
+ promise();
+ template <class _Allocator>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ promise(allocator_arg_t, const _Allocator& __a);
+ _LIBCPP_INLINE_VISIBILITY
+ promise(promise&& __rhs) _NOEXCEPT
+ : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;}
+ promise(const promise& __rhs) = delete;
+ ~promise();
+
+ // assignment
+ _LIBCPP_INLINE_VISIBILITY
+ promise& operator=(promise&& __rhs) _NOEXCEPT
+ {
+ promise(_VSTD::move(__rhs)).swap(*this);
+ return *this;
+ }
+ promise& operator=(const promise& __rhs) = delete;
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(promise& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);}
+
+ // retrieving the result
+ future<void> get_future();
+
+ // setting the result
+ void set_value();
+ void set_exception(exception_ptr __p);
+
+ // setting the result with deferred notification
+ void set_value_at_thread_exit();
+ void set_exception_at_thread_exit(exception_ptr __p);
+};
+
+template <class _Alloc>
+promise<void>::promise(allocator_arg_t, const _Alloc& __a0)
+{
+ typedef __assoc_sub_state_alloc<_Alloc> _State;
+ typedef typename __allocator_traits_rebind<_Alloc, _State>::type _A2;
+ typedef __allocator_destructor<_A2> _D2;
+ _A2 __a(__a0);
+ unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1));
+ ::new ((void*)_VSTD::addressof(*__hold.get())) _State(__a0);
+ __state_ = _VSTD::addressof(*__hold.release());
+}
+
+template <class _Rp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(promise<_Rp>& __x, promise<_Rp>& __y) _NOEXCEPT
+{
+ __x.swap(__y);
+}
+
+template <class _Rp, class _Alloc>
+ struct _LIBCPP_TEMPLATE_VIS uses_allocator<promise<_Rp>, _Alloc>
+ : public true_type {};
+
+// packaged_task
+
+template<class _Fp> class __packaged_task_base;
+
+template<class _Rp, class ..._ArgTypes>
+class _LIBCPP_AVAILABILITY_FUTURE __packaged_task_base<_Rp(_ArgTypes...)>
+{
+ __packaged_task_base(const __packaged_task_base&);
+ __packaged_task_base& operator=(const __packaged_task_base&);
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ __packaged_task_base() {}
+ _LIBCPP_INLINE_VISIBILITY
+ virtual ~__packaged_task_base() {}
+ virtual void __move_to(__packaged_task_base*) _NOEXCEPT = 0;
+ virtual void destroy() = 0;
+ virtual void destroy_deallocate() = 0;
+ virtual _Rp operator()(_ArgTypes&& ...) = 0;
+};
+
+template<class _FD, class _Alloc, class _FB> class __packaged_task_func;
+
+template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
+class _LIBCPP_AVAILABILITY_FUTURE __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>
+ : public __packaged_task_base<_Rp(_ArgTypes...)>
+{
+ __compressed_pair<_Fp, _Alloc> __f_;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __packaged_task_func(const _Fp& __f) : __f_(__f, __default_init_tag()) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __packaged_task_func(_Fp&& __f) : __f_(_VSTD::move(__f), __default_init_tag()) {}
+ _LIBCPP_INLINE_VISIBILITY
+ __packaged_task_func(const _Fp& __f, const _Alloc& __a)
+ : __f_(__f, __a) {}
+ _LIBCPP_INLINE_VISIBILITY
+ __packaged_task_func(_Fp&& __f, const _Alloc& __a)
+ : __f_(_VSTD::move(__f), __a) {}
+ virtual void __move_to(__packaged_task_base<_Rp(_ArgTypes...)>*) _NOEXCEPT;
+ virtual void destroy();
+ virtual void destroy_deallocate();
+ virtual _Rp operator()(_ArgTypes&& ... __args);
+};
+
+template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
+void
+__packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__move_to(
+ __packaged_task_base<_Rp(_ArgTypes...)>* __p) _NOEXCEPT
+{
+ ::new ((void*)__p) __packaged_task_func(_VSTD::move(__f_.first()), _VSTD::move(__f_.second()));
+}
+
+template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
+void
+__packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy()
+{
+ __f_.~__compressed_pair<_Fp, _Alloc>();
+}
+
+template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
+void
+__packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate()
+{
+ typedef typename __allocator_traits_rebind<_Alloc, __packaged_task_func>::type _Ap;
+ typedef allocator_traits<_Ap> _ATraits;
+ typedef pointer_traits<typename _ATraits::pointer> _PTraits;
+ _Ap __a(__f_.second());
+ __f_.~__compressed_pair<_Fp, _Alloc>();
+ __a.deallocate(_PTraits::pointer_to(*this), 1);
+}
+
+template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
+_Rp
+__packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg)
+{
+ return _VSTD::__invoke(__f_.first(), _VSTD::forward<_ArgTypes>(__arg)...);
+}
+
+template <class _Callable> class __packaged_task_function;
+
+template<class _Rp, class ..._ArgTypes>
+class _LIBCPP_AVAILABILITY_FUTURE __packaged_task_function<_Rp(_ArgTypes...)>
+{
+ typedef __packaged_task_base<_Rp(_ArgTypes...)> __base;
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_NO_CFI
+ __base* __get_buf() { return (__base*)&__buf_; }
+
+ typename aligned_storage<3*sizeof(void*)>::type __buf_;
+ __base* __f_;
+
+public:
+ typedef _Rp result_type;
+
+ // construct/copy/destroy:
+ _LIBCPP_INLINE_VISIBILITY
+ __packaged_task_function() _NOEXCEPT : __f_(nullptr) {}
+ template<class _Fp>
+ __packaged_task_function(_Fp&& __f);
+ template<class _Fp, class _Alloc>
+ __packaged_task_function(allocator_arg_t, const _Alloc& __a, _Fp&& __f);
+
+ __packaged_task_function(__packaged_task_function&&) _NOEXCEPT;
+ __packaged_task_function& operator=(__packaged_task_function&&) _NOEXCEPT;
+
+ __packaged_task_function(const __packaged_task_function&) = delete;
+ __packaged_task_function& operator=(const __packaged_task_function&) = delete;
+
+ ~__packaged_task_function();
+
+ void swap(__packaged_task_function&) _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY
+ _Rp operator()(_ArgTypes...) const;
+};
+
+template<class _Rp, class ..._ArgTypes>
+__packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(__packaged_task_function&& __f) _NOEXCEPT
+{
+ if (__f.__f_ == nullptr)
+ __f_ = nullptr;
+ else if (__f.__f_ == __f.__get_buf())
+ {
+ __f.__f_->__move_to(__get_buf());
+ __f_ = (__base*)&__buf_;
+ }
+ else
+ {
+ __f_ = __f.__f_;
+ __f.__f_ = nullptr;
+ }
+}
+
+template<class _Rp, class ..._ArgTypes>
+template <class _Fp>
+__packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(_Fp&& __f)
+ : __f_(nullptr)
+{
+ typedef typename remove_reference<typename decay<_Fp>::type>::type _FR;
+ typedef __packaged_task_func<_FR, allocator<_FR>, _Rp(_ArgTypes...)> _FF;
+ if (sizeof(_FF) <= sizeof(__buf_))
+ {
+ ::new ((void*)&__buf_) _FF(_VSTD::forward<_Fp>(__f));
+ __f_ = (__base*)&__buf_;
+ }
+ else
+ {
+ typedef allocator<_FF> _Ap;
+ _Ap __a;
+ typedef __allocator_destructor<_Ap> _Dp;
+ unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+ ::new ((void*)__hold.get()) _FF(_VSTD::forward<_Fp>(__f), allocator<_FR>(__a));
+ __f_ = __hold.release();
+ }
+}
+
+template<class _Rp, class ..._ArgTypes>
+template <class _Fp, class _Alloc>
+__packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(
+ allocator_arg_t, const _Alloc& __a0, _Fp&& __f)
+ : __f_(nullptr)
+{
+ typedef typename remove_reference<typename decay<_Fp>::type>::type _FR;
+ typedef __packaged_task_func<_FR, _Alloc, _Rp(_ArgTypes...)> _FF;
+ if (sizeof(_FF) <= sizeof(__buf_))
+ {
+ __f_ = (__base*)&__buf_;
+ ::new ((void*)__f_) _FF(_VSTD::forward<_Fp>(__f));
+ }
+ else
+ {
+ typedef typename __allocator_traits_rebind<_Alloc, _FF>::type _Ap;
+ _Ap __a(__a0);
+ typedef __allocator_destructor<_Ap> _Dp;
+ unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+ ::new ((void*)_VSTD::addressof(*__hold.get()))
+ _FF(_VSTD::forward<_Fp>(__f), _Alloc(__a));
+ __f_ = _VSTD::addressof(*__hold.release());
+ }
+}
+
+template<class _Rp, class ..._ArgTypes>
+__packaged_task_function<_Rp(_ArgTypes...)>&
+__packaged_task_function<_Rp(_ArgTypes...)>::operator=(__packaged_task_function&& __f) _NOEXCEPT
+{
+ if (__f_ == __get_buf())
+ __f_->destroy();
+ else if (__f_)
+ __f_->destroy_deallocate();
+ __f_ = nullptr;
+ if (__f.__f_ == nullptr)
+ __f_ = nullptr;
+ else if (__f.__f_ == __f.__get_buf())
+ {
+ __f.__f_->__move_to(__get_buf());
+ __f_ = __get_buf();
+ }
+ else
+ {
+ __f_ = __f.__f_;
+ __f.__f_ = nullptr;
+ }
+ return *this;
+}
+
+template<class _Rp, class ..._ArgTypes>
+__packaged_task_function<_Rp(_ArgTypes...)>::~__packaged_task_function()
+{
+ if (__f_ == __get_buf())
+ __f_->destroy();
+ else if (__f_)
+ __f_->destroy_deallocate();
+}
+
+template<class _Rp, class ..._ArgTypes>
+_LIBCPP_NO_CFI
+void
+__packaged_task_function<_Rp(_ArgTypes...)>::swap(__packaged_task_function& __f) _NOEXCEPT
+{
+ if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
+ {
+ typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
+ __base* __t = (__base*)&__tempbuf;
+ __f_->__move_to(__t);
+ __f_->destroy();
+ __f_ = nullptr;
+ __f.__f_->__move_to((__base*)&__buf_);
+ __f.__f_->destroy();
+ __f.__f_ = nullptr;
+ __f_ = (__base*)&__buf_;
+ __t->__move_to((__base*)&__f.__buf_);
+ __t->destroy();
+ __f.__f_ = (__base*)&__f.__buf_;
+ }
+ else if (__f_ == (__base*)&__buf_)
+ {
+ __f_->__move_to((__base*)&__f.__buf_);
+ __f_->destroy();
+ __f_ = __f.__f_;
+ __f.__f_ = (__base*)&__f.__buf_;
+ }
+ else if (__f.__f_ == (__base*)&__f.__buf_)
+ {
+ __f.__f_->__move_to((__base*)&__buf_);
+ __f.__f_->destroy();
+ __f.__f_ = __f_;
+ __f_ = (__base*)&__buf_;
+ }
+ else
+ _VSTD::swap(__f_, __f.__f_);
+}
+
+template<class _Rp, class ..._ArgTypes>
+inline
+_Rp
+__packaged_task_function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const
+{
+ return (*__f_)(_VSTD::forward<_ArgTypes>(__arg)...);
+}
+
+template<class _Rp, class ..._ArgTypes>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FUTURE packaged_task<_Rp(_ArgTypes...)>
+{
+public:
+ typedef _Rp result_type; // extension
+
+private:
+ __packaged_task_function<result_type(_ArgTypes...)> __f_;
+ promise<result_type> __p_;
+
+public:
+ // construction and destruction
+ _LIBCPP_INLINE_VISIBILITY
+ packaged_task() _NOEXCEPT : __p_(nullptr) {}
+ template <class _Fp,
+ class = __enable_if_t<!is_same<__uncvref_t<_Fp>, packaged_task>::value> >
+ _LIBCPP_INLINE_VISIBILITY
+ explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {}
+ template <class _Fp, class _Allocator,
+ class = __enable_if_t<!is_same<__uncvref_t<_Fp>, packaged_task>::value> >
+ _LIBCPP_INLINE_VISIBILITY
+ packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
+ : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)),
+ __p_(allocator_arg, __a) {}
+ // ~packaged_task() = default;
+
+ // no copy
+ packaged_task(const packaged_task&) = delete;
+ packaged_task& operator=(const packaged_task&) = delete;
+
+ // move support
+ _LIBCPP_INLINE_VISIBILITY
+ packaged_task(packaged_task&& __other) _NOEXCEPT
+ : __f_(_VSTD::move(__other.__f_)), __p_(_VSTD::move(__other.__p_)) {}
+ _LIBCPP_INLINE_VISIBILITY
+ packaged_task& operator=(packaged_task&& __other) _NOEXCEPT
+ {
+ __f_ = _VSTD::move(__other.__f_);
+ __p_ = _VSTD::move(__other.__p_);
+ return *this;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(packaged_task& __other) _NOEXCEPT
+ {
+ __f_.swap(__other.__f_);
+ __p_.swap(__other.__p_);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool valid() const _NOEXCEPT {return __p_.__state_ != nullptr;}
+
+ // result retrieval
+ _LIBCPP_INLINE_VISIBILITY
+ future<result_type> get_future() {return __p_.get_future();}
+
+ // execution
+ void operator()(_ArgTypes... __args);
+ void make_ready_at_thread_exit(_ArgTypes... __args);
+
+ void reset();
+};
+
+template<class _Rp, class ..._ArgTypes>
+void
+packaged_task<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __args)
+{
+ if (__p_.__state_ == nullptr)
+ __throw_future_error(future_errc::no_state);
+ if (__p_.__state_->__has_value())
+ __throw_future_error(future_errc::promise_already_satisfied);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ __p_.set_value(__f_(_VSTD::forward<_ArgTypes>(__args)...));
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __p_.set_exception(current_exception());
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+}
+
+template<class _Rp, class ..._ArgTypes>
+void
+packaged_task<_Rp(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __args)
+{
+ if (__p_.__state_ == nullptr)
+ __throw_future_error(future_errc::no_state);
+ if (__p_.__state_->__has_value())
+ __throw_future_error(future_errc::promise_already_satisfied);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ __p_.set_value_at_thread_exit(__f_(_VSTD::forward<_ArgTypes>(__args)...));
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __p_.set_exception_at_thread_exit(current_exception());
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+}
+
+template<class _Rp, class ..._ArgTypes>
+void
+packaged_task<_Rp(_ArgTypes...)>::reset()
+{
+ if (!valid())
+ __throw_future_error(future_errc::no_state);
+ __p_ = promise<result_type>();
+}
+
+template<class ..._ArgTypes>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FUTURE packaged_task<void(_ArgTypes...)>
+{
+public:
+ typedef void result_type; // extension
+
+private:
+ __packaged_task_function<result_type(_ArgTypes...)> __f_;
+ promise<result_type> __p_;
+
+public:
+ // construction and destruction
+ _LIBCPP_INLINE_VISIBILITY
+ packaged_task() _NOEXCEPT : __p_(nullptr) {}
+ template <class _Fp,
+ class = __enable_if_t<!is_same<__uncvref_t<_Fp>, packaged_task>::value> >
+ _LIBCPP_INLINE_VISIBILITY
+ explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {}
+ template <class _Fp, class _Allocator,
+ class = __enable_if_t<!is_same<__uncvref_t<_Fp>, packaged_task>::value> >
+ _LIBCPP_INLINE_VISIBILITY
+ packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
+ : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)),
+ __p_(allocator_arg, __a) {}
+ // ~packaged_task() = default;
+
+ // no copy
+ packaged_task(const packaged_task&) = delete;
+ packaged_task& operator=(const packaged_task&) = delete;
+
+ // move support
+ _LIBCPP_INLINE_VISIBILITY
+ packaged_task(packaged_task&& __other) _NOEXCEPT
+ : __f_(_VSTD::move(__other.__f_)), __p_(_VSTD::move(__other.__p_)) {}
+ _LIBCPP_INLINE_VISIBILITY
+ packaged_task& operator=(packaged_task&& __other) _NOEXCEPT
+ {
+ __f_ = _VSTD::move(__other.__f_);
+ __p_ = _VSTD::move(__other.__p_);
+ return *this;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(packaged_task& __other) _NOEXCEPT
+ {
+ __f_.swap(__other.__f_);
+ __p_.swap(__other.__p_);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool valid() const _NOEXCEPT {return __p_.__state_ != nullptr;}
+
+ // result retrieval
+ _LIBCPP_INLINE_VISIBILITY
+ future<result_type> get_future() {return __p_.get_future();}
+
+ // execution
+ void operator()(_ArgTypes... __args);
+ void make_ready_at_thread_exit(_ArgTypes... __args);
+
+ void reset();
+};
+
+template<class ..._ArgTypes>
+void
+packaged_task<void(_ArgTypes...)>::operator()(_ArgTypes... __args)
+{
+ if (__p_.__state_ == nullptr)
+ __throw_future_error(future_errc::no_state);
+ if (__p_.__state_->__has_value())
+ __throw_future_error(future_errc::promise_already_satisfied);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ __f_(_VSTD::forward<_ArgTypes>(__args)...);
+ __p_.set_value();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __p_.set_exception(current_exception());
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+}
+
+template<class ..._ArgTypes>
+void
+packaged_task<void(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __args)
+{
+ if (__p_.__state_ == nullptr)
+ __throw_future_error(future_errc::no_state);
+ if (__p_.__state_->__has_value())
+ __throw_future_error(future_errc::promise_already_satisfied);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ __f_(_VSTD::forward<_ArgTypes>(__args)...);
+ __p_.set_value_at_thread_exit();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __p_.set_exception_at_thread_exit(current_exception());
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+}
+
+template<class ..._ArgTypes>
+void
+packaged_task<void(_ArgTypes...)>::reset()
+{
+ if (!valid())
+ __throw_future_error(future_errc::no_state);
+ __p_ = promise<result_type>();
+}
+
+template <class _Rp, class... _ArgTypes>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(packaged_task<_Rp(_ArgTypes...)>& __x, packaged_task<_Rp(_ArgTypes...)>& __y) _NOEXCEPT
+{
+ __x.swap(__y);
+}
+
+template <class _Callable, class _Alloc>
+struct _LIBCPP_TEMPLATE_VIS uses_allocator<packaged_task<_Callable>, _Alloc>
+ : public true_type {};
+
+template <class _Rp, class _Fp>
+_LIBCPP_INLINE_VISIBILITY future<_Rp>
+__make_deferred_assoc_state(_Fp&& __f)
+{
+ unique_ptr<__deferred_assoc_state<_Rp, _Fp>, __release_shared_count>
+ __h(new __deferred_assoc_state<_Rp, _Fp>(_VSTD::forward<_Fp>(__f)));
+ return future<_Rp>(__h.get());
+}
+
+template <class _Rp, class _Fp>
+_LIBCPP_INLINE_VISIBILITY future<_Rp>
+__make_async_assoc_state(_Fp&& __f)
+{
+ unique_ptr<__async_assoc_state<_Rp, _Fp>, __release_shared_count>
+ __h(new __async_assoc_state<_Rp, _Fp>(_VSTD::forward<_Fp>(__f)));
+ _VSTD::thread(&__async_assoc_state<_Rp, _Fp>::__execute, __h.get()).detach();
+ return future<_Rp>(__h.get());
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Fp, class... _Args>
+class _LIBCPP_HIDDEN __async_func
+{
+ tuple<_Fp, _Args...> __f_;
+
+public:
+ typedef typename __invoke_of<_Fp, _Args...>::type _Rp;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __async_func(_Fp&& __f, _Args&&... __args)
+ : __f_(_VSTD::move(__f), _VSTD::move(__args)...) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __async_func(__async_func&& __f) : __f_(_VSTD::move(__f.__f_)) {}
+
+ _Rp operator()()
+ {
+ typedef typename __make_tuple_indices<1+sizeof...(_Args), 1>::type _Index;
+ return __execute(_Index());
+ }
+private:
+ template <size_t ..._Indices>
+ _Rp
+ __execute(__tuple_indices<_Indices...>)
+ {
+ return _VSTD::__invoke(_VSTD::move(_VSTD::get<0>(__f_)), _VSTD::move(_VSTD::get<_Indices>(__f_))...);
+ }
+};
+
+inline _LIBCPP_INLINE_VISIBILITY bool __does_policy_contain(launch __policy, launch __value )
+{ return (int(__policy) & int(__value)) != 0; }
+
+template <class _Fp, class... _Args>
+_LIBCPP_NODISCARD_AFTER_CXX17
+future<typename __invoke_of<typename decay<_Fp>::type, typename decay<_Args>::type...>::type>
+async(launch __policy, _Fp&& __f, _Args&&... __args)
+{
+ typedef __async_func<typename decay<_Fp>::type, typename decay<_Args>::type...> _BF;
+ typedef typename _BF::_Rp _Rp;
+
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif
+ if (__does_policy_contain(__policy, launch::async))
+ return _VSTD::__make_async_assoc_state<_Rp>(_BF(_LIBCPP_AUTO_CAST(_VSTD::forward<_Fp>(__f)),
+ _LIBCPP_AUTO_CAST(_VSTD::forward<_Args>(__args))...));
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch ( ... ) { if (__policy == launch::async) throw ; }
+#endif
+
+ if (__does_policy_contain(__policy, launch::deferred))
+ return _VSTD::__make_deferred_assoc_state<_Rp>(_BF(_LIBCPP_AUTO_CAST(_VSTD::forward<_Fp>(__f)),
+ _LIBCPP_AUTO_CAST(_VSTD::forward<_Args>(__args))...));
+ return future<_Rp>{};
+}
+
+template <class _Fp, class... _Args>
+_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY
+future<typename __invoke_of<typename decay<_Fp>::type, typename decay<_Args>::type...>::type>
+async(_Fp&& __f, _Args&&... __args)
+{
+ return _VSTD::async(launch::any, _VSTD::forward<_Fp>(__f),
+ _VSTD::forward<_Args>(__args)...);
+}
+
+#endif // C++03
+
+// shared_future
+
+template <class _Rp>
+class _LIBCPP_TEMPLATE_VIS shared_future
+{
+ __assoc_state<_Rp>* __state_;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ shared_future() _NOEXCEPT : __state_(nullptr) {}
+ _LIBCPP_INLINE_VISIBILITY
+ shared_future(const shared_future& __rhs) _NOEXCEPT : __state_(__rhs.__state_)
+ {if (__state_) __state_->__add_shared();}
+ _LIBCPP_INLINE_VISIBILITY
+ shared_future(future<_Rp>&& __f) _NOEXCEPT : __state_(__f.__state_)
+ {__f.__state_ = nullptr;}
+ _LIBCPP_INLINE_VISIBILITY
+ shared_future(shared_future&& __rhs) _NOEXCEPT : __state_(__rhs.__state_)
+ {__rhs.__state_ = nullptr;}
+ ~shared_future();
+ shared_future& operator=(const shared_future& __rhs) _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ shared_future& operator=(shared_future&& __rhs) _NOEXCEPT
+ {
+ shared_future(_VSTD::move(__rhs)).swap(*this);
+ return *this;
+ }
+
+ // retrieving the value
+ _LIBCPP_INLINE_VISIBILITY
+ const _Rp& get() const {return __state_->copy();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(shared_future& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);}
+
+ // functions to check state
+ _LIBCPP_INLINE_VISIBILITY
+ bool valid() const _NOEXCEPT {return __state_ != nullptr;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void wait() const {__state_->wait();}
+ template <class _Rep, class _Period>
+ _LIBCPP_INLINE_VISIBILITY
+ future_status
+ wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const
+ {return __state_->wait_for(__rel_time);}
+ template <class _Clock, class _Duration>
+ _LIBCPP_INLINE_VISIBILITY
+ future_status
+ wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const
+ {return __state_->wait_until(__abs_time);}
+};
+
+template <class _Rp>
+shared_future<_Rp>::~shared_future()
+{
+ if (__state_)
+ __state_->__release_shared();
+}
+
+template <class _Rp>
+shared_future<_Rp>&
+shared_future<_Rp>::operator=(const shared_future& __rhs) _NOEXCEPT
+{
+ if (__rhs.__state_)
+ __rhs.__state_->__add_shared();
+ if (__state_)
+ __state_->__release_shared();
+ __state_ = __rhs.__state_;
+ return *this;
+}
+
+template <class _Rp>
+class _LIBCPP_TEMPLATE_VIS shared_future<_Rp&>
+{
+ __assoc_state<_Rp&>* __state_;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ shared_future() _NOEXCEPT : __state_(nullptr) {}
+ _LIBCPP_INLINE_VISIBILITY
+ shared_future(const shared_future& __rhs) : __state_(__rhs.__state_)
+ {if (__state_) __state_->__add_shared();}
+ _LIBCPP_INLINE_VISIBILITY
+ shared_future(future<_Rp&>&& __f) _NOEXCEPT : __state_(__f.__state_)
+ {__f.__state_ = nullptr;}
+ _LIBCPP_INLINE_VISIBILITY
+ shared_future(shared_future&& __rhs) _NOEXCEPT : __state_(__rhs.__state_)
+ {__rhs.__state_ = nullptr;}
+ ~shared_future();
+ shared_future& operator=(const shared_future& __rhs);
+ _LIBCPP_INLINE_VISIBILITY
+ shared_future& operator=(shared_future&& __rhs) _NOEXCEPT
+ {
+ shared_future(_VSTD::move(__rhs)).swap(*this);
+ return *this;
+ }
+
+ // retrieving the value
+ _LIBCPP_INLINE_VISIBILITY
+ _Rp& get() const {return __state_->copy();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(shared_future& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);}
+
+ // functions to check state
+ _LIBCPP_INLINE_VISIBILITY
+ bool valid() const _NOEXCEPT {return __state_ != nullptr;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void wait() const {__state_->wait();}
+ template <class _Rep, class _Period>
+ _LIBCPP_INLINE_VISIBILITY
+ future_status
+ wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const
+ {return __state_->wait_for(__rel_time);}
+ template <class _Clock, class _Duration>
+ _LIBCPP_INLINE_VISIBILITY
+ future_status
+ wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const
+ {return __state_->wait_until(__abs_time);}
+};
+
+template <class _Rp>
+shared_future<_Rp&>::~shared_future()
+{
+ if (__state_)
+ __state_->__release_shared();
+}
+
+template <class _Rp>
+shared_future<_Rp&>&
+shared_future<_Rp&>::operator=(const shared_future& __rhs)
+{
+ if (__rhs.__state_)
+ __rhs.__state_->__add_shared();
+ if (__state_)
+ __state_->__release_shared();
+ __state_ = __rhs.__state_;
+ return *this;
+}
+
+template <>
+class _LIBCPP_TYPE_VIS _LIBCPP_AVAILABILITY_FUTURE shared_future<void>
+{
+ __assoc_sub_state* __state_;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ shared_future() _NOEXCEPT : __state_(nullptr) {}
+ _LIBCPP_INLINE_VISIBILITY
+ shared_future(const shared_future& __rhs) : __state_(__rhs.__state_)
+ {if (__state_) __state_->__add_shared();}
+ _LIBCPP_INLINE_VISIBILITY
+ shared_future(future<void>&& __f) _NOEXCEPT : __state_(__f.__state_)
+ {__f.__state_ = nullptr;}
+ _LIBCPP_INLINE_VISIBILITY
+ shared_future(shared_future&& __rhs) _NOEXCEPT : __state_(__rhs.__state_)
+ {__rhs.__state_ = nullptr;}
+ ~shared_future();
+ shared_future& operator=(const shared_future& __rhs);
+ _LIBCPP_INLINE_VISIBILITY
+ shared_future& operator=(shared_future&& __rhs) _NOEXCEPT
+ {
+ shared_future(_VSTD::move(__rhs)).swap(*this);
+ return *this;
+ }
+
+ // retrieving the value
+ _LIBCPP_INLINE_VISIBILITY
+ void get() const {__state_->copy();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(shared_future& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);}
+
+ // functions to check state
+ _LIBCPP_INLINE_VISIBILITY
+ bool valid() const _NOEXCEPT {return __state_ != nullptr;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void wait() const {__state_->wait();}
+ template <class _Rep, class _Period>
+ _LIBCPP_INLINE_VISIBILITY
+ future_status
+ wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const
+ {return __state_->wait_for(__rel_time);}
+ template <class _Clock, class _Duration>
+ _LIBCPP_INLINE_VISIBILITY
+ future_status
+ wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const
+ {return __state_->wait_until(__abs_time);}
+};
+
+template <class _Rp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(shared_future<_Rp>& __x, shared_future<_Rp>& __y) _NOEXCEPT
+{
+ __x.swap(__y);
+}
+
+template <class _Rp>
+inline
+shared_future<_Rp>
+future<_Rp>::share() _NOEXCEPT
+{
+ return shared_future<_Rp>(_VSTD::move(*this));
+}
+
+template <class _Rp>
+inline
+shared_future<_Rp&>
+future<_Rp&>::share() _NOEXCEPT
+{
+ return shared_future<_Rp&>(_VSTD::move(*this));
+}
+
+inline
+shared_future<void>
+future<void>::share() _NOEXCEPT
+{
+ return shared_future<void>(_VSTD::move(*this));
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // !_LIBCPP_HAS_NO_THREADS
+
+#endif // _LIBCPP_FUTURE
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/initializer_list b/contrib/libs/cxxsupp/libcxxmsvc/include/initializer_list
new file mode 100644
index 0000000000..827f137fd5
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/initializer_list
@@ -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_INITIALIZER_LIST
+#define _LIBCPP_INITIALIZER_LIST
+
+/*
+ initializer_list synopsis
+
+namespace std
+{
+
+template<class E>
+class initializer_list
+{
+public:
+ typedef E value_type;
+ typedef const E& reference;
+ typedef const E& const_reference;
+ typedef size_t size_type;
+
+ typedef const E* iterator;
+ typedef const E* const_iterator;
+
+ initializer_list() noexcept; // constexpr in C++14
+
+ size_t size() const noexcept; // constexpr in C++14
+ const E* begin() const noexcept; // constexpr in C++14
+ const E* end() const noexcept; // constexpr in C++14
+};
+
+template<class E> const E* begin(initializer_list<E> il) noexcept; // constexpr in C++14
+template<class E> const E* end(initializer_list<E> il) noexcept; // constexpr in C++14
+
+} // std
+
+*/
+
+#include <__config>
+#include <cstddef>
+
+#if defined(_LIBCPP_COMPILER_MSVC) && !defined(__clang__)
+
+#include Y_MSVC_INCLUDE_NEXT(yvals.h)
+#include Y_MSVC_INCLUDE_NEXT(initializer_list)
+
+#else
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+namespace std // purposefully not versioned
+{
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template<class _Ep>
+class _LIBCPP_TEMPLATE_VIS initializer_list
+{
+ const _Ep* __begin_;
+ size_t __size_;
+
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX11
+ initializer_list(const _Ep* __b, size_t __s) _NOEXCEPT
+ : __begin_(__b),
+ __size_(__s)
+ {}
+public:
+ typedef _Ep value_type;
+ typedef const _Ep& reference;
+ typedef const _Ep& const_reference;
+ typedef size_t size_type;
+
+ typedef const _Ep* iterator;
+ typedef const _Ep* const_iterator;
+
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX11
+ initializer_list() _NOEXCEPT : __begin_(nullptr), __size_(0) {}
+
+ initializer_list(const initializer_list&) = default;
+ initializer_list(initializer_list&&) = default;
+ initializer_list& operator=(const initializer_list&) = delete;
+ initializer_list& operator=(initializer_list&&) = delete;
+
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX11
+ size_t size() const _NOEXCEPT {return __size_;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX11
+ const _Ep* begin() const _NOEXCEPT {return __begin_;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX11
+ const _Ep* end() const _NOEXCEPT {return __begin_ + __size_;}
+};
+
+template<class _Ep>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_AFTER_CXX11
+const _Ep*
+begin(initializer_list<_Ep> __il) _NOEXCEPT
+{
+ return __il.begin();
+}
+
+template<class _Ep>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_AFTER_CXX11
+const _Ep*
+end(initializer_list<_Ep> __il) _NOEXCEPT
+{
+ return __il.end();
+}
+
+#endif // !defined(_LIBCPP_CXX03_LANG)
+
+} // namespace std
+
+#endif // _LIBCPP_COMPILER_MSVC
+
+#endif // _LIBCPP_INITIALIZER_LIST
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/inttypes.h b/contrib/libs/cxxsupp/libcxxmsvc/include/inttypes.h
new file mode 100644
index 0000000000..5873e3f647
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/inttypes.h
@@ -0,0 +1,266 @@
+// -*- 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_INTTYPES_H
+// AIX system headers need inttypes.h to be re-enterable while _STD_TYPES_T
+// is defined until an inclusion of it without _STD_TYPES_T occurs, in which
+// case the header guard macro is defined.
+#if !defined(_AIX) || !defined(_STD_TYPES_T)
+#define _LIBCPP_INTTYPES_H
+#endif // _STD_TYPES_T
+
+/*
+ inttypes.h synopsis
+
+This entire header is C99 / C++0X
+
+#include <stdint.h> // <cinttypes> includes <cstdint>
+
+Macros:
+
+ PRId8
+ PRId16
+ PRId32
+ PRId64
+
+ PRIdLEAST8
+ PRIdLEAST16
+ PRIdLEAST32
+ PRIdLEAST64
+
+ PRIdFAST8
+ PRIdFAST16
+ PRIdFAST32
+ PRIdFAST64
+
+ PRIdMAX
+ PRIdPTR
+
+ PRIi8
+ PRIi16
+ PRIi32
+ PRIi64
+
+ PRIiLEAST8
+ PRIiLEAST16
+ PRIiLEAST32
+ PRIiLEAST64
+
+ PRIiFAST8
+ PRIiFAST16
+ PRIiFAST32
+ PRIiFAST64
+
+ PRIiMAX
+ PRIiPTR
+
+ PRIo8
+ PRIo16
+ PRIo32
+ PRIo64
+
+ PRIoLEAST8
+ PRIoLEAST16
+ PRIoLEAST32
+ PRIoLEAST64
+
+ PRIoFAST8
+ PRIoFAST16
+ PRIoFAST32
+ PRIoFAST64
+
+ PRIoMAX
+ PRIoPTR
+
+ PRIu8
+ PRIu16
+ PRIu32
+ PRIu64
+
+ PRIuLEAST8
+ PRIuLEAST16
+ PRIuLEAST32
+ PRIuLEAST64
+
+ PRIuFAST8
+ PRIuFAST16
+ PRIuFAST32
+ PRIuFAST64
+
+ PRIuMAX
+ PRIuPTR
+
+ PRIx8
+ PRIx16
+ PRIx32
+ PRIx64
+
+ PRIxLEAST8
+ PRIxLEAST16
+ PRIxLEAST32
+ PRIxLEAST64
+
+ PRIxFAST8
+ PRIxFAST16
+ PRIxFAST32
+ PRIxFAST64
+
+ PRIxMAX
+ PRIxPTR
+
+ PRIX8
+ PRIX16
+ PRIX32
+ PRIX64
+
+ PRIXLEAST8
+ PRIXLEAST16
+ PRIXLEAST32
+ PRIXLEAST64
+
+ PRIXFAST8
+ PRIXFAST16
+ PRIXFAST32
+ PRIXFAST64
+
+ PRIXMAX
+ PRIXPTR
+
+ SCNd8
+ SCNd16
+ SCNd32
+ SCNd64
+
+ SCNdLEAST8
+ SCNdLEAST16
+ SCNdLEAST32
+ SCNdLEAST64
+
+ SCNdFAST8
+ SCNdFAST16
+ SCNdFAST32
+ SCNdFAST64
+
+ SCNdMAX
+ SCNdPTR
+
+ SCNi8
+ SCNi16
+ SCNi32
+ SCNi64
+
+ SCNiLEAST8
+ SCNiLEAST16
+ SCNiLEAST32
+ SCNiLEAST64
+
+ SCNiFAST8
+ SCNiFAST16
+ SCNiFAST32
+ SCNiFAST64
+
+ SCNiMAX
+ SCNiPTR
+
+ SCNo8
+ SCNo16
+ SCNo32
+ SCNo64
+
+ SCNoLEAST8
+ SCNoLEAST16
+ SCNoLEAST32
+ SCNoLEAST64
+
+ SCNoFAST8
+ SCNoFAST16
+ SCNoFAST32
+ SCNoFAST64
+
+ SCNoMAX
+ SCNoPTR
+
+ SCNu8
+ SCNu16
+ SCNu32
+ SCNu64
+
+ SCNuLEAST8
+ SCNuLEAST16
+ SCNuLEAST32
+ SCNuLEAST64
+
+ SCNuFAST8
+ SCNuFAST16
+ SCNuFAST32
+ SCNuFAST64
+
+ SCNuMAX
+ SCNuPTR
+
+ SCNx8
+ SCNx16
+ SCNx32
+ SCNx64
+
+ SCNxLEAST8
+ SCNxLEAST16
+ SCNxLEAST32
+ SCNxLEAST64
+
+ SCNxFAST8
+ SCNxFAST16
+ SCNxFAST32
+ SCNxFAST64
+
+ SCNxMAX
+ SCNxPTR
+
+Types:
+
+ imaxdiv_t
+
+intmax_t imaxabs(intmax_t j);
+imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom);
+intmax_t strtoimax(const char* restrict nptr, char** restrict endptr, int base);
+uintmax_t strtoumax(const char* restrict nptr, char** restrict endptr, int base);
+intmax_t wcstoimax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
+uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+/* C99 stdlib (e.g. glibc < 2.18) does not provide format macros needed
+ for C++11 unless __STDC_FORMAT_MACROS is defined
+*/
+#if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS)
+# define __STDC_FORMAT_MACROS
+#endif
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#include Y_UCRT_INCLUDE_NEXT(inttypes.h)
+#else
+#include_next <inttypes.h>
+#endif
+
+#ifdef __cplusplus
+
+#include <stdint.h>
+
+#undef imaxabs
+#undef imaxdiv
+
+#endif // __cplusplus
+
+#endif // _LIBCPP_INTTYPES_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/iomanip b/contrib/libs/cxxsupp/libcxxmsvc/include/iomanip
new file mode 100644
index 0000000000..3d7915410f
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/iomanip
@@ -0,0 +1,670 @@
+// -*- 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_IOMANIP
+#define _LIBCPP_IOMANIP
+
+/*
+ iomanip synopsis
+
+namespace std {
+
+// types T1, T2, ... are unspecified implementation types
+T1 resetiosflags(ios_base::fmtflags mask);
+T2 setiosflags (ios_base::fmtflags mask);
+T3 setbase(int base);
+template<charT> T4 setfill(charT c);
+T5 setprecision(int n);
+T6 setw(int n);
+template <class moneyT> T7 get_money(moneyT& mon, bool intl = false);
+template <class charT, class moneyT> T8 put_money(const moneyT& mon, bool intl = false);
+template <class charT> T9 get_time(struct tm* tmb, const charT* fmt);
+template <class charT> T10 put_time(const struct tm* tmb, const charT* fmt);
+
+template <class charT>
+ T11 quoted(const charT* s, charT delim=charT('"'), charT escape=charT('\\')); // C++14
+
+template <class charT, class traits, class Allocator>
+ T12 quoted(const basic_string<charT, traits, Allocator>& s,
+ charT delim=charT('"'), charT escape=charT('\\')); // C++14
+
+template <class charT, class traits, class Allocator>
+ T13 quoted(basic_string<charT, traits, Allocator>& s,
+ charT delim=charT('"'), charT escape=charT('\\')); // C++14
+
+} // std
+
+*/
+
+#include <__config>
+#include <__string>
+#include <istream>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// resetiosflags
+
+class __iom_t1
+{
+ ios_base::fmtflags __mask_;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __iom_t1(ios_base::fmtflags __m) : __mask_(__m) {}
+
+ template <class _CharT, class _Traits>
+ friend
+ _LIBCPP_INLINE_VISIBILITY
+ basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t1& __x)
+ {
+ __is.unsetf(__x.__mask_);
+ return __is;
+ }
+
+ template <class _CharT, class _Traits>
+ friend
+ _LIBCPP_INLINE_VISIBILITY
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t1& __x)
+ {
+ __os.unsetf(__x.__mask_);
+ return __os;
+ }
+};
+
+inline _LIBCPP_INLINE_VISIBILITY
+__iom_t1
+resetiosflags(ios_base::fmtflags __mask)
+{
+ return __iom_t1(__mask);
+}
+
+// setiosflags
+
+class __iom_t2
+{
+ ios_base::fmtflags __mask_;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __iom_t2(ios_base::fmtflags __m) : __mask_(__m) {}
+
+ template <class _CharT, class _Traits>
+ friend
+ _LIBCPP_INLINE_VISIBILITY
+ basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t2& __x)
+ {
+ __is.setf(__x.__mask_);
+ return __is;
+ }
+
+ template <class _CharT, class _Traits>
+ friend
+ _LIBCPP_INLINE_VISIBILITY
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t2& __x)
+ {
+ __os.setf(__x.__mask_);
+ return __os;
+ }
+};
+
+inline _LIBCPP_INLINE_VISIBILITY
+__iom_t2
+setiosflags(ios_base::fmtflags __mask)
+{
+ return __iom_t2(__mask);
+}
+
+// setbase
+
+class __iom_t3
+{
+ int __base_;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __iom_t3(int __b) : __base_(__b) {}
+
+ template <class _CharT, class _Traits>
+ friend
+ _LIBCPP_INLINE_VISIBILITY
+ basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t3& __x)
+ {
+ __is.setf(__x.__base_ == 8 ? ios_base::oct :
+ __x.__base_ == 10 ? ios_base::dec :
+ __x.__base_ == 16 ? ios_base::hex :
+ ios_base::fmtflags(0), ios_base::basefield);
+ return __is;
+ }
+
+ template <class _CharT, class _Traits>
+ friend
+ _LIBCPP_INLINE_VISIBILITY
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t3& __x)
+ {
+ __os.setf(__x.__base_ == 8 ? ios_base::oct :
+ __x.__base_ == 10 ? ios_base::dec :
+ __x.__base_ == 16 ? ios_base::hex :
+ ios_base::fmtflags(0), ios_base::basefield);
+ return __os;
+ }
+};
+
+inline _LIBCPP_INLINE_VISIBILITY
+__iom_t3
+setbase(int __base)
+{
+ return __iom_t3(__base);
+}
+
+// setfill
+
+template<class _CharT>
+class __iom_t4
+{
+ _CharT __fill_;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __iom_t4(_CharT __c) : __fill_(__c) {}
+
+ template <class _Traits>
+ friend
+ _LIBCPP_INLINE_VISIBILITY
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t4& __x)
+ {
+ __os.fill(__x.__fill_);
+ return __os;
+ }
+};
+
+template<class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+__iom_t4<_CharT>
+setfill(_CharT __c)
+{
+ return __iom_t4<_CharT>(__c);
+}
+
+// setprecision
+
+class __iom_t5
+{
+ int __n_;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __iom_t5(int __n) : __n_(__n) {}
+
+ template <class _CharT, class _Traits>
+ friend
+ _LIBCPP_INLINE_VISIBILITY
+ basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t5& __x)
+ {
+ __is.precision(__x.__n_);
+ return __is;
+ }
+
+ template <class _CharT, class _Traits>
+ friend
+ _LIBCPP_INLINE_VISIBILITY
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t5& __x)
+ {
+ __os.precision(__x.__n_);
+ return __os;
+ }
+};
+
+inline _LIBCPP_INLINE_VISIBILITY
+__iom_t5
+setprecision(int __n)
+{
+ return __iom_t5(__n);
+}
+
+// setw
+
+class __iom_t6
+{
+ int __n_;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __iom_t6(int __n) : __n_(__n) {}
+
+ template <class _CharT, class _Traits>
+ friend
+ _LIBCPP_INLINE_VISIBILITY
+ basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t6& __x)
+ {
+ __is.width(__x.__n_);
+ return __is;
+ }
+
+ template <class _CharT, class _Traits>
+ friend
+ _LIBCPP_INLINE_VISIBILITY
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t6& __x)
+ {
+ __os.width(__x.__n_);
+ return __os;
+ }
+};
+
+inline _LIBCPP_INLINE_VISIBILITY
+__iom_t6
+setw(int __n)
+{
+ return __iom_t6(__n);
+}
+
+// get_money
+
+template <class _MoneyT> class __iom_t7;
+
+template <class _CharT, class _Traits, class _MoneyT>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x);
+
+template <class _MoneyT>
+class __iom_t7
+{
+ _MoneyT& __mon_;
+ bool __intl_;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ __iom_t7(_MoneyT& __mon, bool __intl)
+ : __mon_(__mon), __intl_(__intl) {}
+
+ template <class _CharT, class _Traits, class _Mp>
+ friend
+ basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_Mp>& __x);
+};
+
+template <class _CharT, class _Traits, class _MoneyT>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ typename basic_istream<_CharT, _Traits>::sentry __s(__is);
+ if (__s)
+ {
+ typedef istreambuf_iterator<_CharT, _Traits> _Ip;
+ typedef money_get<_CharT, _Ip> _Fp;
+ ios_base::iostate __err = ios_base::goodbit;
+ const _Fp& __mf = use_facet<_Fp>(__is.getloc());
+ __mf.get(_Ip(__is), _Ip(), __x.__intl_, __is, __err, __x.__mon_);
+ __is.setstate(__err);
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __is.__set_badbit_and_consider_rethrow();
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ return __is;
+}
+
+template <class _MoneyT>
+inline _LIBCPP_INLINE_VISIBILITY
+__iom_t7<_MoneyT>
+get_money(_MoneyT& __mon, bool __intl = false)
+{
+ return __iom_t7<_MoneyT>(__mon, __intl);
+}
+
+// put_money
+
+template <class _MoneyT> class __iom_t8;
+
+template <class _CharT, class _Traits, class _MoneyT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x);
+
+template <class _MoneyT>
+class __iom_t8
+{
+ const _MoneyT& __mon_;
+ bool __intl_;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ __iom_t8(const _MoneyT& __mon, bool __intl)
+ : __mon_(__mon), __intl_(__intl) {}
+
+ template <class _CharT, class _Traits, class _Mp>
+ friend
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_Mp>& __x);
+};
+
+template <class _CharT, class _Traits, class _MoneyT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
+ if (__s)
+ {
+ typedef ostreambuf_iterator<_CharT, _Traits> _Op;
+ typedef money_put<_CharT, _Op> _Fp;
+ const _Fp& __mf = use_facet<_Fp>(__os.getloc());
+ if (__mf.put(_Op(__os), __x.__intl_, __os, __os.fill(), __x.__mon_).failed())
+ __os.setstate(ios_base::badbit);
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __os.__set_badbit_and_consider_rethrow();
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ return __os;
+}
+
+template <class _MoneyT>
+inline _LIBCPP_INLINE_VISIBILITY
+__iom_t8<_MoneyT>
+put_money(const _MoneyT& __mon, bool __intl = false)
+{
+ return __iom_t8<_MoneyT>(__mon, __intl);
+}
+
+// get_time
+
+template <class _CharT> class __iom_t9;
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x);
+
+template <class _CharT>
+class __iom_t9
+{
+ tm* __tm_;
+ const _CharT* __fmt_;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ __iom_t9(tm* __tm, const _CharT* __fmt)
+ : __tm_(__tm), __fmt_(__fmt) {}
+
+ template <class _Cp, class _Traits>
+ friend
+ basic_istream<_Cp, _Traits>&
+ operator>>(basic_istream<_Cp, _Traits>& __is, const __iom_t9<_Cp>& __x);
+};
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ typename basic_istream<_CharT, _Traits>::sentry __s(__is);
+ if (__s)
+ {
+ typedef istreambuf_iterator<_CharT, _Traits> _Ip;
+ typedef time_get<_CharT, _Ip> _Fp;
+ ios_base::iostate __err = ios_base::goodbit;
+ const _Fp& __tf = use_facet<_Fp>(__is.getloc());
+ __tf.get(_Ip(__is), _Ip(), __is, __err, __x.__tm_,
+ __x.__fmt_, __x.__fmt_ + _Traits::length(__x.__fmt_));
+ __is.setstate(__err);
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __is.__set_badbit_and_consider_rethrow();
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ return __is;
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+__iom_t9<_CharT>
+get_time(tm* __tm, const _CharT* __fmt)
+{
+ return __iom_t9<_CharT>(__tm, __fmt);
+}
+
+// put_time
+
+template <class _CharT> class __iom_t10;
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x);
+
+template <class _CharT>
+class __iom_t10
+{
+ const tm* __tm_;
+ const _CharT* __fmt_;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ __iom_t10(const tm* __tm, const _CharT* __fmt)
+ : __tm_(__tm), __fmt_(__fmt) {}
+
+ template <class _Cp, class _Traits>
+ friend
+ basic_ostream<_Cp, _Traits>&
+ operator<<(basic_ostream<_Cp, _Traits>& __os, const __iom_t10<_Cp>& __x);
+};
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
+ if (__s)
+ {
+ typedef ostreambuf_iterator<_CharT, _Traits> _Op;
+ typedef time_put<_CharT, _Op> _Fp;
+ const _Fp& __tf = use_facet<_Fp>(__os.getloc());
+ if (__tf.put(_Op(__os), __os, __os.fill(), __x.__tm_,
+ __x.__fmt_, __x.__fmt_ + _Traits::length(__x.__fmt_)).failed())
+ __os.setstate(ios_base::badbit);
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __os.__set_badbit_and_consider_rethrow();
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ return __os;
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+__iom_t10<_CharT>
+put_time(const tm* __tm, const _CharT* __fmt)
+{
+ return __iom_t10<_CharT>(__tm, __fmt);
+}
+
+template <class _CharT, class _Traits, class _ForwardIterator>
+basic_ostream<_CharT, _Traits> &
+__quoted_output ( basic_ostream<_CharT, _Traits> &__os,
+ _ForwardIterator __first, _ForwardIterator __last, _CharT __delim, _CharT __escape )
+{
+ basic_string<_CharT, _Traits> __str;
+ __str.push_back(__delim);
+ for ( ; __first != __last; ++ __first )
+ {
+ if (_Traits::eq (*__first, __escape) || _Traits::eq (*__first, __delim))
+ __str.push_back(__escape);
+ __str.push_back(*__first);
+ }
+ __str.push_back(__delim);
+ return _VSTD::__put_character_sequence(__os, __str.data(), __str.size());
+}
+
+template <class _CharT, class _Traits, class _String>
+basic_istream<_CharT, _Traits> &
+__quoted_input ( basic_istream<_CharT, _Traits> &__is, _String & __string, _CharT __delim, _CharT __escape )
+{
+ __string.clear ();
+ _CharT __c;
+ __is >> __c;
+ if ( __is.fail ())
+ return __is;
+
+ if (!_Traits::eq (__c, __delim)) // no delimiter, read the whole string
+ {
+ __is.unget ();
+ __is >> __string;
+ return __is;
+ }
+
+ __save_flags<_CharT, _Traits> sf(__is);
+ noskipws (__is);
+ while (true)
+ {
+ __is >> __c;
+ if ( __is.fail ())
+ break;
+ if (_Traits::eq (__c, __escape))
+ {
+ __is >> __c;
+ if ( __is.fail ())
+ break;
+ }
+ else if (_Traits::eq (__c, __delim))
+ break;
+ __string.push_back ( __c );
+ }
+ return __is;
+}
+
+
+template <class _CharT, class _Traits, class _Iter>
+basic_ostream<_CharT, _Traits>& operator<<(
+ basic_ostream<_CharT, _Traits>& __os,
+ const __quoted_output_proxy<_CharT, _Iter, _Traits> & __proxy)
+{
+ return __quoted_output (__os, __proxy.__first, __proxy.__last, __proxy.__delim, __proxy.__escape);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+struct __quoted_proxy
+{
+ basic_string<_CharT, _Traits, _Allocator> &__string;
+ _CharT __delim;
+ _CharT __escape;
+
+ __quoted_proxy(basic_string<_CharT, _Traits, _Allocator> &__s, _CharT __d, _CharT __e)
+ : __string(__s), __delim(__d), __escape(__e) {}
+};
+
+template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _Traits>& operator<<(
+ basic_ostream<_CharT, _Traits>& __os,
+ const __quoted_proxy<_CharT, _Traits, _Allocator> & __proxy)
+{
+ return __quoted_output (__os, __proxy.__string.cbegin (), __proxy.__string.cend (), __proxy.__delim, __proxy.__escape);
+}
+
+// extractor for non-const basic_string& proxies
+template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>& operator>>(
+ basic_istream<_CharT, _Traits>& __is,
+ const __quoted_proxy<_CharT, _Traits, _Allocator> & __proxy)
+{
+ return __quoted_input ( __is, __proxy.__string, __proxy.__delim, __proxy.__escape );
+}
+
+
+template <class _CharT>
+_LIBCPP_INLINE_VISIBILITY
+__quoted_output_proxy<_CharT, const _CharT *>
+quoted ( const _CharT *__s, _CharT __delim = _CharT('"'), _CharT __escape =_CharT('\\'))
+{
+ const _CharT *__end = __s;
+ while ( *__end ) ++__end;
+ return __quoted_output_proxy<_CharT, const _CharT *> ( __s, __end, __delim, __escape );
+}
+
+
+template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_INLINE_VISIBILITY
+__quoted_output_proxy<_CharT, typename basic_string <_CharT, _Traits, _Allocator>::const_iterator>
+__quoted ( const basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
+{
+ return __quoted_output_proxy<_CharT,
+ typename basic_string <_CharT, _Traits, _Allocator>::const_iterator>
+ ( __s.cbegin(), __s.cend (), __delim, __escape );
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_INLINE_VISIBILITY
+__quoted_proxy<_CharT, _Traits, _Allocator>
+__quoted ( basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
+{
+ return __quoted_proxy<_CharT, _Traits, _Allocator>( __s, __delim, __escape );
+}
+
+
+#if _LIBCPP_STD_VER > 11
+
+template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_INLINE_VISIBILITY
+__quoted_output_proxy<_CharT, typename basic_string <_CharT, _Traits, _Allocator>::const_iterator>
+quoted ( const basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
+{
+ return __quoted(__s, __delim, __escape);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_INLINE_VISIBILITY
+__quoted_proxy<_CharT, _Traits, _Allocator>
+quoted ( basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
+{
+ return __quoted(__s, __delim, __escape);
+}
+
+template <class _CharT, class _Traits>
+__quoted_output_proxy<_CharT, const _CharT *, _Traits>
+quoted (basic_string_view <_CharT, _Traits> __sv,
+ _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
+{
+ return __quoted_output_proxy<_CharT, const _CharT *, _Traits>
+ ( __sv.data(), __sv.data() + __sv.size(), __delim, __escape );
+}
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_IOMANIP
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/ios b/contrib/libs/cxxsupp/libcxxmsvc/include/ios
new file mode 100644
index 0000000000..6c8267a39c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/ios
@@ -0,0 +1,1028 @@
+// -*- 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_IOS
+#define _LIBCPP_IOS
+
+/*
+ ios synopsis
+
+#include <iosfwd>
+
+namespace std
+{
+
+typedef OFF_T streamoff;
+typedef SZ_T streamsize;
+template <class stateT> class fpos;
+
+class ios_base
+{
+public:
+ class failure;
+
+ typedef T1 fmtflags;
+ static constexpr fmtflags boolalpha;
+ static constexpr fmtflags dec;
+ static constexpr fmtflags fixed;
+ static constexpr fmtflags hex;
+ static constexpr fmtflags internal;
+ static constexpr fmtflags left;
+ static constexpr fmtflags oct;
+ static constexpr fmtflags right;
+ static constexpr fmtflags scientific;
+ static constexpr fmtflags showbase;
+ static constexpr fmtflags showpoint;
+ static constexpr fmtflags showpos;
+ static constexpr fmtflags skipws;
+ static constexpr fmtflags unitbuf;
+ static constexpr fmtflags uppercase;
+ static constexpr fmtflags adjustfield;
+ static constexpr fmtflags basefield;
+ static constexpr fmtflags floatfield;
+
+ typedef T2 iostate;
+ static constexpr iostate badbit;
+ static constexpr iostate eofbit;
+ static constexpr iostate failbit;
+ static constexpr iostate goodbit;
+
+ typedef T3 openmode;
+ static constexpr openmode app;
+ static constexpr openmode ate;
+ static constexpr openmode binary;
+ static constexpr openmode in;
+ static constexpr openmode out;
+ static constexpr openmode trunc;
+
+ typedef T4 seekdir;
+ static constexpr seekdir beg;
+ static constexpr seekdir cur;
+ static constexpr seekdir end;
+
+ class Init;
+
+ // 27.5.2.2 fmtflags state:
+ fmtflags flags() const;
+ fmtflags flags(fmtflags fmtfl);
+ fmtflags setf(fmtflags fmtfl);
+ fmtflags setf(fmtflags fmtfl, fmtflags mask);
+ void unsetf(fmtflags mask);
+
+ streamsize precision() const;
+ streamsize precision(streamsize prec);
+ streamsize width() const;
+ streamsize width(streamsize wide);
+
+ // 27.5.2.3 locales:
+ locale imbue(const locale& loc);
+ locale getloc() const;
+
+ // 27.5.2.5 storage:
+ static int xalloc();
+ long& iword(int index);
+ void*& pword(int index);
+
+ // destructor
+ virtual ~ios_base();
+
+ // 27.5.2.6 callbacks;
+ enum event { erase_event, imbue_event, copyfmt_event };
+ typedef void (*event_callback)(event, ios_base&, int index);
+ void register_callback(event_callback fn, int index);
+
+ ios_base(const ios_base&) = delete;
+ ios_base& operator=(const ios_base&) = delete;
+
+ static bool sync_with_stdio(bool sync = true);
+
+protected:
+ ios_base();
+};
+
+template <class charT, class traits = char_traits<charT> >
+class basic_ios
+ : public ios_base
+{
+public:
+ // types:
+ typedef charT char_type;
+ typedef typename traits::int_type int_type; // removed in C++17
+ typedef typename traits::pos_type pos_type; // removed in C++17
+ typedef typename traits::off_type off_type; // removed in C++17
+ typedef traits traits_type;
+
+ operator unspecified-bool-type() const;
+ bool operator!() const;
+ iostate rdstate() const;
+ void clear(iostate state = goodbit);
+ void setstate(iostate state);
+ bool good() const;
+ bool eof() const;
+ bool fail() const;
+ bool bad() const;
+
+ iostate exceptions() const;
+ void exceptions(iostate except);
+
+ // 27.5.4.1 Constructor/destructor:
+ explicit basic_ios(basic_streambuf<charT,traits>* sb);
+ virtual ~basic_ios();
+
+ // 27.5.4.2 Members:
+ basic_ostream<charT,traits>* tie() const;
+ basic_ostream<charT,traits>* tie(basic_ostream<charT,traits>* tiestr);
+
+ basic_streambuf<charT,traits>* rdbuf() const;
+ basic_streambuf<charT,traits>* rdbuf(basic_streambuf<charT,traits>* sb);
+
+ basic_ios& copyfmt(const basic_ios& rhs);
+
+ char_type fill() const;
+ char_type fill(char_type ch);
+
+ locale imbue(const locale& loc);
+
+ char narrow(char_type c, char dfault) const;
+ char_type widen(char c) const;
+
+ basic_ios(const basic_ios& ) = delete;
+ basic_ios& operator=(const basic_ios&) = delete;
+
+protected:
+ basic_ios();
+ void init(basic_streambuf<charT,traits>* sb);
+ void move(basic_ios& rhs);
+ void swap(basic_ios& rhs) noexcept;
+ void set_rdbuf(basic_streambuf<charT, traits>* sb);
+};
+
+// 27.5.5, manipulators:
+ios_base& boolalpha (ios_base& str);
+ios_base& noboolalpha(ios_base& str);
+ios_base& showbase (ios_base& str);
+ios_base& noshowbase (ios_base& str);
+ios_base& showpoint (ios_base& str);
+ios_base& noshowpoint(ios_base& str);
+ios_base& showpos (ios_base& str);
+ios_base& noshowpos (ios_base& str);
+ios_base& skipws (ios_base& str);
+ios_base& noskipws (ios_base& str);
+ios_base& uppercase (ios_base& str);
+ios_base& nouppercase(ios_base& str);
+ios_base& unitbuf (ios_base& str);
+ios_base& nounitbuf (ios_base& str);
+
+// 27.5.5.2 adjustfield:
+ios_base& internal (ios_base& str);
+ios_base& left (ios_base& str);
+ios_base& right (ios_base& str);
+
+// 27.5.5.3 basefield:
+ios_base& dec (ios_base& str);
+ios_base& hex (ios_base& str);
+ios_base& oct (ios_base& str);
+
+// 27.5.5.4 floatfield:
+ios_base& fixed (ios_base& str);
+ios_base& scientific (ios_base& str);
+ios_base& hexfloat (ios_base& str);
+ios_base& defaultfloat(ios_base& str);
+
+// 27.5.5.5 error reporting:
+enum class io_errc
+{
+ stream = 1
+};
+
+concept_map ErrorCodeEnum<io_errc> { };
+error_code make_error_code(io_errc e) noexcept;
+error_condition make_error_condition(io_errc e) noexcept;
+storage-class-specifier const error_category& iostream_category() noexcept;
+
+} // std
+
+*/
+
+#include <__config>
+#include <__ios/fpos.h>
+#include <__locale>
+#include <iosfwd>
+#include <system_error>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
+#include <atomic> // for __xindex_
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+typedef ptrdiff_t streamsize;
+
+class _LIBCPP_TYPE_VIS ios_base
+{
+public:
+ class _LIBCPP_EXCEPTION_ABI failure;
+
+ typedef unsigned int fmtflags;
+ static const fmtflags boolalpha = 0x0001;
+ static const fmtflags dec = 0x0002;
+ static const fmtflags fixed = 0x0004;
+ static const fmtflags hex = 0x0008;
+ static const fmtflags internal = 0x0010;
+ static const fmtflags left = 0x0020;
+ static const fmtflags oct = 0x0040;
+ static const fmtflags right = 0x0080;
+ static const fmtflags scientific = 0x0100;
+ static const fmtflags showbase = 0x0200;
+ static const fmtflags showpoint = 0x0400;
+ static const fmtflags showpos = 0x0800;
+ static const fmtflags skipws = 0x1000;
+ static const fmtflags unitbuf = 0x2000;
+ static const fmtflags uppercase = 0x4000;
+ static const fmtflags adjustfield = left | right | internal;
+ static const fmtflags basefield = dec | oct | hex;
+ static const fmtflags floatfield = scientific | fixed;
+
+ typedef unsigned int iostate;
+ static const iostate badbit = 0x1;
+ static const iostate eofbit = 0x2;
+ static const iostate failbit = 0x4;
+ static const iostate goodbit = 0x0;
+
+ typedef unsigned int openmode;
+ static const openmode app = 0x01;
+ static const openmode ate = 0x02;
+ static const openmode binary = 0x04;
+ static const openmode in = 0x08;
+ static const openmode out = 0x10;
+ static const openmode trunc = 0x20;
+
+ enum seekdir {beg, cur, end};
+
+#if _LIBCPP_STD_VER <= 14
+ typedef iostate io_state;
+ typedef openmode open_mode;
+ typedef seekdir seek_dir;
+
+ typedef _VSTD::streamoff streamoff;
+ typedef _VSTD::streampos streampos;
+#endif
+
+ class _LIBCPP_TYPE_VIS Init;
+
+ // 27.5.2.2 fmtflags state:
+ _LIBCPP_INLINE_VISIBILITY fmtflags flags() const;
+ _LIBCPP_INLINE_VISIBILITY fmtflags flags(fmtflags __fmtfl);
+ _LIBCPP_INLINE_VISIBILITY fmtflags setf(fmtflags __fmtfl);
+ _LIBCPP_INLINE_VISIBILITY fmtflags setf(fmtflags __fmtfl, fmtflags __mask);
+ _LIBCPP_INLINE_VISIBILITY void unsetf(fmtflags __mask);
+
+ _LIBCPP_INLINE_VISIBILITY streamsize precision() const;
+ _LIBCPP_INLINE_VISIBILITY streamsize precision(streamsize __prec);
+ _LIBCPP_INLINE_VISIBILITY streamsize width() const;
+ _LIBCPP_INLINE_VISIBILITY streamsize width(streamsize __wide);
+
+ // 27.5.2.3 locales:
+ locale imbue(const locale& __loc);
+ locale getloc() const;
+
+ // 27.5.2.5 storage:
+ static int xalloc();
+ long& iword(int __index);
+ void*& pword(int __index);
+
+ // destructor
+ virtual ~ios_base();
+
+ // 27.5.2.6 callbacks;
+ enum event { erase_event, imbue_event, copyfmt_event };
+ typedef void (*event_callback)(event, ios_base&, int __index);
+ void register_callback(event_callback __fn, int __index);
+
+ ios_base(const ios_base&) = delete;
+ ios_base& operator=(const ios_base&) = delete;
+
+ static bool sync_with_stdio(bool __sync = true);
+
+ _LIBCPP_INLINE_VISIBILITY iostate rdstate() const;
+ void clear(iostate __state = goodbit);
+ _LIBCPP_INLINE_VISIBILITY void setstate(iostate __state);
+
+ _LIBCPP_INLINE_VISIBILITY bool good() const;
+ _LIBCPP_INLINE_VISIBILITY bool eof() const;
+ _LIBCPP_INLINE_VISIBILITY bool fail() const;
+ _LIBCPP_INLINE_VISIBILITY bool bad() const;
+
+ _LIBCPP_INLINE_VISIBILITY iostate exceptions() const;
+ _LIBCPP_INLINE_VISIBILITY void exceptions(iostate __iostate);
+
+ void __set_badbit_and_consider_rethrow();
+ void __set_failbit_and_consider_rethrow();
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __setstate_nothrow(iostate __state)
+ {
+ if (__rdbuf_)
+ __rdstate_ |= __state;
+ else
+ __rdstate_ |= __state | ios_base::badbit;
+ }
+
+protected:
+ _LIBCPP_INLINE_VISIBILITY
+ ios_base() {// purposefully does no initialization
+ }
+
+ void init(void* __sb);
+ _LIBCPP_INLINE_VISIBILITY void* rdbuf() const {return __rdbuf_;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void rdbuf(void* __sb)
+ {
+ __rdbuf_ = __sb;
+ clear();
+ }
+
+ void __call_callbacks(event);
+ void copyfmt(const ios_base&);
+ void move(ios_base&);
+ void swap(ios_base&) _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY
+ void set_rdbuf(void* __sb)
+ {
+ __rdbuf_ = __sb;
+ }
+
+private:
+ // All data members must be scalars
+ fmtflags __fmtflags_;
+ streamsize __precision_;
+ streamsize __width_;
+ iostate __rdstate_;
+ iostate __exceptions_;
+ void* __rdbuf_;
+ void* __loc_;
+ event_callback* __fn_;
+ int* __index_;
+ size_t __event_size_;
+ size_t __event_cap_;
+// TODO(EricWF): Enable this for both Clang and GCC. Currently it is only
+// enabled with clang.
+#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS)
+ static atomic<int> __xindex_;
+#else
+ static int __xindex_;
+#endif
+ long* __iarray_;
+ size_t __iarray_size_;
+ size_t __iarray_cap_;
+ void** __parray_;
+ size_t __parray_size_;
+ size_t __parray_cap_;
+};
+
+//enum class io_errc
+_LIBCPP_DECLARE_STRONG_ENUM(io_errc)
+{
+ stream = 1
+};
+_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc)
+
+template <>
+struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc> : public true_type { };
+
+#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
+template <>
+struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc::__lx> : public true_type { };
+#endif
+
+_LIBCPP_FUNC_VIS
+const error_category& iostream_category() _NOEXCEPT;
+
+inline _LIBCPP_INLINE_VISIBILITY
+error_code
+make_error_code(io_errc __e) _NOEXCEPT
+{
+ return error_code(static_cast<int>(__e), iostream_category());
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+error_condition
+make_error_condition(io_errc __e) _NOEXCEPT
+{
+ return error_condition(static_cast<int>(__e), iostream_category());
+}
+
+class _LIBCPP_EXCEPTION_ABI ios_base::failure
+ : public system_error
+{
+public:
+ explicit failure(const string& __msg, const error_code& __ec = io_errc::stream);
+ explicit failure(const char* __msg, const error_code& __ec = io_errc::stream);
+ failure(const failure&) _NOEXCEPT = default;
+ virtual ~failure() _NOEXCEPT;
+};
+
+_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
+void __throw_failure(char const* __msg) {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw ios_base::failure(__msg);
+#else
+ ((void)__msg);
+ _VSTD::abort();
+#endif
+}
+
+class _LIBCPP_TYPE_VIS ios_base::Init
+{
+public:
+ Init();
+ ~Init();
+};
+
+// fmtflags
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base::fmtflags
+ios_base::flags() const
+{
+ return __fmtflags_;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base::fmtflags
+ios_base::flags(fmtflags __fmtfl)
+{
+ fmtflags __r = __fmtflags_;
+ __fmtflags_ = __fmtfl;
+ return __r;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base::fmtflags
+ios_base::setf(fmtflags __fmtfl)
+{
+ fmtflags __r = __fmtflags_;
+ __fmtflags_ |= __fmtfl;
+ return __r;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+ios_base::unsetf(fmtflags __mask)
+{
+ __fmtflags_ &= ~__mask;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base::fmtflags
+ios_base::setf(fmtflags __fmtfl, fmtflags __mask)
+{
+ fmtflags __r = __fmtflags_;
+ unsetf(__mask);
+ __fmtflags_ |= __fmtfl & __mask;
+ return __r;
+}
+
+// precision
+
+inline _LIBCPP_INLINE_VISIBILITY
+streamsize
+ios_base::precision() const
+{
+ return __precision_;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+streamsize
+ios_base::precision(streamsize __prec)
+{
+ streamsize __r = __precision_;
+ __precision_ = __prec;
+ return __r;
+}
+
+// width
+
+inline _LIBCPP_INLINE_VISIBILITY
+streamsize
+ios_base::width() const
+{
+ return __width_;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+streamsize
+ios_base::width(streamsize __wide)
+{
+ streamsize __r = __width_;
+ __width_ = __wide;
+ return __r;
+}
+
+// iostate
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base::iostate
+ios_base::rdstate() const
+{
+ return __rdstate_;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+ios_base::setstate(iostate __state)
+{
+ clear(__rdstate_ | __state);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+ios_base::good() const
+{
+ return __rdstate_ == 0;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+ios_base::eof() const
+{
+ return (__rdstate_ & eofbit) != 0;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+ios_base::fail() const
+{
+ return (__rdstate_ & (failbit | badbit)) != 0;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+ios_base::bad() const
+{
+ return (__rdstate_ & badbit) != 0;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base::iostate
+ios_base::exceptions() const
+{
+ return __exceptions_;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+ios_base::exceptions(iostate __iostate)
+{
+ __exceptions_ = __iostate;
+ clear(__rdstate_);
+}
+
+template <class _CharT, class _Traits>
+class _LIBCPP_TEMPLATE_VIS basic_ios
+ : public ios_base
+{
+public:
+ // types:
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+
+ static_assert((is_same<_CharT, typename traits_type::char_type>::value),
+ "traits_type::char_type must be the same type as CharT");
+
+#ifdef _LIBCPP_CXX03_LANG
+ // Preserve the ability to compare with literal 0,
+ // and implicitly convert to bool, but not implicitly convert to int.
+ _LIBCPP_INLINE_VISIBILITY
+ operator void*() const {return fail() ? nullptr : (void*)this;}
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit operator bool() const {return !fail();}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY bool operator!() const {return fail();}
+ _LIBCPP_INLINE_VISIBILITY iostate rdstate() const {return ios_base::rdstate();}
+ _LIBCPP_INLINE_VISIBILITY void clear(iostate __state = goodbit) {ios_base::clear(__state);}
+ _LIBCPP_INLINE_VISIBILITY void setstate(iostate __state) {ios_base::setstate(__state);}
+ _LIBCPP_INLINE_VISIBILITY bool good() const {return ios_base::good();}
+ _LIBCPP_INLINE_VISIBILITY bool eof() const {return ios_base::eof();}
+ _LIBCPP_INLINE_VISIBILITY bool fail() const {return ios_base::fail();}
+ _LIBCPP_INLINE_VISIBILITY bool bad() const {return ios_base::bad();}
+
+ _LIBCPP_INLINE_VISIBILITY iostate exceptions() const {return ios_base::exceptions();}
+ _LIBCPP_INLINE_VISIBILITY void exceptions(iostate __iostate) {ios_base::exceptions(__iostate);}
+
+ // 27.5.4.1 Constructor/destructor:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit basic_ios(basic_streambuf<char_type,traits_type>* __sb);
+ virtual ~basic_ios();
+
+ // 27.5.4.2 Members:
+ _LIBCPP_INLINE_VISIBILITY
+ basic_ostream<char_type, traits_type>* tie() const;
+ _LIBCPP_INLINE_VISIBILITY
+ basic_ostream<char_type, traits_type>* tie(basic_ostream<char_type, traits_type>* __tiestr);
+
+ _LIBCPP_INLINE_VISIBILITY
+ basic_streambuf<char_type, traits_type>* rdbuf() const;
+ _LIBCPP_INLINE_VISIBILITY
+ basic_streambuf<char_type, traits_type>* rdbuf(basic_streambuf<char_type, traits_type>* __sb);
+
+ basic_ios& copyfmt(const basic_ios& __rhs);
+
+ _LIBCPP_INLINE_VISIBILITY
+ char_type fill() const;
+ _LIBCPP_INLINE_VISIBILITY
+ char_type fill(char_type __ch);
+
+ _LIBCPP_INLINE_VISIBILITY
+ locale imbue(const locale& __loc);
+
+ _LIBCPP_INLINE_VISIBILITY
+ char narrow(char_type __c, char __dfault) const;
+ _LIBCPP_INLINE_VISIBILITY
+ char_type widen(char __c) const;
+
+protected:
+ _LIBCPP_INLINE_VISIBILITY
+ basic_ios() {// purposefully does no initialization
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ void init(basic_streambuf<char_type, traits_type>* __sb);
+
+ _LIBCPP_INLINE_VISIBILITY
+ void move(basic_ios& __rhs);
+ _LIBCPP_INLINE_VISIBILITY
+ void move(basic_ios&& __rhs) {move(__rhs);}
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(basic_ios& __rhs) _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ void set_rdbuf(basic_streambuf<char_type, traits_type>* __sb);
+private:
+ basic_ostream<char_type, traits_type>* __tie_;
+ mutable int_type __fill_;
+};
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ios<_CharT, _Traits>::basic_ios(basic_streambuf<char_type,traits_type>* __sb)
+{
+ init(__sb);
+}
+
+template <class _CharT, class _Traits>
+basic_ios<_CharT, _Traits>::~basic_ios()
+{
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_ios<_CharT, _Traits>::init(basic_streambuf<char_type, traits_type>* __sb)
+{
+ ios_base::init(__sb);
+ __tie_ = nullptr;
+ __fill_ = traits_type::eof();
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _Traits>*
+basic_ios<_CharT, _Traits>::tie() const
+{
+ return __tie_;
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _Traits>*
+basic_ios<_CharT, _Traits>::tie(basic_ostream<char_type, traits_type>* __tiestr)
+{
+ basic_ostream<char_type, traits_type>* __r = __tie_;
+ __tie_ = __tiestr;
+ return __r;
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_streambuf<_CharT, _Traits>*
+basic_ios<_CharT, _Traits>::rdbuf() const
+{
+ return static_cast<basic_streambuf<char_type, traits_type>*>(ios_base::rdbuf());
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_streambuf<_CharT, _Traits>*
+basic_ios<_CharT, _Traits>::rdbuf(basic_streambuf<char_type, traits_type>* __sb)
+{
+ basic_streambuf<char_type, traits_type>* __r = rdbuf();
+ ios_base::rdbuf(__sb);
+ return __r;
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+locale
+basic_ios<_CharT, _Traits>::imbue(const locale& __loc)
+{
+ locale __r = getloc();
+ ios_base::imbue(__loc);
+ if (rdbuf())
+ rdbuf()->pubimbue(__loc);
+ return __r;
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+char
+basic_ios<_CharT, _Traits>::narrow(char_type __c, char __dfault) const
+{
+ return use_facet<ctype<char_type> >(getloc()).narrow(__c, __dfault);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+_CharT
+basic_ios<_CharT, _Traits>::widen(char __c) const
+{
+ return use_facet<ctype<char_type> >(getloc()).widen(__c);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+_CharT
+basic_ios<_CharT, _Traits>::fill() const
+{
+ if (traits_type::eq_int_type(traits_type::eof(), __fill_))
+ __fill_ = widen(' ');
+ return __fill_;
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+_CharT
+basic_ios<_CharT, _Traits>::fill(char_type __ch)
+{
+ char_type __r = __fill_;
+ __fill_ = __ch;
+ return __r;
+}
+
+template <class _CharT, class _Traits>
+basic_ios<_CharT, _Traits>&
+basic_ios<_CharT, _Traits>::copyfmt(const basic_ios& __rhs)
+{
+ if (this != &__rhs)
+ {
+ __call_callbacks(erase_event);
+ ios_base::copyfmt(__rhs);
+ __tie_ = __rhs.__tie_;
+ __fill_ = __rhs.__fill_;
+ __call_callbacks(copyfmt_event);
+ exceptions(__rhs.exceptions());
+ }
+ return *this;
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_ios<_CharT, _Traits>::move(basic_ios& __rhs)
+{
+ ios_base::move(__rhs);
+ __tie_ = __rhs.__tie_;
+ __rhs.__tie_ = nullptr;
+ __fill_ = __rhs.__fill_;
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_ios<_CharT, _Traits>::swap(basic_ios& __rhs) _NOEXCEPT
+{
+ ios_base::swap(__rhs);
+ _VSTD::swap(__tie_, __rhs.__tie_);
+ _VSTD::swap(__fill_, __rhs.__fill_);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_ios<_CharT, _Traits>::set_rdbuf(basic_streambuf<char_type, traits_type>* __sb)
+{
+ ios_base::set_rdbuf(__sb);
+}
+
+inline
+ios_base&
+boolalpha(ios_base& __str)
+{
+ __str.setf(ios_base::boolalpha);
+ return __str;
+}
+
+inline
+ios_base&
+noboolalpha(ios_base& __str)
+{
+ __str.unsetf(ios_base::boolalpha);
+ return __str;
+}
+
+inline
+ios_base&
+showbase(ios_base& __str)
+{
+ __str.setf(ios_base::showbase);
+ return __str;
+}
+
+inline
+ios_base&
+noshowbase(ios_base& __str)
+{
+ __str.unsetf(ios_base::showbase);
+ return __str;
+}
+
+inline
+ios_base&
+showpoint(ios_base& __str)
+{
+ __str.setf(ios_base::showpoint);
+ return __str;
+}
+
+inline
+ios_base&
+noshowpoint(ios_base& __str)
+{
+ __str.unsetf(ios_base::showpoint);
+ return __str;
+}
+
+inline
+ios_base&
+showpos(ios_base& __str)
+{
+ __str.setf(ios_base::showpos);
+ return __str;
+}
+
+inline
+ios_base&
+noshowpos(ios_base& __str)
+{
+ __str.unsetf(ios_base::showpos);
+ return __str;
+}
+
+inline
+ios_base&
+skipws(ios_base& __str)
+{
+ __str.setf(ios_base::skipws);
+ return __str;
+}
+
+inline
+ios_base&
+noskipws(ios_base& __str)
+{
+ __str.unsetf(ios_base::skipws);
+ return __str;
+}
+
+inline
+ios_base&
+uppercase(ios_base& __str)
+{
+ __str.setf(ios_base::uppercase);
+ return __str;
+}
+
+inline
+ios_base&
+nouppercase(ios_base& __str)
+{
+ __str.unsetf(ios_base::uppercase);
+ return __str;
+}
+
+inline
+ios_base&
+unitbuf(ios_base& __str)
+{
+ __str.setf(ios_base::unitbuf);
+ return __str;
+}
+
+inline
+ios_base&
+nounitbuf(ios_base& __str)
+{
+ __str.unsetf(ios_base::unitbuf);
+ return __str;
+}
+
+inline
+ios_base&
+internal(ios_base& __str)
+{
+ __str.setf(ios_base::internal, ios_base::adjustfield);
+ return __str;
+}
+
+inline
+ios_base&
+left(ios_base& __str)
+{
+ __str.setf(ios_base::left, ios_base::adjustfield);
+ return __str;
+}
+
+inline
+ios_base&
+right(ios_base& __str)
+{
+ __str.setf(ios_base::right, ios_base::adjustfield);
+ return __str;
+}
+
+inline
+ios_base&
+dec(ios_base& __str)
+{
+ __str.setf(ios_base::dec, ios_base::basefield);
+ return __str;
+}
+
+inline
+ios_base&
+hex(ios_base& __str)
+{
+ __str.setf(ios_base::hex, ios_base::basefield);
+ return __str;
+}
+
+inline
+ios_base&
+oct(ios_base& __str)
+{
+ __str.setf(ios_base::oct, ios_base::basefield);
+ return __str;
+}
+
+inline
+ios_base&
+fixed(ios_base& __str)
+{
+ __str.setf(ios_base::fixed, ios_base::floatfield);
+ return __str;
+}
+
+inline
+ios_base&
+scientific(ios_base& __str)
+{
+ __str.setf(ios_base::scientific, ios_base::floatfield);
+ return __str;
+}
+
+inline
+ios_base&
+hexfloat(ios_base& __str)
+{
+ __str.setf(ios_base::fixed | ios_base::scientific, ios_base::floatfield);
+ return __str;
+}
+
+inline
+ios_base&
+defaultfloat(ios_base& __str)
+{
+ __str.unsetf(ios_base::floatfield);
+ return __str;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_IOS
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/iosfwd b/contrib/libs/cxxsupp/libcxxmsvc/include/iosfwd
new file mode 100644
index 0000000000..63850f2fc9
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/iosfwd
@@ -0,0 +1,292 @@
+// -*- 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_IOSFWD
+#define _LIBCPP_IOSFWD
+
+/*
+ iosfwd synopsis
+
+namespace std
+{
+
+template<class charT> struct char_traits;
+template<> struct char_traits<char>;
+template<> struct char_traits<char8_t>; // C++20
+template<> struct char_traits<char16_t>;
+template<> struct char_traits<char32_t>;
+template<> struct char_traits<wchar_t>;
+
+template<class T> class allocator;
+
+class ios_base;
+template <class charT, class traits = char_traits<charT> > class basic_ios;
+
+template <class charT, class traits = char_traits<charT> > class basic_streambuf;
+template <class charT, class traits = char_traits<charT> > class basic_istream;
+template <class charT, class traits = char_traits<charT> > class basic_ostream;
+template <class charT, class traits = char_traits<charT> > class basic_iostream;
+
+template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+ class basic_stringbuf;
+template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+ class basic_istringstream;
+template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+ class basic_ostringstream;
+template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+ class basic_stringstream;
+
+template <class charT, class traits = char_traits<charT> > class basic_filebuf;
+template <class charT, class traits = char_traits<charT> > class basic_ifstream;
+template <class charT, class traits = char_traits<charT> > class basic_ofstream;
+template <class charT, class traits = char_traits<charT> > class basic_fstream;
+
+template <class charT, class traits = char_traits<charT> > class istreambuf_iterator;
+template <class charT, class traits = char_traits<charT> > class ostreambuf_iterator;
+
+typedef basic_ios<char> ios;
+typedef basic_ios<wchar_t> wios;
+
+typedef basic_streambuf<char> streambuf;
+typedef basic_istream<char> istream;
+typedef basic_ostream<char> ostream;
+typedef basic_iostream<char> iostream;
+
+typedef basic_stringbuf<char> stringbuf;
+typedef basic_istringstream<char> istringstream;
+typedef basic_ostringstream<char> ostringstream;
+typedef basic_stringstream<char> stringstream;
+
+typedef basic_filebuf<char> filebuf;
+typedef basic_ifstream<char> ifstream;
+typedef basic_ofstream<char> ofstream;
+typedef basic_fstream<char> fstream;
+
+typedef basic_streambuf<wchar_t> wstreambuf;
+typedef basic_istream<wchar_t> wistream;
+typedef basic_ostream<wchar_t> wostream;
+typedef basic_iostream<wchar_t> wiostream;
+
+typedef basic_stringbuf<wchar_t> wstringbuf;
+typedef basic_istringstream<wchar_t> wistringstream;
+typedef basic_ostringstream<wchar_t> wostringstream;
+typedef basic_stringstream<wchar_t> wstringstream;
+
+typedef basic_filebuf<wchar_t> wfilebuf;
+typedef basic_ifstream<wchar_t> wifstream;
+typedef basic_ofstream<wchar_t> wofstream;
+typedef basic_fstream<wchar_t> wfstream;
+
+template <class state> class fpos;
+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
+
+*/
+
+#include <__config>
+#include <__mbstate_t.h>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+class _LIBCPP_TYPE_VIS ios_base;
+
+template<class _CharT> struct _LIBCPP_TEMPLATE_VIS char_traits;
+template<> struct char_traits<char>;
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
+template<> struct char_traits<char8_t>;
+#endif
+template<> struct char_traits<char16_t>;
+template<> struct char_traits<char32_t>;
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template<> struct char_traits<wchar_t>;
+#endif
+
+template<class _Tp> class _LIBCPP_TEMPLATE_VIS allocator;
+
+template <class _CharT, class _Traits = char_traits<_CharT> >
+ class _LIBCPP_TEMPLATE_VIS basic_ios;
+
+template <class _CharT, class _Traits = char_traits<_CharT> >
+ class _LIBCPP_TEMPLATE_VIS basic_streambuf;
+template <class _CharT, class _Traits = char_traits<_CharT> >
+ class _LIBCPP_TEMPLATE_VIS basic_istream;
+template <class _CharT, class _Traits = char_traits<_CharT> >
+ class _LIBCPP_TEMPLATE_VIS basic_ostream;
+template <class _CharT, class _Traits = char_traits<_CharT> >
+ class _LIBCPP_TEMPLATE_VIS basic_iostream;
+
+template <class _CharT, class _Traits = char_traits<_CharT>,
+ class _Allocator = allocator<_CharT> >
+ class _LIBCPP_TEMPLATE_VIS basic_stringbuf;
+template <class _CharT, class _Traits = char_traits<_CharT>,
+ class _Allocator = allocator<_CharT> >
+ class _LIBCPP_TEMPLATE_VIS basic_istringstream;
+template <class _CharT, class _Traits = char_traits<_CharT>,
+ class _Allocator = allocator<_CharT> >
+ class _LIBCPP_TEMPLATE_VIS basic_ostringstream;
+template <class _CharT, class _Traits = char_traits<_CharT>,
+ class _Allocator = allocator<_CharT> >
+ class _LIBCPP_TEMPLATE_VIS basic_stringstream;
+
+template <class _CharT, class _Traits = char_traits<_CharT> >
+ class _LIBCPP_TEMPLATE_VIS basic_filebuf;
+template <class _CharT, class _Traits = char_traits<_CharT> >
+ class _LIBCPP_TEMPLATE_VIS basic_ifstream;
+template <class _CharT, class _Traits = char_traits<_CharT> >
+ class _LIBCPP_TEMPLATE_VIS basic_ofstream;
+template <class _CharT, class _Traits = char_traits<_CharT> >
+ class _LIBCPP_TEMPLATE_VIS basic_fstream;
+
+template <class _CharT, class _Traits = char_traits<_CharT> >
+ class _LIBCPP_TEMPLATE_VIS istreambuf_iterator;
+template <class _CharT, class _Traits = char_traits<_CharT> >
+ class _LIBCPP_TEMPLATE_VIS ostreambuf_iterator;
+
+typedef basic_ios<char> ios;
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+typedef basic_ios<wchar_t> wios;
+#endif
+
+typedef basic_streambuf<char> streambuf;
+typedef basic_istream<char> istream;
+typedef basic_ostream<char> ostream;
+typedef basic_iostream<char> iostream;
+
+typedef basic_stringbuf<char> stringbuf;
+typedef basic_istringstream<char> istringstream;
+typedef basic_ostringstream<char> ostringstream;
+typedef basic_stringstream<char> stringstream;
+
+typedef basic_filebuf<char> filebuf;
+typedef basic_ifstream<char> ifstream;
+typedef basic_ofstream<char> ofstream;
+typedef basic_fstream<char> fstream;
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+typedef basic_streambuf<wchar_t> wstreambuf;
+typedef basic_istream<wchar_t> wistream;
+typedef basic_ostream<wchar_t> wostream;
+typedef basic_iostream<wchar_t> wiostream;
+
+typedef basic_stringbuf<wchar_t> wstringbuf;
+typedef basic_istringstream<wchar_t> wistringstream;
+typedef basic_ostringstream<wchar_t> wostringstream;
+typedef basic_stringstream<wchar_t> wstringstream;
+
+typedef basic_filebuf<wchar_t> wfilebuf;
+typedef basic_ifstream<wchar_t> wifstream;
+typedef basic_ofstream<wchar_t> wofstream;
+typedef basic_fstream<wchar_t> wfstream;
+#endif
+
+template <class _CharT, class _Traits>
+ class _LIBCPP_PREFERRED_NAME(ios) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wios)) basic_ios;
+
+template <class _CharT, class _Traits>
+ class _LIBCPP_PREFERRED_NAME(streambuf) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstreambuf)) basic_streambuf;
+template <class _CharT, class _Traits>
+ class _LIBCPP_PREFERRED_NAME(istream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wistream)) basic_istream;
+template <class _CharT, class _Traits>
+ class _LIBCPP_PREFERRED_NAME(ostream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wostream)) basic_ostream;
+template <class _CharT, class _Traits>
+ class _LIBCPP_PREFERRED_NAME(iostream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wiostream)) basic_iostream;
+
+template <class _CharT, class _Traits, class _Allocator>
+ class _LIBCPP_PREFERRED_NAME(stringbuf) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstringbuf)) basic_stringbuf;
+template <class _CharT, class _Traits, class _Allocator>
+ class _LIBCPP_PREFERRED_NAME(istringstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wistringstream)) basic_istringstream;
+template <class _CharT, class _Traits, class _Allocator>
+ class _LIBCPP_PREFERRED_NAME(ostringstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wostringstream)) basic_ostringstream;
+template <class _CharT, class _Traits, class _Allocator>
+ class _LIBCPP_PREFERRED_NAME(stringstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstringstream)) basic_stringstream;
+
+template <class _CharT, class _Traits>
+ class _LIBCPP_PREFERRED_NAME(filebuf) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wfilebuf)) basic_filebuf;
+template <class _CharT, class _Traits>
+ class _LIBCPP_PREFERRED_NAME(ifstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wifstream)) basic_ifstream;
+template <class _CharT, class _Traits>
+ class _LIBCPP_PREFERRED_NAME(ofstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wofstream)) basic_ofstream;
+template <class _CharT, class _Traits>
+ class _LIBCPP_PREFERRED_NAME(fstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wfstream)) basic_fstream;
+
+template <class _State> class _LIBCPP_TEMPLATE_VIS fpos;
+typedef fpos<mbstate_t> streampos;
+typedef fpos<mbstate_t> wstreampos;
+#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
+
+#if defined(_NEWLIB_VERSION)
+// On newlib, off_t is 'long int'
+typedef long int streamoff; // for char_traits in <string>
+#else
+typedef long long streamoff; // for char_traits in <string>
+#endif
+
+template <class _CharT, // for <stdexcept>
+ class _Traits = char_traits<_CharT>,
+ class _Allocator = allocator<_CharT> >
+ class _LIBCPP_TEMPLATE_VIS basic_string;
+typedef basic_string<char, char_traits<char>, allocator<char> > string;
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+typedef basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstring;
+#endif
+typedef basic_string<char16_t, char_traits<char16_t>, allocator<char16_t> > u16string;
+
+template <class _CharT, class _Traits, class _Allocator>
+ class _LIBCPP_PREFERRED_NAME(string) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstring)) basic_string;
+
+// Include other forward declarations here
+template <class _Tp, class _Alloc = allocator<_Tp> >
+class _LIBCPP_TEMPLATE_VIS vector;
+
+template <class _CharT, class _Traits>
+class __save_flags
+{
+ typedef basic_ios<_CharT, _Traits> __stream_type;
+ typedef typename __stream_type::fmtflags fmtflags;
+
+ __stream_type& __stream_;
+ fmtflags __fmtflags_;
+ _CharT __fill_;
+
+ __save_flags(const __save_flags&);
+ __save_flags& operator=(const __save_flags&);
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __save_flags(__stream_type& __stream)
+ : __stream_(__stream),
+ __fmtflags_(__stream.flags()),
+ __fill_(__stream.fill())
+ {}
+ _LIBCPP_INLINE_VISIBILITY
+ ~__save_flags()
+ {
+ __stream_.flags(__fmtflags_);
+ __stream_.fill(__fill_);
+ }
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_IOSFWD
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/iostream b/contrib/libs/cxxsupp/libcxxmsvc/include/iostream
new file mode 100644
index 0000000000..dbabf3ad32
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/iostream
@@ -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_IOSTREAM
+#define _LIBCPP_IOSTREAM
+
+/*
+ iostream synopsis
+
+#include <ios>
+#include <istream>
+#include <ostream>
+#include <streambuf>
+
+namespace std {
+
+extern istream cin;
+extern ostream cout;
+extern ostream cerr;
+extern ostream clog;
+extern wistream wcin;
+extern wostream wcout;
+extern wostream wcerr;
+extern wostream wclog;
+
+} // std
+
+*/
+
+#include <__config>
+#include <ios>
+#include <istream>
+#include <ostream>
+#include <streambuf>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if defined(_MSC_VER) && !defined(__clang__)
+extern _LIBCPP_FUNC_VIS istream& cin;
+#else
+extern _LIBCPP_FUNC_VIS istream cin;
+#endif
+#if defined(_MSC_VER) && !defined(__clang__)
+extern _LIBCPP_FUNC_VIS ostream& cout;
+#else
+extern _LIBCPP_FUNC_VIS ostream cout;
+#endif
+#if defined(_MSC_VER) && !defined(__clang__)
+extern _LIBCPP_FUNC_VIS ostream& cerr;
+extern _LIBCPP_FUNC_VIS ostream& clog;
+#else
+extern _LIBCPP_FUNC_VIS ostream cerr;
+extern _LIBCPP_FUNC_VIS ostream clog;
+#endif
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+#if defined(_MSC_VER) && !defined(__clang__)
+extern _LIBCPP_FUNC_VIS wistream& wcin;
+#else
+extern _LIBCPP_FUNC_VIS wistream wcin;
+#endif
+#if defined(_MSC_VER) && !defined(__clang__)
+extern _LIBCPP_FUNC_VIS wostream& wcout;
+#else
+extern _LIBCPP_FUNC_VIS wostream wcout;
+#endif
+#if defined(_MSC_VER) && !defined(__clang__)
+extern _LIBCPP_FUNC_VIS wostream& wcerr;
+extern _LIBCPP_FUNC_VIS wostream& wclog;
+#else
+extern _LIBCPP_FUNC_VIS wostream wcerr;
+extern _LIBCPP_FUNC_VIS wostream wclog;
+#endif
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_IOSTREAM
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/istream b/contrib/libs/cxxsupp/libcxxmsvc/include/istream
new file mode 100644
index 0000000000..8735a79c21
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/istream
@@ -0,0 +1,1640 @@
+// -*- 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_ISTREAM
+#define _LIBCPP_ISTREAM
+
+/*
+ istream synopsis
+
+template <class charT, class traits = char_traits<charT> >
+class basic_istream
+ : virtual public basic_ios<charT,traits>
+{
+public:
+ // types (inherited from basic_ios (27.5.4)):
+ typedef charT char_type;
+ typedef traits traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+
+ // 27.7.1.1.1 Constructor/destructor:
+ explicit basic_istream(basic_streambuf<char_type, traits_type>* sb);
+ basic_istream(basic_istream&& rhs);
+ virtual ~basic_istream();
+
+ // 27.7.1.1.2 Assign/swap:
+ basic_istream& operator=(basic_istream&& rhs);
+ void swap(basic_istream& rhs);
+
+ // 27.7.1.1.3 Prefix/suffix:
+ class sentry;
+
+ // 27.7.1.2 Formatted input:
+ basic_istream& operator>>(basic_istream& (*pf)(basic_istream&));
+ basic_istream& operator>>(basic_ios<char_type, traits_type>&
+ (*pf)(basic_ios<char_type, traits_type>&));
+ basic_istream& operator>>(ios_base& (*pf)(ios_base&));
+ basic_istream& operator>>(basic_streambuf<char_type, traits_type>* sb);
+ basic_istream& operator>>(bool& n);
+ basic_istream& operator>>(short& n);
+ basic_istream& operator>>(unsigned short& n);
+ basic_istream& operator>>(int& n);
+ basic_istream& operator>>(unsigned int& n);
+ basic_istream& operator>>(long& n);
+ basic_istream& operator>>(unsigned long& n);
+ basic_istream& operator>>(long long& n);
+ basic_istream& operator>>(unsigned long long& n);
+ basic_istream& operator>>(float& f);
+ basic_istream& operator>>(double& f);
+ basic_istream& operator>>(long double& f);
+ basic_istream& operator>>(void*& p);
+
+ // 27.7.1.3 Unformatted input:
+ streamsize gcount() const;
+ int_type get();
+ basic_istream& get(char_type& c);
+ basic_istream& get(char_type* s, streamsize n);
+ basic_istream& get(char_type* s, streamsize n, char_type delim);
+ basic_istream& get(basic_streambuf<char_type,traits_type>& sb);
+ basic_istream& get(basic_streambuf<char_type,traits_type>& sb, char_type delim);
+
+ basic_istream& getline(char_type* s, streamsize n);
+ basic_istream& getline(char_type* s, streamsize n, char_type delim);
+
+ basic_istream& ignore(streamsize n = 1, int_type delim = traits_type::eof());
+ int_type peek();
+ basic_istream& read (char_type* s, streamsize n);
+ streamsize readsome(char_type* s, streamsize n);
+
+ basic_istream& putback(char_type c);
+ basic_istream& unget();
+ int sync();
+
+ pos_type tellg();
+ basic_istream& seekg(pos_type);
+ basic_istream& seekg(off_type, ios_base::seekdir);
+protected:
+ basic_istream(const basic_istream& rhs) = delete;
+ basic_istream(basic_istream&& rhs);
+ // 27.7.2.1.2 Assign/swap:
+ basic_istream& operator=(const basic_istream& rhs) = delete;
+ basic_istream& operator=(basic_istream&& rhs);
+ void swap(basic_istream& rhs);
+};
+
+// 27.7.1.2.3 character extraction templates:
+template<class charT, class traits>
+ basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&, charT&);
+
+template<class traits>
+ basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, unsigned char&);
+
+template<class traits>
+ basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, signed char&);
+
+template<class charT, class traits>
+ basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&, charT*);
+
+template<class traits>
+ basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, unsigned char*);
+
+template<class traits>
+ basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, signed char*);
+
+template <class charT, class traits>
+ void
+ swap(basic_istream<charT, traits>& x, basic_istream<charT, traits>& y);
+
+typedef basic_istream<char> istream;
+typedef basic_istream<wchar_t> wistream;
+
+template <class charT, class traits = char_traits<charT> >
+class basic_iostream :
+ public basic_istream<charT,traits>,
+ public basic_ostream<charT,traits>
+{
+public:
+ // types:
+ typedef charT char_type;
+ typedef traits traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+
+ // constructor/destructor
+ explicit basic_iostream(basic_streambuf<char_type, traits_type>* sb);
+ basic_iostream(basic_iostream&& rhs);
+ virtual ~basic_iostream();
+
+ // assign/swap
+ basic_iostream& operator=(basic_iostream&& rhs);
+ void swap(basic_iostream& rhs);
+};
+
+template <class charT, class traits>
+ void
+ swap(basic_iostream<charT, traits>& x, basic_iostream<charT, traits>& y);
+
+typedef basic_iostream<char> iostream;
+typedef basic_iostream<wchar_t> wiostream;
+
+template <class charT, class traits>
+ basic_istream<charT,traits>&
+ ws(basic_istream<charT,traits>& is);
+
+// rvalue stream extraction
+template <class Stream, class T>
+ Stream&& operator>>(Stream&& is, T&& x);
+
+} // std
+
+*/
+
+#include <__config>
+#include <__utility/forward.h>
+#include <ostream>
+#include <version>
+
+#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 _CharT, class _Traits>
+class _LIBCPP_TEMPLATE_VIS basic_istream
+ : virtual public basic_ios<_CharT, _Traits>
+{
+ streamsize __gc_;
+public:
+ // types (inherited from basic_ios (27.5.4)):
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+
+ // 27.7.1.1.1 Constructor/destructor:
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ explicit basic_istream(basic_streambuf<char_type, traits_type>* __sb) : __gc_(0)
+ { this->init(__sb); }
+ virtual ~basic_istream();
+protected:
+ 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);
+
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ void swap(basic_istream& __rhs) {
+ _VSTD::swap(__gc_, __rhs.__gc_);
+ basic_ios<char_type, traits_type>::swap(__rhs);
+ }
+
+ basic_istream (const basic_istream& __rhs) = delete;
+ basic_istream& operator=(const basic_istream& __rhs) = delete;
+public:
+
+ // 27.7.1.1.3 Prefix/suffix:
+ class _LIBCPP_TEMPLATE_VIS sentry;
+
+ // 27.7.1.2 Formatted input:
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ basic_istream& operator>>(basic_istream& (*__pf)(basic_istream&))
+ { return __pf(*this); }
+
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ basic_istream& operator>>(basic_ios<char_type, traits_type>&
+ (*__pf)(basic_ios<char_type, traits_type>&))
+ { __pf(*this); return *this; }
+
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ basic_istream& operator>>(ios_base& (*__pf)(ios_base&))
+ { __pf(*this); return *this; }
+
+ basic_istream& operator>>(basic_streambuf<char_type, traits_type>* __sb);
+ basic_istream& operator>>(bool& __n);
+ basic_istream& operator>>(short& __n);
+ basic_istream& operator>>(unsigned short& __n);
+ basic_istream& operator>>(int& __n);
+ basic_istream& operator>>(unsigned int& __n);
+ basic_istream& operator>>(long& __n);
+ basic_istream& operator>>(unsigned long& __n);
+ basic_istream& operator>>(long long& __n);
+ basic_istream& operator>>(unsigned long long& __n);
+ basic_istream& operator>>(float& __f);
+ basic_istream& operator>>(double& __f);
+ basic_istream& operator>>(long double& __f);
+ basic_istream& operator>>(void*& __p);
+
+ // 27.7.1.3 Unformatted input:
+ _LIBCPP_INLINE_VISIBILITY
+ streamsize gcount() const {return __gc_;}
+ int_type get();
+
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ basic_istream& get(char_type& __c) {
+ int_type __ch = get();
+ if (__ch != traits_type::eof())
+ __c = traits_type::to_char_type(__ch);
+ return *this;
+ }
+
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ basic_istream& get(char_type* __s, streamsize __n)
+ { return get(__s, __n, this->widen('\n')); }
+
+ basic_istream& get(char_type* __s, streamsize __n, char_type __dlm);
+
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ basic_istream& get(basic_streambuf<char_type, traits_type>& __sb)
+ { return get(__sb, this->widen('\n')); }
+
+ basic_istream& get(basic_streambuf<char_type, traits_type>& __sb, char_type __dlm);
+
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ basic_istream& getline(char_type* __s, streamsize __n)
+ { return getline(__s, __n, this->widen('\n')); }
+
+ basic_istream& getline(char_type* __s, streamsize __n, char_type __dlm);
+
+ basic_istream& ignore(streamsize __n = 1, int_type __dlm = traits_type::eof());
+ int_type peek();
+ basic_istream& read (char_type* __s, streamsize __n);
+ streamsize readsome(char_type* __s, streamsize __n);
+
+ basic_istream& putback(char_type __c);
+ basic_istream& unget();
+ int sync();
+
+ pos_type tellg();
+ basic_istream& seekg(pos_type __pos);
+ basic_istream& seekg(off_type __off, ios_base::seekdir __dir);
+};
+
+template <class _CharT, class _Traits>
+class _LIBCPP_TEMPLATE_VIS basic_istream<_CharT, _Traits>::sentry
+{
+ bool __ok_;
+
+public:
+ explicit sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false);
+// ~sentry() = default;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit operator bool() const {return __ok_;}
+
+ sentry(const sentry&) = delete;
+ sentry& operator=(const sentry&) = delete;
+};
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>::sentry::sentry(basic_istream<_CharT, _Traits>& __is,
+ bool __noskipws)
+ : __ok_(false)
+{
+ if (__is.good())
+ {
+ if (__is.tie())
+ __is.tie()->flush();
+ if (!__noskipws && (__is.flags() & ios_base::skipws))
+ {
+ typedef istreambuf_iterator<_CharT, _Traits> _Ip;
+ const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
+ _Ip __i(__is);
+ _Ip __eof;
+ for (; __i != __eof; ++__i)
+ if (!__ct.is(__ct.space, *__i))
+ break;
+ if (__i == __eof)
+ __is.setstate(ios_base::failbit | ios_base::eofbit);
+ }
+ __ok_ = __is.good();
+ }
+ else
+ __is.setstate(ios_base::failbit);
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>::basic_istream(basic_istream&& __rhs)
+ : __gc_(__rhs.__gc_)
+{
+ __rhs.__gc_ = 0;
+ this->move(__rhs);
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator=(basic_istream&& __rhs)
+{
+ swap(__rhs);
+ return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>::~basic_istream()
+{
+}
+
+template <class _Tp, class _CharT, class _Traits>
+_LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>&
+__input_arithmetic(basic_istream<_CharT, _Traits>& __is, _Tp& __n) {
+ ios_base::iostate __state = ios_base::goodbit;
+ typename basic_istream<_CharT, _Traits>::sentry __s(__is);
+ if (__s)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#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);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ __is.__setstate_nothrow(__state);
+ if (__is.exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
+#endif
+ __is.setstate(__state);
+ }
+ return __is;
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator>>(unsigned short& __n)
+{
+ return _VSTD::__input_arithmetic<unsigned short>(*this, __n);
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator>>(unsigned int& __n)
+{
+ return _VSTD::__input_arithmetic<unsigned int>(*this, __n);
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator>>(long& __n)
+{
+ return _VSTD::__input_arithmetic<long>(*this, __n);
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator>>(unsigned long& __n)
+{
+ return _VSTD::__input_arithmetic<unsigned long>(*this, __n);
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator>>(long long& __n)
+{
+ return _VSTD::__input_arithmetic<long long>(*this, __n);
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator>>(unsigned long long& __n)
+{
+ return _VSTD::__input_arithmetic<unsigned long long>(*this, __n);
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator>>(float& __n)
+{
+ return _VSTD::__input_arithmetic<float>(*this, __n);
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator>>(double& __n)
+{
+ return _VSTD::__input_arithmetic<double>(*this, __n);
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator>>(long double& __n)
+{
+ return _VSTD::__input_arithmetic<long double>(*this, __n);
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator>>(bool& __n)
+{
+ return _VSTD::__input_arithmetic<bool>(*this, __n);
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator>>(void*& __n)
+{
+ return _VSTD::__input_arithmetic<void*>(*this, __n);
+}
+
+template <class _Tp, class _CharT, class _Traits>
+_LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>&
+__input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp& __n) {
+ ios_base::iostate __state = ios_base::goodbit;
+ typename basic_istream<_CharT, _Traits>::sentry __s(__is);
+ if (__s)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ typedef istreambuf_iterator<_CharT, _Traits> _Ip;
+ typedef num_get<_CharT, _Ip> _Fp;
+ long __temp;
+ use_facet<_Fp>(__is.getloc()).get(_Ip(__is), _Ip(), __is, __state, __temp);
+ if (__temp < numeric_limits<_Tp>::min())
+ {
+ __state |= ios_base::failbit;
+ __n = numeric_limits<_Tp>::min();
+ }
+ else if (__temp > numeric_limits<_Tp>::max())
+ {
+ __state |= ios_base::failbit;
+ __n = numeric_limits<_Tp>::max();
+ }
+ else
+ {
+ __n = static_cast<_Tp>(__temp);
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ __is.__setstate_nothrow(__state);
+ if (__is.exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ __is.setstate(__state);
+ }
+ return __is;
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator>>(short& __n)
+{
+ return _VSTD::__input_arithmetic_with_numeric_limits<short>(*this, __n);
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator>>(int& __n)
+{
+ return _VSTD::__input_arithmetic_with_numeric_limits<int>(*this, __n);
+}
+
+template<class _CharT, class _Traits>
+_LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>&
+__input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n)
+{
+ ios_base::iostate __state = ios_base::goodbit;
+ typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
+ if (__sen)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif
+ _CharT* __s = __p;
+ const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
+ while (__s != __p + (__n-1))
+ {
+ typename _Traits::int_type __i = __is.rdbuf()->sgetc();
+ if (_Traits::eq_int_type(__i, _Traits::eof()))
+ {
+ __state |= ios_base::eofbit;
+ break;
+ }
+ _CharT __ch = _Traits::to_char_type(__i);
+ if (__ct.is(__ct.space, __ch))
+ break;
+ *__s++ = __ch;
+ __is.rdbuf()->sbumpc();
+ }
+ *__s = _CharT();
+ __is.width(0);
+ if (__s == __p)
+ __state |= ios_base::failbit;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ __is.__setstate_nothrow(__state);
+ if (__is.exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
+#endif
+ __is.setstate(__state);
+ }
+ return __is;
+}
+
+#if _LIBCPP_STD_VER > 17
+
+template<class _CharT, class _Traits, size_t _Np>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is, _CharT (&__buf)[_Np])
+{
+ size_t __n = _Np;
+ if (__is.width() > 0)
+ __n = _VSTD::min(size_t(__is.width()), _Np);
+ return _VSTD::__input_c_string(__is, __buf, __n);
+}
+
+template<class _Traits, size_t _Np>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<char, _Traits>&
+operator>>(basic_istream<char, _Traits>& __is, unsigned char (&__buf)[_Np])
+{
+ return __is >> (char(&)[_Np])__buf;
+}
+
+template<class _Traits, size_t _Np>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<char, _Traits>&
+operator>>(basic_istream<char, _Traits>& __is, signed char (&__buf)[_Np])
+{
+ return __is >> (char(&)[_Np])__buf;
+}
+
+#else
+
+template<class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is, _CharT* __s)
+{
+ streamsize __n = __is.width();
+ if (__n <= 0)
+ __n = numeric_limits<streamsize>::max() / sizeof(_CharT) - 1;
+ return _VSTD::__input_c_string(__is, __s, size_t(__n));
+}
+
+template<class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<char, _Traits>&
+operator>>(basic_istream<char, _Traits>& __is, unsigned char* __s)
+{
+ return __is >> (char*)__s;
+}
+
+template<class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<char, _Traits>&
+operator>>(basic_istream<char, _Traits>& __is, signed char* __s)
+{
+ return __is >> (char*)__s;
+}
+
+#endif // _LIBCPP_STD_VER > 17
+
+template<class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is, _CharT& __c)
+{
+ ios_base::iostate __state = ios_base::goodbit;
+ typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
+ if (__sen)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif
+ typename _Traits::int_type __i = __is.rdbuf()->sbumpc();
+ if (_Traits::eq_int_type(__i, _Traits::eof()))
+ __state |= ios_base::eofbit | ios_base::failbit;
+ else
+ __c = _Traits::to_char_type(__i);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ __is.__setstate_nothrow(__state);
+ if (__is.exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
+#endif
+ __is.setstate(__state);
+ }
+ return __is;
+}
+
+template<class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<char, _Traits>&
+operator>>(basic_istream<char, _Traits>& __is, unsigned char& __c)
+{
+ return __is >> (char&)__c;
+}
+
+template<class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<char, _Traits>&
+operator>>(basic_istream<char, _Traits>& __is, signed char& __c)
+{
+ return __is >> (char&)__c;
+}
+
+template<class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_type>* __sb)
+{
+ ios_base::iostate __state = ios_base::goodbit;
+ __gc_ = 0;
+ sentry __s(*this, true);
+ if (__s)
+ {
+ if (__sb)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ while (true)
+ {
+ typename traits_type::int_type __i = this->rdbuf()->sgetc();
+ if (traits_type::eq_int_type(__i, _Traits::eof()))
+ {
+ __state |= ios_base::eofbit;
+ break;
+ }
+ if (traits_type::eq_int_type(
+ __sb->sputc(traits_type::to_char_type(__i)),
+ traits_type::eof()))
+ break;
+ ++__gc_;
+ this->rdbuf()->sbumpc();
+ }
+ if (__gc_ == 0)
+ __state |= ios_base::failbit;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ if (__gc_ == 0)
+ __state |= ios_base::failbit;
+
+ this->__setstate_nothrow(__state);
+ if (this->exceptions() & ios_base::failbit || this->exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ }
+ else
+ {
+ __state |= ios_base::failbit;
+ }
+ this->setstate(__state);
+ }
+ return *this;
+}
+
+template<class _CharT, class _Traits>
+typename basic_istream<_CharT, _Traits>::int_type
+basic_istream<_CharT, _Traits>::get()
+{
+ ios_base::iostate __state = ios_base::goodbit;
+ __gc_ = 0;
+ int_type __r = traits_type::eof();
+ sentry __s(*this, true);
+ if (__s)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif
+ __r = this->rdbuf()->sbumpc();
+ if (traits_type::eq_int_type(__r, traits_type::eof()))
+ __state |= ios_base::failbit | ios_base::eofbit;
+ else
+ __gc_ = 1;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ this->__setstate_nothrow(this->rdstate() | ios_base::badbit);
+ if (this->exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
+#endif
+ this->setstate(__state);
+ }
+ return __r;
+}
+
+template<class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n, char_type __dlm)
+{
+ ios_base::iostate __state = ios_base::goodbit;
+ __gc_ = 0;
+ sentry __sen(*this, true);
+ if (__sen)
+ {
+ if (__n > 0)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif
+ while (__gc_ < __n-1)
+ {
+ int_type __i = this->rdbuf()->sgetc();
+ if (traits_type::eq_int_type(__i, traits_type::eof()))
+ {
+ __state |= ios_base::eofbit;
+ break;
+ }
+ char_type __ch = traits_type::to_char_type(__i);
+ if (traits_type::eq(__ch, __dlm))
+ break;
+ *__s++ = __ch;
+ ++__gc_;
+ this->rdbuf()->sbumpc();
+ }
+ if (__gc_ == 0)
+ __state |= ios_base::failbit;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ this->__setstate_nothrow(__state);
+ if (this->exceptions() & ios_base::badbit)
+ {
+ if (__n > 0)
+ *__s = char_type();
+ throw;
+ }
+ }
+#endif
+ }
+ else
+ {
+ __state |= ios_base::failbit;
+ }
+
+ if (__n > 0)
+ *__s = char_type();
+ this->setstate(__state);
+ }
+ if (__n > 0)
+ *__s = char_type();
+ return *this;
+}
+
+template<class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __sb,
+ char_type __dlm)
+{
+ ios_base::iostate __state = ios_base::goodbit;
+ __gc_ = 0;
+ sentry __sen(*this, true);
+ if (__sen)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ while (true)
+ {
+ typename traits_type::int_type __i = this->rdbuf()->sgetc();
+ if (traits_type::eq_int_type(__i, traits_type::eof()))
+ {
+ __state |= ios_base::eofbit;
+ break;
+ }
+ char_type __ch = traits_type::to_char_type(__i);
+ if (traits_type::eq(__ch, __dlm))
+ break;
+ if (traits_type::eq_int_type(__sb.sputc(__ch), traits_type::eof()))
+ break;
+ ++__gc_;
+ this->rdbuf()->sbumpc();
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ // according to the spec, exceptions here are caught but not rethrown
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ if (__gc_ == 0)
+ __state |= ios_base::failbit;
+ this->setstate(__state);
+ }
+ return *this;
+}
+
+template<class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_type __dlm)
+{
+ ios_base::iostate __state = ios_base::goodbit;
+ __gc_ = 0;
+ sentry __sen(*this, true);
+ if (__sen)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ while (true)
+ {
+ typename traits_type::int_type __i = this->rdbuf()->sgetc();
+ if (traits_type::eq_int_type(__i, traits_type::eof()))
+ {
+ __state |= ios_base::eofbit;
+ break;
+ }
+ char_type __ch = traits_type::to_char_type(__i);
+ if (traits_type::eq(__ch, __dlm))
+ {
+ this->rdbuf()->sbumpc();
+ ++__gc_;
+ break;
+ }
+ if (__gc_ >= __n-1)
+ {
+ __state |= ios_base::failbit;
+ break;
+ }
+ *__s++ = __ch;
+ this->rdbuf()->sbumpc();
+ ++__gc_;
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ this->__setstate_nothrow(__state);
+ if (this->exceptions() & ios_base::badbit)
+ {
+ if (__n > 0)
+ *__s = char_type();
+ if (__gc_ == 0)
+ __state |= ios_base::failbit;
+ throw;
+ }
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ }
+ if (__n > 0)
+ *__s = char_type();
+ if (__gc_ == 0)
+ __state |= ios_base::failbit;
+ this->setstate(__state);
+ return *this;
+}
+
+template<class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __dlm)
+{
+ ios_base::iostate __state = ios_base::goodbit;
+ __gc_ = 0;
+ sentry __sen(*this, true);
+ if (__sen)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ if (__n == numeric_limits<streamsize>::max())
+ {
+ while (true)
+ {
+ typename traits_type::int_type __i = this->rdbuf()->sbumpc();
+ if (traits_type::eq_int_type(__i, traits_type::eof()))
+ {
+ __state |= ios_base::eofbit;
+ break;
+ }
+ ++__gc_;
+ if (traits_type::eq_int_type(__i, __dlm))
+ break;
+ }
+ }
+ else
+ {
+ while (__gc_ < __n)
+ {
+ typename traits_type::int_type __i = this->rdbuf()->sbumpc();
+ if (traits_type::eq_int_type(__i, traits_type::eof()))
+ {
+ __state |= ios_base::eofbit;
+ break;
+ }
+ ++__gc_;
+ if (traits_type::eq_int_type(__i, __dlm))
+ break;
+ }
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ this->__setstate_nothrow(__state);
+ if (this->exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ this->setstate(__state);
+ }
+ return *this;
+}
+
+template<class _CharT, class _Traits>
+typename basic_istream<_CharT, _Traits>::int_type
+basic_istream<_CharT, _Traits>::peek()
+{
+ ios_base::iostate __state = ios_base::goodbit;
+ __gc_ = 0;
+ int_type __r = traits_type::eof();
+ sentry __sen(*this, true);
+ if (__sen)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ __r = this->rdbuf()->sgetc();
+ if (traits_type::eq_int_type(__r, traits_type::eof()))
+ __state |= ios_base::eofbit;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ this->__setstate_nothrow(__state);
+ if (this->exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ this->setstate(__state);
+ }
+ return __r;
+}
+
+template<class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::read(char_type* __s, streamsize __n)
+{
+ ios_base::iostate __state = ios_base::goodbit;
+ __gc_ = 0;
+ sentry __sen(*this, true);
+ if (__sen)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ __gc_ = this->rdbuf()->sgetn(__s, __n);
+ if (__gc_ != __n)
+ __state |= ios_base::failbit | ios_base::eofbit;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ this->__setstate_nothrow(__state);
+ if (this->exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ }
+ else
+ {
+ __state |= ios_base::failbit;
+ }
+ this->setstate(__state);
+ return *this;
+}
+
+template<class _CharT, class _Traits>
+streamsize
+basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize __n)
+{
+ ios_base::iostate __state = ios_base::goodbit;
+ __gc_ = 0;
+ sentry __sen(*this, true);
+ if (__sen)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ streamsize __c = this->rdbuf()->in_avail();
+ switch (__c)
+ {
+ case -1:
+ __state |= ios_base::eofbit;
+ break;
+ case 0:
+ break;
+ default:
+ __n = _VSTD::min(__c, __n);
+ __gc_ = this->rdbuf()->sgetn(__s, __n);
+ if (__gc_ != __n)
+ __state |= ios_base::failbit | ios_base::eofbit;
+ break;
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ this->__setstate_nothrow(__state);
+ if (this->exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ }
+ else
+ {
+ __state |= ios_base::failbit;
+ }
+ this->setstate(__state);
+ return __gc_;
+}
+
+template<class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::putback(char_type __c)
+{
+ ios_base::iostate __state = this->rdstate() & ~ios_base::eofbit;
+ __gc_ = 0;
+ this->clear(__state);
+ sentry __sen(*this, true);
+ if (__sen)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ if (this->rdbuf() == nullptr || this->rdbuf()->sputbackc(__c) == traits_type::eof())
+ __state |= ios_base::badbit;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ this->__setstate_nothrow(__state);
+ if (this->exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ }
+ else
+ {
+ __state |= ios_base::failbit;
+ }
+ this->setstate(__state);
+ return *this;
+}
+
+template<class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::unget()
+{
+ ios_base::iostate __state = this->rdstate() & ~ios_base::eofbit;
+ __gc_ = 0;
+ this->clear(__state);
+ sentry __sen(*this, true);
+ if (__sen)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ if (this->rdbuf() == nullptr || this->rdbuf()->sungetc() == traits_type::eof())
+ __state |= ios_base::badbit;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ this->__setstate_nothrow(__state);
+ if (this->exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ }
+ else
+ {
+ __state |= ios_base::failbit;
+ }
+ this->setstate(__state);
+ return *this;
+}
+
+template<class _CharT, class _Traits>
+int
+basic_istream<_CharT, _Traits>::sync()
+{
+ ios_base::iostate __state = ios_base::goodbit;
+ int __r = 0;
+ sentry __sen(*this, true);
+ if (__sen)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ if (this->rdbuf() == nullptr)
+ return -1;
+ if (this->rdbuf()->pubsync() == -1)
+ {
+ __state |= ios_base::badbit;
+ return -1;
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ this->__setstate_nothrow(__state);
+ if (this->exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ this->setstate(__state);
+ }
+ return __r;
+}
+
+template<class _CharT, class _Traits>
+typename basic_istream<_CharT, _Traits>::pos_type
+basic_istream<_CharT, _Traits>::tellg()
+{
+ ios_base::iostate __state = ios_base::goodbit;
+ pos_type __r(-1);
+ sentry __sen(*this, true);
+ if (__sen)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ __r = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::in);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ this->__setstate_nothrow(__state);
+ if (this->exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ this->setstate(__state);
+ }
+ return __r;
+}
+
+template<class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::seekg(pos_type __pos)
+{
+ ios_base::iostate __state = this->rdstate() & ~ios_base::eofbit;
+ this->clear(__state);
+ sentry __sen(*this, true);
+ if (__sen)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ if (this->rdbuf()->pubseekpos(__pos, ios_base::in) == pos_type(-1))
+ __state |= ios_base::failbit;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ this->__setstate_nothrow(__state);
+ if (this->exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ this->setstate(__state);
+ }
+ return *this;
+}
+
+template<class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::seekg(off_type __off, ios_base::seekdir __dir)
+{
+ ios_base::iostate __state = this->rdstate() & ~ios_base::eofbit;
+ this->clear(__state);
+ sentry __sen(*this, true);
+ if (__sen)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::in) == pos_type(-1))
+ __state |= ios_base::failbit;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ this->__setstate_nothrow(__state);
+ if (this->exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ this->setstate(__state);
+ }
+ return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+ws(basic_istream<_CharT, _Traits>& __is)
+{
+ ios_base::iostate __state = ios_base::goodbit;
+ typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true);
+ if (__sen)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
+ while (true)
+ {
+ typename _Traits::int_type __i = __is.rdbuf()->sgetc();
+ if (_Traits::eq_int_type(__i, _Traits::eof()))
+ {
+ __state |= ios_base::eofbit;
+ break;
+ }
+ if (!__ct.is(__ct.space, _Traits::to_char_type(__i)))
+ break;
+ __is.rdbuf()->sbumpc();
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ __is.__setstate_nothrow(__state);
+ if (__is.exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ __is.setstate(__state);
+ }
+ return __is;
+}
+
+template <class _Stream, class _Tp, class = void>
+struct __is_istreamable : false_type { };
+
+template <class _Stream, class _Tp>
+struct __is_istreamable<_Stream, _Tp, decltype(
+ 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
+>::type>
+_LIBCPP_INLINE_VISIBILITY
+_Stream&& operator>>(_Stream&& __is, _Tp&& __x)
+{
+ __is >> _VSTD::forward<_Tp>(__x);
+ return _VSTD::move(__is);
+}
+
+template <class _CharT, class _Traits>
+class _LIBCPP_TEMPLATE_VIS basic_iostream
+ : public basic_istream<_CharT, _Traits>,
+ public basic_ostream<_CharT, _Traits>
+{
+public:
+ // types:
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+
+ // constructor/destructor
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ explicit basic_iostream(basic_streambuf<char_type, traits_type>* __sb)
+ : basic_istream<_CharT, _Traits>(__sb)
+ {}
+
+ virtual ~basic_iostream();
+protected:
+ inline _LIBCPP_INLINE_VISIBILITY
+ basic_iostream(basic_iostream&& __rhs);
+
+ // assign/swap
+ inline _LIBCPP_INLINE_VISIBILITY
+ basic_iostream& operator=(basic_iostream&& __rhs);
+
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ void swap(basic_iostream& __rhs)
+ { basic_istream<char_type, traits_type>::swap(__rhs); }
+};
+
+template <class _CharT, class _Traits>
+basic_iostream<_CharT, _Traits>::basic_iostream(basic_iostream&& __rhs)
+ : basic_istream<_CharT, _Traits>(_VSTD::move(__rhs))
+{
+}
+
+template <class _CharT, class _Traits>
+basic_iostream<_CharT, _Traits>&
+basic_iostream<_CharT, _Traits>::operator=(basic_iostream&& __rhs)
+{
+ swap(__rhs);
+ return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_iostream<_CharT, _Traits>::~basic_iostream()
+{
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ basic_string<_CharT, _Traits, _Allocator>& __str)
+{
+ ios_base::iostate __state = ios_base::goodbit;
+ typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
+ if (__sen)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif
+ __str.clear();
+ streamsize __n = __is.width();
+ if (__n <= 0)
+ __n = __str.max_size();
+ if (__n <= 0)
+ __n = numeric_limits<streamsize>::max();
+ streamsize __c = 0;
+ const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
+ while (__c < __n)
+ {
+ typename _Traits::int_type __i = __is.rdbuf()->sgetc();
+ if (_Traits::eq_int_type(__i, _Traits::eof()))
+ {
+ __state |= ios_base::eofbit;
+ break;
+ }
+ _CharT __ch = _Traits::to_char_type(__i);
+ if (__ct.is(__ct.space, __ch))
+ break;
+ __str.push_back(__ch);
+ ++__c;
+ __is.rdbuf()->sbumpc();
+ }
+ __is.width(0);
+ if (__c == 0)
+ __state |= ios_base::failbit;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ __is.__setstate_nothrow(__state);
+ if (__is.exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
+#endif
+ __is.setstate(__state);
+ }
+ return __is;
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+basic_istream<_CharT, _Traits>&
+getline(basic_istream<_CharT, _Traits>& __is,
+ basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm)
+{
+ ios_base::iostate __state = ios_base::goodbit;
+ typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true);
+ if (__sen)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif
+ __str.clear();
+ streamsize __extr = 0;
+ while (true)
+ {
+ typename _Traits::int_type __i = __is.rdbuf()->sbumpc();
+ if (_Traits::eq_int_type(__i, _Traits::eof()))
+ {
+ __state |= ios_base::eofbit;
+ break;
+ }
+ ++__extr;
+ _CharT __ch = _Traits::to_char_type(__i);
+ if (_Traits::eq(__ch, __dlm))
+ break;
+ __str.push_back(__ch);
+ if (__str.size() == __str.max_size())
+ {
+ __state |= ios_base::failbit;
+ break;
+ }
+ }
+ if (__extr == 0)
+ __state |= ios_base::failbit;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ __is.__setstate_nothrow(__state);
+ if (__is.exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
+#endif
+ __is.setstate(__state);
+ }
+ return __is;
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>&
+getline(basic_istream<_CharT, _Traits>& __is,
+ basic_string<_CharT, _Traits, _Allocator>& __str)
+{
+ return getline(__is, __str, __is.widen('\n'));
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>&
+getline(basic_istream<_CharT, _Traits>&& __is,
+ basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm)
+{
+ return getline(__is, __str, __dlm);
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>&
+getline(basic_istream<_CharT, _Traits>&& __is,
+ basic_string<_CharT, _Traits, _Allocator>& __str)
+{
+ return getline(__is, __str, __is.widen('\n'));
+}
+
+template <class _CharT, class _Traits, size_t _Size>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
+{
+ ios_base::iostate __state = ios_base::goodbit;
+ typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
+ if (__sen)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif
+ basic_string<_CharT, _Traits> __str;
+ const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
+ size_t __c = 0;
+ _CharT __zero = __ct.widen('0');
+ _CharT __one = __ct.widen('1');
+ while (__c < _Size)
+ {
+ typename _Traits::int_type __i = __is.rdbuf()->sgetc();
+ if (_Traits::eq_int_type(__i, _Traits::eof()))
+ {
+ __state |= ios_base::eofbit;
+ break;
+ }
+ _CharT __ch = _Traits::to_char_type(__i);
+ if (!_Traits::eq(__ch, __zero) && !_Traits::eq(__ch, __one))
+ break;
+ __str.push_back(__ch);
+ ++__c;
+ __is.rdbuf()->sbumpc();
+ }
+ __x = bitset<_Size>(__str);
+ if (_Size > 0 && __c == 0)
+ __state |= ios_base::failbit;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ __is.__setstate_nothrow(__state);
+ if (__is.exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
+#endif
+ __is.setstate(__state);
+ }
+ return __is;
+}
+
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<char>)
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<wchar_t>)
+#endif
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_iostream<char>)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_ISTREAM
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/iterator b/contrib/libs/cxxsupp/libcxxmsvc/include/iterator
new file mode 100644
index 0000000000..6e2eb4a78c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/iterator
@@ -0,0 +1,677 @@
+// -*- 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
+#define _LIBCPP_ITERATOR
+
+/*
+ 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;
+
+template<class T>
+ 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.copy], concept indirectly_copyable
+template<class In, class Out>
+ concept indirectly_copyable = see below; // since C++20
+
+template<class In, class Out>
+ concept indirectly_copyable_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<class I1, class I2, class R, class P1 = identity,
+ class P2 = identity>
+ concept indirectly_comparable =
+ indirect_binary_predicate<R, projected<I1, P1>, projected<I2, P2>>; // since C++20
+
+// [alg.req.permutable], concept permutable
+template<class I>
+ concept permutable = see below; // since C++20
+
+ // [alg.req.mergeable], concept mergeable
+template<class I1, class I2, class Out,
+ class R = ranges::less, class P1 = identity, class P2 = identity>
+ concept mergeable = see below; // since C++20
+
+// [alg.req.sortable], concept sortable
+template<class I, class R = ranges::less, class P = identity>
+ concept sortable = 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 // deprecated in C++17
+{
+ typedef T value_type;
+ typedef Distance difference_type;
+ typedef Pointer pointer;
+ typedef Reference reference;
+ typedef Category iterator_category;
+};
+
+struct input_iterator_tag {};
+struct output_iterator_tag {};
+struct forward_iterator_tag : public input_iterator_tag {};
+struct bidirectional_iterator_tag : public forward_iterator_tag {};
+struct random_access_iterator_tag : public bidirectional_iterator_tag {};
+struct contiguous_iterator_tag : public random_access_iterator_tag {};
+
+// 27.4.3, iterator operations
+template <class InputIterator, class Distance> // constexpr in C++17
+ constexpr void advance(InputIterator& i, Distance n);
+
+template <class InputIterator> // constexpr in C++17
+ constexpr typename iterator_traits<InputIterator>::difference_type
+ distance(InputIterator first, InputIterator last);
+
+template <class InputIterator> // constexpr in C++17
+ constexpr InputIterator next(InputIterator x,
+typename iterator_traits<InputIterator>::difference_type n = 1);
+
+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, // until C++17
+ typename iterator_traits<Iterator>::value_type,
+ typename iterator_traits<Iterator>::difference_type,
+ typename iterator_traits<Iterator>::pointer,
+ typename iterator_traits<Iterator>::reference>
+{
+protected:
+ Iterator current;
+public:
+ typedef Iterator iterator_type;
+ typedef typename iterator_traits<Iterator>::difference_type difference_type;
+ typedef typename iterator_traits<Iterator>::reference reference;
+ typedef typename iterator_traits<Iterator>::pointer pointer;
+
+ constexpr reverse_iterator();
+ constexpr explicit reverse_iterator(Iterator x);
+ template <class U> constexpr reverse_iterator(const reverse_iterator<U>& u);
+ template <class U> constexpr reverse_iterator& operator=(const reverse_iterator<U>& u);
+ constexpr Iterator base() const;
+ constexpr reference operator*() const;
+ constexpr pointer operator->() const;
+ constexpr reverse_iterator& operator++();
+ constexpr reverse_iterator operator++(int);
+ constexpr reverse_iterator& operator--();
+ constexpr reverse_iterator operator--(int);
+ constexpr reverse_iterator operator+ (difference_type n) const;
+ constexpr reverse_iterator& operator+=(difference_type n);
+ constexpr reverse_iterator operator- (difference_type n) const;
+ constexpr reverse_iterator& operator-=(difference_type n);
+ constexpr reference operator[](difference_type n) const;
+};
+
+template <class Iterator1, class Iterator2>
+constexpr bool // constexpr in C++17
+operator==(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
+
+template <class Iterator1, class Iterator2>
+constexpr bool // constexpr in C++17
+operator<(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
+
+template <class Iterator1, class Iterator2>
+constexpr bool // constexpr in C++17
+operator!=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
+
+template <class Iterator1, class Iterator2>
+constexpr bool // constexpr in C++17
+operator>(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
+
+template <class Iterator1, class Iterator2>
+constexpr bool // constexpr in C++17
+operator>=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
+
+template <class Iterator1, class Iterator2>
+constexpr bool // constexpr in C++17
+operator<=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
+
+template <class Iterator1, class Iterator2>
+constexpr auto
+operator-(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y)
+-> decltype(__y.base() - __x.base()); // constexpr in C++17
+
+template <class Iterator>
+constexpr reverse_iterator<Iterator>
+operator+(typename reverse_iterator<Iterator>::difference_type n,
+ const reverse_iterator<Iterator>& x); // constexpr in C++17
+
+template <class Iterator>
+constexpr reverse_iterator<Iterator> make_reverse_iterator(Iterator i); // C++14, constexpr in C++17
+
+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; // until C++20
+ typedef ptrdiff_t difference_type; // since C++20
+ typedef void reference;
+ typedef void pointer;
+
+ 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); // 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; // until C++20
+ typedef ptrdiff_t difference_type; // since C++20
+ typedef void reference;
+ typedef void pointer;
+
+ 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); // 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;
+ typename Container::iterator iter;
+public:
+ typedef Container container_type;
+ typedef void value_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); // 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>
+insert_iterator<Container> inserter(Container& x, typename Container::iterator i); // until C++20
+template <class Container>
+constexpr insert_iterator<Container> inserter(Container& x, ranges::iterator_t<Container> i); // since C++20
+
+template <class Iterator>
+class move_iterator {
+public:
+ typedef Iterator iterator_type;
+ typedef typename iterator_traits<Iterator>::difference_type difference_type;
+ typedef Iterator pointer;
+ typedef typename iterator_traits<Iterator>::value_type value_type;
+ typedef typename iterator_traits<Iterator>::iterator_category iterator_category;
+ typedef value_type&& reference;
+
+ constexpr move_iterator(); // all the constexprs are in C++17
+ constexpr explicit move_iterator(Iterator i);
+ template <class U>
+ constexpr move_iterator(const move_iterator<U>& u);
+ template <class U>
+ constexpr move_iterator& operator=(const move_iterator<U>& u);
+ constexpr iterator_type base() const;
+ constexpr reference operator*() const;
+ constexpr pointer operator->() const;
+ constexpr move_iterator& operator++();
+ constexpr move_iterator operator++(int);
+ constexpr move_iterator& operator--();
+ constexpr move_iterator operator--(int);
+ constexpr move_iterator operator+(difference_type n) const;
+ constexpr move_iterator& operator+=(difference_type n);
+ constexpr move_iterator operator-(difference_type n) const;
+ constexpr move_iterator& operator-=(difference_type n);
+ constexpr unspecified operator[](difference_type n) const;
+private:
+ Iterator current; // exposition only
+};
+
+template <class Iterator1, class Iterator2>
+constexpr bool // constexpr in C++17
+operator==(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
+
+template <class Iterator1, class Iterator2>
+constexpr bool // constexpr in C++17
+operator!=(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
+
+template <class Iterator1, class Iterator2>
+constexpr bool // constexpr in C++17
+operator<(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
+
+template <class Iterator1, class Iterator2>
+constexpr bool // constexpr in C++17
+operator<=(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
+
+template <class Iterator1, class Iterator2>
+constexpr bool // constexpr in C++17
+operator>(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
+
+template <class Iterator1, class Iterator2>
+constexpr bool // constexpr in C++17
+operator>=(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
+
+template <class Iterator1, class Iterator2>
+constexpr auto // constexpr in C++17
+operator-(const move_iterator<Iterator1>& x,
+ const move_iterator<Iterator2>& y) -> decltype(x.base() - y.base());
+
+template <class Iterator>
+constexpr move_iterator<Iterator> operator+( // constexpr in C++17
+ typename move_iterator<Iterator>::difference_type n,
+ const move_iterator<Iterator>& x);
+
+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>>;
+
+// [unreachable.sentinel], unreachable sentinel
+struct unreachable_sentinel_t;
+inline constexpr unreachable_sentinel_t unreachable_sentinel{};
+
+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&> // until C++17
+{
+public:
+ 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;
+
+ istream_iterator(); // constexpr since C++11
+ constexpr istream_iterator(default_sentinel_t); // since C++20
+ istream_iterator(istream_type& s);
+ istream_iterator(const istream_iterator& x);
+ ~istream_iterator();
+
+ const T& operator*() const;
+ const T* operator->() const;
+ istream_iterator& operator++();
+ istream_iterator operator++(int);
+ friend bool operator==(const istream_iterator& i, default_sentinel_t); // since C++20
+};
+
+template <class T, class charT, class traits, class Distance>
+bool operator==(const istream_iterator<T,charT,traits,Distance>& x,
+ const istream_iterator<T,charT,traits,Distance>& y);
+template <class T, class charT, class traits, class Distance>
+bool operator!=(const istream_iterator<T,charT,traits,Distance>& x,
+ const istream_iterator<T,charT,traits,Distance>& y); // until C++20
+
+template <class T, class charT = char, class traits = char_traits<charT> >
+class ostream_iterator
+ : 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;
+
+ ostream_iterator(ostream_type& s);
+ ostream_iterator(ostream_type& s, const charT* delimiter);
+ ostream_iterator(const ostream_iterator& x);
+ ~ostream_iterator();
+ ostream_iterator& operator=(const T& value);
+
+ ostream_iterator& operator*();
+ ostream_iterator& operator++();
+ ostream_iterator& operator++(int);
+};
+
+template<class charT, class traits = char_traits<charT> >
+class istreambuf_iterator
+ : public iterator<input_iterator_tag, charT, traits::off_type, unspecified, charT> // until C++17
+{
+public:
+ 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; // constexpr since C++11
+ constexpr istreambuf_iterator(default_sentinel_t) noexcept; // since C++20
+ istreambuf_iterator(istream_type& s) noexcept;
+ istreambuf_iterator(streambuf_type* s) noexcept;
+ istreambuf_iterator(a-private-type) noexcept;
+
+ charT operator*() const;
+ pointer operator->() const;
+ istreambuf_iterator& operator++();
+ a-private-type operator++(int);
+
+ bool equal(const istreambuf_iterator& b) const;
+ friend bool operator==(const istreambuf_iterator& i, default_sentinel_t s); // since C++20
+};
+
+template <class charT, class traits>
+bool operator==(const istreambuf_iterator<charT,traits>& a,
+ const istreambuf_iterator<charT,traits>& b);
+template <class charT, class traits>
+bool operator!=(const istreambuf_iterator<charT,traits>& a,
+ const istreambuf_iterator<charT,traits>& b); // until C++20
+
+template <class charT, class traits = char_traits<charT> >
+class ostreambuf_iterator
+ : 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_streambuf<charT, traits> streambuf_type;
+ typedef basic_ostream<charT, traits> ostream_type;
+
+ ostreambuf_iterator(ostream_type& s) noexcept;
+ ostreambuf_iterator(streambuf_type* s) noexcept;
+ ostreambuf_iterator& operator=(charT c);
+ ostreambuf_iterator& operator*();
+ ostreambuf_iterator& operator++();
+ ostreambuf_iterator& operator++(int);
+ bool failed() const noexcept;
+};
+
+template <class C> constexpr auto begin(C& c) -> decltype(c.begin());
+template <class C> constexpr auto begin(const C& c) -> decltype(c.begin());
+template <class C> constexpr auto end(C& c) -> decltype(c.end());
+template <class C> constexpr auto end(const C& c) -> decltype(c.end());
+template <class T, size_t N> constexpr T* begin(T (&array)[N]);
+template <class T, size_t N> constexpr T* end(T (&array)[N]);
+
+template <class C> auto constexpr cbegin(const C& c) -> decltype(std::begin(c)); // C++14
+template <class C> auto constexpr cend(const C& c) -> decltype(std::end(c)); // C++14
+template <class C> auto constexpr rbegin(C& c) -> decltype(c.rbegin()); // C++14
+template <class C> auto constexpr rbegin(const C& c) -> decltype(c.rbegin()); // C++14
+template <class C> auto constexpr rend(C& c) -> decltype(c.rend()); // C++14
+template <class C> constexpr auto rend(const C& c) -> decltype(c.rend()); // C++14
+template <class E> reverse_iterator<const E*> constexpr rbegin(initializer_list<E> il); // C++14
+template <class E> reverse_iterator<const E*> constexpr rend(initializer_list<E> il); // C++14
+template <class T, size_t N> reverse_iterator<T*> constexpr rbegin(T (&array)[N]); // C++14
+template <class T, size_t N> reverse_iterator<T*> constexpr rend(T (&array)[N]); // C++14
+template <class C> constexpr auto crbegin(const C& c) -> decltype(std::rbegin(c)); // C++14
+template <class C> constexpr auto crend(const C& c) -> decltype(std::rend(c)); // C++14
+
+// 24.8, container access:
+template <class C> constexpr auto size(const C& c) -> decltype(c.size()); // C++17
+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
+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
+template <class T, size_t N> constexpr bool empty(const T (&array)[N]) noexcept; // C++17
+template <class E> constexpr bool empty(initializer_list<E> il) noexcept; // C++17
+template <class C> constexpr auto data(C& c) -> decltype(c.data()); // C++17
+template <class C> constexpr auto data(const C& c) -> decltype(c.data()); // C++17
+template <class T, size_t N> constexpr T* data(T (&array)[N]) noexcept; // C++17
+template <class E> constexpr const E* data(initializer_list<E> il) noexcept; // C++17
+
+} // std
+
+*/
+
+#include <__config>
+#include <__debug>
+#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/indirectly_comparable.h>
+#include <__iterator/insert_iterator.h>
+#include <__iterator/istream_iterator.h>
+#include <__iterator/istreambuf_iterator.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/iterator.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/mergeable.h>
+#include <__iterator/move_iterator.h>
+#include <__iterator/next.h>
+#include <__iterator/ostream_iterator.h>
+#include <__iterator/ostreambuf_iterator.h>
+#include <__iterator/permutable.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/sortable.h>
+#include <__iterator/unreachable_sentinel.h>
+#include <__iterator/wrap_iter.h>
+#include <__memory/addressof.h>
+#include <__memory/pointer_traits.h>
+#include <compare>
+#include <concepts> // Mandated by the Standard.
+#include <cstddef>
+#include <initializer_list>
+#include <type_traits>
+#include <utility>
+#include <version>
+
+// TODO: remove these headers
+#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 <typeinfo>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#endif // _LIBCPP_ITERATOR
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/latch b/contrib/libs/cxxsupp/libcxxmsvc/include/latch
new file mode 100644
index 0000000000..e1e15190ae
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/latch
@@ -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_LATCH
+#define _LIBCPP_LATCH
+
+/*
+ latch synopsis
+
+namespace std
+{
+
+ class latch
+ {
+ public:
+ static constexpr ptrdiff_t max() noexcept;
+
+ constexpr explicit latch(ptrdiff_t __expected);
+ ~latch();
+
+ latch(const latch&) = delete;
+ latch& operator=(const latch&) = delete;
+
+ void count_down(ptrdiff_t __update = 1);
+ bool try_wait() const noexcept;
+ void wait() const;
+ void arrive_and_wait(ptrdiff_t __update = 1);
+
+ private:
+ ptrdiff_t __counter; // exposition only
+ };
+
+}
+
+*/
+
+#include <__availability>
+#include <__config>
+#include <atomic>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifdef _LIBCPP_HAS_NO_THREADS
+# error <latch> is not supported on this single threaded system
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+#if _LIBCPP_STD_VER >= 14
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+class latch
+{
+ __atomic_base<ptrdiff_t> __a;
+
+public:
+ static constexpr ptrdiff_t max() noexcept {
+ return numeric_limits<ptrdiff_t>::max();
+ }
+
+ inline _LIBCPP_INLINE_VISIBILITY
+ constexpr explicit latch(ptrdiff_t __expected) : __a(__expected) { }
+
+ ~latch() = default;
+ latch(const latch&) = delete;
+ latch& operator=(const latch&) = delete;
+
+ inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ void count_down(ptrdiff_t __update = 1)
+ {
+ auto const __old = __a.fetch_sub(__update, memory_order_release);
+ if(__old == __update)
+ __a.notify_all();
+ }
+ inline _LIBCPP_INLINE_VISIBILITY
+ bool try_wait() const noexcept
+ {
+ return 0 == __a.load(memory_order_acquire);
+ }
+ inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ void wait() const
+ {
+ auto const __test_fn = [=]() -> bool {
+ return try_wait();
+ };
+ __cxx_atomic_wait(&__a.__a_, __test_fn);
+ }
+ inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ void arrive_and_wait(ptrdiff_t __update = 1)
+ {
+ count_down(__update);
+ wait();
+ }
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 14
+
+_LIBCPP_POP_MACROS
+
+#endif //_LIBCPP_LATCH
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/limits b/contrib/libs/cxxsupp/libcxxmsvc/include/limits
new file mode 100644
index 0000000000..bf5d6d1fc4
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/limits
@@ -0,0 +1,818 @@
+// -*- 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_LIMITS
+#define _LIBCPP_LIMITS
+
+/*
+ limits synopsis
+
+namespace std
+{
+
+template<class T>
+class numeric_limits
+{
+public:
+ static constexpr bool is_specialized = false;
+ static constexpr T min() noexcept;
+ static constexpr T max() noexcept;
+ static constexpr T lowest() noexcept;
+
+ static constexpr int digits = 0;
+ static constexpr int digits10 = 0;
+ static constexpr int max_digits10 = 0;
+ static constexpr bool is_signed = false;
+ static constexpr bool is_integer = false;
+ static constexpr bool is_exact = false;
+ static constexpr int radix = 0;
+ static constexpr T epsilon() noexcept;
+ static constexpr T round_error() noexcept;
+
+ static constexpr int min_exponent = 0;
+ static constexpr int min_exponent10 = 0;
+ static constexpr int max_exponent = 0;
+ static constexpr int max_exponent10 = 0;
+
+ static constexpr bool has_infinity = false;
+ static constexpr bool has_quiet_NaN = false;
+ static constexpr bool has_signaling_NaN = false;
+ static constexpr float_denorm_style has_denorm = denorm_absent;
+ static constexpr bool has_denorm_loss = false;
+ static constexpr T infinity() noexcept;
+ static constexpr T quiet_NaN() noexcept;
+ static constexpr T signaling_NaN() noexcept;
+ static constexpr T denorm_min() noexcept;
+
+ static constexpr bool is_iec559 = false;
+ static constexpr bool is_bounded = false;
+ static constexpr bool is_modulo = false;
+
+ static constexpr bool traps = false;
+ static constexpr bool tinyness_before = false;
+ static constexpr float_round_style round_style = round_toward_zero;
+};
+
+enum float_round_style
+{
+ round_indeterminate = -1,
+ round_toward_zero = 0,
+ round_to_nearest = 1,
+ round_toward_infinity = 2,
+ round_toward_neg_infinity = 3
+};
+
+enum float_denorm_style
+{
+ denorm_indeterminate = -1,
+ denorm_absent = 0,
+ denorm_present = 1
+};
+
+template<> class numeric_limits<cv bool>;
+
+template<> class numeric_limits<cv char>;
+template<> class numeric_limits<cv signed char>;
+template<> class numeric_limits<cv unsigned char>;
+template<> class numeric_limits<cv wchar_t>;
+template<> class numeric_limits<cv char8_t>; // C++20
+template<> class numeric_limits<cv char16_t>;
+template<> class numeric_limits<cv char32_t>;
+
+template<> class numeric_limits<cv short>;
+template<> class numeric_limits<cv int>;
+template<> class numeric_limits<cv long>;
+template<> class numeric_limits<cv long long>;
+template<> class numeric_limits<cv unsigned short>;
+template<> class numeric_limits<cv unsigned int>;
+template<> class numeric_limits<cv unsigned long>;
+template<> class numeric_limits<cv unsigned long long>;
+
+template<> class numeric_limits<cv float>;
+template<> class numeric_limits<cv double>;
+template<> class numeric_limits<cv long double>;
+
+} // std
+
+*/
+#include <__config>
+#include <type_traits>
+
+#if defined(_LIBCPP_COMPILER_MSVC)
+#include "__support/win32/limits_msvc_win32.h"
+#endif // _LIBCPP_MSVCRT
+
+#if defined(__IBMCPP__)
+#include "__support/ibm/limits.h"
+#endif // __IBMCPP__
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+#include <version>
+
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+enum float_round_style
+{
+ round_indeterminate = -1,
+ round_toward_zero = 0,
+ round_to_nearest = 1,
+ round_toward_infinity = 2,
+ round_toward_neg_infinity = 3
+};
+
+enum float_denorm_style
+{
+ denorm_indeterminate = -1,
+ denorm_absent = 0,
+ denorm_present = 1
+};
+
+template <class _Tp, bool = is_arithmetic<_Tp>::value>
+class __libcpp_numeric_limits
+{
+protected:
+ typedef _Tp type;
+
+ static _LIBCPP_CONSTEXPR const bool is_specialized = false;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return type();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return type();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return type();}
+
+ static _LIBCPP_CONSTEXPR const int digits = 0;
+ static _LIBCPP_CONSTEXPR const int digits10 = 0;
+ static _LIBCPP_CONSTEXPR const int max_digits10 = 0;
+ static _LIBCPP_CONSTEXPR const bool is_signed = false;
+ static _LIBCPP_CONSTEXPR const bool is_integer = false;
+ static _LIBCPP_CONSTEXPR const bool is_exact = false;
+ static _LIBCPP_CONSTEXPR const int radix = 0;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return type();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return type();}
+
+ static _LIBCPP_CONSTEXPR const int min_exponent = 0;
+ static _LIBCPP_CONSTEXPR const int min_exponent10 = 0;
+ static _LIBCPP_CONSTEXPR const int max_exponent = 0;
+ static _LIBCPP_CONSTEXPR const int max_exponent10 = 0;
+
+ static _LIBCPP_CONSTEXPR const bool has_infinity = false;
+ static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = false;
+ static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false;
+ static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent;
+ static _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return type();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return type();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return type();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return type();}
+
+ static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
+ static _LIBCPP_CONSTEXPR const bool is_bounded = false;
+ static _LIBCPP_CONSTEXPR const bool is_modulo = false;
+
+ static _LIBCPP_CONSTEXPR const bool traps = false;
+ static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
+ static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero;
+};
+
+template <class _Tp, int __digits, bool _IsSigned>
+struct __libcpp_compute_min
+{
+ static _LIBCPP_CONSTEXPR const _Tp value = _Tp(_Tp(1) << __digits);
+};
+
+template <class _Tp, int __digits>
+struct __libcpp_compute_min<_Tp, __digits, false>
+{
+ static _LIBCPP_CONSTEXPR const _Tp value = _Tp(0);
+};
+
+template <class _Tp>
+class __libcpp_numeric_limits<_Tp, true>
+{
+protected:
+ typedef _Tp type;
+
+ static _LIBCPP_CONSTEXPR const bool is_specialized = true;
+
+ static _LIBCPP_CONSTEXPR const bool is_signed = type(-1) < type(0);
+ static _LIBCPP_CONSTEXPR const int digits = static_cast<int>(sizeof(type) * __CHAR_BIT__ - is_signed);
+ static _LIBCPP_CONSTEXPR const int digits10 = digits * 3 / 10;
+ static _LIBCPP_CONSTEXPR const int max_digits10 = 0;
+ static _LIBCPP_CONSTEXPR const type __min = __libcpp_compute_min<type, digits, is_signed>::value;
+ static _LIBCPP_CONSTEXPR const type __max = is_signed ? type(type(~0) ^ __min) : type(~0);
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __min;}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __max;}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return min();}
+
+ static _LIBCPP_CONSTEXPR const bool is_integer = true;
+ static _LIBCPP_CONSTEXPR const bool is_exact = true;
+ static _LIBCPP_CONSTEXPR const int radix = 2;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return type(0);}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return type(0);}
+
+ static _LIBCPP_CONSTEXPR const int min_exponent = 0;
+ static _LIBCPP_CONSTEXPR const int min_exponent10 = 0;
+ static _LIBCPP_CONSTEXPR const int max_exponent = 0;
+ static _LIBCPP_CONSTEXPR const int max_exponent10 = 0;
+
+ static _LIBCPP_CONSTEXPR const bool has_infinity = false;
+ static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = false;
+ static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false;
+ static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent;
+ static _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return type(0);}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return type(0);}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return type(0);}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return type(0);}
+
+ static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
+ static _LIBCPP_CONSTEXPR const bool is_bounded = true;
+ static _LIBCPP_CONSTEXPR const bool is_modulo = !_VSTD::is_signed<_Tp>::value;
+
+#if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__) || \
+ defined(__wasm__)
+ static _LIBCPP_CONSTEXPR const bool traps = true;
+#else
+ static _LIBCPP_CONSTEXPR const bool traps = false;
+#endif
+ static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
+ static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero;
+};
+
+template <>
+class __libcpp_numeric_limits<bool, true>
+{
+protected:
+ typedef bool type;
+
+ static _LIBCPP_CONSTEXPR const bool is_specialized = true;
+
+ static _LIBCPP_CONSTEXPR const bool is_signed = false;
+ static _LIBCPP_CONSTEXPR const int digits = 1;
+ static _LIBCPP_CONSTEXPR const int digits10 = 0;
+ static _LIBCPP_CONSTEXPR const int max_digits10 = 0;
+ static _LIBCPP_CONSTEXPR const type __min = false;
+ static _LIBCPP_CONSTEXPR const type __max = true;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __min;}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __max;}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return min();}
+
+ static _LIBCPP_CONSTEXPR const bool is_integer = true;
+ static _LIBCPP_CONSTEXPR const bool is_exact = true;
+ static _LIBCPP_CONSTEXPR const int radix = 2;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return type(0);}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return type(0);}
+
+ static _LIBCPP_CONSTEXPR const int min_exponent = 0;
+ static _LIBCPP_CONSTEXPR const int min_exponent10 = 0;
+ static _LIBCPP_CONSTEXPR const int max_exponent = 0;
+ static _LIBCPP_CONSTEXPR const int max_exponent10 = 0;
+
+ static _LIBCPP_CONSTEXPR const bool has_infinity = false;
+ static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = false;
+ static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false;
+ static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent;
+ static _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return type(0);}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return type(0);}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return type(0);}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return type(0);}
+
+ static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
+ static _LIBCPP_CONSTEXPR const bool is_bounded = true;
+ static _LIBCPP_CONSTEXPR const bool is_modulo = false;
+
+ static _LIBCPP_CONSTEXPR const bool traps = false;
+ static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
+ static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero;
+};
+
+template <>
+class __libcpp_numeric_limits<float, true>
+{
+protected:
+ typedef float type;
+
+ static _LIBCPP_CONSTEXPR const bool is_specialized = true;
+
+ static _LIBCPP_CONSTEXPR const bool is_signed = true;
+ static _LIBCPP_CONSTEXPR const int digits = __FLT_MANT_DIG__;
+ static _LIBCPP_CONSTEXPR const int digits10 = __FLT_DIG__;
+ static _LIBCPP_CONSTEXPR const int max_digits10 = 2+(digits * 30103l)/100000l;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __FLT_MIN__;}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __FLT_MAX__;}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return -max();}
+
+ static _LIBCPP_CONSTEXPR const bool is_integer = false;
+ static _LIBCPP_CONSTEXPR const bool is_exact = false;
+ static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return __FLT_EPSILON__;}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return 0.5F;}
+
+ static _LIBCPP_CONSTEXPR const int min_exponent = __FLT_MIN_EXP__;
+ static _LIBCPP_CONSTEXPR const int min_exponent10 = __FLT_MIN_10_EXP__;
+ static _LIBCPP_CONSTEXPR const int max_exponent = __FLT_MAX_EXP__;
+ static _LIBCPP_CONSTEXPR const int max_exponent10 = __FLT_MAX_10_EXP__;
+
+ static _LIBCPP_CONSTEXPR const bool has_infinity = true;
+ static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = true;
+ static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true;
+ static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present;
+ static _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __builtin_huge_valf();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __builtin_nanf("");}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __builtin_nansf("");}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __FLT_DENORM_MIN__;}
+
+ static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
+ static _LIBCPP_CONSTEXPR const bool is_bounded = true;
+ static _LIBCPP_CONSTEXPR const bool is_modulo = false;
+
+ static _LIBCPP_CONSTEXPR const bool traps = false;
+ static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
+ static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;
+};
+
+template <>
+class __libcpp_numeric_limits<double, true>
+{
+protected:
+ typedef double type;
+
+ static _LIBCPP_CONSTEXPR const bool is_specialized = true;
+
+ static _LIBCPP_CONSTEXPR const bool is_signed = true;
+ static _LIBCPP_CONSTEXPR const int digits = __DBL_MANT_DIG__;
+ static _LIBCPP_CONSTEXPR const int digits10 = __DBL_DIG__;
+ static _LIBCPP_CONSTEXPR const int max_digits10 = 2+(digits * 30103l)/100000l;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __DBL_MIN__;}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __DBL_MAX__;}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return -max();}
+
+ static _LIBCPP_CONSTEXPR const bool is_integer = false;
+ static _LIBCPP_CONSTEXPR const bool is_exact = false;
+ static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return __DBL_EPSILON__;}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return 0.5;}
+
+ static _LIBCPP_CONSTEXPR const int min_exponent = __DBL_MIN_EXP__;
+ static _LIBCPP_CONSTEXPR const int min_exponent10 = __DBL_MIN_10_EXP__;
+ static _LIBCPP_CONSTEXPR const int max_exponent = __DBL_MAX_EXP__;
+ static _LIBCPP_CONSTEXPR const int max_exponent10 = __DBL_MAX_10_EXP__;
+
+ static _LIBCPP_CONSTEXPR const bool has_infinity = true;
+ static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = true;
+ static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true;
+ static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present;
+ static _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __builtin_huge_val();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __builtin_nan("");}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __builtin_nans("");}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __DBL_DENORM_MIN__;}
+
+ static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
+ static _LIBCPP_CONSTEXPR const bool is_bounded = true;
+ static _LIBCPP_CONSTEXPR const bool is_modulo = false;
+
+ static _LIBCPP_CONSTEXPR const bool traps = false;
+ static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
+ static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;
+};
+
+template <>
+class __libcpp_numeric_limits<long double, true>
+{
+protected:
+ typedef long double type;
+
+ static _LIBCPP_CONSTEXPR const bool is_specialized = true;
+
+ static _LIBCPP_CONSTEXPR const bool is_signed = true;
+ static _LIBCPP_CONSTEXPR const int digits = __LDBL_MANT_DIG__;
+ static _LIBCPP_CONSTEXPR const int digits10 = __LDBL_DIG__;
+ static _LIBCPP_CONSTEXPR const int max_digits10 = 2+(digits * 30103l)/100000l;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __LDBL_MIN__;}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __LDBL_MAX__;}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return -max();}
+
+ static _LIBCPP_CONSTEXPR const bool is_integer = false;
+ static _LIBCPP_CONSTEXPR const bool is_exact = false;
+ static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return __LDBL_EPSILON__;}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return 0.5L;}
+
+ static _LIBCPP_CONSTEXPR const int min_exponent = __LDBL_MIN_EXP__;
+ static _LIBCPP_CONSTEXPR const int min_exponent10 = __LDBL_MIN_10_EXP__;
+ static _LIBCPP_CONSTEXPR const int max_exponent = __LDBL_MAX_EXP__;
+ static _LIBCPP_CONSTEXPR const int max_exponent10 = __LDBL_MAX_10_EXP__;
+
+ static _LIBCPP_CONSTEXPR const bool has_infinity = true;
+ static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = true;
+ static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true;
+ static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present;
+ static _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __builtin_huge_vall();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __builtin_nanl("");}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __builtin_nansl("");}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __LDBL_DENORM_MIN__;}
+
+#if (defined(__ppc__) || defined(__ppc64__))
+ static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
+#else
+ static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
+#endif
+ static _LIBCPP_CONSTEXPR const bool is_bounded = true;
+ static _LIBCPP_CONSTEXPR const bool is_modulo = false;
+
+ static _LIBCPP_CONSTEXPR const bool traps = false;
+ static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
+ static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;
+};
+
+template <class _Tp>
+class _LIBCPP_TEMPLATE_VIS numeric_limits
+ : private __libcpp_numeric_limits<typename remove_cv<_Tp>::type>
+{
+ typedef __libcpp_numeric_limits<typename remove_cv<_Tp>::type> __base;
+ typedef typename __base::type type;
+public:
+ static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __base::min();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __base::max();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return __base::lowest();}
+
+ static _LIBCPP_CONSTEXPR const int digits = __base::digits;
+ static _LIBCPP_CONSTEXPR const int digits10 = __base::digits10;
+ static _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10;
+ static _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed;
+ static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer;
+ static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact;
+ static _LIBCPP_CONSTEXPR const int radix = __base::radix;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return __base::epsilon();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return __base::round_error();}
+
+ static _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent;
+ static _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10;
+ static _LIBCPP_CONSTEXPR const int max_exponent = __base::max_exponent;
+ static _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10;
+
+ static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity;
+ static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN;
+ static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN;
+ static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm;
+ static _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __base::infinity();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __base::quiet_NaN();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __base::signaling_NaN();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __base::denorm_min();}
+
+ static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559;
+ static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded;
+ static _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo;
+
+ static _LIBCPP_CONSTEXPR const bool traps = __base::traps;
+ static _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before;
+ static _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style;
+};
+
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_specialized;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::digits;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::digits10;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_digits10;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_signed;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_integer;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_exact;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::radix;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::min_exponent;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::min_exponent10;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_exponent;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_exponent10;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_infinity;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_quiet_NaN;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_signaling_NaN;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const float_denorm_style numeric_limits<_Tp>::has_denorm;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_denorm_loss;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_iec559;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_bounded;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_modulo;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::traps;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::tinyness_before;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const float_round_style numeric_limits<_Tp>::round_style;
+
+template <class _Tp>
+class _LIBCPP_TEMPLATE_VIS numeric_limits<const _Tp>
+ : private numeric_limits<_Tp>
+{
+ typedef numeric_limits<_Tp> __base;
+ typedef _Tp type;
+public:
+ static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __base::min();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __base::max();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return __base::lowest();}
+
+ static _LIBCPP_CONSTEXPR const int digits = __base::digits;
+ static _LIBCPP_CONSTEXPR const int digits10 = __base::digits10;
+ static _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10;
+ static _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed;
+ static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer;
+ static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact;
+ static _LIBCPP_CONSTEXPR const int radix = __base::radix;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return __base::epsilon();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return __base::round_error();}
+
+ static _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent;
+ static _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10;
+ static _LIBCPP_CONSTEXPR const int max_exponent = __base::max_exponent;
+ static _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10;
+
+ static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity;
+ static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN;
+ static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN;
+ static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm;
+ static _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __base::infinity();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __base::quiet_NaN();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __base::signaling_NaN();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __base::denorm_min();}
+
+ static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559;
+ static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded;
+ static _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo;
+
+ static _LIBCPP_CONSTEXPR const bool traps = __base::traps;
+ static _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before;
+ static _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style;
+};
+
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_specialized;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::digits;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::digits10;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::max_digits10;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_signed;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_integer;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_exact;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::radix;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::min_exponent;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::min_exponent10;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::max_exponent;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::max_exponent10;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::has_infinity;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::has_quiet_NaN;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::has_signaling_NaN;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const float_denorm_style numeric_limits<const _Tp>::has_denorm;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::has_denorm_loss;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_iec559;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_bounded;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_modulo;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::traps;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::tinyness_before;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const float_round_style numeric_limits<const _Tp>::round_style;
+
+template <class _Tp>
+class _LIBCPP_TEMPLATE_VIS numeric_limits<volatile _Tp>
+ : private numeric_limits<_Tp>
+{
+ typedef numeric_limits<_Tp> __base;
+ typedef _Tp type;
+public:
+ static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __base::min();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __base::max();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return __base::lowest();}
+
+ static _LIBCPP_CONSTEXPR const int digits = __base::digits;
+ static _LIBCPP_CONSTEXPR const int digits10 = __base::digits10;
+ static _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10;
+ static _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed;
+ static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer;
+ static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact;
+ static _LIBCPP_CONSTEXPR const int radix = __base::radix;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return __base::epsilon();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return __base::round_error();}
+
+ static _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent;
+ static _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10;
+ static _LIBCPP_CONSTEXPR const int max_exponent = __base::max_exponent;
+ static _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10;
+
+ static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity;
+ static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN;
+ static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN;
+ static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm;
+ static _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __base::infinity();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __base::quiet_NaN();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __base::signaling_NaN();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __base::denorm_min();}
+
+ static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559;
+ static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded;
+ static _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo;
+
+ static _LIBCPP_CONSTEXPR const bool traps = __base::traps;
+ static _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before;
+ static _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style;
+};
+
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_specialized;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::digits;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::digits10;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::max_digits10;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_signed;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_integer;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_exact;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::radix;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::min_exponent;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::min_exponent10;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::max_exponent;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::max_exponent10;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::has_infinity;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::has_quiet_NaN;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::has_signaling_NaN;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const float_denorm_style numeric_limits<volatile _Tp>::has_denorm;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::has_denorm_loss;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_iec559;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_bounded;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_modulo;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::traps;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::tinyness_before;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const float_round_style numeric_limits<volatile _Tp>::round_style;
+
+template <class _Tp>
+class _LIBCPP_TEMPLATE_VIS numeric_limits<const volatile _Tp>
+ : private numeric_limits<_Tp>
+{
+ typedef numeric_limits<_Tp> __base;
+ typedef _Tp type;
+public:
+ static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __base::min();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __base::max();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return __base::lowest();}
+
+ static _LIBCPP_CONSTEXPR const int digits = __base::digits;
+ static _LIBCPP_CONSTEXPR const int digits10 = __base::digits10;
+ static _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10;
+ static _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed;
+ static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer;
+ static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact;
+ static _LIBCPP_CONSTEXPR const int radix = __base::radix;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return __base::epsilon();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return __base::round_error();}
+
+ static _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent;
+ static _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10;
+ static _LIBCPP_CONSTEXPR const int max_exponent = __base::max_exponent;
+ static _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10;
+
+ static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity;
+ static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN;
+ static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN;
+ static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm;
+ static _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss;
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __base::infinity();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __base::quiet_NaN();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __base::signaling_NaN();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __base::denorm_min();}
+
+ static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559;
+ static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded;
+ static _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo;
+
+ static _LIBCPP_CONSTEXPR const bool traps = __base::traps;
+ static _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before;
+ static _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style;
+};
+
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_specialized;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::digits;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::digits10;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::max_digits10;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_signed;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_integer;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_exact;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::radix;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::min_exponent;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::min_exponent10;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::max_exponent;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::max_exponent10;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::has_infinity;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::has_quiet_NaN;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::has_signaling_NaN;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const float_denorm_style numeric_limits<const volatile _Tp>::has_denorm;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::has_denorm_loss;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_iec559;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_bounded;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_modulo;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::traps;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::tinyness_before;
+template <class _Tp>
+ _LIBCPP_CONSTEXPR const float_round_style numeric_limits<const volatile _Tp>::round_style;
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_LIMITS
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/limits.h b/contrib/libs/cxxsupp/libcxxmsvc/include/limits.h
new file mode 100644
index 0000000000..51ff28eefd
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/limits.h
@@ -0,0 +1,68 @@
+// -*- 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_LIMITS_H
+#define _LIBCPP_LIMITS_H
+
+/*
+ limits.h synopsis
+
+Macros:
+
+ CHAR_BIT
+ SCHAR_MIN
+ SCHAR_MAX
+ UCHAR_MAX
+ CHAR_MIN
+ CHAR_MAX
+ MB_LEN_MAX
+ SHRT_MIN
+ SHRT_MAX
+ USHRT_MAX
+ INT_MIN
+ INT_MAX
+ UINT_MAX
+ LONG_MIN
+ LONG_MAX
+ ULONG_MAX
+ LLONG_MIN // C99
+ LLONG_MAX // C99
+ ULLONG_MAX // C99
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifndef __GNUC__
+#ifdef _LIBCPP_COMPILER_MSVC
+#include Y_MSVC_INCLUDE_NEXT(limits.h)
+#else
+#include_next <limits.h>
+#endif
+#else
+// GCC header limits.h recursively includes itself through another header called
+// syslimits.h for some reason. This setup breaks down if we directly
+// #include_next GCC's limits.h (reasons not entirely clear to me). Therefore,
+// we manually re-create the necessary include sequence below:
+
+// Get the system limits.h defines (force recurse into the next level)
+#define _GCC_LIMITS_H_
+#define _GCC_NEXT_LIMITS_H
+#include_next <limits.h>
+
+// Get the ISO C defines
+#undef _GCC_LIMITS_H_
+#include_next <limits.h>
+#endif // __GNUC__
+
+#endif // _LIBCPP_LIMITS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/list b/contrib/libs/cxxsupp/libcxxmsvc/include/list
new file mode 100644
index 0000000000..b1f6c57007
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/list
@@ -0,0 +1,2422 @@
+// -*- 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_LIST
+#define _LIBCPP_LIST
+
+/*
+ list synopsis
+
+namespace std
+{
+
+template <class T, class Alloc = allocator<T> >
+class list
+{
+public:
+
+ // types:
+ typedef T value_type;
+ typedef Alloc allocator_type;
+ typedef typename allocator_type::reference reference;
+ typedef typename allocator_type::const_reference const_reference;
+ typedef typename allocator_type::pointer pointer;
+ typedef typename allocator_type::const_pointer const_pointer;
+ typedef implementation-defined iterator;
+ typedef implementation-defined const_iterator;
+ typedef implementation-defined size_type;
+ typedef implementation-defined difference_type;
+ typedef reverse_iterator<iterator> reverse_iterator;
+ typedef reverse_iterator<const_iterator> const_reverse_iterator;
+
+ list()
+ noexcept(is_nothrow_default_constructible<allocator_type>::value);
+ explicit list(const allocator_type& a);
+ explicit list(size_type n);
+ explicit list(size_type n, const allocator_type& a); // C++14
+ list(size_type n, const value_type& value);
+ list(size_type n, const value_type& value, const allocator_type& a);
+ template <class Iter>
+ list(Iter first, Iter last);
+ template <class Iter>
+ list(Iter first, Iter last, const allocator_type& a);
+ list(const list& x);
+ list(const list&, const allocator_type& a);
+ list(list&& x)
+ noexcept(is_nothrow_move_constructible<allocator_type>::value);
+ list(list&&, const allocator_type& a);
+ list(initializer_list<value_type>);
+ list(initializer_list<value_type>, const allocator_type& a);
+
+ ~list();
+
+ list& operator=(const list& x);
+ list& operator=(list&& x)
+ noexcept(
+ allocator_type::propagate_on_container_move_assignment::value &&
+ is_nothrow_move_assignable<allocator_type>::value);
+ list& operator=(initializer_list<value_type>);
+ template <class Iter>
+ void assign(Iter first, Iter last);
+ void assign(size_type n, const value_type& t);
+ void assign(initializer_list<value_type>);
+
+ allocator_type get_allocator() const noexcept;
+
+ iterator begin() noexcept;
+ const_iterator begin() const noexcept;
+ iterator end() noexcept;
+ const_iterator end() const noexcept;
+ reverse_iterator rbegin() noexcept;
+ const_reverse_iterator rbegin() const noexcept;
+ reverse_iterator rend() noexcept;
+ const_reverse_iterator rend() const noexcept;
+ const_iterator cbegin() const noexcept;
+ const_iterator cend() const noexcept;
+ const_reverse_iterator crbegin() const noexcept;
+ const_reverse_iterator crend() const noexcept;
+
+ reference front();
+ const_reference front() const;
+ reference back();
+ const_reference back() const;
+
+ bool empty() const noexcept;
+ size_type size() const noexcept;
+ size_type max_size() const noexcept;
+
+ template <class... Args>
+ reference emplace_front(Args&&... args); // reference in C++17
+ void pop_front();
+ template <class... Args>
+ reference emplace_back(Args&&... args); // reference in C++17
+ void pop_back();
+ void push_front(const value_type& x);
+ void push_front(value_type&& x);
+ void push_back(const value_type& x);
+ void push_back(value_type&& x);
+ template <class... Args>
+ iterator emplace(const_iterator position, Args&&... args);
+ iterator insert(const_iterator position, const value_type& x);
+ iterator insert(const_iterator position, value_type&& x);
+ iterator insert(const_iterator position, size_type n, const value_type& x);
+ template <class Iter>
+ iterator insert(const_iterator position, Iter first, Iter last);
+ iterator insert(const_iterator position, initializer_list<value_type> il);
+
+ iterator erase(const_iterator position);
+ iterator erase(const_iterator position, const_iterator last);
+
+ void resize(size_type sz);
+ void resize(size_type sz, const value_type& c);
+
+ void swap(list&)
+ noexcept(allocator_traits<allocator_type>::is_always_equal::value); // C++17
+ void clear() noexcept;
+
+ void splice(const_iterator position, list& x);
+ void splice(const_iterator position, list&& x);
+ void splice(const_iterator position, list& x, const_iterator i);
+ void splice(const_iterator position, list&& x, const_iterator i);
+ void splice(const_iterator position, list& x, const_iterator first,
+ const_iterator last);
+ void splice(const_iterator position, list&& x, const_iterator first,
+ const_iterator last);
+
+ size_type remove(const value_type& value); // void before C++20
+ template <class Pred>
+ size_type remove_if(Pred pred); // void before C++20
+ size_type unique(); // void before C++20
+ template <class BinaryPredicate>
+ size_type unique(BinaryPredicate binary_pred); // void before C++20
+ void merge(list& x);
+ void merge(list&& x);
+ template <class Compare>
+ void merge(list& x, Compare comp);
+ template <class Compare>
+ void merge(list&& x, Compare comp);
+ void sort();
+ template <class Compare>
+ void sort(Compare comp);
+ void reverse() noexcept;
+};
+
+
+template <class InputIterator, class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
+ list(InputIterator, InputIterator, Allocator = Allocator())
+ -> list<typename iterator_traits<InputIterator>::value_type, Allocator>; // C++17
+
+template <class T, class Alloc>
+ bool operator==(const list<T,Alloc>& x, const list<T,Alloc>& y);
+template <class T, class Alloc>
+ bool operator< (const list<T,Alloc>& x, const list<T,Alloc>& y);
+template <class T, class Alloc>
+ bool operator!=(const list<T,Alloc>& x, const list<T,Alloc>& y);
+template <class T, class Alloc>
+ bool operator> (const list<T,Alloc>& x, const list<T,Alloc>& y);
+template <class T, class Alloc>
+ bool operator>=(const list<T,Alloc>& x, const list<T,Alloc>& y);
+template <class T, class Alloc>
+ bool operator<=(const list<T,Alloc>& x, const list<T,Alloc>& y);
+
+template <class T, class Alloc>
+ void swap(list<T,Alloc>& x, list<T,Alloc>& y)
+ noexcept(noexcept(x.swap(y)));
+
+template <class T, class Allocator, class U>
+ typename list<T, Allocator>::size_type
+ erase(list<T, Allocator>& c, const U& value); // C++20
+template <class T, class Allocator, class Predicate>
+ typename list<T, Allocator>::size_type
+ erase_if(list<T, Allocator>& c, Predicate pred); // C++20
+
+} // std
+
+*/
+
+#include <__algorithm/comp.h>
+#include <__algorithm/equal.h>
+#include <__algorithm/lexicographical_compare.h>
+#include <__algorithm/min.h>
+#include <__assert>
+#include <__config>
+#include <__debug>
+#include <__utility/forward.h>
+#include <initializer_list>
+#include <iterator>
+#include <limits>
+#include <memory>
+#include <type_traits>
+#include <version>
+
+#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 _VoidPtr> struct __list_node;
+template <class _Tp, class _VoidPtr> struct __list_node_base;
+
+template <class _Tp, class _VoidPtr>
+struct __list_node_pointer_traits {
+ typedef typename __rebind_pointer<_VoidPtr, __list_node<_Tp, _VoidPtr> >::type
+ __node_pointer;
+ typedef typename __rebind_pointer<_VoidPtr, __list_node_base<_Tp, _VoidPtr> >::type
+ __base_pointer;
+
+#if defined(_LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB)
+ typedef __base_pointer __link_pointer;
+#else
+ typedef typename conditional<
+ is_pointer<_VoidPtr>::value,
+ __base_pointer,
+ __node_pointer
+ >::type __link_pointer;
+#endif
+
+ typedef typename conditional<
+ is_same<__link_pointer, __node_pointer>::value,
+ __base_pointer,
+ __node_pointer
+ >::type __non_link_pointer;
+
+ static _LIBCPP_INLINE_VISIBILITY
+ __link_pointer __unsafe_link_pointer_cast(__link_pointer __p) {
+ return __p;
+ }
+
+ static _LIBCPP_INLINE_VISIBILITY
+ __link_pointer __unsafe_link_pointer_cast(__non_link_pointer __p) {
+ return static_cast<__link_pointer>(static_cast<_VoidPtr>(__p));
+ }
+
+};
+
+template <class _Tp, class _VoidPtr>
+struct __list_node_base
+{
+ typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits;
+ typedef typename _NodeTraits::__node_pointer __node_pointer;
+ typedef typename _NodeTraits::__base_pointer __base_pointer;
+ typedef typename _NodeTraits::__link_pointer __link_pointer;
+
+ __link_pointer __prev_;
+ __link_pointer __next_;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __list_node_base() : __prev_(_NodeTraits::__unsafe_link_pointer_cast(__self())),
+ __next_(_NodeTraits::__unsafe_link_pointer_cast(__self())) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __base_pointer __self() {
+ return pointer_traits<__base_pointer>::pointer_to(*this);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __node_pointer __as_node() {
+ return static_cast<__node_pointer>(__self());
+ }
+};
+
+template <class _Tp, class _VoidPtr>
+struct _LIBCPP_STANDALONE_DEBUG __list_node
+ : public __list_node_base<_Tp, _VoidPtr>
+{
+ _Tp __value_;
+
+ typedef __list_node_base<_Tp, _VoidPtr> __base;
+ typedef typename __base::__link_pointer __link_pointer;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __link_pointer __as_link() {
+ return static_cast<__link_pointer>(__base::__self());
+ }
+};
+
+template <class _Tp, class _Alloc = allocator<_Tp> > class _LIBCPP_TEMPLATE_VIS list;
+template <class _Tp, class _Alloc> class __list_imp;
+template <class _Tp, class _VoidPtr> class _LIBCPP_TEMPLATE_VIS __list_const_iterator;
+
+template <class _Tp, class _VoidPtr>
+class _LIBCPP_TEMPLATE_VIS __list_iterator
+{
+ typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits;
+ typedef typename _NodeTraits::__link_pointer __link_pointer;
+
+ __link_pointer __ptr_;
+
+#if _LIBCPP_DEBUG_LEVEL == 2
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __list_iterator(__link_pointer __p, const void* __c) _NOEXCEPT
+ : __ptr_(__p)
+ {
+ __get_db()->__insert_ic(this, __c);
+ }
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __list_iterator(__link_pointer __p) _NOEXCEPT : __ptr_(__p) {}
+#endif
+
+
+
+ template<class, class> friend class list;
+ template<class, class> friend class __list_imp;
+ template<class, class> friend class __list_const_iterator;
+public:
+ typedef bidirectional_iterator_tag iterator_category;
+ typedef _Tp value_type;
+ typedef value_type& reference;
+ typedef typename __rebind_pointer<_VoidPtr, value_type>::type pointer;
+ typedef typename pointer_traits<pointer>::difference_type difference_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __list_iterator() _NOEXCEPT : __ptr_(nullptr)
+ {
+ _VSTD::__debug_db_insert_i(this);
+ }
+
+#if _LIBCPP_DEBUG_LEVEL == 2
+
+ _LIBCPP_INLINE_VISIBILITY
+ __list_iterator(const __list_iterator& __p)
+ : __ptr_(__p.__ptr_)
+ {
+ __get_db()->__iterator_copy(this, _VSTD::addressof(__p));
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ ~__list_iterator()
+ {
+ __get_db()->__erase_i(this);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __list_iterator& operator=(const __list_iterator& __p)
+ {
+ if (this != _VSTD::addressof(__p))
+ {
+ __get_db()->__iterator_copy(this, _VSTD::addressof(__p));
+ __ptr_ = __p.__ptr_;
+ }
+ return *this;
+ }
+
+#endif // _LIBCPP_DEBUG_LEVEL == 2
+
+ _LIBCPP_INLINE_VISIBILITY
+ reference operator*() const
+ {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
+ "Attempted to dereference a non-dereferenceable list::iterator");
+ return __ptr_->__as_node()->__value_;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ pointer operator->() const
+ {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
+ "Attempted to dereference a non-dereferenceable list::iterator");
+ return pointer_traits<pointer>::pointer_to(__ptr_->__as_node()->__value_);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __list_iterator& operator++()
+ {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
+ "Attempted to increment a non-incrementable list::iterator");
+ __ptr_ = __ptr_->__next_;
+ return *this;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ __list_iterator operator++(int) {__list_iterator __t(*this); ++(*this); return __t;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __list_iterator& operator--()
+ {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__decrementable(this),
+ "Attempted to decrement a non-decrementable list::iterator");
+ __ptr_ = __ptr_->__prev_;
+ return *this;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ __list_iterator operator--(int) {__list_iterator __t(*this); --(*this); return __t;}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const __list_iterator& __x, const __list_iterator& __y)
+ {
+ return __x.__ptr_ == __y.__ptr_;
+ }
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const __list_iterator& __x, const __list_iterator& __y)
+ {return !(__x == __y);}
+};
+
+template <class _Tp, class _VoidPtr>
+class _LIBCPP_TEMPLATE_VIS __list_const_iterator
+{
+ typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits;
+ typedef typename _NodeTraits::__link_pointer __link_pointer;
+
+ __link_pointer __ptr_;
+
+#if _LIBCPP_DEBUG_LEVEL == 2
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __list_const_iterator(__link_pointer __p, const void* __c) _NOEXCEPT
+ : __ptr_(__p)
+ {
+ __get_db()->__insert_ic(this, __c);
+ }
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __list_const_iterator(__link_pointer __p) _NOEXCEPT : __ptr_(__p) {}
+#endif
+
+ template<class, class> friend class list;
+ template<class, class> friend class __list_imp;
+public:
+ typedef bidirectional_iterator_tag iterator_category;
+ typedef _Tp value_type;
+ typedef const value_type& reference;
+ typedef typename __rebind_pointer<_VoidPtr, const value_type>::type pointer;
+ typedef typename pointer_traits<pointer>::difference_type difference_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __list_const_iterator() _NOEXCEPT : __ptr_(nullptr)
+ {
+ _VSTD::__debug_db_insert_i(this);
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ __list_const_iterator(const __list_iterator<_Tp, _VoidPtr>& __p) _NOEXCEPT
+ : __ptr_(__p.__ptr_)
+ {
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __get_db()->__iterator_copy(this, _VSTD::addressof(__p));
+#endif
+ }
+
+#if _LIBCPP_DEBUG_LEVEL == 2
+
+ _LIBCPP_INLINE_VISIBILITY
+ __list_const_iterator(const __list_const_iterator& __p)
+ : __ptr_(__p.__ptr_)
+ {
+ __get_db()->__iterator_copy(this, _VSTD::addressof(__p));
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ ~__list_const_iterator()
+ {
+ __get_db()->__erase_i(this);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __list_const_iterator& operator=(const __list_const_iterator& __p)
+ {
+ if (this != _VSTD::addressof(__p))
+ {
+ __get_db()->__iterator_copy(this, _VSTD::addressof(__p));
+ __ptr_ = __p.__ptr_;
+ }
+ return *this;
+ }
+
+#endif // _LIBCPP_DEBUG_LEVEL == 2
+ _LIBCPP_INLINE_VISIBILITY
+ reference operator*() const
+ {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
+ "Attempted to dereference a non-dereferenceable list::const_iterator");
+ return __ptr_->__as_node()->__value_;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ pointer operator->() const
+ {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
+ "Attempted to dereference a non-dereferenceable list::const_iterator");
+ return pointer_traits<pointer>::pointer_to(__ptr_->__as_node()->__value_);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __list_const_iterator& operator++()
+ {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
+ "Attempted to increment a non-incrementable list::const_iterator");
+ __ptr_ = __ptr_->__next_;
+ return *this;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ __list_const_iterator operator++(int) {__list_const_iterator __t(*this); ++(*this); return __t;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __list_const_iterator& operator--()
+ {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__decrementable(this),
+ "Attempted to decrement a non-decrementable list::const_iterator");
+ __ptr_ = __ptr_->__prev_;
+ return *this;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ __list_const_iterator operator--(int) {__list_const_iterator __t(*this); --(*this); return __t;}
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const __list_const_iterator& __x, const __list_const_iterator& __y)
+ {
+ return __x.__ptr_ == __y.__ptr_;
+ }
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const __list_const_iterator& __x, const __list_const_iterator& __y)
+ {return !(__x == __y);}
+};
+
+template <class _Tp, class _Alloc>
+class __list_imp
+{
+ __list_imp(const __list_imp&);
+ __list_imp& operator=(const __list_imp&);
+public:
+ typedef _Alloc allocator_type;
+ typedef allocator_traits<allocator_type> __alloc_traits;
+ typedef typename __alloc_traits::size_type size_type;
+protected:
+ typedef _Tp value_type;
+ typedef typename __alloc_traits::void_pointer __void_pointer;
+ typedef __list_iterator<value_type, __void_pointer> iterator;
+ typedef __list_const_iterator<value_type, __void_pointer> const_iterator;
+ typedef __list_node_base<value_type, __void_pointer> __node_base;
+ typedef __list_node<value_type, __void_pointer> __node;
+ typedef typename __rebind_alloc_helper<__alloc_traits, __node>::type __node_allocator;
+ typedef allocator_traits<__node_allocator> __node_alloc_traits;
+ typedef typename __node_alloc_traits::pointer __node_pointer;
+ typedef typename __node_alloc_traits::pointer __node_const_pointer;
+ typedef __list_node_pointer_traits<value_type, __void_pointer> __node_pointer_traits;
+ typedef typename __node_pointer_traits::__link_pointer __link_pointer;
+ typedef __link_pointer __link_const_pointer;
+ typedef typename __alloc_traits::pointer pointer;
+ typedef typename __alloc_traits::const_pointer const_pointer;
+ typedef typename __alloc_traits::difference_type difference_type;
+
+ typedef typename __rebind_alloc_helper<__alloc_traits, __node_base>::type __node_base_allocator;
+ typedef typename allocator_traits<__node_base_allocator>::pointer __node_base_pointer;
+ static_assert((!is_same<allocator_type, __node_allocator>::value),
+ "internal allocator type must differ from user-specified "
+ "type; otherwise overload resolution breaks");
+
+ __node_base __end_;
+ __compressed_pair<size_type, __node_allocator> __size_alloc_;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __link_pointer __end_as_link() const _NOEXCEPT {
+ return __node_pointer_traits::__unsafe_link_pointer_cast(
+ const_cast<__node_base&>(__end_).__self());
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type& __sz() _NOEXCEPT {return __size_alloc_.first();}
+ _LIBCPP_INLINE_VISIBILITY
+ const size_type& __sz() const _NOEXCEPT
+ {return __size_alloc_.first();}
+ _LIBCPP_INLINE_VISIBILITY
+ __node_allocator& __node_alloc() _NOEXCEPT
+ {return __size_alloc_.second();}
+ _LIBCPP_INLINE_VISIBILITY
+ const __node_allocator& __node_alloc() const _NOEXCEPT
+ {return __size_alloc_.second();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type __node_alloc_max_size() const _NOEXCEPT {
+ return __node_alloc_traits::max_size(__node_alloc());
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ static void __unlink_nodes(__link_pointer __f, __link_pointer __l) _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __list_imp()
+ _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value);
+ _LIBCPP_INLINE_VISIBILITY
+ __list_imp(const allocator_type& __a);
+ _LIBCPP_INLINE_VISIBILITY
+ __list_imp(const __node_allocator& __a);
+#ifndef _LIBCPP_CXX03_LANG
+ __list_imp(__node_allocator&& __a) _NOEXCEPT;
+#endif
+ ~__list_imp();
+ void clear() _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ bool empty() const _NOEXCEPT {return __sz() == 0;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator begin() _NOEXCEPT
+ {
+#if _LIBCPP_DEBUG_LEVEL == 2
+ return iterator(__end_.__next_, this);
+#else
+ return iterator(__end_.__next_);
+#endif
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator begin() const _NOEXCEPT
+ {
+#if _LIBCPP_DEBUG_LEVEL == 2
+ return const_iterator(__end_.__next_, this);
+#else
+ return const_iterator(__end_.__next_);
+#endif
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ iterator end() _NOEXCEPT
+ {
+#if _LIBCPP_DEBUG_LEVEL == 2
+ return iterator(__end_as_link(), this);
+#else
+ return iterator(__end_as_link());
+#endif
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator end() const _NOEXCEPT
+ {
+#if _LIBCPP_DEBUG_LEVEL == 2
+ return const_iterator(__end_as_link(), this);
+#else
+ return const_iterator(__end_as_link());
+#endif
+ }
+
+ void swap(__list_imp& __c)
+#if _LIBCPP_STD_VER >= 14
+ _NOEXCEPT;
+#else
+ _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
+ __is_nothrow_swappable<allocator_type>::value);
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __copy_assign_alloc(const __list_imp& __c)
+ {__copy_assign_alloc(__c, integral_constant<bool,
+ __node_alloc_traits::propagate_on_container_copy_assignment::value>());}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __move_assign_alloc(__list_imp& __c)
+ _NOEXCEPT_(
+ !__node_alloc_traits::propagate_on_container_move_assignment::value ||
+ is_nothrow_move_assignable<__node_allocator>::value)
+ {__move_assign_alloc(__c, integral_constant<bool,
+ __node_alloc_traits::propagate_on_container_move_assignment::value>());}
+
+private:
+ _LIBCPP_INLINE_VISIBILITY
+ void __copy_assign_alloc(const __list_imp& __c, true_type)
+ {
+ if (__node_alloc() != __c.__node_alloc())
+ clear();
+ __node_alloc() = __c.__node_alloc();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __copy_assign_alloc(const __list_imp&, false_type)
+ {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __move_assign_alloc(__list_imp& __c, true_type)
+ _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value)
+ {
+ __node_alloc() = _VSTD::move(__c.__node_alloc());
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __move_assign_alloc(__list_imp&, false_type)
+ _NOEXCEPT
+ {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __invalidate_all_iterators() {
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __get_db()->__invalidate_all(this);
+#endif
+ }
+};
+
+// Unlink nodes [__f, __l]
+template <class _Tp, class _Alloc>
+inline
+void
+__list_imp<_Tp, _Alloc>::__unlink_nodes(__link_pointer __f, __link_pointer __l)
+ _NOEXCEPT
+{
+ __f->__prev_->__next_ = __l->__next_;
+ __l->__next_->__prev_ = __f->__prev_;
+}
+
+template <class _Tp, class _Alloc>
+inline
+__list_imp<_Tp, _Alloc>::__list_imp()
+ _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)
+ : __size_alloc_(0, __default_init_tag())
+{
+}
+
+template <class _Tp, class _Alloc>
+inline
+__list_imp<_Tp, _Alloc>::__list_imp(const allocator_type& __a)
+ : __size_alloc_(0, __node_allocator(__a))
+{
+}
+
+template <class _Tp, class _Alloc>
+inline __list_imp<_Tp, _Alloc>::__list_imp(const __node_allocator& __a)
+ : __size_alloc_(0, __a) {}
+
+#ifndef _LIBCPP_CXX03_LANG
+template <class _Tp, class _Alloc>
+inline __list_imp<_Tp, _Alloc>::__list_imp(__node_allocator&& __a) _NOEXCEPT
+ : __size_alloc_(0, _VSTD::move(__a)) {}
+#endif
+
+template <class _Tp, class _Alloc>
+__list_imp<_Tp, _Alloc>::~__list_imp() {
+ clear();
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __get_db()->__erase_c(this);
+#endif
+}
+
+template <class _Tp, class _Alloc>
+void
+__list_imp<_Tp, _Alloc>::clear() _NOEXCEPT
+{
+ if (!empty())
+ {
+ __node_allocator& __na = __node_alloc();
+ __link_pointer __f = __end_.__next_;
+ __link_pointer __l = __end_as_link();
+ __unlink_nodes(__f, __l->__prev_);
+ __sz() = 0;
+ while (__f != __l)
+ {
+ __node_pointer __np = __f->__as_node();
+ __f = __f->__next_;
+ __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_));
+ __node_alloc_traits::deallocate(__na, __np, 1);
+ }
+ __invalidate_all_iterators();
+ }
+}
+
+template <class _Tp, class _Alloc>
+void
+__list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
+#if _LIBCPP_STD_VER >= 14
+ _NOEXCEPT
+#else
+ _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
+ __is_nothrow_swappable<allocator_type>::value)
+#endif
+{
+ _LIBCPP_ASSERT(__alloc_traits::propagate_on_container_swap::value ||
+ this->__node_alloc() == __c.__node_alloc(),
+ "list::swap: Either propagate_on_container_swap must be true"
+ " or the allocators must compare equal");
+ using _VSTD::swap;
+ _VSTD::__swap_allocator(__node_alloc(), __c.__node_alloc());
+ swap(__sz(), __c.__sz());
+ swap(__end_, __c.__end_);
+ if (__sz() == 0)
+ __end_.__next_ = __end_.__prev_ = __end_as_link();
+ else
+ __end_.__prev_->__next_ = __end_.__next_->__prev_ = __end_as_link();
+ if (__c.__sz() == 0)
+ __c.__end_.__next_ = __c.__end_.__prev_ = __c.__end_as_link();
+ else
+ __c.__end_.__prev_->__next_ = __c.__end_.__next_->__prev_ = __c.__end_as_link();
+
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __libcpp_db* __db = __get_db();
+ __c_node* __cn1 = __db->__find_c_and_lock(this);
+ __c_node* __cn2 = __db->__find_c(_VSTD::addressof(__c));
+ _VSTD::swap(__cn1->beg_, __cn2->beg_);
+ _VSTD::swap(__cn1->end_, __cn2->end_);
+ _VSTD::swap(__cn1->cap_, __cn2->cap_);
+ for (__i_node** __p = __cn1->end_; __p != __cn1->beg_;)
+ {
+ --__p;
+ const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_);
+ if (__i->__ptr_ == __c.__end_as_link())
+ {
+ __cn2->__add(*__p);
+ if (--__cn1->end_ != __p)
+ _VSTD::memmove(__p, __p+1, (__cn1->end_ - __p)*sizeof(__i_node*));
+ }
+ else
+ (*__p)->__c_ = __cn1;
+ }
+ for (__i_node** __p = __cn2->end_; __p != __cn2->beg_;)
+ {
+ --__p;
+ const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_);
+ if (__i->__ptr_ == __end_as_link())
+ {
+ __cn1->__add(*__p);
+ if (--__cn2->end_ != __p)
+ _VSTD::memmove(__p, __p+1, (__cn2->end_ - __p)*sizeof(__i_node*));
+ }
+ else
+ (*__p)->__c_ = __cn2;
+ }
+ __db->unlock();
+#endif
+}
+
+template <class _Tp, class _Alloc /*= allocator<_Tp>*/>
+class _LIBCPP_TEMPLATE_VIS list
+ : private __list_imp<_Tp, _Alloc>
+{
+ typedef __list_imp<_Tp, _Alloc> base;
+ typedef typename base::__node __node;
+ typedef typename base::__node_allocator __node_allocator;
+ typedef typename base::__node_pointer __node_pointer;
+ typedef typename base::__node_alloc_traits __node_alloc_traits;
+ typedef typename base::__node_base __node_base;
+ typedef typename base::__node_base_pointer __node_base_pointer;
+ typedef typename base::__link_pointer __link_pointer;
+
+public:
+ typedef _Tp value_type;
+ typedef _Alloc allocator_type;
+ static_assert((is_same<value_type, typename allocator_type::value_type>::value),
+ "Invalid allocator::value_type");
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef typename base::pointer pointer;
+ typedef typename base::const_pointer const_pointer;
+ typedef typename base::size_type size_type;
+ typedef typename base::difference_type difference_type;
+ typedef typename base::iterator iterator;
+ typedef typename base::const_iterator const_iterator;
+ typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
+ typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
+#if _LIBCPP_STD_VER > 17
+ typedef size_type __remove_return_type;
+#else
+ typedef void __remove_return_type;
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ list()
+ _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)
+ {
+ _VSTD::__debug_db_insert_c(this);
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ explicit list(const allocator_type& __a) : base(__a)
+ {
+ _VSTD::__debug_db_insert_c(this);
+ }
+ explicit list(size_type __n);
+#if _LIBCPP_STD_VER > 11
+ explicit list(size_type __n, const allocator_type& __a);
+#endif
+ list(size_type __n, const value_type& __x);
+ template <class = __enable_if_t<__is_allocator<_Alloc>::value> >
+ list(size_type __n, const value_type& __x, const allocator_type& __a) : base(__a)
+ {
+ _VSTD::__debug_db_insert_c(this);
+ for (; __n > 0; --__n)
+ push_back(__x);
+ }
+
+ template <class _InpIter>
+ list(_InpIter __f, _InpIter __l,
+ typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type* = 0);
+ template <class _InpIter>
+ list(_InpIter __f, _InpIter __l, const allocator_type& __a,
+ typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type* = 0);
+
+ list(const list& __c);
+ list(const list& __c, const __identity_t<allocator_type>& __a);
+ _LIBCPP_INLINE_VISIBILITY
+ list& operator=(const list& __c);
+#ifndef _LIBCPP_CXX03_LANG
+ list(initializer_list<value_type> __il);
+ list(initializer_list<value_type> __il, const allocator_type& __a);
+
+ _LIBCPP_INLINE_VISIBILITY
+ list(list&& __c)
+ _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value);
+ _LIBCPP_INLINE_VISIBILITY
+ list(list&& __c, const __identity_t<allocator_type>& __a);
+ _LIBCPP_INLINE_VISIBILITY
+ list& operator=(list&& __c)
+ _NOEXCEPT_(
+ __node_alloc_traits::propagate_on_container_move_assignment::value &&
+ is_nothrow_move_assignable<__node_allocator>::value);
+
+ _LIBCPP_INLINE_VISIBILITY
+ list& operator=(initializer_list<value_type> __il)
+ {assign(__il.begin(), __il.end()); return *this;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void assign(initializer_list<value_type> __il)
+ {assign(__il.begin(), __il.end());}
+#endif // _LIBCPP_CXX03_LANG
+
+ template <class _InpIter>
+ void assign(_InpIter __f, _InpIter __l,
+ typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type* = 0);
+ void assign(size_type __n, const value_type& __x);
+
+ _LIBCPP_INLINE_VISIBILITY
+ allocator_type get_allocator() const _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type size() const _NOEXCEPT {return base::__sz();}
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+ bool empty() const _NOEXCEPT {return base::empty();}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type max_size() const _NOEXCEPT
+ {
+ return _VSTD::min<size_type>(
+ base::__node_alloc_max_size(),
+ numeric_limits<difference_type >::max());
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator begin() _NOEXCEPT {return base::begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator begin() const _NOEXCEPT {return base::begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator end() _NOEXCEPT {return base::end();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator end() const _NOEXCEPT {return base::end();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator cbegin() const _NOEXCEPT {return base::begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator cend() const _NOEXCEPT {return base::end();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ reverse_iterator rbegin() _NOEXCEPT
+ {return reverse_iterator(end());}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator rbegin() const _NOEXCEPT
+ {return const_reverse_iterator(end());}
+ _LIBCPP_INLINE_VISIBILITY
+ reverse_iterator rend() _NOEXCEPT
+ {return reverse_iterator(begin());}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator rend() const _NOEXCEPT
+ {return const_reverse_iterator(begin());}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator crbegin() const _NOEXCEPT
+ {return const_reverse_iterator(end());}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator crend() const _NOEXCEPT
+ {return const_reverse_iterator(begin());}
+
+ _LIBCPP_INLINE_VISIBILITY
+ reference front()
+ {
+ _LIBCPP_ASSERT(!empty(), "list::front called on empty list");
+ return base::__end_.__next_->__as_node()->__value_;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ const_reference front() const
+ {
+ _LIBCPP_ASSERT(!empty(), "list::front called on empty list");
+ return base::__end_.__next_->__as_node()->__value_;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ reference back()
+ {
+ _LIBCPP_ASSERT(!empty(), "list::back called on empty list");
+ return base::__end_.__prev_->__as_node()->__value_;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ const_reference back() const
+ {
+ _LIBCPP_ASSERT(!empty(), "list::back called on empty list");
+ return base::__end_.__prev_->__as_node()->__value_;
+ }
+
+#ifndef _LIBCPP_CXX03_LANG
+ void push_front(value_type&& __x);
+ void push_back(value_type&& __x);
+
+ template <class... _Args>
+#if _LIBCPP_STD_VER > 14
+ reference emplace_front(_Args&&... __args);
+#else
+ void emplace_front(_Args&&... __args);
+#endif
+ template <class... _Args>
+#if _LIBCPP_STD_VER > 14
+ reference emplace_back(_Args&&... __args);
+#else
+ void emplace_back(_Args&&... __args);
+#endif
+ template <class... _Args>
+ iterator emplace(const_iterator __p, _Args&&... __args);
+
+ iterator insert(const_iterator __p, value_type&& __x);
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const_iterator __p, initializer_list<value_type> __il)
+ {return insert(__p, __il.begin(), __il.end());}
+#endif // _LIBCPP_CXX03_LANG
+
+ void push_front(const value_type& __x);
+ void push_back(const value_type& __x);
+
+#ifndef _LIBCPP_CXX03_LANG
+ template <class _Arg>
+ _LIBCPP_INLINE_VISIBILITY
+ void __emplace_back(_Arg&& __arg) { emplace_back(_VSTD::forward<_Arg>(__arg)); }
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ void __emplace_back(value_type const& __arg) { push_back(__arg); }
+#endif
+
+ iterator insert(const_iterator __p, const value_type& __x);
+ iterator insert(const_iterator __p, size_type __n, const value_type& __x);
+ template <class _InpIter>
+ iterator insert(const_iterator __p, _InpIter __f, _InpIter __l,
+ typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type* = 0);
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(list& __c)
+#if _LIBCPP_STD_VER >= 14
+ _NOEXCEPT
+#else
+ _NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value ||
+ __is_nothrow_swappable<__node_allocator>::value)
+#endif
+ {base::swap(__c);}
+ _LIBCPP_INLINE_VISIBILITY
+ void clear() _NOEXCEPT {base::clear();}
+
+ void pop_front();
+ void pop_back();
+
+ iterator erase(const_iterator __p);
+ iterator erase(const_iterator __f, const_iterator __l);
+
+ void resize(size_type __n);
+ void resize(size_type __n, const value_type& __x);
+
+ void splice(const_iterator __p, list& __c);
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ void splice(const_iterator __p, list&& __c) {splice(__p, __c);}
+ _LIBCPP_INLINE_VISIBILITY
+ void splice(const_iterator __p, list&& __c, const_iterator __i)
+ {splice(__p, __c, __i);}
+ _LIBCPP_INLINE_VISIBILITY
+ void splice(const_iterator __p, list&& __c, const_iterator __f, const_iterator __l)
+ {splice(__p, __c, __f, __l);}
+#endif
+ void splice(const_iterator __p, list& __c, const_iterator __i);
+ void splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l);
+
+ __remove_return_type remove(const value_type& __x);
+ template <class _Pred> __remove_return_type remove_if(_Pred __pred);
+ _LIBCPP_INLINE_VISIBILITY
+ __remove_return_type unique() { return unique(__equal_to<value_type>()); }
+ template <class _BinaryPred>
+ __remove_return_type unique(_BinaryPred __binary_pred);
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(list& __c);
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(list&& __c) {merge(__c);}
+
+ template <class _Comp>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(list&& __c, _Comp __comp) {merge(__c, __comp);}
+#endif
+ template <class _Comp>
+ void merge(list& __c, _Comp __comp);
+
+ _LIBCPP_INLINE_VISIBILITY
+ void sort();
+ template <class _Comp>
+ _LIBCPP_INLINE_VISIBILITY
+ void sort(_Comp __comp);
+
+ void reverse() _NOEXCEPT;
+
+ bool __invariants() const;
+
+ typedef __allocator_destructor<__node_allocator> __node_destructor;
+ typedef unique_ptr<__node, __node_destructor> __hold_pointer;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __hold_pointer __allocate_node(__node_allocator& __na) {
+ __node_pointer __p = __node_alloc_traits::allocate(__na, 1);
+ __p->__prev_ = nullptr;
+ return __hold_pointer(__p, __node_destructor(__na, 1));
+ }
+
+#if _LIBCPP_DEBUG_LEVEL == 2
+
+ bool __dereferenceable(const const_iterator* __i) const;
+ bool __decrementable(const const_iterator* __i) const;
+ 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
+
+private:
+ _LIBCPP_INLINE_VISIBILITY
+ static void __link_nodes (__link_pointer __p, __link_pointer __f, __link_pointer __l);
+ _LIBCPP_INLINE_VISIBILITY
+ void __link_nodes_at_front(__link_pointer __f, __link_pointer __l);
+ _LIBCPP_INLINE_VISIBILITY
+ void __link_nodes_at_back (__link_pointer __f, __link_pointer __l);
+ iterator __iterator(size_type __n);
+ template <class _Comp>
+ static iterator __sort(iterator __f1, iterator __e2, size_type __n, _Comp& __comp);
+
+ void __move_assign(list& __c, true_type)
+ _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value);
+ void __move_assign(list& __c, false_type);
+};
+
+#if _LIBCPP_STD_VER >= 17
+template<class _InputIterator,
+ class _Alloc = allocator<__iter_value_type<_InputIterator>>,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = enable_if_t<__is_allocator<_Alloc>::value>
+ >
+list(_InputIterator, _InputIterator)
+ -> list<__iter_value_type<_InputIterator>, _Alloc>;
+
+template<class _InputIterator,
+ class _Alloc,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = enable_if_t<__is_allocator<_Alloc>::value>
+ >
+list(_InputIterator, _InputIterator, _Alloc)
+ -> list<__iter_value_type<_InputIterator>, _Alloc>;
+#endif
+
+// Link in nodes [__f, __l] just prior to __p
+template <class _Tp, class _Alloc>
+inline
+void
+list<_Tp, _Alloc>::__link_nodes(__link_pointer __p, __link_pointer __f, __link_pointer __l)
+{
+ __p->__prev_->__next_ = __f;
+ __f->__prev_ = __p->__prev_;
+ __p->__prev_ = __l;
+ __l->__next_ = __p;
+}
+
+// Link in nodes [__f, __l] at the front of the list
+template <class _Tp, class _Alloc>
+inline
+void
+list<_Tp, _Alloc>::__link_nodes_at_front(__link_pointer __f, __link_pointer __l)
+{
+ __f->__prev_ = base::__end_as_link();
+ __l->__next_ = base::__end_.__next_;
+ __l->__next_->__prev_ = __l;
+ base::__end_.__next_ = __f;
+}
+
+// Link in nodes [__f, __l] at the back of the list
+template <class _Tp, class _Alloc>
+inline
+void
+list<_Tp, _Alloc>::__link_nodes_at_back(__link_pointer __f, __link_pointer __l)
+{
+ __l->__next_ = base::__end_as_link();
+ __f->__prev_ = base::__end_.__prev_;
+ __f->__prev_->__next_ = __f;
+ base::__end_.__prev_ = __l;
+}
+
+
+template <class _Tp, class _Alloc>
+inline
+typename list<_Tp, _Alloc>::iterator
+list<_Tp, _Alloc>::__iterator(size_type __n)
+{
+ return __n <= base::__sz() / 2 ? _VSTD::next(begin(), __n)
+ : _VSTD::prev(end(), base::__sz() - __n);
+}
+
+template <class _Tp, class _Alloc>
+list<_Tp, _Alloc>::list(size_type __n)
+{
+ _VSTD::__debug_db_insert_c(this);
+ for (; __n > 0; --__n)
+#ifndef _LIBCPP_CXX03_LANG
+ emplace_back();
+#else
+ push_back(value_type());
+#endif
+}
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp, class _Alloc>
+list<_Tp, _Alloc>::list(size_type __n, const allocator_type& __a) : base(__a)
+{
+ _VSTD::__debug_db_insert_c(this);
+ for (; __n > 0; --__n)
+ emplace_back();
+}
+#endif
+
+template <class _Tp, class _Alloc>
+list<_Tp, _Alloc>::list(size_type __n, const value_type& __x)
+{
+ _VSTD::__debug_db_insert_c(this);
+ for (; __n > 0; --__n)
+ push_back(__x);
+}
+
+template <class _Tp, class _Alloc>
+template <class _InpIter>
+list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l,
+ typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type*)
+{
+ _VSTD::__debug_db_insert_c(this);
+ for (; __f != __l; ++__f)
+ __emplace_back(*__f);
+}
+
+template <class _Tp, class _Alloc>
+template <class _InpIter>
+list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, const allocator_type& __a,
+ typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type*)
+ : base(__a)
+{
+ _VSTD::__debug_db_insert_c(this);
+ for (; __f != __l; ++__f)
+ __emplace_back(*__f);
+}
+
+template <class _Tp, class _Alloc>
+list<_Tp, _Alloc>::list(const list& __c)
+ : base(__node_alloc_traits::select_on_container_copy_construction(
+ __c.__node_alloc())) {
+ _VSTD::__debug_db_insert_c(this);
+ for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i)
+ push_back(*__i);
+}
+
+template <class _Tp, class _Alloc>
+list<_Tp, _Alloc>::list(const list& __c, const __identity_t<allocator_type>& __a)
+ : base(__a)
+{
+ _VSTD::__debug_db_insert_c(this);
+ for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i)
+ push_back(*__i);
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Alloc>
+list<_Tp, _Alloc>::list(initializer_list<value_type> __il, const allocator_type& __a)
+ : base(__a)
+{
+ _VSTD::__debug_db_insert_c(this);
+ for (typename initializer_list<value_type>::const_iterator __i = __il.begin(),
+ __e = __il.end(); __i != __e; ++__i)
+ push_back(*__i);
+}
+
+template <class _Tp, class _Alloc>
+list<_Tp, _Alloc>::list(initializer_list<value_type> __il)
+{
+ _VSTD::__debug_db_insert_c(this);
+ for (typename initializer_list<value_type>::const_iterator __i = __il.begin(),
+ __e = __il.end(); __i != __e; ++__i)
+ push_back(*__i);
+}
+
+template <class _Tp, class _Alloc>
+inline list<_Tp, _Alloc>::list(list&& __c)
+ _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value)
+ : base(_VSTD::move(__c.__node_alloc())) {
+ _VSTD::__debug_db_insert_c(this);
+ splice(end(), __c);
+}
+
+template <class _Tp, class _Alloc>
+inline
+list<_Tp, _Alloc>::list(list&& __c, const __identity_t<allocator_type>& __a)
+ : base(__a)
+{
+ _VSTD::__debug_db_insert_c(this);
+ if (__a == __c.get_allocator())
+ splice(end(), __c);
+ else
+ {
+ typedef move_iterator<iterator> _Ip;
+ assign(_Ip(__c.begin()), _Ip(__c.end()));
+ }
+}
+
+template <class _Tp, class _Alloc>
+inline
+list<_Tp, _Alloc>&
+list<_Tp, _Alloc>::operator=(list&& __c)
+ _NOEXCEPT_(
+ __node_alloc_traits::propagate_on_container_move_assignment::value &&
+ is_nothrow_move_assignable<__node_allocator>::value)
+{
+ __move_assign(__c, integral_constant<bool,
+ __node_alloc_traits::propagate_on_container_move_assignment::value>());
+ return *this;
+}
+
+template <class _Tp, class _Alloc>
+void
+list<_Tp, _Alloc>::__move_assign(list& __c, false_type)
+{
+ if (base::__node_alloc() != __c.__node_alloc())
+ {
+ typedef move_iterator<iterator> _Ip;
+ assign(_Ip(__c.begin()), _Ip(__c.end()));
+ }
+ else
+ __move_assign(__c, true_type());
+}
+
+template <class _Tp, class _Alloc>
+void
+list<_Tp, _Alloc>::__move_assign(list& __c, true_type)
+ _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value)
+{
+ clear();
+ base::__move_assign_alloc(__c);
+ splice(end(), __c);
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Alloc>
+inline
+list<_Tp, _Alloc>&
+list<_Tp, _Alloc>::operator=(const list& __c)
+{
+ if (this != _VSTD::addressof(__c))
+ {
+ base::__copy_assign_alloc(__c);
+ assign(__c.begin(), __c.end());
+ }
+ return *this;
+}
+
+template <class _Tp, class _Alloc>
+template <class _InpIter>
+void
+list<_Tp, _Alloc>::assign(_InpIter __f, _InpIter __l,
+ typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type*)
+{
+ iterator __i = begin();
+ iterator __e = end();
+ for (; __f != __l && __i != __e; ++__f, (void) ++__i)
+ *__i = *__f;
+ if (__i == __e)
+ insert(__e, __f, __l);
+ else
+ erase(__i, __e);
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __get_db()->__invalidate_all(this);
+#endif
+}
+
+template <class _Tp, class _Alloc>
+void
+list<_Tp, _Alloc>::assign(size_type __n, const value_type& __x)
+{
+ iterator __i = begin();
+ iterator __e = end();
+ for (; __n > 0 && __i != __e; --__n, (void) ++__i)
+ *__i = __x;
+ if (__i == __e)
+ insert(__e, __n, __x);
+ else
+ erase(__i, __e);
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __get_db()->__invalidate_all(this);
+#endif
+}
+
+template <class _Tp, class _Alloc>
+inline
+_Alloc
+list<_Tp, _Alloc>::get_allocator() const _NOEXCEPT
+{
+ return allocator_type(base::__node_alloc());
+}
+
+template <class _Tp, class _Alloc>
+typename list<_Tp, _Alloc>::iterator
+list<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x)
+{
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
+ "list::insert(iterator, x) called with an iterator not referring to this list");
+ __node_allocator& __na = base::__node_alloc();
+ __hold_pointer __hold = __allocate_node(__na);
+ __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
+ __link_nodes(__p.__ptr_, __hold->__as_link(), __hold->__as_link());
+ ++base::__sz();
+#if _LIBCPP_DEBUG_LEVEL == 2
+ return iterator(__hold.release()->__as_link(), this);
+#else
+ return iterator(__hold.release()->__as_link());
+#endif
+}
+
+template <class _Tp, class _Alloc>
+typename list<_Tp, _Alloc>::iterator
+list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& __x)
+{
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
+ "list::insert(iterator, n, x) called with an iterator not referring to this list");
+#if _LIBCPP_DEBUG_LEVEL == 2
+ iterator __r(__p.__ptr_, this);
+#else
+ iterator __r(__p.__ptr_);
+#endif
+ if (__n > 0)
+ {
+ size_type __ds = 0;
+ __node_allocator& __na = base::__node_alloc();
+ __hold_pointer __hold = __allocate_node(__na);
+ __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
+ ++__ds;
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __r = iterator(__hold->__as_link(), this);
+#else
+ __r = iterator(__hold->__as_link());
+#endif
+ __hold.release();
+ iterator __e = __r;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ for (--__n; __n != 0; --__n, (void) ++__e, ++__ds)
+ {
+ __hold.reset(__node_alloc_traits::allocate(__na, 1));
+ __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
+ __e.__ptr_->__next_ = __hold->__as_link();
+ __hold->__prev_ = __e.__ptr_;
+ __hold.release();
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ while (true)
+ {
+ __node_alloc_traits::destroy(__na, _VSTD::addressof(*__e));
+ __link_pointer __prev = __e.__ptr_->__prev_;
+ __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);
+ if (__prev == 0)
+ break;
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __e = iterator(__prev, this);
+#else
+ __e = iterator(__prev);
+#endif
+ }
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ __link_nodes(__p.__ptr_, __r.__ptr_, __e.__ptr_);
+ base::__sz() += __ds;
+ }
+ return __r;
+}
+
+template <class _Tp, class _Alloc>
+template <class _InpIter>
+typename list<_Tp, _Alloc>::iterator
+list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l,
+ typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type*)
+{
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
+ "list::insert(iterator, range) called with an iterator not referring to this list");
+#if _LIBCPP_DEBUG_LEVEL == 2
+ iterator __r(__p.__ptr_, this);
+#else
+ iterator __r(__p.__ptr_);
+#endif
+ if (__f != __l)
+ {
+ size_type __ds = 0;
+ __node_allocator& __na = base::__node_alloc();
+ __hold_pointer __hold = __allocate_node(__na);
+ __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), *__f);
+ ++__ds;
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __r = iterator(__hold.get()->__as_link(), this);
+#else
+ __r = iterator(__hold.get()->__as_link());
+#endif
+ __hold.release();
+ iterator __e = __r;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ for (++__f; __f != __l; ++__f, (void) ++__e, ++__ds)
+ {
+ __hold.reset(__node_alloc_traits::allocate(__na, 1));
+ __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), *__f);
+ __e.__ptr_->__next_ = __hold.get()->__as_link();
+ __hold->__prev_ = __e.__ptr_;
+ __hold.release();
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ while (true)
+ {
+ __node_alloc_traits::destroy(__na, _VSTD::addressof(*__e));
+ __link_pointer __prev = __e.__ptr_->__prev_;
+ __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);
+ if (__prev == 0)
+ break;
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __e = iterator(__prev, this);
+#else
+ __e = iterator(__prev);
+#endif
+ }
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ __link_nodes(__p.__ptr_, __r.__ptr_, __e.__ptr_);
+ base::__sz() += __ds;
+ }
+ return __r;
+}
+
+template <class _Tp, class _Alloc>
+void
+list<_Tp, _Alloc>::push_front(const value_type& __x)
+{
+ __node_allocator& __na = base::__node_alloc();
+ __hold_pointer __hold = __allocate_node(__na);
+ __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
+ __link_pointer __nl = __hold->__as_link();
+ __link_nodes_at_front(__nl, __nl);
+ ++base::__sz();
+ __hold.release();
+}
+
+template <class _Tp, class _Alloc>
+void
+list<_Tp, _Alloc>::push_back(const value_type& __x)
+{
+ __node_allocator& __na = base::__node_alloc();
+ __hold_pointer __hold = __allocate_node(__na);
+ __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
+ __link_nodes_at_back(__hold.get()->__as_link(), __hold.get()->__as_link());
+ ++base::__sz();
+ __hold.release();
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Alloc>
+void
+list<_Tp, _Alloc>::push_front(value_type&& __x)
+{
+ __node_allocator& __na = base::__node_alloc();
+ __hold_pointer __hold = __allocate_node(__na);
+ __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x));
+ __link_nodes_at_front(__hold.get()->__as_link(), __hold.get()->__as_link());
+ ++base::__sz();
+ __hold.release();
+}
+
+template <class _Tp, class _Alloc>
+void
+list<_Tp, _Alloc>::push_back(value_type&& __x)
+{
+ __node_allocator& __na = base::__node_alloc();
+ __hold_pointer __hold = __allocate_node(__na);
+ __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x));
+ __link_nodes_at_back(__hold.get()->__as_link(), __hold.get()->__as_link());
+ ++base::__sz();
+ __hold.release();
+}
+
+template <class _Tp, class _Alloc>
+template <class... _Args>
+#if _LIBCPP_STD_VER > 14
+typename list<_Tp, _Alloc>::reference
+#else
+void
+#endif
+list<_Tp, _Alloc>::emplace_front(_Args&&... __args)
+{
+ __node_allocator& __na = base::__node_alloc();
+ __hold_pointer __hold = __allocate_node(__na);
+ __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...);
+ __link_nodes_at_front(__hold.get()->__as_link(), __hold.get()->__as_link());
+ ++base::__sz();
+#if _LIBCPP_STD_VER > 14
+ return __hold.release()->__value_;
+#else
+ __hold.release();
+#endif
+}
+
+template <class _Tp, class _Alloc>
+template <class... _Args>
+#if _LIBCPP_STD_VER > 14
+typename list<_Tp, _Alloc>::reference
+#else
+void
+#endif
+list<_Tp, _Alloc>::emplace_back(_Args&&... __args)
+{
+ __node_allocator& __na = base::__node_alloc();
+ __hold_pointer __hold = __allocate_node(__na);
+ __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...);
+ __link_pointer __nl = __hold->__as_link();
+ __link_nodes_at_back(__nl, __nl);
+ ++base::__sz();
+#if _LIBCPP_STD_VER > 14
+ return __hold.release()->__value_;
+#else
+ __hold.release();
+#endif
+}
+
+template <class _Tp, class _Alloc>
+template <class... _Args>
+typename list<_Tp, _Alloc>::iterator
+list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args)
+{
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
+ "list::emplace(iterator, args...) called with an iterator not referring to this list");
+ __node_allocator& __na = base::__node_alloc();
+ __hold_pointer __hold = __allocate_node(__na);
+ __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...);
+ __link_pointer __nl = __hold.get()->__as_link();
+ __link_nodes(__p.__ptr_, __nl, __nl);
+ ++base::__sz();
+ __hold.release();
+#if _LIBCPP_DEBUG_LEVEL == 2
+ return iterator(__nl, this);
+#else
+ return iterator(__nl);
+#endif
+}
+
+template <class _Tp, class _Alloc>
+typename list<_Tp, _Alloc>::iterator
+list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x)
+{
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
+ "list::insert(iterator, x) called with an iterator not referring to this list");
+ __node_allocator& __na = base::__node_alloc();
+ __hold_pointer __hold = __allocate_node(__na);
+ __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x));
+ __link_pointer __nl = __hold->__as_link();
+ __link_nodes(__p.__ptr_, __nl, __nl);
+ ++base::__sz();
+ __hold.release();
+#if _LIBCPP_DEBUG_LEVEL == 2
+ return iterator(__nl, this);
+#else
+ return iterator(__nl);
+#endif
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Alloc>
+void
+list<_Tp, _Alloc>::pop_front()
+{
+ _LIBCPP_ASSERT(!empty(), "list::pop_front() called with empty list");
+ __node_allocator& __na = base::__node_alloc();
+ __link_pointer __n = base::__end_.__next_;
+ base::__unlink_nodes(__n, __n);
+ --base::__sz();
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __c_node* __c = __get_db()->__find_c_and_lock(this);
+ for (__i_node** __p = __c->end_; __p != __c->beg_; )
+ {
+ --__p;
+ iterator* __i = static_cast<iterator*>((*__p)->__i_);
+ if (__i->__ptr_ == __n)
+ {
+ (*__p)->__c_ = nullptr;
+ if (--__c->end_ != __p)
+ _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
+ }
+ }
+ __get_db()->unlock();
+#endif
+ __node_pointer __np = __n->__as_node();
+ __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_));
+ __node_alloc_traits::deallocate(__na, __np, 1);
+}
+
+template <class _Tp, class _Alloc>
+void
+list<_Tp, _Alloc>::pop_back()
+{
+ _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);
+ --base::__sz();
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __c_node* __c = __get_db()->__find_c_and_lock(this);
+ for (__i_node** __p = __c->end_; __p != __c->beg_; )
+ {
+ --__p;
+ iterator* __i = static_cast<iterator*>((*__p)->__i_);
+ if (__i->__ptr_ == __n)
+ {
+ (*__p)->__c_ = nullptr;
+ if (--__c->end_ != __p)
+ _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
+ }
+ }
+ __get_db()->unlock();
+#endif
+ __node_pointer __np = __n->__as_node();
+ __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_));
+ __node_alloc_traits::deallocate(__na, __np, 1);
+}
+
+template <class _Tp, class _Alloc>
+typename list<_Tp, _Alloc>::iterator
+list<_Tp, _Alloc>::erase(const_iterator __p)
+{
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
+ "list::erase(iterator) called with an iterator not referring to this list");
+ _LIBCPP_ASSERT(__p != end(),
+ "list::erase(iterator) called with a non-dereferenceable iterator");
+ __node_allocator& __na = base::__node_alloc();
+ __link_pointer __n = __p.__ptr_;
+ __link_pointer __r = __n->__next_;
+ base::__unlink_nodes(__n, __n);
+ --base::__sz();
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __c_node* __c = __get_db()->__find_c_and_lock(this);
+ for (__i_node** __ip = __c->end_; __ip != __c->beg_; )
+ {
+ --__ip;
+ iterator* __i = static_cast<iterator*>((*__ip)->__i_);
+ if (__i->__ptr_ == __n)
+ {
+ (*__ip)->__c_ = nullptr;
+ if (--__c->end_ != __ip)
+ _VSTD::memmove(__ip, __ip+1, (__c->end_ - __ip)*sizeof(__i_node*));
+ }
+ }
+ __get_db()->unlock();
+#endif
+ __node_pointer __np = __n->__as_node();
+ __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_));
+ __node_alloc_traits::deallocate(__na, __np, 1);
+#if _LIBCPP_DEBUG_LEVEL == 2
+ return iterator(__r, this);
+#else
+ return iterator(__r);
+#endif
+}
+
+template <class _Tp, class _Alloc>
+typename list<_Tp, _Alloc>::iterator
+list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l)
+{
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__f)) == this,
+ "list::erase(iterator, iterator) called with an iterator not referring to this list");
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__l)) == this,
+ "list::erase(iterator, iterator) called with an iterator not referring to this list");
+ if (__f != __l)
+ {
+ __node_allocator& __na = base::__node_alloc();
+ base::__unlink_nodes(__f.__ptr_, __l.__ptr_->__prev_);
+ while (__f != __l)
+ {
+ __link_pointer __n = __f.__ptr_;
+ ++__f;
+ --base::__sz();
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __c_node* __c = __get_db()->__find_c_and_lock(this);
+ for (__i_node** __p = __c->end_; __p != __c->beg_; )
+ {
+ --__p;
+ iterator* __i = static_cast<iterator*>((*__p)->__i_);
+ if (__i->__ptr_ == __n)
+ {
+ (*__p)->__c_ = nullptr;
+ if (--__c->end_ != __p)
+ _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
+ }
+ }
+ __get_db()->unlock();
+#endif
+ __node_pointer __np = __n->__as_node();
+ __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_));
+ __node_alloc_traits::deallocate(__na, __np, 1);
+ }
+ }
+#if _LIBCPP_DEBUG_LEVEL == 2
+ return iterator(__l.__ptr_, this);
+#else
+ return iterator(__l.__ptr_);
+#endif
+}
+
+template <class _Tp, class _Alloc>
+void
+list<_Tp, _Alloc>::resize(size_type __n)
+{
+ if (__n < base::__sz())
+ erase(__iterator(__n), end());
+ else if (__n > base::__sz())
+ {
+ __n -= base::__sz();
+ size_type __ds = 0;
+ __node_allocator& __na = base::__node_alloc();
+ __hold_pointer __hold = __allocate_node(__na);
+ __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_));
+ ++__ds;
+#if _LIBCPP_DEBUG_LEVEL == 2
+ iterator __r = iterator(__hold.release()->__as_link(), this);
+#else
+ iterator __r = iterator(__hold.release()->__as_link());
+#endif
+ iterator __e = __r;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ for (--__n; __n != 0; --__n, (void) ++__e, ++__ds)
+ {
+ __hold.reset(__node_alloc_traits::allocate(__na, 1));
+ __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_));
+ __e.__ptr_->__next_ = __hold.get()->__as_link();
+ __hold->__prev_ = __e.__ptr_;
+ __hold.release();
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ while (true)
+ {
+ __node_alloc_traits::destroy(__na, _VSTD::addressof(*__e));
+ __link_pointer __prev = __e.__ptr_->__prev_;
+ __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);
+ if (__prev == 0)
+ break;
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __e = iterator(__prev, this);
+#else
+ __e = iterator(__prev);
+#endif
+ }
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ __link_nodes_at_back(__r.__ptr_, __e.__ptr_);
+ base::__sz() += __ds;
+ }
+}
+
+template <class _Tp, class _Alloc>
+void
+list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x)
+{
+ if (__n < base::__sz())
+ erase(__iterator(__n), end());
+ else if (__n > base::__sz())
+ {
+ __n -= base::__sz();
+ size_type __ds = 0;
+ __node_allocator& __na = base::__node_alloc();
+ __hold_pointer __hold = __allocate_node(__na);
+ __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
+ ++__ds;
+ __link_pointer __nl = __hold.release()->__as_link();
+#if _LIBCPP_DEBUG_LEVEL == 2
+ iterator __r = iterator(__nl, this);
+#else
+ iterator __r = iterator(__nl);
+#endif
+ iterator __e = __r;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ for (--__n; __n != 0; --__n, (void) ++__e, ++__ds)
+ {
+ __hold.reset(__node_alloc_traits::allocate(__na, 1));
+ __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
+ __e.__ptr_->__next_ = __hold.get()->__as_link();
+ __hold->__prev_ = __e.__ptr_;
+ __hold.release();
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ while (true)
+ {
+ __node_alloc_traits::destroy(__na, _VSTD::addressof(*__e));
+ __link_pointer __prev = __e.__ptr_->__prev_;
+ __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);
+ if (__prev == 0)
+ break;
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __e = iterator(__prev, this);
+#else
+ __e = iterator(__prev);
+#endif
+ }
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ __link_nodes(base::__end_as_link(), __r.__ptr_, __e.__ptr_);
+ base::__sz() += __ds;
+ }
+}
+
+template <class _Tp, class _Alloc>
+void
+list<_Tp, _Alloc>::splice(const_iterator __p, list& __c)
+{
+ _LIBCPP_ASSERT(this != _VSTD::addressof(__c),
+ "list::splice(iterator, list) called with this == &list");
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
+ "list::splice(iterator, list) called with an iterator not referring to this list");
+ if (!__c.empty())
+ {
+ __link_pointer __f = __c.__end_.__next_;
+ __link_pointer __l = __c.__end_.__prev_;
+ base::__unlink_nodes(__f, __l);
+ __link_nodes(__p.__ptr_, __f, __l);
+ base::__sz() += __c.__sz();
+ __c.__sz() = 0;
+#if _LIBCPP_DEBUG_LEVEL == 2
+ if (_VSTD::addressof(__c) != this) {
+ __libcpp_db* __db = __get_db();
+ __c_node* __cn1 = __db->__find_c_and_lock(this);
+ __c_node* __cn2 = __db->__find_c(_VSTD::addressof(__c));
+ for (__i_node** __ip = __cn2->end_; __ip != __cn2->beg_;)
+ {
+ --__ip;
+ iterator* __i = static_cast<iterator*>((*__ip)->__i_);
+ if (__i->__ptr_ != __c.__end_as_link())
+ {
+ __cn1->__add(*__ip);
+ (*__ip)->__c_ = __cn1;
+ if (--__cn2->end_ != __ip)
+ memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));
+ }
+ }
+ __db->unlock();
+ }
+#endif
+ }
+}
+
+template <class _Tp, class _Alloc>
+void
+list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i)
+{
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
+ "list::splice(iterator, list, iterator) called with the first iterator not referring to this list");
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__i)) == _VSTD::addressof(__c),
+ "list::splice(iterator, list, iterator) called with the second iterator not referring to the list argument");
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(_VSTD::addressof(__i)),
+ "list::splice(iterator, list, iterator) called with the second iterator not dereferenceable");
+
+ if (__p.__ptr_ != __i.__ptr_ && __p.__ptr_ != __i.__ptr_->__next_)
+ {
+ __link_pointer __f = __i.__ptr_;
+ base::__unlink_nodes(__f, __f);
+ __link_nodes(__p.__ptr_, __f, __f);
+ --__c.__sz();
+ ++base::__sz();
+#if _LIBCPP_DEBUG_LEVEL == 2
+ if (_VSTD::addressof(__c) != this) {
+ __libcpp_db* __db = __get_db();
+ __c_node* __cn1 = __db->__find_c_and_lock(this);
+ __c_node* __cn2 = __db->__find_c(_VSTD::addressof(__c));
+ for (__i_node** __ip = __cn2->end_; __ip != __cn2->beg_;)
+ {
+ --__ip;
+ iterator* __j = static_cast<iterator*>((*__ip)->__i_);
+ if (__j->__ptr_ == __f)
+ {
+ __cn1->__add(*__ip);
+ (*__ip)->__c_ = __cn1;
+ if (--__cn2->end_ != __ip)
+ _VSTD::memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));
+ }
+ }
+ __db->unlock();
+ }
+#endif
+ }
+}
+
+template <class _Tp, class _Alloc>
+void
+list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l)
+{
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
+ "list::splice(iterator, list, iterator, iterator) called with first iterator not referring to this list");
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__f)) == _VSTD::addressof(__c),
+ "list::splice(iterator, list, iterator, iterator) called with second iterator not referring to the list argument");
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__l)) == _VSTD::addressof(__c),
+ "list::splice(iterator, list, iterator, iterator) called with third iterator not referring to the list argument");
+
+#if _LIBCPP_DEBUG_LEVEL == 2
+ if (this == _VSTD::addressof(__c))
+ {
+ for (const_iterator __i = __f; __i != __l; ++__i)
+ _LIBCPP_DEBUG_ASSERT(__i != __p,
+ "list::splice(iterator, list, iterator, iterator)"
+ " called with the first iterator within the range of the second and third iterators");
+ }
+#endif
+ if (__f != __l)
+ {
+ __link_pointer __first = __f.__ptr_;
+ --__l;
+ __link_pointer __last = __l.__ptr_;
+ if (this != _VSTD::addressof(__c))
+ {
+ size_type __s = _VSTD::distance(__f, __l) + 1;
+ __c.__sz() -= __s;
+ base::__sz() += __s;
+ }
+ base::__unlink_nodes(__first, __last);
+ __link_nodes(__p.__ptr_, __first, __last);
+#if _LIBCPP_DEBUG_LEVEL == 2
+ if (_VSTD::addressof(__c) != this) {
+ __libcpp_db* __db = __get_db();
+ __c_node* __cn1 = __db->__find_c_and_lock(this);
+ __c_node* __cn2 = __db->__find_c(_VSTD::addressof(__c));
+ for (__i_node** __ip = __cn2->end_; __ip != __cn2->beg_;)
+ {
+ --__ip;
+ iterator* __j = static_cast<iterator*>((*__ip)->__i_);
+ for (__link_pointer __k = __f.__ptr_;
+ __k != __l.__ptr_; __k = __k->__next_)
+ {
+ if (__j->__ptr_ == __k)
+ {
+ __cn1->__add(*__ip);
+ (*__ip)->__c_ = __cn1;
+ if (--__cn2->end_ != __ip)
+ _VSTD::memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));
+ }
+ }
+ }
+ __db->unlock();
+ }
+#endif
+ }
+}
+
+template <class _Tp, class _Alloc>
+typename list<_Tp, _Alloc>::__remove_return_type
+list<_Tp, _Alloc>::remove(const value_type& __x)
+{
+ list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing
+ for (const_iterator __i = begin(), __e = end(); __i != __e;)
+ {
+ if (*__i == __x)
+ {
+ const_iterator __j = _VSTD::next(__i);
+ for (; __j != __e && *__j == __x; ++__j)
+ ;
+ __deleted_nodes.splice(__deleted_nodes.end(), *this, __i, __j);
+ __i = __j;
+ if (__i != __e)
+ ++__i;
+ }
+ else
+ ++__i;
+ }
+
+ return (__remove_return_type) __deleted_nodes.size();
+}
+
+template <class _Tp, class _Alloc>
+template <class _Pred>
+typename list<_Tp, _Alloc>::__remove_return_type
+list<_Tp, _Alloc>::remove_if(_Pred __pred)
+{
+ list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing
+ for (iterator __i = begin(), __e = end(); __i != __e;)
+ {
+ if (__pred(*__i))
+ {
+ iterator __j = _VSTD::next(__i);
+ for (; __j != __e && __pred(*__j); ++__j)
+ ;
+ __deleted_nodes.splice(__deleted_nodes.end(), *this, __i, __j);
+ __i = __j;
+ if (__i != __e)
+ ++__i;
+ }
+ else
+ ++__i;
+ }
+
+ return (__remove_return_type) __deleted_nodes.size();
+}
+
+template <class _Tp, class _Alloc>
+template <class _BinaryPred>
+typename list<_Tp, _Alloc>::__remove_return_type
+list<_Tp, _Alloc>::unique(_BinaryPred __binary_pred)
+{
+ list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing
+ for (iterator __i = begin(), __e = end(); __i != __e;)
+ {
+ iterator __j = _VSTD::next(__i);
+ for (; __j != __e && __binary_pred(*__i, *__j); ++__j)
+ ;
+ if (++__i != __j) {
+ __deleted_nodes.splice(__deleted_nodes.end(), *this, __i, __j);
+ __i = __j;
+ }
+ }
+
+ return (__remove_return_type) __deleted_nodes.size();
+}
+
+template <class _Tp, class _Alloc>
+inline
+void
+list<_Tp, _Alloc>::merge(list& __c)
+{
+ merge(__c, __less<value_type>());
+}
+
+template <class _Tp, class _Alloc>
+template <class _Comp>
+void
+list<_Tp, _Alloc>::merge(list& __c, _Comp __comp)
+{
+ if (this != _VSTD::addressof(__c))
+ {
+ iterator __f1 = begin();
+ iterator __e1 = end();
+ iterator __f2 = __c.begin();
+ iterator __e2 = __c.end();
+ while (__f1 != __e1 && __f2 != __e2)
+ {
+ if (__comp(*__f2, *__f1))
+ {
+ size_type __ds = 1;
+ iterator __m2 = _VSTD::next(__f2);
+ for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2, (void) ++__ds)
+ ;
+ base::__sz() += __ds;
+ __c.__sz() -= __ds;
+ __link_pointer __f = __f2.__ptr_;
+ __link_pointer __l = __m2.__ptr_->__prev_;
+ __f2 = __m2;
+ base::__unlink_nodes(__f, __l);
+ __m2 = _VSTD::next(__f1);
+ __link_nodes(__f1.__ptr_, __f, __l);
+ __f1 = __m2;
+ }
+ else
+ ++__f1;
+ }
+ splice(__e1, __c);
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __libcpp_db* __db = __get_db();
+ __c_node* __cn1 = __db->__find_c_and_lock(this);
+ __c_node* __cn2 = __db->__find_c(_VSTD::addressof(__c));
+ for (__i_node** __p = __cn2->end_; __p != __cn2->beg_;)
+ {
+ --__p;
+ iterator* __i = static_cast<iterator*>((*__p)->__i_);
+ if (__i->__ptr_ != __c.__end_as_link())
+ {
+ __cn1->__add(*__p);
+ (*__p)->__c_ = __cn1;
+ if (--__cn2->end_ != __p)
+ _VSTD::memmove(__p, __p+1, (__cn2->end_ - __p)*sizeof(__i_node*));
+ }
+ }
+ __db->unlock();
+#endif
+ }
+}
+
+template <class _Tp, class _Alloc>
+inline
+void
+list<_Tp, _Alloc>::sort()
+{
+ sort(__less<value_type>());
+}
+
+template <class _Tp, class _Alloc>
+template <class _Comp>
+inline
+void
+list<_Tp, _Alloc>::sort(_Comp __comp)
+{
+ __sort(begin(), end(), base::__sz(), __comp);
+}
+
+template <class _Tp, class _Alloc>
+template <class _Comp>
+typename list<_Tp, _Alloc>::iterator
+list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __comp)
+{
+ switch (__n)
+ {
+ case 0:
+ case 1:
+ return __f1;
+ case 2:
+ if (__comp(*--__e2, *__f1))
+ {
+ __link_pointer __f = __e2.__ptr_;
+ base::__unlink_nodes(__f, __f);
+ __link_nodes(__f1.__ptr_, __f, __f);
+ return __e2;
+ }
+ return __f1;
+ }
+ size_type __n2 = __n / 2;
+ iterator __e1 = _VSTD::next(__f1, __n2);
+ iterator __r = __f1 = __sort(__f1, __e1, __n2, __comp);
+ iterator __f2 = __e1 = __sort(__e1, __e2, __n - __n2, __comp);
+ if (__comp(*__f2, *__f1))
+ {
+ iterator __m2 = _VSTD::next(__f2);
+ for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2)
+ ;
+ __link_pointer __f = __f2.__ptr_;
+ __link_pointer __l = __m2.__ptr_->__prev_;
+ __r = __f2;
+ __e1 = __f2 = __m2;
+ base::__unlink_nodes(__f, __l);
+ __m2 = _VSTD::next(__f1);
+ __link_nodes(__f1.__ptr_, __f, __l);
+ __f1 = __m2;
+ }
+ else
+ ++__f1;
+ while (__f1 != __e1 && __f2 != __e2)
+ {
+ if (__comp(*__f2, *__f1))
+ {
+ iterator __m2 = _VSTD::next(__f2);
+ for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2)
+ ;
+ __link_pointer __f = __f2.__ptr_;
+ __link_pointer __l = __m2.__ptr_->__prev_;
+ if (__e1 == __f2)
+ __e1 = __m2;
+ __f2 = __m2;
+ base::__unlink_nodes(__f, __l);
+ __m2 = _VSTD::next(__f1);
+ __link_nodes(__f1.__ptr_, __f, __l);
+ __f1 = __m2;
+ }
+ else
+ ++__f1;
+ }
+ return __r;
+}
+
+template <class _Tp, class _Alloc>
+void
+list<_Tp, _Alloc>::reverse() _NOEXCEPT
+{
+ if (base::__sz() > 1)
+ {
+ iterator __e = end();
+ for (iterator __i = begin(); __i.__ptr_ != __e.__ptr_;)
+ {
+ _VSTD::swap(__i.__ptr_->__prev_, __i.__ptr_->__next_);
+ __i.__ptr_ = __i.__ptr_->__prev_;
+ }
+ _VSTD::swap(__e.__ptr_->__prev_, __e.__ptr_->__next_);
+ }
+}
+
+template <class _Tp, class _Alloc>
+bool
+list<_Tp, _Alloc>::__invariants() const
+{
+ return size() == _VSTD::distance(begin(), end());
+}
+
+#if _LIBCPP_DEBUG_LEVEL == 2
+
+template <class _Tp, class _Alloc>
+bool
+list<_Tp, _Alloc>::__dereferenceable(const const_iterator* __i) const
+{
+ return __i->__ptr_ != this->__end_as_link();
+}
+
+template <class _Tp, class _Alloc>
+bool
+list<_Tp, _Alloc>::__decrementable(const const_iterator* __i) const
+{
+ return !empty() && __i->__ptr_ != base::__end_.__next_;
+}
+
+template <class _Tp, class _Alloc>
+bool
+list<_Tp, _Alloc>::__addable(const const_iterator*, ptrdiff_t) const
+{
+ return false;
+}
+
+template <class _Tp, class _Alloc>
+bool
+list<_Tp, _Alloc>::__subscriptable(const const_iterator*, ptrdiff_t) const
+{
+ return false;
+}
+
+#endif // _LIBCPP_DEBUG_LEVEL == 2
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
+{
+ return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator< (const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
+{
+ return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
+{
+ return !(__x == __y);
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator> (const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
+{
+ return __y < __x;
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
+{
+ return !(__x < __y);
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
+{
+ return !(__y < __x);
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y)
+ _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+ __x.swap(__y);
+}
+
+#if _LIBCPP_STD_VER > 17
+template <class _Tp, class _Allocator, class _Predicate>
+inline _LIBCPP_INLINE_VISIBILITY typename list<_Tp, _Allocator>::size_type
+erase_if(list<_Tp, _Allocator>& __c, _Predicate __pred) {
+ return __c.remove_if(__pred);
+}
+
+template <class _Tp, class _Allocator, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY typename list<_Tp, _Allocator>::size_type
+erase(list<_Tp, _Allocator>& __c, const _Up& __v) {
+ return _VSTD::erase_if(__c, [&](auto& __elem) { return __elem == __v; });
+}
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_LIST
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/locale b/contrib/libs/cxxsupp/libcxxmsvc/include/locale
new file mode 100644
index 0000000000..1e437027d4
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/locale
@@ -0,0 +1,4364 @@
+// -*- 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_LOCALE
+#define _LIBCPP_LOCALE
+
+/*
+ locale synopsis
+
+namespace std
+{
+
+class locale
+{
+public:
+ // types:
+ class facet;
+ class id;
+
+ typedef int category;
+ static const category // values assigned here are for exposition only
+ none = 0x000,
+ collate = 0x010,
+ ctype = 0x020,
+ monetary = 0x040,
+ numeric = 0x080,
+ time = 0x100,
+ messages = 0x200,
+ all = collate | ctype | monetary | numeric | time | messages;
+
+ // construct/copy/destroy:
+ locale() noexcept;
+ locale(const locale& other) noexcept;
+ explicit locale(const char* std_name);
+ explicit locale(const string& std_name);
+ locale(const locale& other, const char* std_name, category);
+ locale(const locale& other, const string& std_name, category);
+ template <class Facet> locale(const locale& other, Facet* f);
+ locale(const locale& other, const locale& one, category);
+
+ ~locale(); // not virtual
+
+ const locale& operator=(const locale& other) noexcept;
+
+ template <class Facet> locale combine(const locale& other) const;
+
+ // locale operations:
+ basic_string<char> name() const;
+ bool operator==(const locale& other) const;
+ bool operator!=(const locale& other) const;
+ template <class charT, class Traits, class Allocator>
+ bool operator()(const basic_string<charT,Traits,Allocator>& s1,
+ const basic_string<charT,Traits,Allocator>& s2) const;
+
+ // global locale objects:
+ static locale global(const locale&);
+ static const locale& classic();
+};
+
+template <class Facet> const Facet& use_facet(const locale&);
+template <class Facet> bool has_facet(const locale&) noexcept;
+
+// 22.3.3, convenience interfaces:
+template <class charT> bool isspace (charT c, const locale& loc);
+template <class charT> bool isprint (charT c, const locale& loc);
+template <class charT> bool iscntrl (charT c, const locale& loc);
+template <class charT> bool isupper (charT c, const locale& loc);
+template <class charT> bool islower (charT c, const locale& loc);
+template <class charT> bool isalpha (charT c, const locale& loc);
+template <class charT> bool isdigit (charT c, const locale& loc);
+template <class charT> bool ispunct (charT c, const locale& loc);
+template <class charT> bool isxdigit(charT c, const locale& loc);
+template <class charT> bool isalnum (charT c, const locale& loc);
+template <class charT> bool isgraph (charT c, const locale& loc);
+template <class charT> charT toupper(charT c, const locale& loc);
+template <class charT> charT tolower(charT c, const locale& loc);
+
+template<class Codecvt, class Elem = wchar_t,
+ class Wide_alloc = allocator<Elem>,
+ class Byte_alloc = allocator<char>>
+class wstring_convert
+{
+public:
+ typedef basic_string<char, char_traits<char>, Byte_alloc> byte_string;
+ typedef basic_string<Elem, char_traits<Elem>, Wide_alloc> wide_string;
+ typedef typename Codecvt::state_type state_type;
+ typedef typename wide_string::traits_type::int_type int_type;
+
+ wstring_convert(Codecvt* pcvt = new Codecvt); // before C++14
+ explicit wstring_convert(Codecvt* pcvt = new Codecvt); // before C++20
+ wstring_convert() : wstring_convert(new Codecvt) {} // C++20
+ explicit wstring_convert(Codecvt* pcvt); // C++20
+
+ wstring_convert(Codecvt* pcvt, state_type state);
+ explicit wstring_convert(const byte_string& byte_err, // explicit in C++14
+ const wide_string& wide_err = wide_string());
+ wstring_convert(const wstring_convert&) = delete; // C++14
+ wstring_convert & operator=(const wstring_convert &) = delete; // C++14
+ ~wstring_convert();
+
+ wide_string from_bytes(char byte);
+ wide_string from_bytes(const char* ptr);
+ wide_string from_bytes(const byte_string& str);
+ wide_string from_bytes(const char* first, const char* last);
+
+ byte_string to_bytes(Elem wchar);
+ byte_string to_bytes(const Elem* wptr);
+ byte_string to_bytes(const wide_string& wstr);
+ byte_string to_bytes(const Elem* first, const Elem* last);
+
+ size_t converted() const; // noexcept in C++14
+ state_type state() const;
+};
+
+template <class Codecvt, class Elem = wchar_t, class Tr = char_traits<Elem>>
+class wbuffer_convert
+ : public basic_streambuf<Elem, Tr>
+{
+public:
+ typedef typename Tr::state_type state_type;
+
+ wbuffer_convert(streambuf* bytebuf = 0, Codecvt* pcvt = new Codecvt,
+ state_type state = state_type()); // before C++14
+ explicit wbuffer_convert(streambuf* bytebuf = nullptr, Codecvt* pcvt = new Codecvt,
+ state_type state = state_type()); // before C++20
+ wbuffer_convert() : wbuffer_convert(nullptr) {} // C++20
+ explicit wbuffer_convert(streambuf* bytebuf, Codecvt* pcvt = new Codecvt,
+ state_type state = state_type()); // C++20
+
+ wbuffer_convert(const wbuffer_convert&) = delete; // C++14
+ wbuffer_convert & operator=(const wbuffer_convert &) = delete; // C++14
+ ~wbuffer_convert(); // C++14
+
+ streambuf* rdbuf() const;
+ streambuf* rdbuf(streambuf* bytebuf);
+
+ state_type state() const;
+};
+
+// 22.4.1 and 22.4.1.3, ctype:
+class ctype_base;
+template <class charT> class ctype;
+template <> class ctype<char>; // specialization
+template <class charT> class ctype_byname;
+template <> class ctype_byname<char>; // specialization
+
+class codecvt_base;
+template <class internT, class externT, class stateT> class codecvt;
+template <class internT, class externT, class stateT> class codecvt_byname;
+
+// 22.4.2 and 22.4.3, numeric:
+template <class charT, class InputIterator> class num_get;
+template <class charT, class OutputIterator> class num_put;
+template <class charT> class numpunct;
+template <class charT> class numpunct_byname;
+
+// 22.4.4, col lation:
+template <class charT> class collate;
+template <class charT> class collate_byname;
+
+// 22.4.5, date and time:
+class time_base;
+template <class charT, class InputIterator> class time_get;
+template <class charT, class InputIterator> class time_get_byname;
+template <class charT, class OutputIterator> class time_put;
+template <class charT, class OutputIterator> class time_put_byname;
+
+// 22.4.6, money:
+class money_base;
+template <class charT, class InputIterator> class money_get;
+template <class charT, class OutputIterator> class money_put;
+template <class charT, bool Intl> class moneypunct;
+template <class charT, bool Intl> class moneypunct_byname;
+
+// 22.4.7, message retrieval:
+class messages_base;
+template <class charT> class messages;
+template <class charT> class messages_byname;
+
+} // std
+
+*/
+
+#include <__algorithm/equal.h>
+#include <__algorithm/find.h>
+#include <__algorithm/max.h>
+#include <__algorithm/reverse.h>
+#include <__algorithm/unwrap_iter.h>
+#include <__assert>
+#include <__config>
+#include <__debug>
+#include <__locale>
+#ifndef __APPLE__
+# include <cstdarg>
+#endif
+#include <cstdio>
+#include <cstdlib>
+#include <ctime>
+#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
+#include <__bsd_locale_defaults.h>
+#else
+#include <__bsd_locale_fallbacks.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
+
+#if defined(__APPLE__) || defined(__FreeBSD__)
+# define _LIBCPP_GET_C_LOCALE 0
+#elif defined(__NetBSD__)
+# define _LIBCPP_GET_C_LOCALE LC_C_LOCALE
+#else
+# define _LIBCPP_GET_C_LOCALE __cloc()
+ // Get the C locale object
+ _LIBCPP_FUNC_VIS locale_t __cloc();
+#define __cloc_defined
+#endif
+
+// __scan_keyword
+// Scans [__b, __e) until a match is found in the basic_strings range
+// [__kb, __ke) or until it can be shown that there is no match in [__kb, __ke).
+// __b will be incremented (visibly), consuming CharT until a match is found
+// or proved to not exist. A keyword may be "", in which will match anything.
+// If one keyword is a prefix of another, and the next CharT in the input
+// might match another keyword, the algorithm will attempt to find the longest
+// matching keyword. If the longer matching keyword ends up not matching, then
+// no keyword match is found. If no keyword match is found, __ke is returned
+// and failbit is set in __err.
+// Else an iterator pointing to the matching keyword is found. If more than
+// one keyword matches, an iterator to the first matching keyword is returned.
+// If on exit __b == __e, eofbit is set in __err. If __case_sensitive is false,
+// __ct is used to force to lower case before comparing characters.
+// Examples:
+// Keywords: "a", "abb"
+// If the input is "a", the first keyword matches and eofbit is set.
+// If the input is "abc", no match is found and "ab" are consumed.
+template <class _InputIterator, class _ForwardIterator, class _Ctype>
+_LIBCPP_HIDDEN
+_ForwardIterator
+__scan_keyword(_InputIterator& __b, _InputIterator __e,
+ _ForwardIterator __kb, _ForwardIterator __ke,
+ const _Ctype& __ct, ios_base::iostate& __err,
+ bool __case_sensitive = true)
+{
+ typedef typename iterator_traits<_InputIterator>::value_type _CharT;
+ size_t __nkw = static_cast<size_t>(_VSTD::distance(__kb, __ke));
+ const unsigned char __doesnt_match = '\0';
+ const unsigned char __might_match = '\1';
+ const unsigned char __does_match = '\2';
+ unsigned char __statbuf[100];
+ unsigned char* __status = __statbuf;
+ unique_ptr<unsigned char, void(*)(void*)> __stat_hold(nullptr, free);
+ if (__nkw > sizeof(__statbuf))
+ {
+ __status = (unsigned char*)malloc(__nkw);
+ if (__status == nullptr)
+ __throw_bad_alloc();
+ __stat_hold.reset(__status);
+ }
+ size_t __n_might_match = __nkw; // At this point, any keyword might match
+ size_t __n_does_match = 0; // but none of them definitely do
+ // Initialize all statuses to __might_match, except for "" keywords are __does_match
+ unsigned char* __st = __status;
+ for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, (void) ++__st)
+ {
+ if (!__ky->empty())
+ *__st = __might_match;
+ else
+ {
+ *__st = __does_match;
+ --__n_might_match;
+ ++__n_does_match;
+ }
+ }
+ // While there might be a match, test keywords against the next CharT
+ for (size_t __indx = 0; __b != __e && __n_might_match > 0; ++__indx)
+ {
+ // Peek at the next CharT but don't consume it
+ _CharT __c = *__b;
+ if (!__case_sensitive)
+ __c = __ct.toupper(__c);
+ bool __consume = false;
+ // For each keyword which might match, see if the __indx character is __c
+ // If a match if found, consume __c
+ // If a match is found, and that is the last character in the keyword,
+ // then that keyword matches.
+ // If the keyword doesn't match this character, then change the keyword
+ // to doesn't match
+ __st = __status;
+ for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, (void) ++__st)
+ {
+ if (*__st == __might_match)
+ {
+ _CharT __kc = (*__ky)[__indx];
+ if (!__case_sensitive)
+ __kc = __ct.toupper(__kc);
+ if (__c == __kc)
+ {
+ __consume = true;
+ if (__ky->size() == __indx+1)
+ {
+ *__st = __does_match;
+ --__n_might_match;
+ ++__n_does_match;
+ }
+ }
+ else
+ {
+ *__st = __doesnt_match;
+ --__n_might_match;
+ }
+ }
+ }
+ // consume if we matched a character
+ if (__consume)
+ {
+ ++__b;
+ // If we consumed a character and there might be a matched keyword that
+ // was marked matched on a previous iteration, then such keywords
+ // which are now marked as not matching.
+ if (__n_might_match + __n_does_match > 1)
+ {
+ __st = __status;
+ for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, (void) ++__st)
+ {
+ if (*__st == __does_match && __ky->size() != __indx+1)
+ {
+ *__st = __doesnt_match;
+ --__n_does_match;
+ }
+ }
+ }
+ }
+ }
+ // We've exited the loop because we hit eof and/or we have no more "might matches".
+ if (__b == __e)
+ __err |= ios_base::eofbit;
+ // Return the first matching result
+ for (__st = __status; __kb != __ke; ++__kb, (void) ++__st)
+ if (*__st == __does_match)
+ break;
+ if (__kb == __ke)
+ __err |= ios_base::failbit;
+ return __kb;
+}
+
+struct _LIBCPP_TYPE_VIS __num_get_base
+{
+ static const int __num_get_buf_sz = 40;
+
+ static int __get_base(ios_base&);
+ static const char __src[33];
+};
+
+_LIBCPP_FUNC_VIS
+void __check_grouping(const string& __grouping, unsigned* __g, unsigned* __g_end,
+ ios_base::iostate& __err);
+
+template <class _CharT>
+struct __num_get
+ : protected __num_get_base
+{
+ static string __stage2_float_prep(ios_base& __iob, _CharT* __atoms, _CharT& __decimal_point,
+ _CharT& __thousands_sep);
+
+ static int __stage2_float_loop(_CharT __ct, bool& __in_units, char& __exp,
+ char* __a, char*& __a_end,
+ _CharT __decimal_point, _CharT __thousands_sep,
+ const string& __grouping, unsigned* __g,
+ unsigned*& __g_end, unsigned& __dc, _CharT* __atoms);
+#ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
+ static string __stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep);
+ static int __stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
+ unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
+ unsigned* __g, unsigned*& __g_end, _CharT* __atoms);
+
+#else
+ static string __stage2_int_prep(ios_base& __iob, _CharT& __thousands_sep)
+ {
+ locale __loc = __iob.getloc();
+ const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
+ __thousands_sep = __np.thousands_sep();
+ return __np.grouping();
+ }
+
+ const _CharT* __do_widen(ios_base& __iob, _CharT* __atoms) const
+ {
+ return __do_widen_p(__iob, __atoms);
+ }
+
+
+ static int __stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
+ unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
+ unsigned* __g, unsigned*& __g_end, const _CharT* __atoms);
+private:
+ template<typename _Tp>
+ const _Tp* __do_widen_p(ios_base& __iob, _Tp* __atoms) const
+ {
+ locale __loc = __iob.getloc();
+ use_facet<ctype<_Tp> >(__loc).widen(__src, __src + 26, __atoms);
+ return __atoms;
+ }
+
+ const char* __do_widen_p(ios_base& __iob, char* __atoms) const
+ {
+ (void)__iob;
+ (void)__atoms;
+ return __src;
+ }
+#endif
+};
+
+#ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
+template <class _CharT>
+string
+__num_get<_CharT>::__stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep)
+{
+ locale __loc = __iob.getloc();
+ use_facet<ctype<_CharT> >(__loc).widen(__src, __src + 26, __atoms);
+ const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
+ __thousands_sep = __np.thousands_sep();
+ return __np.grouping();
+}
+#endif
+
+template <class _CharT>
+string
+__num_get<_CharT>::__stage2_float_prep(ios_base& __iob, _CharT* __atoms, _CharT& __decimal_point,
+ _CharT& __thousands_sep)
+{
+ locale __loc = __iob.getloc();
+ use_facet<ctype<_CharT> >(__loc).widen(__src, __src + 32, __atoms);
+ const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
+ __decimal_point = __np.decimal_point();
+ __thousands_sep = __np.thousands_sep();
+ return __np.grouping();
+}
+
+template <class _CharT>
+int
+#ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
+__num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
+ unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
+ unsigned* __g, unsigned*& __g_end, _CharT* __atoms)
+#else
+__num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
+ unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
+ unsigned* __g, unsigned*& __g_end, const _CharT* __atoms)
+
+#endif
+{
+ if (__a_end == __a && (__ct == __atoms[24] || __ct == __atoms[25]))
+ {
+ *__a_end++ = __ct == __atoms[24] ? '+' : '-';
+ __dc = 0;
+ return 0;
+ }
+ if (__grouping.size() != 0 && __ct == __thousands_sep)
+ {
+ if (__g_end-__g < __num_get_buf_sz)
+ {
+ *__g_end++ = __dc;
+ __dc = 0;
+ }
+ return 0;
+ }
+ ptrdiff_t __f = find(__atoms, __atoms + 26, __ct) - __atoms;
+ if (__f >= 24)
+ return -1;
+ switch (__base)
+ {
+ case 8:
+ case 10:
+ if (__f >= __base)
+ return -1;
+ break;
+ case 16:
+ if (__f < 22)
+ break;
+ if (__a_end != __a && __a_end - __a <= 2 && __a_end[-1] == '0')
+ {
+ __dc = 0;
+ *__a_end++ = __src[__f];
+ return 0;
+ }
+ return -1;
+ }
+ *__a_end++ = __src[__f];
+ ++__dc;
+ return 0;
+}
+
+template <class _CharT>
+int
+__num_get<_CharT>::__stage2_float_loop(_CharT __ct, bool& __in_units, char& __exp, char* __a, char*& __a_end,
+ _CharT __decimal_point, _CharT __thousands_sep, const string& __grouping,
+ unsigned* __g, unsigned*& __g_end, unsigned& __dc, _CharT* __atoms)
+{
+ if (__ct == __decimal_point)
+ {
+ if (!__in_units)
+ return -1;
+ __in_units = false;
+ *__a_end++ = '.';
+ if (__grouping.size() != 0 && __g_end-__g < __num_get_buf_sz)
+ *__g_end++ = __dc;
+ return 0;
+ }
+ if (__ct == __thousands_sep && __grouping.size() != 0)
+ {
+ if (!__in_units)
+ return -1;
+ if (__g_end-__g < __num_get_buf_sz)
+ {
+ *__g_end++ = __dc;
+ __dc = 0;
+ }
+ return 0;
+ }
+ ptrdiff_t __f = find(__atoms, __atoms + 32, __ct) - __atoms;
+ if (__f >= 32)
+ return -1;
+ char __x = __src[__f];
+ if (__x == '-' || __x == '+')
+ {
+ if (__a_end == __a || (__a_end[-1] & 0x5F) == (__exp & 0x7F))
+ {
+ *__a_end++ = __x;
+ return 0;
+ }
+ return -1;
+ }
+ if (__x == 'x' || __x == 'X')
+ __exp = 'P';
+ else if ((__x & 0x5F) == __exp)
+ {
+ __exp |= (char) 0x80;
+ if (__in_units)
+ {
+ __in_units = false;
+ if (__grouping.size() != 0 && __g_end-__g < __num_get_buf_sz)
+ *__g_end++ = __dc;
+ }
+ }
+ *__a_end++ = __x;
+ if (__f >= 22)
+ return 0;
+ ++__dc;
+ return 0;
+}
+
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<char>)
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<wchar_t>)
+#endif
+
+template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
+class _LIBCPP_TEMPLATE_VIS num_get
+ : public locale::facet,
+ private __num_get<_CharT>
+{
+public:
+ typedef _CharT char_type;
+ typedef _InputIterator iter_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit num_get(size_t __refs = 0)
+ : locale::facet(__refs) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, bool& __v) const
+ {
+ return do_get(__b, __e, __iob, __err, __v);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, long& __v) const
+ {
+ return do_get(__b, __e, __iob, __err, __v);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, long long& __v) const
+ {
+ return do_get(__b, __e, __iob, __err, __v);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, unsigned short& __v) const
+ {
+ return do_get(__b, __e, __iob, __err, __v);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, unsigned int& __v) const
+ {
+ return do_get(__b, __e, __iob, __err, __v);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, unsigned long& __v) const
+ {
+ return do_get(__b, __e, __iob, __err, __v);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, unsigned long long& __v) const
+ {
+ return do_get(__b, __e, __iob, __err, __v);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, float& __v) const
+ {
+ return do_get(__b, __e, __iob, __err, __v);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, double& __v) const
+ {
+ return do_get(__b, __e, __iob, __err, __v);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, long double& __v) const
+ {
+ return do_get(__b, __e, __iob, __err, __v);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, void*& __v) const
+ {
+ return do_get(__b, __e, __iob, __err, __v);
+ }
+
+ static locale::id id;
+
+protected:
+ _LIBCPP_INLINE_VISIBILITY
+ ~num_get() {}
+
+ template <class _Fp>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ iter_type __do_get_floating_point
+ (iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, _Fp& __v) const;
+
+ template <class _Signed>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ iter_type __do_get_signed
+ (iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, _Signed& __v) const;
+
+ template <class _Unsigned>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ iter_type __do_get_unsigned
+ (iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, _Unsigned& __v) const;
+
+
+ virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, bool& __v) const;
+
+ virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, long& __v) const
+ { return this->__do_get_signed ( __b, __e, __iob, __err, __v ); }
+
+ virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, long long& __v) const
+ { return this->__do_get_signed ( __b, __e, __iob, __err, __v ); }
+
+ virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, unsigned short& __v) const
+ { return this->__do_get_unsigned ( __b, __e, __iob, __err, __v ); }
+
+ virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, unsigned int& __v) const
+ { return this->__do_get_unsigned ( __b, __e, __iob, __err, __v ); }
+
+ virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, unsigned long& __v) const
+ { return this->__do_get_unsigned ( __b, __e, __iob, __err, __v ); }
+
+ virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, unsigned long long& __v) const
+ { return this->__do_get_unsigned ( __b, __e, __iob, __err, __v ); }
+
+ virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, float& __v) const
+ { return this->__do_get_floating_point ( __b, __e, __iob, __err, __v ); }
+
+ virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, double& __v) const
+ { return this->__do_get_floating_point ( __b, __e, __iob, __err, __v ); }
+
+ virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, long double& __v) const
+ { return this->__do_get_floating_point ( __b, __e, __iob, __err, __v ); }
+
+ virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, void*& __v) const;
+};
+
+template <class _CharT, class _InputIterator>
+locale::id
+num_get<_CharT, _InputIterator>::id;
+
+template <class _Tp>
+_LIBCPP_HIDDEN _Tp
+__num_get_signed_integral(const char* __a, const char* __a_end,
+ ios_base::iostate& __err, int __base)
+{
+ if (__a != __a_end)
+ {
+ typename remove_reference<decltype(errno)>::type __save_errno = errno;
+ errno = 0;
+ char *__p2;
+ long long __ll = strtoll_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
+ typename remove_reference<decltype(errno)>::type __current_errno = errno;
+ if (__current_errno == 0)
+ errno = __save_errno;
+ if (__p2 != __a_end)
+ {
+ __err = ios_base::failbit;
+ return 0;
+ }
+ else if (__current_errno == ERANGE ||
+ __ll < numeric_limits<_Tp>::min() ||
+ numeric_limits<_Tp>::max() < __ll)
+ {
+ __err = ios_base::failbit;
+ if (__ll > 0)
+ return numeric_limits<_Tp>::max();
+ else
+ return numeric_limits<_Tp>::min();
+ }
+ return static_cast<_Tp>(__ll);
+ }
+ __err = ios_base::failbit;
+ return 0;
+}
+
+template <class _Tp>
+_LIBCPP_HIDDEN _Tp
+__num_get_unsigned_integral(const char* __a, const char* __a_end,
+ ios_base::iostate& __err, int __base)
+{
+ if (__a != __a_end)
+ {
+ const bool __negate = *__a == '-';
+ if (__negate && ++__a == __a_end) {
+ __err = ios_base::failbit;
+ return 0;
+ }
+ typename remove_reference<decltype(errno)>::type __save_errno = errno;
+ errno = 0;
+ char *__p2;
+ unsigned long long __ll = strtoull_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
+ typename remove_reference<decltype(errno)>::type __current_errno = errno;
+ if (__current_errno == 0)
+ errno = __save_errno;
+ if (__p2 != __a_end)
+ {
+ __err = ios_base::failbit;
+ return 0;
+ }
+ else if (__current_errno == ERANGE || numeric_limits<_Tp>::max() < __ll)
+ {
+ __err = ios_base::failbit;
+ return numeric_limits<_Tp>::max();
+ }
+ _Tp __res = static_cast<_Tp>(__ll);
+ if (__negate) __res = -__res;
+ return __res;
+ }
+ __err = ios_base::failbit;
+ return 0;
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __do_strtod(const char* __a, char** __p2);
+
+template <>
+inline _LIBCPP_INLINE_VISIBILITY
+float __do_strtod<float>(const char* __a, char** __p2) {
+ return strtof_l(__a, __p2, _LIBCPP_GET_C_LOCALE);
+}
+
+template <>
+inline _LIBCPP_INLINE_VISIBILITY
+double __do_strtod<double>(const char* __a, char** __p2) {
+ return strtod_l(__a, __p2, _LIBCPP_GET_C_LOCALE);
+}
+
+template <>
+inline _LIBCPP_INLINE_VISIBILITY
+long double __do_strtod<long double>(const char* __a, char** __p2) {
+ return strtold_l(__a, __p2, _LIBCPP_GET_C_LOCALE);
+}
+
+template <class _Tp>
+_LIBCPP_HIDDEN
+_Tp
+__num_get_float(const char* __a, const char* __a_end, ios_base::iostate& __err)
+{
+ if (__a != __a_end)
+ {
+ typename remove_reference<decltype(errno)>::type __save_errno = errno;
+ errno = 0;
+ char *__p2;
+ _Tp __ld = __do_strtod<_Tp>(__a, &__p2);
+ typename remove_reference<decltype(errno)>::type __current_errno = errno;
+ if (__current_errno == 0)
+ errno = __save_errno;
+ if (__p2 != __a_end)
+ {
+ __err = ios_base::failbit;
+ return 0;
+ }
+ else if (__current_errno == ERANGE)
+ __err = ios_base::failbit;
+ return __ld;
+ }
+ __err = ios_base::failbit;
+ return 0;
+}
+
+template <class _CharT, class _InputIterator>
+_InputIterator
+num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
+ ios_base& __iob,
+ ios_base::iostate& __err,
+ bool& __v) const
+{
+ if ((__iob.flags() & ios_base::boolalpha) == 0)
+ {
+ long __lv = -1;
+ __b = do_get(__b, __e, __iob, __err, __lv);
+ switch (__lv)
+ {
+ case 0:
+ __v = false;
+ break;
+ case 1:
+ __v = true;
+ break;
+ default:
+ __v = true;
+ __err = ios_base::failbit;
+ break;
+ }
+ return __b;
+ }
+ const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__iob.getloc());
+ const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__iob.getloc());
+ typedef typename numpunct<_CharT>::string_type string_type;
+ const string_type __names[2] = {__np.truename(), __np.falsename()};
+ const string_type* __i = _VSTD::__scan_keyword(__b, __e, __names, __names+2,
+ __ct, __err);
+ __v = __i == __names;
+ return __b;
+}
+
+// signed
+
+template <class _CharT, class _InputIterator>
+template <class _Signed>
+_InputIterator
+num_get<_CharT, _InputIterator>::__do_get_signed(iter_type __b, iter_type __e,
+ ios_base& __iob,
+ ios_base::iostate& __err,
+ _Signed& __v) const
+{
+ // Stage 1
+ int __base = this->__get_base(__iob);
+ // Stage 2
+ char_type __thousands_sep;
+ const int __atoms_size = 26;
+#ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
+ char_type __atoms1[__atoms_size];
+ const char_type *__atoms = this->__do_widen(__iob, __atoms1);
+ string __grouping = this->__stage2_int_prep(__iob, __thousands_sep);
+#else
+ char_type __atoms[__atoms_size];
+ string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep);
+#endif
+ string __buf;
+ __buf.resize(__buf.capacity());
+ char* __a = &__buf[0];
+ char* __a_end = __a;
+ unsigned __g[__num_get_base::__num_get_buf_sz];
+ unsigned* __g_end = __g;
+ unsigned __dc = 0;
+ for (; __b != __e; ++__b)
+ {
+ if (__a_end == __a + __buf.size())
+ {
+ size_t __tmp = __buf.size();
+ __buf.resize(2*__buf.size());
+ __buf.resize(__buf.capacity());
+ __a = &__buf[0];
+ __a_end = __a + __tmp;
+ }
+ if (this->__stage2_int_loop(*__b, __base, __a, __a_end, __dc,
+ __thousands_sep, __grouping, __g, __g_end,
+ __atoms))
+ break;
+ }
+ if (__grouping.size() != 0 && __g_end-__g < __num_get_base::__num_get_buf_sz)
+ *__g_end++ = __dc;
+ // Stage 3
+ __v = __num_get_signed_integral<_Signed>(__a, __a_end, __err, __base);
+ // Digit grouping checked
+ __check_grouping(__grouping, __g, __g_end, __err);
+ // EOF checked
+ if (__b == __e)
+ __err |= ios_base::eofbit;
+ return __b;
+}
+
+// unsigned
+
+template <class _CharT, class _InputIterator>
+template <class _Unsigned>
+_InputIterator
+num_get<_CharT, _InputIterator>::__do_get_unsigned(iter_type __b, iter_type __e,
+ ios_base& __iob,
+ ios_base::iostate& __err,
+ _Unsigned& __v) const
+{
+ // Stage 1
+ int __base = this->__get_base(__iob);
+ // Stage 2
+ char_type __thousands_sep;
+ const int __atoms_size = 26;
+#ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
+ char_type __atoms1[__atoms_size];
+ const char_type *__atoms = this->__do_widen(__iob, __atoms1);
+ string __grouping = this->__stage2_int_prep(__iob, __thousands_sep);
+#else
+ char_type __atoms[__atoms_size];
+ string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep);
+#endif
+ string __buf;
+ __buf.resize(__buf.capacity());
+ char* __a = &__buf[0];
+ char* __a_end = __a;
+ unsigned __g[__num_get_base::__num_get_buf_sz];
+ unsigned* __g_end = __g;
+ unsigned __dc = 0;
+ for (; __b != __e; ++__b)
+ {
+ if (__a_end == __a + __buf.size())
+ {
+ size_t __tmp = __buf.size();
+ __buf.resize(2*__buf.size());
+ __buf.resize(__buf.capacity());
+ __a = &__buf[0];
+ __a_end = __a + __tmp;
+ }
+ if (this->__stage2_int_loop(*__b, __base, __a, __a_end, __dc,
+ __thousands_sep, __grouping, __g, __g_end,
+ __atoms))
+ break;
+ }
+ if (__grouping.size() != 0 && __g_end-__g < __num_get_base::__num_get_buf_sz)
+ *__g_end++ = __dc;
+ // Stage 3
+ __v = __num_get_unsigned_integral<_Unsigned>(__a, __a_end, __err, __base);
+ // Digit grouping checked
+ __check_grouping(__grouping, __g, __g_end, __err);
+ // EOF checked
+ if (__b == __e)
+ __err |= ios_base::eofbit;
+ return __b;
+}
+
+// floating point
+
+template <class _CharT, class _InputIterator>
+template <class _Fp>
+_InputIterator
+num_get<_CharT, _InputIterator>::__do_get_floating_point(iter_type __b, iter_type __e,
+ ios_base& __iob,
+ ios_base::iostate& __err,
+ _Fp& __v) const
+{
+ // Stage 1, nothing to do
+ // Stage 2
+ char_type __atoms[32];
+ char_type __decimal_point;
+ char_type __thousands_sep;
+ string __grouping = this->__stage2_float_prep(__iob, __atoms,
+ __decimal_point,
+ __thousands_sep);
+ string __buf;
+ __buf.resize(__buf.capacity());
+ char* __a = &__buf[0];
+ char* __a_end = __a;
+ unsigned __g[__num_get_base::__num_get_buf_sz];
+ unsigned* __g_end = __g;
+ unsigned __dc = 0;
+ bool __in_units = true;
+ char __exp = 'E';
+ for (; __b != __e; ++__b)
+ {
+ if (__a_end == __a + __buf.size())
+ {
+ size_t __tmp = __buf.size();
+ __buf.resize(2*__buf.size());
+ __buf.resize(__buf.capacity());
+ __a = &__buf[0];
+ __a_end = __a + __tmp;
+ }
+ if (this->__stage2_float_loop(*__b, __in_units, __exp, __a, __a_end,
+ __decimal_point, __thousands_sep,
+ __grouping, __g, __g_end,
+ __dc, __atoms))
+ break;
+ }
+ if (__grouping.size() != 0 && __in_units && __g_end-__g < __num_get_base::__num_get_buf_sz)
+ *__g_end++ = __dc;
+ // Stage 3
+ __v = __num_get_float<_Fp>(__a, __a_end, __err);
+ // Digit grouping checked
+ __check_grouping(__grouping, __g, __g_end, __err);
+ // EOF checked
+ if (__b == __e)
+ __err |= ios_base::eofbit;
+ return __b;
+}
+
+template <class _CharT, class _InputIterator>
+_InputIterator
+num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
+ ios_base& __iob,
+ ios_base::iostate& __err,
+ void*& __v) const
+{
+ // Stage 1
+ int __base = 16;
+ // Stage 2
+ char_type __atoms[26];
+ char_type __thousands_sep = 0;
+ string __grouping;
+ use_facet<ctype<_CharT> >(__iob.getloc()).widen(__num_get_base::__src,
+ __num_get_base::__src + 26, __atoms);
+ string __buf;
+ __buf.resize(__buf.capacity());
+ char* __a = &__buf[0];
+ char* __a_end = __a;
+ unsigned __g[__num_get_base::__num_get_buf_sz];
+ unsigned* __g_end = __g;
+ unsigned __dc = 0;
+ for (; __b != __e; ++__b)
+ {
+ if (__a_end == __a + __buf.size())
+ {
+ size_t __tmp = __buf.size();
+ __buf.resize(2*__buf.size());
+ __buf.resize(__buf.capacity());
+ __a = &__buf[0];
+ __a_end = __a + __tmp;
+ }
+ if (this->__stage2_int_loop(*__b, __base, __a, __a_end, __dc,
+ __thousands_sep, __grouping,
+ __g, __g_end, __atoms))
+ break;
+ }
+ // Stage 3
+ __buf.resize(__a_end - __a);
+ if (__libcpp_sscanf_l(__buf.c_str(), _LIBCPP_GET_C_LOCALE, "%p", &__v) != 1)
+ __err = ios_base::failbit;
+ // EOF checked
+ if (__b == __e)
+ __err |= ios_base::eofbit;
+ return __b;
+}
+
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<char>)
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<wchar_t>)
+#endif
+
+struct _LIBCPP_TYPE_VIS __num_put_base
+{
+protected:
+ static void __format_int(char* __fmt, const char* __len, bool __signd,
+ ios_base::fmtflags __flags);
+ static bool __format_float(char* __fmt, const char* __len,
+ ios_base::fmtflags __flags);
+ static char* __identify_padding(char* __nb, char* __ne,
+ const ios_base& __iob);
+};
+
+template <class _CharT>
+struct __num_put
+ : protected __num_put_base
+{
+ static void __widen_and_group_int(char* __nb, char* __np, char* __ne,
+ _CharT* __ob, _CharT*& __op, _CharT*& __oe,
+ const locale& __loc);
+ static void __widen_and_group_float(char* __nb, char* __np, char* __ne,
+ _CharT* __ob, _CharT*& __op, _CharT*& __oe,
+ const locale& __loc);
+};
+
+template <class _CharT>
+void
+__num_put<_CharT>::__widen_and_group_int(char* __nb, char* __np, char* __ne,
+ _CharT* __ob, _CharT*& __op, _CharT*& __oe,
+ const locale& __loc)
+{
+ const ctype<_CharT>& __ct = use_facet<ctype<_CharT> > (__loc);
+ const numpunct<_CharT>& __npt = use_facet<numpunct<_CharT> >(__loc);
+ string __grouping = __npt.grouping();
+ if (__grouping.empty())
+ {
+ __ct.widen(__nb, __ne, __ob);
+ __oe = __ob + (__ne - __nb);
+ }
+ else
+ {
+ __oe = __ob;
+ char* __nf = __nb;
+ if (*__nf == '-' || *__nf == '+')
+ *__oe++ = __ct.widen(*__nf++);
+ if (__ne - __nf >= 2 && __nf[0] == '0' && (__nf[1] == 'x' ||
+ __nf[1] == 'X'))
+ {
+ *__oe++ = __ct.widen(*__nf++);
+ *__oe++ = __ct.widen(*__nf++);
+ }
+ reverse(__nf, __ne);
+ _CharT __thousands_sep = __npt.thousands_sep();
+ unsigned __dc = 0;
+ unsigned __dg = 0;
+ for (char* __p = __nf; __p < __ne; ++__p)
+ {
+ if (static_cast<unsigned>(__grouping[__dg]) > 0 &&
+ __dc == static_cast<unsigned>(__grouping[__dg]))
+ {
+ *__oe++ = __thousands_sep;
+ __dc = 0;
+ if (__dg < __grouping.size()-1)
+ ++__dg;
+ }
+ *__oe++ = __ct.widen(*__p);
+ ++__dc;
+ }
+ reverse(__ob + (__nf - __nb), __oe);
+ }
+ if (__np == __ne)
+ __op = __oe;
+ else
+ __op = __ob + (__np - __nb);
+}
+
+template <class _CharT>
+void
+__num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne,
+ _CharT* __ob, _CharT*& __op, _CharT*& __oe,
+ const locale& __loc)
+{
+ const ctype<_CharT>& __ct = use_facet<ctype<_CharT> > (__loc);
+ const numpunct<_CharT>& __npt = use_facet<numpunct<_CharT> >(__loc);
+ string __grouping = __npt.grouping();
+ __oe = __ob;
+ char* __nf = __nb;
+ if (*__nf == '-' || *__nf == '+')
+ *__oe++ = __ct.widen(*__nf++);
+ char* __ns;
+ if (__ne - __nf >= 2 && __nf[0] == '0' && (__nf[1] == 'x' ||
+ __nf[1] == 'X'))
+ {
+ *__oe++ = __ct.widen(*__nf++);
+ *__oe++ = __ct.widen(*__nf++);
+ for (__ns = __nf; __ns < __ne; ++__ns)
+ if (!isxdigit_l(*__ns, _LIBCPP_GET_C_LOCALE))
+ break;
+ }
+ else
+ {
+ for (__ns = __nf; __ns < __ne; ++__ns)
+ if (!isdigit_l(*__ns, _LIBCPP_GET_C_LOCALE))
+ break;
+ }
+ if (__grouping.empty())
+ {
+ __ct.widen(__nf, __ns, __oe);
+ __oe += __ns - __nf;
+ }
+ else
+ {
+ reverse(__nf, __ns);
+ _CharT __thousands_sep = __npt.thousands_sep();
+ unsigned __dc = 0;
+ unsigned __dg = 0;
+ for (char* __p = __nf; __p < __ns; ++__p)
+ {
+ if (__grouping[__dg] > 0 && __dc == static_cast<unsigned>(__grouping[__dg]))
+ {
+ *__oe++ = __thousands_sep;
+ __dc = 0;
+ if (__dg < __grouping.size()-1)
+ ++__dg;
+ }
+ *__oe++ = __ct.widen(*__p);
+ ++__dc;
+ }
+ reverse(__ob + (__nf - __nb), __oe);
+ }
+ for (__nf = __ns; __nf < __ne; ++__nf)
+ {
+ if (*__nf == '.')
+ {
+ *__oe++ = __npt.decimal_point();
+ ++__nf;
+ break;
+ }
+ else
+ *__oe++ = __ct.widen(*__nf);
+ }
+ __ct.widen(__nf, __ne, __oe);
+ __oe += __ne - __nf;
+ if (__np == __ne)
+ __op = __oe;
+ else
+ __op = __ob + (__np - __nb);
+}
+
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<char>)
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<wchar_t>)
+#endif
+
+template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
+class _LIBCPP_TEMPLATE_VIS num_put
+ : public locale::facet,
+ private __num_put<_CharT>
+{
+public:
+ typedef _CharT char_type;
+ typedef _OutputIterator iter_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit num_put(size_t __refs = 0)
+ : locale::facet(__refs) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ iter_type put(iter_type __s, ios_base& __iob, char_type __fl,
+ bool __v) const
+ {
+ return do_put(__s, __iob, __fl, __v);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iter_type put(iter_type __s, ios_base& __iob, char_type __fl,
+ long __v) const
+ {
+ return do_put(__s, __iob, __fl, __v);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iter_type put(iter_type __s, ios_base& __iob, char_type __fl,
+ long long __v) const
+ {
+ return do_put(__s, __iob, __fl, __v);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iter_type put(iter_type __s, ios_base& __iob, char_type __fl,
+ unsigned long __v) const
+ {
+ return do_put(__s, __iob, __fl, __v);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iter_type put(iter_type __s, ios_base& __iob, char_type __fl,
+ unsigned long long __v) const
+ {
+ return do_put(__s, __iob, __fl, __v);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iter_type put(iter_type __s, ios_base& __iob, char_type __fl,
+ double __v) const
+ {
+ return do_put(__s, __iob, __fl, __v);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iter_type put(iter_type __s, ios_base& __iob, char_type __fl,
+ long double __v) const
+ {
+ return do_put(__s, __iob, __fl, __v);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iter_type put(iter_type __s, ios_base& __iob, char_type __fl,
+ const void* __v) const
+ {
+ return do_put(__s, __iob, __fl, __v);
+ }
+
+ static locale::id id;
+
+protected:
+ _LIBCPP_INLINE_VISIBILITY
+ ~num_put() {}
+
+ virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl,
+ bool __v) const;
+ virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl,
+ long __v) const;
+ virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl,
+ long long __v) const;
+ virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl,
+ unsigned long) const;
+ virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl,
+ unsigned long long) const;
+ virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl,
+ double __v) const;
+ virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl,
+ long double __v) const;
+ virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl,
+ const void* __v) const;
+
+ template <class _Integral>
+ _LIBCPP_HIDE_FROM_ABI inline
+ _OutputIterator __do_put_integral(iter_type __s, ios_base& __iob,
+ char_type __fl, _Integral __v,
+ char const* __len) const;
+
+ template <class _Float>
+ _LIBCPP_HIDE_FROM_ABI inline
+ _OutputIterator __do_put_floating_point(iter_type __s, ios_base& __iob,
+ char_type __fl, _Float __v,
+ char const* __len) const;
+};
+
+template <class _CharT, class _OutputIterator>
+locale::id
+num_put<_CharT, _OutputIterator>::id;
+
+template <class _CharT, class _OutputIterator>
+_LIBCPP_HIDDEN
+_OutputIterator
+__pad_and_output(_OutputIterator __s,
+ const _CharT* __ob, const _CharT* __op, const _CharT* __oe,
+ ios_base& __iob, _CharT __fl)
+{
+ streamsize __sz = __oe - __ob;
+ streamsize __ns = __iob.width();
+ if (__ns > __sz)
+ __ns -= __sz;
+ else
+ __ns = 0;
+ for (;__ob < __op; ++__ob, ++__s)
+ *__s = *__ob;
+ for (; __ns; --__ns, ++__s)
+ *__s = __fl;
+ for (; __ob < __oe; ++__ob, ++__s)
+ *__s = *__ob;
+ __iob.width(0);
+ return __s;
+}
+
+template <class _CharT, class _Traits>
+_LIBCPP_HIDDEN
+ostreambuf_iterator<_CharT, _Traits>
+__pad_and_output(ostreambuf_iterator<_CharT, _Traits> __s,
+ const _CharT* __ob, const _CharT* __op, const _CharT* __oe,
+ ios_base& __iob, _CharT __fl)
+{
+ if (__s.__sbuf_ == nullptr)
+ return __s;
+ streamsize __sz = __oe - __ob;
+ streamsize __ns = __iob.width();
+ if (__ns > __sz)
+ __ns -= __sz;
+ else
+ __ns = 0;
+ streamsize __np = __op - __ob;
+ if (__np > 0)
+ {
+ if (__s.__sbuf_->sputn(__ob, __np) != __np)
+ {
+ __s.__sbuf_ = nullptr;
+ return __s;
+ }
+ }
+ if (__ns > 0)
+ {
+ basic_string<_CharT, _Traits> __sp(__ns, __fl);
+ if (__s.__sbuf_->sputn(__sp.data(), __ns) != __ns)
+ {
+ __s.__sbuf_ = nullptr;
+ return __s;
+ }
+ }
+ __np = __oe - __op;
+ if (__np > 0)
+ {
+ if (__s.__sbuf_->sputn(__op, __np) != __np)
+ {
+ __s.__sbuf_ = nullptr;
+ return __s;
+ }
+ }
+ __iob.width(0);
+ return __s;
+}
+
+template <class _CharT, class _OutputIterator>
+_OutputIterator
+num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
+ char_type __fl, bool __v) const
+{
+ if ((__iob.flags() & ios_base::boolalpha) == 0)
+ return do_put(__s, __iob, __fl, (unsigned long)__v);
+ const numpunct<char_type>& __np = use_facet<numpunct<char_type> >(__iob.getloc());
+ typedef typename numpunct<char_type>::string_type string_type;
+#if _LIBCPP_DEBUG_LEVEL == 2
+ string_type __tmp(__v ? __np.truename() : __np.falsename());
+ string_type __nm = _VSTD::move(__tmp);
+#else
+ string_type __nm = __v ? __np.truename() : __np.falsename();
+#endif
+ for (typename string_type::iterator __i = __nm.begin(); __i != __nm.end(); ++__i, ++__s)
+ *__s = *__i;
+ return __s;
+}
+
+template <class _CharT, class _OutputIterator>
+template <class _Integral>
+_LIBCPP_HIDE_FROM_ABI inline
+_OutputIterator
+num_put<_CharT, _OutputIterator>::__do_put_integral(iter_type __s, ios_base& __iob,
+ char_type __fl, _Integral __v,
+ char const* __len) const
+{
+ // Stage 1 - Get number in narrow char
+ char __fmt[8] = {'%', 0};
+ this->__format_int(__fmt+1, __len, is_signed<_Integral>::value, __iob.flags());
+ // Worst case is octal, with showbase enabled. Note that octal is always
+ // printed as an unsigned value.
+ using _Unsigned = typename make_unsigned<_Integral>::type;
+ _LIBCPP_CONSTEXPR const unsigned __nbuf
+ = (numeric_limits<_Unsigned>::digits / 3) // 1 char per 3 bits
+ + ((numeric_limits<_Unsigned>::digits % 3) != 0) // round up
+ + 2; // base prefix + terminating null character
+ char __nar[__nbuf];
+ _LIBCPP_DIAGNOSTIC_PUSH
+ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
+ _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
+ int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
+ _LIBCPP_DIAGNOSTIC_POP
+ char* __ne = __nar + __nc;
+ char* __np = this->__identify_padding(__nar, __ne, __iob);
+ // Stage 2 - Widen __nar while adding thousands separators
+ char_type __o[2*(__nbuf-1) - 1];
+ char_type* __op; // pad here
+ char_type* __oe; // end of output
+ this->__widen_and_group_int(__nar, __np, __ne, __o, __op, __oe, __iob.getloc());
+ // [__o, __oe) contains thousands_sep'd wide number
+ // Stage 3 & 4
+ return __pad_and_output(__s, __o, __op, __oe, __iob, __fl);
+}
+
+template <class _CharT, class _OutputIterator>
+_OutputIterator
+num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
+ char_type __fl, long __v) const
+{
+ return this->__do_put_integral(__s, __iob, __fl, __v, "l");
+}
+
+template <class _CharT, class _OutputIterator>
+_OutputIterator
+num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
+ char_type __fl, long long __v) const
+{
+ return this->__do_put_integral(__s, __iob, __fl, __v, "ll");
+}
+
+template <class _CharT, class _OutputIterator>
+_OutputIterator
+num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
+ char_type __fl, unsigned long __v) const
+{
+ return this->__do_put_integral(__s, __iob, __fl, __v, "l");
+}
+
+template <class _CharT, class _OutputIterator>
+_OutputIterator
+num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
+ char_type __fl, unsigned long long __v) const
+{
+ return this->__do_put_integral(__s, __iob, __fl, __v, "ll");
+}
+
+template <class _CharT, class _OutputIterator>
+template <class _Float>
+_LIBCPP_HIDE_FROM_ABI inline
+_OutputIterator
+num_put<_CharT, _OutputIterator>::__do_put_floating_point(iter_type __s, ios_base& __iob,
+ char_type __fl, _Float __v,
+ char const* __len) const
+{
+ // Stage 1 - Get number in narrow char
+ char __fmt[8] = {'%', 0};
+ bool __specify_precision = this->__format_float(__fmt+1, __len, __iob.flags());
+ const unsigned __nbuf = 30;
+ char __nar[__nbuf];
+ char* __nb = __nar;
+ int __nc;
+ _LIBCPP_DIAGNOSTIC_PUSH
+ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
+ _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
+ if (__specify_precision)
+ __nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt,
+ (int)__iob.precision(), __v);
+ else
+ __nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v);
+ unique_ptr<char, void(*)(void*)> __nbh(nullptr, free);
+ if (__nc > static_cast<int>(__nbuf-1))
+ {
+ if (__specify_precision)
+ __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
+ else
+ __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v);
+ if (__nc == -1)
+ __throw_bad_alloc();
+ __nbh.reset(__nb);
+ }
+ _LIBCPP_DIAGNOSTIC_POP
+ char* __ne = __nb + __nc;
+ char* __np = this->__identify_padding(__nb, __ne, __iob);
+ // Stage 2 - Widen __nar while adding thousands separators
+ char_type __o[2*(__nbuf-1) - 1];
+ char_type* __ob = __o;
+ unique_ptr<char_type, void(*)(void*)> __obh(0, free);
+ if (__nb != __nar)
+ {
+ __ob = (char_type*)malloc(2*static_cast<size_t>(__nc)*sizeof(char_type));
+ if (__ob == 0)
+ __throw_bad_alloc();
+ __obh.reset(__ob);
+ }
+ char_type* __op; // pad here
+ char_type* __oe; // end of output
+ this->__widen_and_group_float(__nb, __np, __ne, __ob, __op, __oe, __iob.getloc());
+ // [__o, __oe) contains thousands_sep'd wide number
+ // Stage 3 & 4
+ __s = __pad_and_output(__s, __ob, __op, __oe, __iob, __fl);
+ return __s;
+}
+
+template <class _CharT, class _OutputIterator>
+_OutputIterator
+num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
+ char_type __fl, double __v) const
+{
+ return this->__do_put_floating_point(__s, __iob, __fl, __v, "");
+}
+
+template <class _CharT, class _OutputIterator>
+_OutputIterator
+num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
+ char_type __fl, long double __v) const
+{
+ return this->__do_put_floating_point(__s, __iob, __fl, __v, "L");
+}
+
+template <class _CharT, class _OutputIterator>
+_OutputIterator
+num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
+ char_type __fl, const void* __v) const
+{
+ // Stage 1 - Get pointer in narrow char
+ const unsigned __nbuf = 20;
+ char __nar[__nbuf];
+ int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, "%p", __v);
+ char* __ne = __nar + __nc;
+ char* __np = this->__identify_padding(__nar, __ne, __iob);
+ // Stage 2 - Widen __nar
+ char_type __o[2*(__nbuf-1) - 1];
+ char_type* __op; // pad here
+ char_type* __oe; // end of output
+ const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__iob.getloc());
+ __ct.widen(__nar, __ne, __o);
+ __oe = __o + (__ne - __nar);
+ if (__np == __ne)
+ __op = __oe;
+ else
+ __op = __o + (__np - __nar);
+ // [__o, __oe) contains wide number
+ // Stage 3 & 4
+ return __pad_and_output(__s, __o, __op, __oe, __iob, __fl);
+}
+
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<char>)
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<wchar_t>)
+#endif
+
+template <class _CharT, class _InputIterator>
+_LIBCPP_HIDDEN
+int
+__get_up_to_n_digits(_InputIterator& __b, _InputIterator __e,
+ ios_base::iostate& __err, const ctype<_CharT>& __ct, int __n)
+{
+ // Precondition: __n >= 1
+ if (__b == __e)
+ {
+ __err |= ios_base::eofbit | ios_base::failbit;
+ return 0;
+ }
+ // get first digit
+ _CharT __c = *__b;
+ if (!__ct.is(ctype_base::digit, __c))
+ {
+ __err |= ios_base::failbit;
+ return 0;
+ }
+ int __r = __ct.narrow(__c, 0) - '0';
+ for (++__b, (void) --__n; __b != __e && __n > 0; ++__b, (void) --__n)
+ {
+ // get next digit
+ __c = *__b;
+ if (!__ct.is(ctype_base::digit, __c))
+ return __r;
+ __r = __r * 10 + __ct.narrow(__c, 0) - '0';
+ }
+ if (__b == __e)
+ __err |= ios_base::eofbit;
+ return __r;
+}
+
+class _LIBCPP_TYPE_VIS time_base
+{
+public:
+ enum dateorder {no_order, dmy, mdy, ymd, ydm};
+};
+
+#ifdef _LIBCPP_COMPILER_MSVC
+// __time_get_c_storage should only be used for private inheritance to avoid
+// problems with non-virtual destructor
+#pragma warning ( push )
+#pragma warning ( disable : 4265 )
+#endif
+
+template <class _CharT>
+class _LIBCPP_TEMPLATE_VIS __time_get_c_storage
+{
+protected:
+ typedef basic_string<_CharT> string_type;
+
+ virtual const string_type* __weeks() const;
+ virtual const string_type* __months() const;
+ virtual const string_type* __am_pm() const;
+ virtual const string_type& __c() const;
+ virtual const string_type& __r() const;
+ virtual const string_type& __x() const;
+ virtual const string_type& __X() const;
+
+ _LIBCPP_INLINE_VISIBILITY
+ ~__time_get_c_storage() {}
+};
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( pop )
+#endif
+
+template <> _LIBCPP_FUNC_VIS const string* __time_get_c_storage<char>::__weeks() const;
+template <> _LIBCPP_FUNC_VIS const string* __time_get_c_storage<char>::__months() const;
+template <> _LIBCPP_FUNC_VIS const string* __time_get_c_storage<char>::__am_pm() const;
+template <> _LIBCPP_FUNC_VIS const string& __time_get_c_storage<char>::__c() const;
+template <> _LIBCPP_FUNC_VIS const string& __time_get_c_storage<char>::__r() const;
+template <> _LIBCPP_FUNC_VIS const string& __time_get_c_storage<char>::__x() const;
+template <> _LIBCPP_FUNC_VIS const string& __time_get_c_storage<char>::__X() const;
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <> _LIBCPP_FUNC_VIS const wstring* __time_get_c_storage<wchar_t>::__weeks() const;
+template <> _LIBCPP_FUNC_VIS const wstring* __time_get_c_storage<wchar_t>::__months() const;
+template <> _LIBCPP_FUNC_VIS const wstring* __time_get_c_storage<wchar_t>::__am_pm() const;
+template <> _LIBCPP_FUNC_VIS const wstring& __time_get_c_storage<wchar_t>::__c() const;
+template <> _LIBCPP_FUNC_VIS const wstring& __time_get_c_storage<wchar_t>::__r() const;
+template <> _LIBCPP_FUNC_VIS const wstring& __time_get_c_storage<wchar_t>::__x() const;
+template <> _LIBCPP_FUNC_VIS const wstring& __time_get_c_storage<wchar_t>::__X() const;
+#endif
+
+template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
+class _LIBCPP_TEMPLATE_VIS time_get
+ : public locale::facet,
+ public time_base,
+ private __time_get_c_storage<_CharT>
+{
+public:
+ typedef _CharT char_type;
+ typedef _InputIterator iter_type;
+ typedef time_base::dateorder dateorder;
+ typedef basic_string<char_type> string_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit time_get(size_t __refs = 0)
+ : locale::facet(__refs) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ dateorder date_order() const
+ {
+ return this->do_date_order();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iter_type get_time(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, tm* __tm) const
+ {
+ return do_get_time(__b, __e, __iob, __err, __tm);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iter_type get_date(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, tm* __tm) const
+ {
+ return do_get_date(__b, __e, __iob, __err, __tm);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iter_type get_weekday(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, tm* __tm) const
+ {
+ return do_get_weekday(__b, __e, __iob, __err, __tm);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iter_type get_monthname(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, tm* __tm) const
+ {
+ return do_get_monthname(__b, __e, __iob, __err, __tm);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iter_type get_year(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, tm* __tm) const
+ {
+ return do_get_year(__b, __e, __iob, __err, __tm);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, tm *__tm,
+ char __fmt, char __mod = 0) const
+ {
+ return do_get(__b, __e, __iob, __err, __tm, __fmt, __mod);
+ }
+
+ iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, tm* __tm,
+ const char_type* __fmtb, const char_type* __fmte) const;
+
+ static locale::id id;
+
+protected:
+ _LIBCPP_INLINE_VISIBILITY
+ ~time_get() {}
+
+ virtual dateorder do_date_order() const;
+ virtual iter_type do_get_time(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, tm* __tm) const;
+ virtual iter_type do_get_date(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, tm* __tm) const;
+ virtual iter_type do_get_weekday(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, tm* __tm) const;
+ virtual iter_type do_get_monthname(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, tm* __tm) const;
+ virtual iter_type do_get_year(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, tm* __tm) const;
+ virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob,
+ ios_base::iostate& __err, tm* __tm,
+ char __fmt, char __mod) const;
+private:
+ void __get_white_space(iter_type& __b, iter_type __e,
+ ios_base::iostate& __err, const ctype<char_type>& __ct) const;
+ void __get_percent(iter_type& __b, iter_type __e, ios_base::iostate& __err,
+ const ctype<char_type>& __ct) const;
+
+ void __get_weekdayname(int& __m,
+ iter_type& __b, iter_type __e,
+ ios_base::iostate& __err,
+ const ctype<char_type>& __ct) const;
+ void __get_monthname(int& __m,
+ iter_type& __b, iter_type __e,
+ ios_base::iostate& __err,
+ const ctype<char_type>& __ct) const;
+ void __get_day(int& __d,
+ iter_type& __b, iter_type __e,
+ ios_base::iostate& __err,
+ const ctype<char_type>& __ct) const;
+ void __get_month(int& __m,
+ iter_type& __b, iter_type __e,
+ ios_base::iostate& __err,
+ const ctype<char_type>& __ct) const;
+ void __get_year(int& __y,
+ iter_type& __b, iter_type __e,
+ ios_base::iostate& __err,
+ const ctype<char_type>& __ct) const;
+ void __get_year4(int& __y,
+ iter_type& __b, iter_type __e,
+ ios_base::iostate& __err,
+ const ctype<char_type>& __ct) const;
+ void __get_hour(int& __d,
+ iter_type& __b, iter_type __e,
+ ios_base::iostate& __err,
+ const ctype<char_type>& __ct) const;
+ void __get_12_hour(int& __h,
+ iter_type& __b, iter_type __e,
+ ios_base::iostate& __err,
+ const ctype<char_type>& __ct) const;
+ void __get_am_pm(int& __h,
+ iter_type& __b, iter_type __e,
+ ios_base::iostate& __err,
+ const ctype<char_type>& __ct) const;
+ void __get_minute(int& __m,
+ iter_type& __b, iter_type __e,
+ ios_base::iostate& __err,
+ const ctype<char_type>& __ct) const;
+ void __get_second(int& __s,
+ iter_type& __b, iter_type __e,
+ ios_base::iostate& __err,
+ const ctype<char_type>& __ct) const;
+ void __get_weekday(int& __w,
+ iter_type& __b, iter_type __e,
+ ios_base::iostate& __err,
+ const ctype<char_type>& __ct) const;
+ void __get_day_year_num(int& __w,
+ iter_type& __b, iter_type __e,
+ ios_base::iostate& __err,
+ const ctype<char_type>& __ct) const;
+};
+
+template <class _CharT, class _InputIterator>
+locale::id
+time_get<_CharT, _InputIterator>::id;
+
+// time_get primitives
+
+template <class _CharT, class _InputIterator>
+void
+time_get<_CharT, _InputIterator>::__get_weekdayname(int& __w,
+ iter_type& __b, iter_type __e,
+ ios_base::iostate& __err,
+ const ctype<char_type>& __ct) const
+{
+ // Note: ignoring case comes from the POSIX strptime spec
+ const string_type* __wk = this->__weeks();
+ ptrdiff_t __i = _VSTD::__scan_keyword(__b, __e, __wk, __wk+14, __ct, __err, false) - __wk;
+ if (__i < 14)
+ __w = __i % 7;
+}
+
+template <class _CharT, class _InputIterator>
+void
+time_get<_CharT, _InputIterator>::__get_monthname(int& __m,
+ iter_type& __b, iter_type __e,
+ ios_base::iostate& __err,
+ const ctype<char_type>& __ct) const
+{
+ // Note: ignoring case comes from the POSIX strptime spec
+ const string_type* __month = this->__months();
+ ptrdiff_t __i = _VSTD::__scan_keyword(__b, __e, __month, __month+24, __ct, __err, false) - __month;
+ if (__i < 24)
+ __m = __i % 12;
+}
+
+template <class _CharT, class _InputIterator>
+void
+time_get<_CharT, _InputIterator>::__get_day(int& __d,
+ iter_type& __b, iter_type __e,
+ ios_base::iostate& __err,
+ const ctype<char_type>& __ct) const
+{
+ int __t = _VSTD::__get_up_to_n_digits(__b, __e, __err, __ct, 2);
+ if (!(__err & ios_base::failbit) && 1 <= __t && __t <= 31)
+ __d = __t;
+ else
+ __err |= ios_base::failbit;
+}
+
+template <class _CharT, class _InputIterator>
+void
+time_get<_CharT, _InputIterator>::__get_month(int& __m,
+ iter_type& __b, iter_type __e,
+ ios_base::iostate& __err,
+ const ctype<char_type>& __ct) const
+{
+ int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2) - 1;
+ if (!(__err & ios_base::failbit) && __t <= 11)
+ __m = __t;
+ else
+ __err |= ios_base::failbit;
+}
+
+template <class _CharT, class _InputIterator>
+void
+time_get<_CharT, _InputIterator>::__get_year(int& __y,
+ iter_type& __b, iter_type __e,
+ ios_base::iostate& __err,
+ const ctype<char_type>& __ct) const
+{
+ int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 4);
+ if (!(__err & ios_base::failbit))
+ {
+ if (__t < 69)
+ __t += 2000;
+ else if (69 <= __t && __t <= 99)
+ __t += 1900;
+ __y = __t - 1900;
+ }
+}
+
+template <class _CharT, class _InputIterator>
+void
+time_get<_CharT, _InputIterator>::__get_year4(int& __y,
+ iter_type& __b, iter_type __e,
+ ios_base::iostate& __err,
+ const ctype<char_type>& __ct) const
+{
+ int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 4);
+ if (!(__err & ios_base::failbit))
+ __y = __t - 1900;
+}
+
+template <class _CharT, class _InputIterator>
+void
+time_get<_CharT, _InputIterator>::__get_hour(int& __h,
+ iter_type& __b, iter_type __e,
+ ios_base::iostate& __err,
+ const ctype<char_type>& __ct) const
+{
+ int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2);
+ if (!(__err & ios_base::failbit) && __t <= 23)
+ __h = __t;
+ else
+ __err |= ios_base::failbit;
+}
+
+template <class _CharT, class _InputIterator>
+void
+time_get<_CharT, _InputIterator>::__get_12_hour(int& __h,
+ iter_type& __b, iter_type __e,
+ ios_base::iostate& __err,
+ const ctype<char_type>& __ct) const
+{
+ int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2);
+ if (!(__err & ios_base::failbit) && 1 <= __t && __t <= 12)
+ __h = __t;
+ else
+ __err |= ios_base::failbit;
+}
+
+template <class _CharT, class _InputIterator>
+void
+time_get<_CharT, _InputIterator>::__get_minute(int& __m,
+ iter_type& __b, iter_type __e,
+ ios_base::iostate& __err,
+ const ctype<char_type>& __ct) const
+{
+ int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2);
+ if (!(__err & ios_base::failbit) && __t <= 59)
+ __m = __t;
+ else
+ __err |= ios_base::failbit;
+}
+
+template <class _CharT, class _InputIterator>
+void
+time_get<_CharT, _InputIterator>::__get_second(int& __s,
+ iter_type& __b, iter_type __e,
+ ios_base::iostate& __err,
+ const ctype<char_type>& __ct) const
+{
+ int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2);
+ if (!(__err & ios_base::failbit) && __t <= 60)
+ __s = __t;
+ else
+ __err |= ios_base::failbit;
+}
+
+template <class _CharT, class _InputIterator>
+void
+time_get<_CharT, _InputIterator>::__get_weekday(int& __w,
+ iter_type& __b, iter_type __e,
+ ios_base::iostate& __err,
+ const ctype<char_type>& __ct) const
+{
+ int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 1);
+ if (!(__err & ios_base::failbit) && __t <= 6)
+ __w = __t;
+ else
+ __err |= ios_base::failbit;
+}
+
+template <class _CharT, class _InputIterator>
+void
+time_get<_CharT, _InputIterator>::__get_day_year_num(int& __d,
+ iter_type& __b, iter_type __e,
+ ios_base::iostate& __err,
+ const ctype<char_type>& __ct) const
+{
+ int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 3);
+ if (!(__err & ios_base::failbit) && __t <= 365)
+ __d = __t;
+ else
+ __err |= ios_base::failbit;
+}
+
+template <class _CharT, class _InputIterator>
+void
+time_get<_CharT, _InputIterator>::__get_white_space(iter_type& __b, iter_type __e,
+ ios_base::iostate& __err,
+ const ctype<char_type>& __ct) const
+{
+ for (; __b != __e && __ct.is(ctype_base::space, *__b); ++__b)
+ ;
+ if (__b == __e)
+ __err |= ios_base::eofbit;
+}
+
+template <class _CharT, class _InputIterator>
+void
+time_get<_CharT, _InputIterator>::__get_am_pm(int& __h,
+ iter_type& __b, iter_type __e,
+ ios_base::iostate& __err,
+ const ctype<char_type>& __ct) const
+{
+ const string_type* __ap = this->__am_pm();
+ if (__ap[0].size() + __ap[1].size() == 0)
+ {
+ __err |= ios_base::failbit;
+ return;
+ }
+ ptrdiff_t __i = _VSTD::__scan_keyword(__b, __e, __ap, __ap+2, __ct, __err, false) - __ap;
+ if (__i == 0 && __h == 12)
+ __h = 0;
+ else if (__i == 1 && __h < 12)
+ __h += 12;
+}
+
+template <class _CharT, class _InputIterator>
+void
+time_get<_CharT, _InputIterator>::__get_percent(iter_type& __b, iter_type __e,
+ ios_base::iostate& __err,
+ const ctype<char_type>& __ct) const
+{
+ if (__b == __e)
+ {
+ __err |= ios_base::eofbit | ios_base::failbit;
+ return;
+ }
+ if (__ct.narrow(*__b, 0) != '%')
+ __err |= ios_base::failbit;
+ else if(++__b == __e)
+ __err |= ios_base::eofbit;
+}
+
+// time_get end primitives
+
+template <class _CharT, class _InputIterator>
+_InputIterator
+time_get<_CharT, _InputIterator>::get(iter_type __b, iter_type __e,
+ ios_base& __iob,
+ ios_base::iostate& __err, tm* __tm,
+ const char_type* __fmtb, const char_type* __fmte) const
+{
+ const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__iob.getloc());
+ __err = ios_base::goodbit;
+ while (__fmtb != __fmte && __err == ios_base::goodbit)
+ {
+ if (__b == __e)
+ {
+ __err = ios_base::failbit;
+ break;
+ }
+ if (__ct.narrow(*__fmtb, 0) == '%')
+ {
+ if (++__fmtb == __fmte)
+ {
+ __err = ios_base::failbit;
+ break;
+ }
+ char __cmd = __ct.narrow(*__fmtb, 0);
+ char __opt = '\0';
+ if (__cmd == 'E' || __cmd == '0')
+ {
+ if (++__fmtb == __fmte)
+ {
+ __err = ios_base::failbit;
+ break;
+ }
+ __opt = __cmd;
+ __cmd = __ct.narrow(*__fmtb, 0);
+ }
+ __b = do_get(__b, __e, __iob, __err, __tm, __cmd, __opt);
+ ++__fmtb;
+ }
+ else if (__ct.is(ctype_base::space, *__fmtb))
+ {
+ for (++__fmtb; __fmtb != __fmte && __ct.is(ctype_base::space, *__fmtb); ++__fmtb)
+ ;
+ for ( ; __b != __e && __ct.is(ctype_base::space, *__b); ++__b)
+ ;
+ }
+ else if (__ct.toupper(*__b) == __ct.toupper(*__fmtb))
+ {
+ ++__b;
+ ++__fmtb;
+ }
+ else
+ __err = ios_base::failbit;
+ }
+ if (__b == __e)
+ __err |= ios_base::eofbit;
+ return __b;
+}
+
+template <class _CharT, class _InputIterator>
+typename time_get<_CharT, _InputIterator>::dateorder
+time_get<_CharT, _InputIterator>::do_date_order() const
+{
+ return mdy;
+}
+
+template <class _CharT, class _InputIterator>
+_InputIterator
+time_get<_CharT, _InputIterator>::do_get_time(iter_type __b, iter_type __e,
+ ios_base& __iob,
+ ios_base::iostate& __err,
+ tm* __tm) const
+{
+ const char_type __fmt[] = {'%', 'H', ':', '%', 'M', ':', '%', 'S'};
+ return get(__b, __e, __iob, __err, __tm, __fmt, __fmt + sizeof(__fmt)/sizeof(__fmt[0]));
+}
+
+template <class _CharT, class _InputIterator>
+_InputIterator
+time_get<_CharT, _InputIterator>::do_get_date(iter_type __b, iter_type __e,
+ ios_base& __iob,
+ ios_base::iostate& __err,
+ tm* __tm) const
+{
+ const string_type& __fmt = this->__x();
+ return get(__b, __e, __iob, __err, __tm, __fmt.data(), __fmt.data() + __fmt.size());
+}
+
+template <class _CharT, class _InputIterator>
+_InputIterator
+time_get<_CharT, _InputIterator>::do_get_weekday(iter_type __b, iter_type __e,
+ ios_base& __iob,
+ ios_base::iostate& __err,
+ tm* __tm) const
+{
+ const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__iob.getloc());
+ __get_weekdayname(__tm->tm_wday, __b, __e, __err, __ct);
+ return __b;
+}
+
+template <class _CharT, class _InputIterator>
+_InputIterator
+time_get<_CharT, _InputIterator>::do_get_monthname(iter_type __b, iter_type __e,
+ ios_base& __iob,
+ ios_base::iostate& __err,
+ tm* __tm) const
+{
+ const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__iob.getloc());
+ __get_monthname(__tm->tm_mon, __b, __e, __err, __ct);
+ return __b;
+}
+
+template <class _CharT, class _InputIterator>
+_InputIterator
+time_get<_CharT, _InputIterator>::do_get_year(iter_type __b, iter_type __e,
+ ios_base& __iob,
+ ios_base::iostate& __err,
+ tm* __tm) const
+{
+ const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__iob.getloc());
+ __get_year(__tm->tm_year, __b, __e, __err, __ct);
+ return __b;
+}
+
+template <class _CharT, class _InputIterator>
+_InputIterator
+time_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
+ ios_base& __iob,
+ ios_base::iostate& __err, tm* __tm,
+ char __fmt, char) const
+{
+ __err = ios_base::goodbit;
+ const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__iob.getloc());
+ switch (__fmt)
+ {
+ case 'a':
+ case 'A':
+ __get_weekdayname(__tm->tm_wday, __b, __e, __err, __ct);
+ break;
+ case 'b':
+ case 'B':
+ case 'h':
+ __get_monthname(__tm->tm_mon, __b, __e, __err, __ct);
+ break;
+ case 'c':
+ {
+ const string_type& __fm = this->__c();
+ __b = get(__b, __e, __iob, __err, __tm, __fm.data(), __fm.data() + __fm.size());
+ }
+ break;
+ case 'd':
+ case 'e':
+ __get_day(__tm->tm_mday, __b, __e, __err, __ct);
+ break;
+ case 'D':
+ {
+ const char_type __fm[] = {'%', 'm', '/', '%', 'd', '/', '%', 'y'};
+ __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm)/sizeof(__fm[0]));
+ }
+ break;
+ case 'F':
+ {
+ const char_type __fm[] = {'%', 'Y', '-', '%', 'm', '-', '%', 'd'};
+ __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm)/sizeof(__fm[0]));
+ }
+ break;
+ case 'H':
+ __get_hour(__tm->tm_hour, __b, __e, __err, __ct);
+ break;
+ case 'I':
+ __get_12_hour(__tm->tm_hour, __b, __e, __err, __ct);
+ break;
+ case 'j':
+ __get_day_year_num(__tm->tm_yday, __b, __e, __err, __ct);
+ break;
+ case 'm':
+ __get_month(__tm->tm_mon, __b, __e, __err, __ct);
+ break;
+ case 'M':
+ __get_minute(__tm->tm_min, __b, __e, __err, __ct);
+ break;
+ case 'n':
+ case 't':
+ __get_white_space(__b, __e, __err, __ct);
+ break;
+ case 'p':
+ __get_am_pm(__tm->tm_hour, __b, __e, __err, __ct);
+ break;
+ case 'r':
+ {
+ const char_type __fm[] = {'%', 'I', ':', '%', 'M', ':', '%', 'S', ' ', '%', 'p'};
+ __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm)/sizeof(__fm[0]));
+ }
+ break;
+ case 'R':
+ {
+ const char_type __fm[] = {'%', 'H', ':', '%', 'M'};
+ __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm)/sizeof(__fm[0]));
+ }
+ break;
+ case 'S':
+ __get_second(__tm->tm_sec, __b, __e, __err, __ct);
+ break;
+ case 'T':
+ {
+ const char_type __fm[] = {'%', 'H', ':', '%', 'M', ':', '%', 'S'};
+ __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm)/sizeof(__fm[0]));
+ }
+ break;
+ case 'w':
+ __get_weekday(__tm->tm_wday, __b, __e, __err, __ct);
+ break;
+ case 'x':
+ return do_get_date(__b, __e, __iob, __err, __tm);
+ case 'X':
+ {
+ const string_type& __fm = this->__X();
+ __b = get(__b, __e, __iob, __err, __tm, __fm.data(), __fm.data() + __fm.size());
+ }
+ break;
+ case 'y':
+ __get_year(__tm->tm_year, __b, __e, __err, __ct);
+ break;
+ case 'Y':
+ __get_year4(__tm->tm_year, __b, __e, __err, __ct);
+ break;
+ case '%':
+ __get_percent(__b, __e, __err, __ct);
+ break;
+ default:
+ __err |= ios_base::failbit;
+ }
+ return __b;
+}
+
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<char>)
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<wchar_t>)
+#endif
+
+class _LIBCPP_TYPE_VIS __time_get
+{
+protected:
+ locale_t __loc_;
+
+ __time_get(const char* __nm);
+ __time_get(const string& __nm);
+ ~__time_get();
+};
+
+template <class _CharT>
+class _LIBCPP_TEMPLATE_VIS __time_get_storage
+ : public __time_get
+{
+protected:
+ typedef basic_string<_CharT> string_type;
+
+ string_type __weeks_[14];
+ string_type __months_[24];
+ string_type __am_pm_[2];
+ string_type __c_;
+ string_type __r_;
+ string_type __x_;
+ string_type __X_;
+
+ explicit __time_get_storage(const char* __nm);
+ explicit __time_get_storage(const string& __nm);
+
+ _LIBCPP_INLINE_VISIBILITY ~__time_get_storage() {}
+
+ time_base::dateorder __do_date_order() const;
+
+private:
+ void init(const ctype<_CharT>&);
+ string_type __analyze(char __fmt, const ctype<_CharT>&);
+};
+
+#define _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(_CharT) \
+template <> _LIBCPP_FUNC_VIS time_base::dateorder __time_get_storage<_CharT>::__do_date_order() const; \
+template <> _LIBCPP_FUNC_VIS __time_get_storage<_CharT>::__time_get_storage(const char*); \
+template <> _LIBCPP_FUNC_VIS __time_get_storage<_CharT>::__time_get_storage(const string&); \
+template <> _LIBCPP_FUNC_VIS void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \
+template <> _LIBCPP_FUNC_VIS __time_get_storage<_CharT>::string_type __time_get_storage<_CharT>::__analyze(char, const ctype<_CharT>&); \
+extern template _LIBCPP_FUNC_VIS time_base::dateorder __time_get_storage<_CharT>::__do_date_order() const; \
+extern template _LIBCPP_FUNC_VIS __time_get_storage<_CharT>::__time_get_storage(const char*); \
+extern template _LIBCPP_FUNC_VIS __time_get_storage<_CharT>::__time_get_storage(const string&); \
+extern template _LIBCPP_FUNC_VIS void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \
+extern template _LIBCPP_FUNC_VIS __time_get_storage<_CharT>::string_type __time_get_storage<_CharT>::__analyze(char, const ctype<_CharT>&); \
+/**/
+
+_LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(char)
+_LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(wchar_t)
+#undef _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION
+
+template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
+class _LIBCPP_TEMPLATE_VIS time_get_byname
+ : public time_get<_CharT, _InputIterator>,
+ private __time_get_storage<_CharT>
+{
+public:
+ typedef time_base::dateorder dateorder;
+ typedef _InputIterator iter_type;
+ typedef _CharT char_type;
+ typedef basic_string<char_type> string_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit time_get_byname(const char* __nm, size_t __refs = 0)
+ : time_get<_CharT, _InputIterator>(__refs),
+ __time_get_storage<_CharT>(__nm) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit time_get_byname(const string& __nm, size_t __refs = 0)
+ : time_get<_CharT, _InputIterator>(__refs),
+ __time_get_storage<_CharT>(__nm) {}
+
+protected:
+ _LIBCPP_INLINE_VISIBILITY
+ ~time_get_byname() {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ virtual dateorder do_date_order() const {return this->__do_date_order();}
+private:
+ _LIBCPP_INLINE_VISIBILITY
+ virtual const string_type* __weeks() const {return this->__weeks_;}
+ _LIBCPP_INLINE_VISIBILITY
+ virtual const string_type* __months() const {return this->__months_;}
+ _LIBCPP_INLINE_VISIBILITY
+ virtual const string_type* __am_pm() const {return this->__am_pm_;}
+ _LIBCPP_INLINE_VISIBILITY
+ virtual const string_type& __c() const {return this->__c_;}
+ _LIBCPP_INLINE_VISIBILITY
+ virtual const string_type& __r() const {return this->__r_;}
+ _LIBCPP_INLINE_VISIBILITY
+ virtual const string_type& __x() const {return this->__x_;}
+ _LIBCPP_INLINE_VISIBILITY
+ virtual const string_type& __X() const {return this->__X_;}
+};
+
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<char>)
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<wchar_t>)
+#endif
+
+class _LIBCPP_TYPE_VIS __time_put
+{
+ locale_t __loc_;
+protected:
+ _LIBCPP_INLINE_VISIBILITY __time_put() : __loc_(_LIBCPP_GET_C_LOCALE) {}
+ __time_put(const char* __nm);
+ __time_put(const string& __nm);
+ ~__time_put();
+ void __do_put(char* __nb, char*& __ne, const tm* __tm,
+ char __fmt, char __mod) const;
+ void __do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm,
+ char __fmt, char __mod) const;
+};
+
+template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
+class _LIBCPP_TEMPLATE_VIS time_put
+ : public locale::facet,
+ private __time_put
+{
+public:
+ typedef _CharT char_type;
+ typedef _OutputIterator iter_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit time_put(size_t __refs = 0)
+ : locale::facet(__refs) {}
+
+ iter_type put(iter_type __s, ios_base& __iob, char_type __fl, const tm* __tm,
+ const char_type* __pb, const char_type* __pe) const;
+
+ _LIBCPP_INLINE_VISIBILITY
+ iter_type put(iter_type __s, ios_base& __iob, char_type __fl,
+ const tm* __tm, char __fmt, char __mod = 0) const
+ {
+ return do_put(__s, __iob, __fl, __tm, __fmt, __mod);
+ }
+
+ static locale::id id;
+
+protected:
+ _LIBCPP_INLINE_VISIBILITY
+ ~time_put() {}
+ virtual iter_type do_put(iter_type __s, ios_base&, char_type, const tm* __tm,
+ char __fmt, char __mod) const;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit time_put(const char* __nm, size_t __refs)
+ : locale::facet(__refs),
+ __time_put(__nm) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit time_put(const string& __nm, size_t __refs)
+ : locale::facet(__refs),
+ __time_put(__nm) {}
+};
+
+template <class _CharT, class _OutputIterator>
+locale::id
+time_put<_CharT, _OutputIterator>::id;
+
+template <class _CharT, class _OutputIterator>
+_OutputIterator
+time_put<_CharT, _OutputIterator>::put(iter_type __s, ios_base& __iob,
+ char_type __fl, const tm* __tm,
+ const char_type* __pb,
+ const char_type* __pe) const
+{
+ const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__iob.getloc());
+ for (; __pb != __pe; ++__pb)
+ {
+ if (__ct.narrow(*__pb, 0) == '%')
+ {
+ if (++__pb == __pe)
+ {
+ *__s++ = __pb[-1];
+ break;
+ }
+ char __mod = 0;
+ char __fmt = __ct.narrow(*__pb, 0);
+ if (__fmt == 'E' || __fmt == 'O')
+ {
+ if (++__pb == __pe)
+ {
+ *__s++ = __pb[-2];
+ *__s++ = __pb[-1];
+ break;
+ }
+ __mod = __fmt;
+ __fmt = __ct.narrow(*__pb, 0);
+ }
+ __s = do_put(__s, __iob, __fl, __tm, __fmt, __mod);
+ }
+ else
+ *__s++ = *__pb;
+ }
+ return __s;
+}
+
+template <class _CharT, class _OutputIterator>
+_OutputIterator
+time_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base&,
+ char_type, const tm* __tm,
+ char __fmt, char __mod) const
+{
+ char_type __nar[100];
+ char_type* __nb = __nar;
+ char_type* __ne = __nb + 100;
+ __do_put(__nb, __ne, __tm, __fmt, __mod);
+ return _VSTD::copy(__nb, __ne, __s);
+}
+
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<char>)
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<wchar_t>)
+#endif
+
+template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
+class _LIBCPP_TEMPLATE_VIS time_put_byname
+ : public time_put<_CharT, _OutputIterator>
+{
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit time_put_byname(const char* __nm, size_t __refs = 0)
+ : time_put<_CharT, _OutputIterator>(__nm, __refs) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit time_put_byname(const string& __nm, size_t __refs = 0)
+ : time_put<_CharT, _OutputIterator>(__nm, __refs) {}
+
+protected:
+#if defined(_MSC_VER) && defined(__clang__)
+ ~time_put_byname() {}
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ ~time_put_byname() {}
+#endif
+};
+
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<char>)
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<wchar_t>)
+#endif
+
+// money_base
+
+class _LIBCPP_TYPE_VIS money_base
+{
+public:
+ enum part {none, space, symbol, sign, value};
+ struct pattern {char field[4];};
+
+ _LIBCPP_INLINE_VISIBILITY money_base() {}
+};
+
+// moneypunct
+
+template <class _CharT, bool _International = false>
+class _LIBCPP_TEMPLATE_VIS moneypunct
+ : public locale::facet,
+ public money_base
+{
+public:
+ typedef _CharT char_type;
+ typedef basic_string<char_type> string_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit moneypunct(size_t __refs = 0)
+ : locale::facet(__refs) {}
+
+ _LIBCPP_INLINE_VISIBILITY char_type decimal_point() const {return do_decimal_point();}
+ _LIBCPP_INLINE_VISIBILITY char_type thousands_sep() const {return do_thousands_sep();}
+ _LIBCPP_INLINE_VISIBILITY string grouping() const {return do_grouping();}
+ _LIBCPP_INLINE_VISIBILITY string_type curr_symbol() const {return do_curr_symbol();}
+ _LIBCPP_INLINE_VISIBILITY string_type positive_sign() const {return do_positive_sign();}
+ _LIBCPP_INLINE_VISIBILITY string_type negative_sign() const {return do_negative_sign();}
+ _LIBCPP_INLINE_VISIBILITY int frac_digits() const {return do_frac_digits();}
+ _LIBCPP_INLINE_VISIBILITY pattern pos_format() const {return do_pos_format();}
+ _LIBCPP_INLINE_VISIBILITY pattern neg_format() const {return do_neg_format();}
+
+ static locale::id id;
+ static const bool intl = _International;
+
+protected:
+ _LIBCPP_INLINE_VISIBILITY
+ ~moneypunct() {}
+
+ virtual char_type do_decimal_point() const {return numeric_limits<char_type>::max();}
+ virtual char_type do_thousands_sep() const {return numeric_limits<char_type>::max();}
+ virtual string do_grouping() const {return string();}
+ virtual string_type do_curr_symbol() const {return string_type();}
+ virtual string_type do_positive_sign() const {return string_type();}
+ virtual string_type do_negative_sign() const {return string_type(1, '-');}
+ virtual int do_frac_digits() const {return 0;}
+ virtual pattern do_pos_format() const
+ {pattern __p = {{symbol, sign, none, value}}; return __p;}
+ virtual pattern do_neg_format() const
+ {pattern __p = {{symbol, sign, none, value}}; return __p;}
+};
+
+template <class _CharT, bool _International>
+locale::id
+moneypunct<_CharT, _International>::id;
+
+template <class _CharT, bool _International>
+const bool
+moneypunct<_CharT, _International>::intl;
+
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, false>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, true>)
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, false>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, true>)
+#endif
+
+// moneypunct_byname
+
+template <class _CharT, bool _International = false>
+class _LIBCPP_TEMPLATE_VIS moneypunct_byname
+ : public moneypunct<_CharT, _International>
+{
+public:
+ typedef money_base::pattern pattern;
+ typedef _CharT char_type;
+ typedef basic_string<char_type> string_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit moneypunct_byname(const char* __nm, size_t __refs = 0)
+ : moneypunct<_CharT, _International>(__refs) {init(__nm);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit moneypunct_byname(const string& __nm, size_t __refs = 0)
+ : moneypunct<_CharT, _International>(__refs) {init(__nm.c_str());}
+
+protected:
+ _LIBCPP_INLINE_VISIBILITY
+ ~moneypunct_byname() {}
+
+ virtual char_type do_decimal_point() const {return __decimal_point_;}
+ virtual char_type do_thousands_sep() const {return __thousands_sep_;}
+ virtual string do_grouping() const {return __grouping_;}
+ virtual string_type do_curr_symbol() const {return __curr_symbol_;}
+ virtual string_type do_positive_sign() const {return __positive_sign_;}
+ virtual string_type do_negative_sign() const {return __negative_sign_;}
+ virtual int do_frac_digits() const {return __frac_digits_;}
+ virtual pattern do_pos_format() const {return __pos_format_;}
+ virtual pattern do_neg_format() const {return __neg_format_;}
+
+private:
+ char_type __decimal_point_;
+ char_type __thousands_sep_;
+ string __grouping_;
+ string_type __curr_symbol_;
+ string_type __positive_sign_;
+ string_type __negative_sign_;
+ int __frac_digits_;
+ pattern __pos_format_;
+ pattern __neg_format_;
+
+ void init(const char*);
+};
+
+template<> _LIBCPP_FUNC_VIS void moneypunct_byname<char, false>::init(const char*);
+template<> _LIBCPP_FUNC_VIS void moneypunct_byname<char, true>::init(const char*);
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, false>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, true>)
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template<> _LIBCPP_FUNC_VIS void moneypunct_byname<wchar_t, false>::init(const char*);
+template<> _LIBCPP_FUNC_VIS void moneypunct_byname<wchar_t, true>::init(const char*);
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, false>)
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, true>)
+#endif
+
+// money_get
+
+template <class _CharT>
+class __money_get
+{
+protected:
+ typedef _CharT char_type;
+ typedef basic_string<char_type> string_type;
+
+ _LIBCPP_INLINE_VISIBILITY __money_get() {}
+
+ static void __gather_info(bool __intl, const locale& __loc,
+ money_base::pattern& __pat, char_type& __dp,
+ char_type& __ts, string& __grp,
+ string_type& __sym, string_type& __psn,
+ string_type& __nsn, int& __fd);
+};
+
+template <class _CharT>
+void
+__money_get<_CharT>::__gather_info(bool __intl, const locale& __loc,
+ money_base::pattern& __pat, char_type& __dp,
+ char_type& __ts, string& __grp,
+ string_type& __sym, string_type& __psn,
+ string_type& __nsn, int& __fd)
+{
+ if (__intl)
+ {
+ const moneypunct<char_type, true>& __mp =
+ use_facet<moneypunct<char_type, true> >(__loc);
+ __pat = __mp.neg_format();
+ __nsn = __mp.negative_sign();
+ __psn = __mp.positive_sign();
+ __dp = __mp.decimal_point();
+ __ts = __mp.thousands_sep();
+ __grp = __mp.grouping();
+ __sym = __mp.curr_symbol();
+ __fd = __mp.frac_digits();
+ }
+ else
+ {
+ const moneypunct<char_type, false>& __mp =
+ use_facet<moneypunct<char_type, false> >(__loc);
+ __pat = __mp.neg_format();
+ __nsn = __mp.negative_sign();
+ __psn = __mp.positive_sign();
+ __dp = __mp.decimal_point();
+ __ts = __mp.thousands_sep();
+ __grp = __mp.grouping();
+ __sym = __mp.curr_symbol();
+ __fd = __mp.frac_digits();
+ }
+}
+
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<char>)
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<wchar_t>)
+#endif
+
+template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
+class _LIBCPP_TEMPLATE_VIS money_get
+ : public locale::facet,
+ private __money_get<_CharT>
+{
+public:
+ typedef _CharT char_type;
+ typedef _InputIterator iter_type;
+ typedef basic_string<char_type> string_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit money_get(size_t __refs = 0)
+ : locale::facet(__refs) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ iter_type get(iter_type __b, iter_type __e, bool __intl, ios_base& __iob,
+ ios_base::iostate& __err, long double& __v) const
+ {
+ return do_get(__b, __e, __intl, __iob, __err, __v);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iter_type get(iter_type __b, iter_type __e, bool __intl, ios_base& __iob,
+ ios_base::iostate& __err, string_type& __v) const
+ {
+ return do_get(__b, __e, __intl, __iob, __err, __v);
+ }
+
+ static locale::id id;
+
+protected:
+
+ _LIBCPP_INLINE_VISIBILITY
+ ~money_get() {}
+
+ virtual iter_type do_get(iter_type __b, iter_type __e, bool __intl,
+ ios_base& __iob, ios_base::iostate& __err,
+ long double& __v) const;
+ virtual iter_type do_get(iter_type __b, iter_type __e, bool __intl,
+ ios_base& __iob, ios_base::iostate& __err,
+ string_type& __v) const;
+
+private:
+ static bool __do_get(iter_type& __b, iter_type __e,
+ bool __intl, const locale& __loc,
+ ios_base::fmtflags __flags, ios_base::iostate& __err,
+ bool& __neg, const ctype<char_type>& __ct,
+ unique_ptr<char_type, void(*)(void*)>& __wb,
+ char_type*& __wn, char_type* __we);
+};
+
+template <class _CharT, class _InputIterator>
+locale::id
+money_get<_CharT, _InputIterator>::id;
+
+_LIBCPP_FUNC_VIS void __do_nothing(void*);
+
+template <class _Tp>
+_LIBCPP_HIDDEN
+void
+__double_or_nothing(unique_ptr<_Tp, void(*)(void*)>& __b, _Tp*& __n, _Tp*& __e)
+{
+ bool __owns = __b.get_deleter() != __do_nothing;
+ size_t __cur_cap = static_cast<size_t>(__e-__b.get()) * sizeof(_Tp);
+ size_t __new_cap = __cur_cap < numeric_limits<size_t>::max() / 2 ?
+ 2 * __cur_cap : numeric_limits<size_t>::max();
+ if (__new_cap == 0)
+ __new_cap = sizeof(_Tp);
+ size_t __n_off = static_cast<size_t>(__n - __b.get());
+ _Tp* __t = (_Tp*)realloc(__owns ? __b.get() : 0, __new_cap);
+ if (__t == 0)
+ __throw_bad_alloc();
+ if (__owns)
+ __b.release();
+ __b = unique_ptr<_Tp, void(*)(void*)>(__t, free);
+ __new_cap /= sizeof(_Tp);
+ __n = __b.get() + __n_off;
+ __e = __b.get() + __new_cap;
+}
+
+// true == success
+template <class _CharT, class _InputIterator>
+bool
+money_get<_CharT, _InputIterator>::__do_get(iter_type& __b, iter_type __e,
+ bool __intl, const locale& __loc,
+ ios_base::fmtflags __flags,
+ ios_base::iostate& __err,
+ bool& __neg,
+ const ctype<char_type>& __ct,
+ unique_ptr<char_type, void(*)(void*)>& __wb,
+ char_type*& __wn, char_type* __we)
+{
+ if (__b == __e) {
+ __err |= ios_base::failbit;
+ return false;
+ }
+ const unsigned __bz = 100;
+ unsigned __gbuf[__bz];
+ unique_ptr<unsigned, void(*)(void*)> __gb(__gbuf, __do_nothing);
+ unsigned* __gn = __gb.get();
+ unsigned* __ge = __gn + __bz;
+ money_base::pattern __pat;
+ char_type __dp;
+ char_type __ts;
+ string __grp;
+ string_type __sym;
+ string_type __psn;
+ string_type __nsn;
+ // Capture the spaces read into money_base::{space,none} so they
+ // can be compared to initial spaces in __sym.
+ string_type __spaces;
+ int __fd;
+ __money_get<_CharT>::__gather_info(__intl, __loc, __pat, __dp, __ts, __grp,
+ __sym, __psn, __nsn, __fd);
+ const string_type* __trailing_sign = 0;
+ __wn = __wb.get();
+ for (unsigned __p = 0; __p < 4 && __b != __e; ++__p)
+ {
+ switch (__pat.field[__p])
+ {
+ case money_base::space:
+ if (__p != 3)
+ {
+ if (__ct.is(ctype_base::space, *__b))
+ __spaces.push_back(*__b++);
+ else
+ {
+ __err |= ios_base::failbit;
+ return false;
+ }
+ }
+ _LIBCPP_FALLTHROUGH();
+ case money_base::none:
+ if (__p != 3)
+ {
+ while (__b != __e && __ct.is(ctype_base::space, *__b))
+ __spaces.push_back(*__b++);
+ }
+ break;
+ case money_base::sign:
+ if (__psn.size() > 0 && *__b == __psn[0])
+ {
+ ++__b;
+ __neg = false;
+ if (__psn.size() > 1)
+ __trailing_sign = &__psn;
+ break;
+ }
+ if (__nsn.size() > 0 && *__b == __nsn[0])
+ {
+ ++__b;
+ __neg = true;
+ if (__nsn.size() > 1)
+ __trailing_sign = &__nsn;
+ break;
+ }
+ if (__psn.size() > 0 && __nsn.size() > 0)
+ { // sign is required
+ __err |= ios_base::failbit;
+ return false;
+ }
+ if (__psn.size() == 0 && __nsn.size() == 0)
+ // locale has no way of specifying a sign. Use the initial value of __neg as a default
+ break;
+ __neg = (__nsn.size() == 0);
+ break;
+ case money_base::symbol:
+ {
+ bool __more_needed = __trailing_sign ||
+ (__p < 2) ||
+ (__p == 2 && __pat.field[3] != static_cast<char>(money_base::none));
+ bool __sb = (__flags & ios_base::showbase) != 0;
+ if (__sb || __more_needed)
+ {
+ typename string_type::const_iterator __sym_space_end = __sym.begin();
+ if (__p > 0 && (__pat.field[__p - 1] == money_base::none ||
+ __pat.field[__p - 1] == money_base::space)) {
+ // Match spaces we've already read against spaces at
+ // the beginning of __sym.
+ while (__sym_space_end != __sym.end() &&
+ __ct.is(ctype_base::space, *__sym_space_end))
+ ++__sym_space_end;
+ const size_t __num_spaces = __sym_space_end - __sym.begin();
+ if (__num_spaces > __spaces.size() ||
+ !equal(__spaces.end() - __num_spaces, __spaces.end(),
+ __sym.begin())) {
+ // No match. Put __sym_space_end back at the
+ // beginning of __sym, which will prevent a
+ // match in the next loop.
+ __sym_space_end = __sym.begin();
+ }
+ }
+ typename string_type::const_iterator __sym_curr_char = __sym_space_end;
+ while (__sym_curr_char != __sym.end() && __b != __e &&
+ *__b == *__sym_curr_char) {
+ ++__b;
+ ++__sym_curr_char;
+ }
+ if (__sb && __sym_curr_char != __sym.end())
+ {
+ __err |= ios_base::failbit;
+ return false;
+ }
+ }
+ }
+ break;
+ case money_base::value:
+ {
+ unsigned __ng = 0;
+ for (; __b != __e; ++__b)
+ {
+ char_type __c = *__b;
+ if (__ct.is(ctype_base::digit, __c))
+ {
+ if (__wn == __we)
+ __double_or_nothing(__wb, __wn, __we);
+ *__wn++ = __c;
+ ++__ng;
+ }
+ else if (__grp.size() > 0 && __ng > 0 && __c == __ts)
+ {
+ if (__gn == __ge)
+ __double_or_nothing(__gb, __gn, __ge);
+ *__gn++ = __ng;
+ __ng = 0;
+ }
+ else
+ break;
+ }
+ if (__gb.get() != __gn && __ng > 0)
+ {
+ if (__gn == __ge)
+ __double_or_nothing(__gb, __gn, __ge);
+ *__gn++ = __ng;
+ }
+ if (__fd > 0)
+ {
+ if (__b == __e || *__b != __dp)
+ {
+ __err |= ios_base::failbit;
+ return false;
+ }
+ for (++__b; __fd > 0; --__fd, ++__b)
+ {
+ if (__b == __e || !__ct.is(ctype_base::digit, *__b))
+ {
+ __err |= ios_base::failbit;
+ return false;
+ }
+ if (__wn == __we)
+ __double_or_nothing(__wb, __wn, __we);
+ *__wn++ = *__b;
+ }
+ }
+ if (__wn == __wb.get())
+ {
+ __err |= ios_base::failbit;
+ return false;
+ }
+ }
+ break;
+ }
+ }
+ if (__trailing_sign)
+ {
+ for (unsigned __i = 1; __i < __trailing_sign->size(); ++__i, ++__b)
+ {
+ if (__b == __e || *__b != (*__trailing_sign)[__i])
+ {
+ __err |= ios_base::failbit;
+ return false;
+ }
+ }
+ }
+ if (__gb.get() != __gn)
+ {
+ ios_base::iostate __et = ios_base::goodbit;
+ __check_grouping(__grp, __gb.get(), __gn, __et);
+ if (__et)
+ {
+ __err |= ios_base::failbit;
+ return false;
+ }
+ }
+ return true;
+}
+
+template <class _CharT, class _InputIterator>
+_InputIterator
+money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
+ bool __intl, ios_base& __iob,
+ ios_base::iostate& __err,
+ long double& __v) const
+{
+ const int __bz = 100;
+ char_type __wbuf[__bz];
+ unique_ptr<char_type, void(*)(void*)> __wb(__wbuf, __do_nothing);
+ char_type* __wn;
+ char_type* __we = __wbuf + __bz;
+ locale __loc = __iob.getloc();
+ const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__loc);
+ bool __neg = false;
+ if (__do_get(__b, __e, __intl, __loc, __iob.flags(), __err, __neg, __ct,
+ __wb, __wn, __we))
+ {
+ const char __src[] = "0123456789";
+ char_type __atoms[sizeof(__src)-1];
+ __ct.widen(__src, __src + (sizeof(__src)-1), __atoms);
+ char __nbuf[__bz];
+ char* __nc = __nbuf;
+ unique_ptr<char, void(*)(void*)> __h(nullptr, free);
+ if (__wn - __wb.get() > __bz-2)
+ {
+ __h.reset((char*)malloc(static_cast<size_t>(__wn - __wb.get() + 2)));
+ if (__h.get() == nullptr)
+ __throw_bad_alloc();
+ __nc = __h.get();
+ }
+ if (__neg)
+ *__nc++ = '-';
+ for (const char_type* __w = __wb.get(); __w < __wn; ++__w, ++__nc)
+ *__nc = __src[find(__atoms, _VSTD::end(__atoms), *__w) - __atoms];
+ *__nc = char();
+ if (sscanf(__nbuf, "%Lf", &__v) != 1)
+ __throw_runtime_error("money_get error");
+ }
+ if (__b == __e)
+ __err |= ios_base::eofbit;
+ return __b;
+}
+
+template <class _CharT, class _InputIterator>
+_InputIterator
+money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
+ bool __intl, ios_base& __iob,
+ ios_base::iostate& __err,
+ string_type& __v) const
+{
+ const int __bz = 100;
+ char_type __wbuf[__bz];
+ unique_ptr<char_type, void(*)(void*)> __wb(__wbuf, __do_nothing);
+ char_type* __wn;
+ char_type* __we = __wbuf + __bz;
+ locale __loc = __iob.getloc();
+ const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__loc);
+ bool __neg = false;
+ if (__do_get(__b, __e, __intl, __loc, __iob.flags(), __err, __neg, __ct,
+ __wb, __wn, __we))
+ {
+ __v.clear();
+ if (__neg)
+ __v.push_back(__ct.widen('-'));
+ char_type __z = __ct.widen('0');
+ char_type* __w;
+ for (__w = __wb.get(); __w < __wn-1; ++__w)
+ if (*__w != __z)
+ break;
+ __v.append(__w, __wn);
+ }
+ if (__b == __e)
+ __err |= ios_base::eofbit;
+ return __b;
+}
+
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<char>)
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<wchar_t>)
+#endif
+
+// money_put
+
+template <class _CharT>
+class __money_put
+{
+protected:
+ typedef _CharT char_type;
+ typedef basic_string<char_type> string_type;
+
+ _LIBCPP_INLINE_VISIBILITY __money_put() {}
+
+ static void __gather_info(bool __intl, bool __neg, const locale& __loc,
+ money_base::pattern& __pat, char_type& __dp,
+ char_type& __ts, string& __grp,
+ string_type& __sym, string_type& __sn,
+ int& __fd);
+ static void __format(char_type* __mb, char_type*& __mi, char_type*& __me,
+ ios_base::fmtflags __flags,
+ const char_type* __db, const char_type* __de,
+ const ctype<char_type>& __ct, bool __neg,
+ const money_base::pattern& __pat, char_type __dp,
+ char_type __ts, const string& __grp,
+ const string_type& __sym, const string_type& __sn,
+ int __fd);
+};
+
+template <class _CharT>
+void
+__money_put<_CharT>::__gather_info(bool __intl, bool __neg, const locale& __loc,
+ money_base::pattern& __pat, char_type& __dp,
+ char_type& __ts, string& __grp,
+ string_type& __sym, string_type& __sn,
+ int& __fd)
+{
+ if (__intl)
+ {
+ const moneypunct<char_type, true>& __mp =
+ use_facet<moneypunct<char_type, true> >(__loc);
+ if (__neg)
+ {
+ __pat = __mp.neg_format();
+ __sn = __mp.negative_sign();
+ }
+ else
+ {
+ __pat = __mp.pos_format();
+ __sn = __mp.positive_sign();
+ }
+ __dp = __mp.decimal_point();
+ __ts = __mp.thousands_sep();
+ __grp = __mp.grouping();
+ __sym = __mp.curr_symbol();
+ __fd = __mp.frac_digits();
+ }
+ else
+ {
+ const moneypunct<char_type, false>& __mp =
+ use_facet<moneypunct<char_type, false> >(__loc);
+ if (__neg)
+ {
+ __pat = __mp.neg_format();
+ __sn = __mp.negative_sign();
+ }
+ else
+ {
+ __pat = __mp.pos_format();
+ __sn = __mp.positive_sign();
+ }
+ __dp = __mp.decimal_point();
+ __ts = __mp.thousands_sep();
+ __grp = __mp.grouping();
+ __sym = __mp.curr_symbol();
+ __fd = __mp.frac_digits();
+ }
+}
+
+template <class _CharT>
+void
+__money_put<_CharT>::__format(char_type* __mb, char_type*& __mi, char_type*& __me,
+ ios_base::fmtflags __flags,
+ const char_type* __db, const char_type* __de,
+ const ctype<char_type>& __ct, bool __neg,
+ const money_base::pattern& __pat, char_type __dp,
+ char_type __ts, const string& __grp,
+ const string_type& __sym, const string_type& __sn,
+ int __fd)
+{
+ __me = __mb;
+ for (unsigned __p = 0; __p < 4; ++__p)
+ {
+ switch (__pat.field[__p])
+ {
+ case money_base::none:
+ __mi = __me;
+ break;
+ case money_base::space:
+ __mi = __me;
+ *__me++ = __ct.widen(' ');
+ break;
+ case money_base::sign:
+ if (!__sn.empty())
+ *__me++ = __sn[0];
+ break;
+ case money_base::symbol:
+ if (!__sym.empty() && (__flags & ios_base::showbase))
+ __me = _VSTD::copy(__sym.begin(), __sym.end(), __me);
+ break;
+ case money_base::value:
+ {
+ // remember start of value so we can reverse it
+ char_type* __t = __me;
+ // find beginning of digits
+ if (__neg)
+ ++__db;
+ // find end of digits
+ const char_type* __d;
+ for (__d = __db; __d < __de; ++__d)
+ if (!__ct.is(ctype_base::digit, *__d))
+ break;
+ // print fractional part
+ if (__fd > 0)
+ {
+ int __f;
+ for (__f = __fd; __d > __db && __f > 0; --__f)
+ *__me++ = *--__d;
+ char_type __z = __f > 0 ? __ct.widen('0') : char_type();
+ for (; __f > 0; --__f)
+ *__me++ = __z;
+ *__me++ = __dp;
+ }
+ // print units part
+ if (__d == __db)
+ {
+ *__me++ = __ct.widen('0');
+ }
+ else
+ {
+ unsigned __ng = 0;
+ unsigned __ig = 0;
+ unsigned __gl = __grp.empty() ? numeric_limits<unsigned>::max()
+ : static_cast<unsigned>(__grp[__ig]);
+ while (__d != __db)
+ {
+ if (__ng == __gl)
+ {
+ *__me++ = __ts;
+ __ng = 0;
+ if (++__ig < __grp.size())
+ __gl = __grp[__ig] == numeric_limits<char>::max() ?
+ numeric_limits<unsigned>::max() :
+ static_cast<unsigned>(__grp[__ig]);
+ }
+ *__me++ = *--__d;
+ ++__ng;
+ }
+ }
+ // reverse it
+ reverse(__t, __me);
+ }
+ break;
+ }
+ }
+ // print rest of sign, if any
+ if (__sn.size() > 1)
+ __me = _VSTD::copy(__sn.begin()+1, __sn.end(), __me);
+ // set alignment
+ if ((__flags & ios_base::adjustfield) == ios_base::left)
+ __mi = __me;
+ else if ((__flags & ios_base::adjustfield) != ios_base::internal)
+ __mi = __mb;
+}
+
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<char>)
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<wchar_t>)
+#endif
+
+template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
+class _LIBCPP_TEMPLATE_VIS money_put
+ : public locale::facet,
+ private __money_put<_CharT>
+{
+public:
+ typedef _CharT char_type;
+ typedef _OutputIterator iter_type;
+ typedef basic_string<char_type> string_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit money_put(size_t __refs = 0)
+ : locale::facet(__refs) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ iter_type put(iter_type __s, bool __intl, ios_base& __iob, char_type __fl,
+ long double __units) const
+ {
+ return do_put(__s, __intl, __iob, __fl, __units);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iter_type put(iter_type __s, bool __intl, ios_base& __iob, char_type __fl,
+ const string_type& __digits) const
+ {
+ return do_put(__s, __intl, __iob, __fl, __digits);
+ }
+
+ static locale::id id;
+
+protected:
+ _LIBCPP_INLINE_VISIBILITY
+ ~money_put() {}
+
+ virtual iter_type do_put(iter_type __s, bool __intl, ios_base& __iob,
+ char_type __fl, long double __units) const;
+ virtual iter_type do_put(iter_type __s, bool __intl, ios_base& __iob,
+ char_type __fl, const string_type& __digits) const;
+};
+
+template <class _CharT, class _OutputIterator>
+locale::id
+money_put<_CharT, _OutputIterator>::id;
+
+template <class _CharT, class _OutputIterator>
+_OutputIterator
+money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,
+ ios_base& __iob, char_type __fl,
+ long double __units) const
+{
+ // convert to char
+ const size_t __bs = 100;
+ char __buf[__bs];
+ char* __bb = __buf;
+ char_type __digits[__bs];
+ char_type* __db = __digits;
+ int __n = snprintf(__bb, __bs, "%.0Lf", __units);
+ unique_ptr<char, void(*)(void*)> __hn(nullptr, free);
+ unique_ptr<char_type, void(*)(void*)> __hd(0, free);
+ // secure memory for digit storage
+ if (static_cast<size_t>(__n) > __bs-1)
+ {
+ __n = __libcpp_asprintf_l(&__bb, _LIBCPP_GET_C_LOCALE, "%.0Lf", __units);
+ if (__n == -1)
+ __throw_bad_alloc();
+ __hn.reset(__bb);
+ __hd.reset((char_type*)malloc(static_cast<size_t>(__n) * sizeof(char_type)));
+ if (__hd == nullptr)
+ __throw_bad_alloc();
+ __db = __hd.get();
+ }
+ // gather info
+ locale __loc = __iob.getloc();
+ const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__loc);
+ __ct.widen(__bb, __bb + __n, __db);
+ bool __neg = __n > 0 && __bb[0] == '-';
+ money_base::pattern __pat;
+ char_type __dp;
+ char_type __ts;
+ string __grp;
+ string_type __sym;
+ string_type __sn;
+ int __fd;
+ this->__gather_info(__intl, __neg, __loc, __pat, __dp, __ts, __grp, __sym, __sn, __fd);
+ // secure memory for formatting
+ char_type __mbuf[__bs];
+ char_type* __mb = __mbuf;
+ unique_ptr<char_type, void(*)(void*)> __hw(0, free);
+ size_t __exn = __n > __fd ?
+ (static_cast<size_t>(__n) - static_cast<size_t>(__fd)) * 2 +
+ __sn.size() + __sym.size() + static_cast<size_t>(__fd) + 1
+ : __sn.size() + __sym.size() + static_cast<size_t>(__fd) + 2;
+ if (__exn > __bs)
+ {
+ __hw.reset((char_type*)malloc(__exn * sizeof(char_type)));
+ __mb = __hw.get();
+ if (__mb == 0)
+ __throw_bad_alloc();
+ }
+ // format
+ char_type* __mi;
+ char_type* __me;
+ this->__format(__mb, __mi, __me, __iob.flags(),
+ __db, __db + __n, __ct,
+ __neg, __pat, __dp, __ts, __grp, __sym, __sn, __fd);
+ return __pad_and_output(__s, __mb, __mi, __me, __iob, __fl);
+}
+
+template <class _CharT, class _OutputIterator>
+_OutputIterator
+money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,
+ ios_base& __iob, char_type __fl,
+ const string_type& __digits) const
+{
+ // gather info
+ locale __loc = __iob.getloc();
+ const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__loc);
+ bool __neg = __digits.size() > 0 && __digits[0] == __ct.widen('-');
+ money_base::pattern __pat;
+ char_type __dp;
+ char_type __ts;
+ string __grp;
+ string_type __sym;
+ string_type __sn;
+ int __fd;
+ this->__gather_info(__intl, __neg, __loc, __pat, __dp, __ts, __grp, __sym, __sn, __fd);
+ // secure memory for formatting
+ char_type __mbuf[100];
+ char_type* __mb = __mbuf;
+ unique_ptr<char_type, void(*)(void*)> __h(0, free);
+ size_t __exn = static_cast<int>(__digits.size()) > __fd ?
+ (__digits.size() - static_cast<size_t>(__fd)) * 2 +
+ __sn.size() + __sym.size() + static_cast<size_t>(__fd) + 1
+ : __sn.size() + __sym.size() + static_cast<size_t>(__fd) + 2;
+ if (__exn > 100)
+ {
+ __h.reset((char_type*)malloc(__exn * sizeof(char_type)));
+ __mb = __h.get();
+ if (__mb == 0)
+ __throw_bad_alloc();
+ }
+ // format
+ char_type* __mi;
+ char_type* __me;
+ this->__format(__mb, __mi, __me, __iob.flags(),
+ __digits.data(), __digits.data() + __digits.size(), __ct,
+ __neg, __pat, __dp, __ts, __grp, __sym, __sn, __fd);
+ return __pad_and_output(__s, __mb, __mi, __me, __iob, __fl);
+}
+
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<char>)
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<wchar_t>)
+#endif
+
+// messages
+
+class _LIBCPP_TYPE_VIS messages_base
+{
+public:
+ typedef ptrdiff_t catalog;
+
+ _LIBCPP_INLINE_VISIBILITY messages_base() {}
+};
+
+template <class _CharT>
+class _LIBCPP_TEMPLATE_VIS messages
+ : public locale::facet,
+ public messages_base
+{
+public:
+ typedef _CharT char_type;
+ typedef basic_string<_CharT> string_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit messages(size_t __refs = 0)
+ : locale::facet(__refs) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ catalog open(const basic_string<char>& __nm, const locale& __loc) const
+ {
+ return do_open(__nm, __loc);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ string_type get(catalog __c, int __set, int __msgid,
+ const string_type& __dflt) const
+ {
+ return do_get(__c, __set, __msgid, __dflt);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void close(catalog __c) const
+ {
+ do_close(__c);
+ }
+
+ static locale::id id;
+
+protected:
+ _LIBCPP_INLINE_VISIBILITY
+ ~messages() {}
+
+ virtual catalog do_open(const basic_string<char>&, const locale&) const;
+ virtual string_type do_get(catalog, int __set, int __msgid,
+ const string_type& __dflt) const;
+ virtual void do_close(catalog) const;
+};
+
+template <class _CharT>
+locale::id
+messages<_CharT>::id;
+
+template <class _CharT>
+typename messages<_CharT>::catalog
+messages<_CharT>::do_open(const basic_string<char>& __nm, const locale&) const
+{
+#ifdef _LIBCPP_HAS_CATOPEN
+ catalog __cat = (catalog)catopen(__nm.c_str(), NL_CAT_LOCALE);
+ if (__cat != -1)
+ __cat = static_cast<catalog>((static_cast<size_t>(__cat) >> 1));
+ return __cat;
+#else // !_LIBCPP_HAS_CATOPEN
+ (void)__nm;
+ return -1;
+#endif // _LIBCPP_HAS_CATOPEN
+}
+
+template <class _CharT>
+typename messages<_CharT>::string_type
+messages<_CharT>::do_get(catalog __c, int __set, int __msgid,
+ const string_type& __dflt) const
+{
+#ifdef _LIBCPP_HAS_CATOPEN
+ string __ndflt;
+ __narrow_to_utf8<sizeof(char_type)*__CHAR_BIT__>()(back_inserter(__ndflt),
+ __dflt.c_str(),
+ __dflt.c_str() + __dflt.size());
+ if (__c != -1)
+ __c <<= 1;
+ nl_catd __cat = (nl_catd)__c;
+ char* __n = catgets(__cat, __set, __msgid, __ndflt.c_str());
+ string_type __w;
+ __widen_from_utf8<sizeof(char_type)*__CHAR_BIT__>()(back_inserter(__w),
+ __n, __n + _VSTD::strlen(__n));
+ return __w;
+#else // !_LIBCPP_HAS_CATOPEN
+ (void)__c;
+ (void)__set;
+ (void)__msgid;
+ return __dflt;
+#endif // _LIBCPP_HAS_CATOPEN
+}
+
+template <class _CharT>
+void
+messages<_CharT>::do_close(catalog __c) const
+{
+#ifdef _LIBCPP_HAS_CATOPEN
+ if (__c != -1)
+ __c <<= 1;
+ nl_catd __cat = (nl_catd)__c;
+ catclose(__cat);
+#else // !_LIBCPP_HAS_CATOPEN
+ (void)__c;
+#endif // _LIBCPP_HAS_CATOPEN
+}
+
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<char>)
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<wchar_t>)
+#endif
+
+template <class _CharT>
+class _LIBCPP_TEMPLATE_VIS messages_byname
+ : public messages<_CharT>
+{
+public:
+ typedef messages_base::catalog catalog;
+ typedef basic_string<_CharT> string_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit messages_byname(const char*, size_t __refs = 0)
+ : messages<_CharT>(__refs) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit messages_byname(const string&, size_t __refs = 0)
+ : messages<_CharT>(__refs) {}
+
+protected:
+ _LIBCPP_INLINE_VISIBILITY
+ ~messages_byname() {}
+};
+
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<char>)
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<wchar_t>)
+#endif
+
+template<class _Codecvt, class _Elem = wchar_t,
+ class _Wide_alloc = allocator<_Elem>,
+ class _Byte_alloc = allocator<char> >
+class _LIBCPP_TEMPLATE_VIS wstring_convert
+{
+public:
+ typedef basic_string<char, char_traits<char>, _Byte_alloc> byte_string;
+ typedef basic_string<_Elem, char_traits<_Elem>, _Wide_alloc> wide_string;
+ typedef typename _Codecvt::state_type state_type;
+ typedef typename wide_string::traits_type::int_type int_type;
+
+private:
+ byte_string __byte_err_string_;
+ wide_string __wide_err_string_;
+ _Codecvt* __cvtptr_;
+ state_type __cvtstate_;
+ size_t __cvtcount_;
+
+ wstring_convert(const wstring_convert& __wc);
+ wstring_convert& operator=(const wstring_convert& __wc);
+public:
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ wstring_convert() : wstring_convert(new _Codecvt) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit wstring_convert(_Codecvt* __pcvt);
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_EXPLICIT_AFTER_CXX11
+ wstring_convert(_Codecvt* __pcvt = new _Codecvt);
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ wstring_convert(_Codecvt* __pcvt, state_type __state);
+ _LIBCPP_EXPLICIT_AFTER_CXX11 wstring_convert(const byte_string& __byte_err,
+ const wide_string& __wide_err = wide_string());
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ wstring_convert(wstring_convert&& __wc);
+#endif
+ ~wstring_convert();
+
+ _LIBCPP_INLINE_VISIBILITY
+ wide_string from_bytes(char __byte)
+ {return from_bytes(&__byte, &__byte+1);}
+ _LIBCPP_INLINE_VISIBILITY
+ wide_string from_bytes(const char* __ptr)
+ {return from_bytes(__ptr, __ptr + char_traits<char>::length(__ptr));}
+ _LIBCPP_INLINE_VISIBILITY
+ wide_string from_bytes(const byte_string& __str)
+ {return from_bytes(__str.data(), __str.data() + __str.size());}
+ wide_string from_bytes(const char* __first, const char* __last);
+
+ _LIBCPP_INLINE_VISIBILITY
+ byte_string to_bytes(_Elem __wchar)
+ {return to_bytes(&__wchar, &__wchar+1);}
+ _LIBCPP_INLINE_VISIBILITY
+ byte_string to_bytes(const _Elem* __wptr)
+ {return to_bytes(__wptr, __wptr + char_traits<_Elem>::length(__wptr));}
+ _LIBCPP_INLINE_VISIBILITY
+ byte_string to_bytes(const wide_string& __wstr)
+ {return to_bytes(__wstr.data(), __wstr.data() + __wstr.size());}
+ byte_string to_bytes(const _Elem* __first, const _Elem* __last);
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_t converted() const _NOEXCEPT {return __cvtcount_;}
+ _LIBCPP_INLINE_VISIBILITY
+ state_type state() const {return __cvtstate_;}
+};
+
+template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc>
+inline
+wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
+ wstring_convert(_Codecvt* __pcvt)
+ : __cvtptr_(__pcvt), __cvtstate_(), __cvtcount_(0)
+{
+}
+
+template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc>
+inline
+wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
+ wstring_convert(_Codecvt* __pcvt, state_type __state)
+ : __cvtptr_(__pcvt), __cvtstate_(__state), __cvtcount_(0)
+{
+}
+
+template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc>
+wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
+ wstring_convert(const byte_string& __byte_err, const wide_string& __wide_err)
+ : __byte_err_string_(__byte_err), __wide_err_string_(__wide_err),
+ __cvtstate_(), __cvtcount_(0)
+{
+ __cvtptr_ = new _Codecvt;
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc>
+inline
+wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
+ wstring_convert(wstring_convert&& __wc)
+ : __byte_err_string_(_VSTD::move(__wc.__byte_err_string_)),
+ __wide_err_string_(_VSTD::move(__wc.__wide_err_string_)),
+ __cvtptr_(__wc.__cvtptr_),
+ __cvtstate_(__wc.__cvtstate_), __cvtcount_(__wc.__cvtcount_)
+{
+ __wc.__cvtptr_ = nullptr;
+}
+
+#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()
+{
+ delete __cvtptr_;
+}
+
+template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc>
+typename wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::wide_string
+wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
+ from_bytes(const char* __frm, const char* __frm_end)
+{
+ __cvtcount_ = 0;
+ if (__cvtptr_ != nullptr)
+ {
+ wide_string __ws(2*(__frm_end - __frm), _Elem());
+ if (__frm != __frm_end)
+ __ws.resize(__ws.capacity());
+ codecvt_base::result __r = codecvt_base::ok;
+ state_type __st = __cvtstate_;
+ if (__frm != __frm_end)
+ {
+ _Elem* __to = &__ws[0];
+ _Elem* __to_end = __to + __ws.size();
+ const char* __frm_nxt;
+ do
+ {
+ _Elem* __to_nxt;
+ __r = __cvtptr_->in(__st, __frm, __frm_end, __frm_nxt,
+ __to, __to_end, __to_nxt);
+ __cvtcount_ += __frm_nxt - __frm;
+ if (__frm_nxt == __frm)
+ {
+ __r = codecvt_base::error;
+ }
+ else if (__r == codecvt_base::noconv)
+ {
+ __ws.resize(__to - &__ws[0]);
+ // This only gets executed if _Elem is char
+ __ws.append((const _Elem*)__frm, (const _Elem*)__frm_end);
+ __frm = __frm_nxt;
+ __r = codecvt_base::ok;
+ }
+ else if (__r == codecvt_base::ok)
+ {
+ __ws.resize(__to_nxt - &__ws[0]);
+ __frm = __frm_nxt;
+ }
+ else if (__r == codecvt_base::partial)
+ {
+ ptrdiff_t __s = __to_nxt - &__ws[0];
+ __ws.resize(2 * __s);
+ __to = &__ws[0] + __s;
+ __to_end = &__ws[0] + __ws.size();
+ __frm = __frm_nxt;
+ }
+ } while (__r == codecvt_base::partial && __frm_nxt < __frm_end);
+ }
+ if (__r == codecvt_base::ok)
+ return __ws;
+ }
+
+ if (__wide_err_string_.empty())
+ __throw_range_error("wstring_convert: from_bytes error");
+
+ return __wide_err_string_;
+}
+
+template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc>
+typename wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::byte_string
+wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
+ to_bytes(const _Elem* __frm, const _Elem* __frm_end)
+{
+ __cvtcount_ = 0;
+ if (__cvtptr_ != nullptr)
+ {
+ byte_string __bs(2*(__frm_end - __frm), char());
+ if (__frm != __frm_end)
+ __bs.resize(__bs.capacity());
+ codecvt_base::result __r = codecvt_base::ok;
+ state_type __st = __cvtstate_;
+ if (__frm != __frm_end)
+ {
+ char* __to = &__bs[0];
+ char* __to_end = __to + __bs.size();
+ const _Elem* __frm_nxt;
+ do
+ {
+ char* __to_nxt;
+ __r = __cvtptr_->out(__st, __frm, __frm_end, __frm_nxt,
+ __to, __to_end, __to_nxt);
+ __cvtcount_ += __frm_nxt - __frm;
+ if (__frm_nxt == __frm)
+ {
+ __r = codecvt_base::error;
+ }
+ else if (__r == codecvt_base::noconv)
+ {
+ __bs.resize(__to - &__bs[0]);
+ // This only gets executed if _Elem is char
+ __bs.append((const char*)__frm, (const char*)__frm_end);
+ __frm = __frm_nxt;
+ __r = codecvt_base::ok;
+ }
+ else if (__r == codecvt_base::ok)
+ {
+ __bs.resize(__to_nxt - &__bs[0]);
+ __frm = __frm_nxt;
+ }
+ else if (__r == codecvt_base::partial)
+ {
+ ptrdiff_t __s = __to_nxt - &__bs[0];
+ __bs.resize(2 * __s);
+ __to = &__bs[0] + __s;
+ __to_end = &__bs[0] + __bs.size();
+ __frm = __frm_nxt;
+ }
+ } while (__r == codecvt_base::partial && __frm_nxt < __frm_end);
+ }
+ if (__r == codecvt_base::ok)
+ {
+ size_t __s = __bs.size();
+ __bs.resize(__bs.capacity());
+ char* __to = &__bs[0] + __s;
+ char* __to_end = __to + __bs.size();
+ do
+ {
+ char* __to_nxt;
+ __r = __cvtptr_->unshift(__st, __to, __to_end, __to_nxt);
+ if (__r == codecvt_base::noconv)
+ {
+ __bs.resize(__to - &__bs[0]);
+ __r = codecvt_base::ok;
+ }
+ else if (__r == codecvt_base::ok)
+ {
+ __bs.resize(__to_nxt - &__bs[0]);
+ }
+ else if (__r == codecvt_base::partial)
+ {
+ ptrdiff_t __sp = __to_nxt - &__bs[0];
+ __bs.resize(2 * __sp);
+ __to = &__bs[0] + __sp;
+ __to_end = &__bs[0] + __bs.size();
+ }
+ } while (__r == codecvt_base::partial);
+ if (__r == codecvt_base::ok)
+ return __bs;
+ }
+ }
+
+ if (__byte_err_string_.empty())
+ __throw_range_error("wstring_convert: to_bytes error");
+
+ return __byte_err_string_;
+}
+
+template <class _Codecvt, class _Elem = wchar_t, class _Tr = char_traits<_Elem> >
+class _LIBCPP_TEMPLATE_VIS wbuffer_convert
+ : public basic_streambuf<_Elem, _Tr>
+{
+public:
+ // types:
+ typedef _Elem char_type;
+ typedef _Tr traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+ typedef typename _Codecvt::state_type state_type;
+
+private:
+ char* __extbuf_;
+ const char* __extbufnext_;
+ const char* __extbufend_;
+ char __extbuf_min_[8];
+ size_t __ebs_;
+ char_type* __intbuf_;
+ size_t __ibs_;
+ streambuf* __bufptr_;
+ _Codecvt* __cv_;
+ state_type __st_;
+ ios_base::openmode __cm_;
+ bool __owns_eb_;
+ bool __owns_ib_;
+ bool __always_noconv_;
+
+ wbuffer_convert(const wbuffer_convert&);
+ wbuffer_convert& operator=(const wbuffer_convert&);
+
+public:
+#ifndef _LIBCPP_CXX03_LANG
+ wbuffer_convert() : wbuffer_convert(nullptr) {}
+ explicit wbuffer_convert(streambuf* __bytebuf,
+ _Codecvt* __pcvt = new _Codecvt,
+ state_type __state = state_type());
+#else
+ _LIBCPP_EXPLICIT_AFTER_CXX11
+ wbuffer_convert(streambuf* __bytebuf = nullptr,
+ _Codecvt* __pcvt = new _Codecvt,
+ state_type __state = state_type());
+#endif
+
+ ~wbuffer_convert();
+
+ _LIBCPP_INLINE_VISIBILITY
+ streambuf* rdbuf() const {return __bufptr_;}
+ _LIBCPP_INLINE_VISIBILITY
+ streambuf* rdbuf(streambuf* __bytebuf)
+ {
+ streambuf* __r = __bufptr_;
+ __bufptr_ = __bytebuf;
+ return __r;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ state_type state() const {return __st_;}
+
+protected:
+ virtual int_type underflow();
+ virtual int_type pbackfail(int_type __c = traits_type::eof());
+ virtual int_type overflow (int_type __c = traits_type::eof());
+ virtual basic_streambuf<char_type, traits_type>* setbuf(char_type* __s,
+ streamsize __n);
+ virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,
+ ios_base::openmode __wch = ios_base::in | ios_base::out);
+ virtual pos_type seekpos(pos_type __sp,
+ ios_base::openmode __wch = ios_base::in | ios_base::out);
+ virtual int sync();
+
+private:
+ bool __read_mode();
+ void __write_mode();
+ wbuffer_convert* __close();
+};
+
+template <class _Codecvt, class _Elem, class _Tr>
+wbuffer_convert<_Codecvt, _Elem, _Tr>::
+ wbuffer_convert(streambuf* __bytebuf, _Codecvt* __pcvt, state_type __state)
+ : __extbuf_(nullptr),
+ __extbufnext_(nullptr),
+ __extbufend_(nullptr),
+ __ebs_(0),
+ __intbuf_(0),
+ __ibs_(0),
+ __bufptr_(__bytebuf),
+ __cv_(__pcvt),
+ __st_(__state),
+ __cm_(0),
+ __owns_eb_(false),
+ __owns_ib_(false),
+ __always_noconv_(__cv_ ? __cv_->always_noconv() : false)
+{
+ setbuf(0, 4096);
+}
+
+template <class _Codecvt, class _Elem, class _Tr>
+wbuffer_convert<_Codecvt, _Elem, _Tr>::~wbuffer_convert()
+{
+ __close();
+ delete __cv_;
+ if (__owns_eb_)
+ delete [] __extbuf_;
+ if (__owns_ib_)
+ delete [] __intbuf_;
+}
+
+template <class _Codecvt, class _Elem, class _Tr>
+typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type
+wbuffer_convert<_Codecvt, _Elem, _Tr>::underflow()
+{
+ if (__cv_ == 0 || __bufptr_ == 0)
+ return traits_type::eof();
+ bool __initial = __read_mode();
+ char_type __1buf;
+ if (this->gptr() == 0)
+ this->setg(&__1buf, &__1buf+1, &__1buf+1);
+ const size_t __unget_sz = __initial ? 0 : min<size_t>((this->egptr() - this->eback()) / 2, 4);
+ int_type __c = traits_type::eof();
+ if (this->gptr() == this->egptr())
+ {
+ _VSTD::memmove(this->eback(), this->egptr() - __unget_sz, __unget_sz * sizeof(char_type));
+ if (__always_noconv_)
+ {
+ streamsize __nmemb = static_cast<streamsize>(this->egptr() - this->eback() - __unget_sz);
+ __nmemb = __bufptr_->sgetn((char*)this->eback() + __unget_sz, __nmemb);
+ if (__nmemb != 0)
+ {
+ this->setg(this->eback(),
+ this->eback() + __unget_sz,
+ this->eback() + __unget_sz + __nmemb);
+ __c = *this->gptr();
+ }
+ }
+ else
+ {
+ _LIBCPP_ASSERT(!(__extbufnext_ == NULL && (__extbufend_ != __extbufnext_)), "underflow moving from NULL" );
+ if (__extbufend_ != __extbufnext_)
+ _VSTD::memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
+ __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);
+ __extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_);
+ streamsize __nmemb = _VSTD::min(static_cast<streamsize>(this->egptr() - this->eback() - __unget_sz),
+ static_cast<streamsize>(__extbufend_ - __extbufnext_));
+ codecvt_base::result __r;
+ // FIXME: Do we ever need to restore the state here?
+ //state_type __svs = __st_;
+ streamsize __nr = __bufptr_->sgetn(const_cast<char*>(__extbufnext_), __nmemb);
+ if (__nr != 0)
+ {
+ __extbufend_ = __extbufnext_ + __nr;
+ char_type* __inext;
+ __r = __cv_->in(__st_, __extbuf_, __extbufend_, __extbufnext_,
+ this->eback() + __unget_sz,
+ this->egptr(), __inext);
+ if (__r == codecvt_base::noconv)
+ {
+ this->setg((char_type*)__extbuf_, (char_type*)__extbuf_,
+ (char_type*) const_cast<char *>(__extbufend_));
+ __c = *this->gptr();
+ }
+ else if (__inext != this->eback() + __unget_sz)
+ {
+ this->setg(this->eback(), this->eback() + __unget_sz, __inext);
+ __c = *this->gptr();
+ }
+ }
+ }
+ }
+ else
+ __c = *this->gptr();
+ if (this->eback() == &__1buf)
+ this->setg(0, 0, 0);
+ return __c;
+}
+
+template <class _Codecvt, class _Elem, class _Tr>
+typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type
+wbuffer_convert<_Codecvt, _Elem, _Tr>::pbackfail(int_type __c)
+{
+ if (__cv_ != 0 && __bufptr_ != 0 && this->eback() < this->gptr())
+ {
+ if (traits_type::eq_int_type(__c, traits_type::eof()))
+ {
+ this->gbump(-1);
+ return traits_type::not_eof(__c);
+ }
+ if (traits_type::eq(traits_type::to_char_type(__c), this->gptr()[-1]))
+ {
+ this->gbump(-1);
+ *this->gptr() = traits_type::to_char_type(__c);
+ return __c;
+ }
+ }
+ return traits_type::eof();
+}
+
+template <class _Codecvt, class _Elem, class _Tr>
+typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type
+wbuffer_convert<_Codecvt, _Elem, _Tr>::overflow(int_type __c)
+{
+ if (__cv_ == 0 || __bufptr_ == 0)
+ return traits_type::eof();
+ __write_mode();
+ char_type __1buf;
+ char_type* __pb_save = this->pbase();
+ char_type* __epb_save = this->epptr();
+ if (!traits_type::eq_int_type(__c, traits_type::eof()))
+ {
+ if (this->pptr() == 0)
+ this->setp(&__1buf, &__1buf+1);
+ *this->pptr() = traits_type::to_char_type(__c);
+ this->pbump(1);
+ }
+ if (this->pptr() != this->pbase())
+ {
+ if (__always_noconv_)
+ {
+ streamsize __nmemb = static_cast<streamsize>(this->pptr() - this->pbase());
+ if (__bufptr_->sputn((const char*)this->pbase(), __nmemb) != __nmemb)
+ return traits_type::eof();
+ }
+ else
+ {
+ char* __extbe = __extbuf_;
+ codecvt_base::result __r;
+ do
+ {
+ const char_type* __e;
+ __r = __cv_->out(__st_, this->pbase(), this->pptr(), __e,
+ __extbuf_, __extbuf_ + __ebs_, __extbe);
+ if (__e == this->pbase())
+ return traits_type::eof();
+ if (__r == codecvt_base::noconv)
+ {
+ streamsize __nmemb = static_cast<size_t>(this->pptr() - this->pbase());
+ if (__bufptr_->sputn((const char*)this->pbase(), __nmemb) != __nmemb)
+ return traits_type::eof();
+ }
+ else if (__r == codecvt_base::ok || __r == codecvt_base::partial)
+ {
+ streamsize __nmemb = static_cast<size_t>(__extbe - __extbuf_);
+ if (__bufptr_->sputn(__extbuf_, __nmemb) != __nmemb)
+ return traits_type::eof();
+ if (__r == codecvt_base::partial)
+ {
+ this->setp(const_cast<char_type *>(__e), this->pptr());
+ this->__pbump(this->epptr() - this->pbase());
+ }
+ }
+ else
+ return traits_type::eof();
+ } while (__r == codecvt_base::partial);
+ }
+ this->setp(__pb_save, __epb_save);
+ }
+ return traits_type::not_eof(__c);
+}
+
+template <class _Codecvt, class _Elem, class _Tr>
+basic_streambuf<_Elem, _Tr>*
+wbuffer_convert<_Codecvt, _Elem, _Tr>::setbuf(char_type* __s, streamsize __n)
+{
+ this->setg(0, 0, 0);
+ this->setp(0, 0);
+ if (__owns_eb_)
+ delete [] __extbuf_;
+ if (__owns_ib_)
+ delete [] __intbuf_;
+ __ebs_ = __n;
+ if (__ebs_ > sizeof(__extbuf_min_))
+ {
+ if (__always_noconv_ && __s)
+ {
+ __extbuf_ = (char*)__s;
+ __owns_eb_ = false;
+ }
+ else
+ {
+ __extbuf_ = new char[__ebs_];
+ __owns_eb_ = true;
+ }
+ }
+ else
+ {
+ __extbuf_ = __extbuf_min_;
+ __ebs_ = sizeof(__extbuf_min_);
+ __owns_eb_ = false;
+ }
+ if (!__always_noconv_)
+ {
+ __ibs_ = max<streamsize>(__n, sizeof(__extbuf_min_));
+ if (__s && __ibs_ >= sizeof(__extbuf_min_))
+ {
+ __intbuf_ = __s;
+ __owns_ib_ = false;
+ }
+ else
+ {
+ __intbuf_ = new char_type[__ibs_];
+ __owns_ib_ = true;
+ }
+ }
+ else
+ {
+ __ibs_ = 0;
+ __intbuf_ = 0;
+ __owns_ib_ = false;
+ }
+ return this;
+}
+
+template <class _Codecvt, class _Elem, class _Tr>
+typename wbuffer_convert<_Codecvt, _Elem, _Tr>::pos_type
+wbuffer_convert<_Codecvt, _Elem, _Tr>::seekoff(off_type __off, ios_base::seekdir __way,
+ ios_base::openmode __om)
+{
+ int __width = __cv_->encoding();
+ if (__cv_ == 0 || __bufptr_ == 0 || (__width <= 0 && __off != 0) || sync())
+ return pos_type(off_type(-1));
+ // __width > 0 || __off == 0, now check __way
+ if (__way != ios_base::beg && __way != ios_base::cur && __way != ios_base::end)
+ return pos_type(off_type(-1));
+ pos_type __r = __bufptr_->pubseekoff(__width * __off, __way, __om);
+ __r.state(__st_);
+ return __r;
+}
+
+template <class _Codecvt, class _Elem, class _Tr>
+typename wbuffer_convert<_Codecvt, _Elem, _Tr>::pos_type
+wbuffer_convert<_Codecvt, _Elem, _Tr>::seekpos(pos_type __sp, ios_base::openmode __wch)
+{
+ if (__cv_ == 0 || __bufptr_ == 0 || sync())
+ return pos_type(off_type(-1));
+ if (__bufptr_->pubseekpos(__sp, __wch) == pos_type(off_type(-1)))
+ return pos_type(off_type(-1));
+ return __sp;
+}
+
+template <class _Codecvt, class _Elem, class _Tr>
+int
+wbuffer_convert<_Codecvt, _Elem, _Tr>::sync()
+{
+ if (__cv_ == 0 || __bufptr_ == 0)
+ return 0;
+ if (__cm_ & ios_base::out)
+ {
+ if (this->pptr() != this->pbase())
+ if (overflow() == traits_type::eof())
+ return -1;
+ codecvt_base::result __r;
+ do
+ {
+ char* __extbe;
+ __r = __cv_->unshift(__st_, __extbuf_, __extbuf_ + __ebs_, __extbe);
+ streamsize __nmemb = static_cast<streamsize>(__extbe - __extbuf_);
+ if (__bufptr_->sputn(__extbuf_, __nmemb) != __nmemb)
+ return -1;
+ } while (__r == codecvt_base::partial);
+ if (__r == codecvt_base::error)
+ return -1;
+ if (__bufptr_->pubsync())
+ return -1;
+ }
+ else if (__cm_ & ios_base::in)
+ {
+ off_type __c;
+ if (__always_noconv_)
+ __c = this->egptr() - this->gptr();
+ else
+ {
+ int __width = __cv_->encoding();
+ __c = __extbufend_ - __extbufnext_;
+ if (__width > 0)
+ __c += __width * (this->egptr() - this->gptr());
+ else
+ {
+ if (this->gptr() != this->egptr())
+ {
+ reverse(this->gptr(), this->egptr());
+ codecvt_base::result __r;
+ const char_type* __e = this->gptr();
+ char* __extbe;
+ do
+ {
+ __r = __cv_->out(__st_, __e, this->egptr(), __e,
+ __extbuf_, __extbuf_ + __ebs_, __extbe);
+ switch (__r)
+ {
+ case codecvt_base::noconv:
+ __c += this->egptr() - this->gptr();
+ break;
+ case codecvt_base::ok:
+ case codecvt_base::partial:
+ __c += __extbe - __extbuf_;
+ break;
+ default:
+ return -1;
+ }
+ } while (__r == codecvt_base::partial);
+ }
+ }
+ }
+ if (__bufptr_->pubseekoff(-__c, ios_base::cur, __cm_) == pos_type(off_type(-1)))
+ return -1;
+ this->setg(0, 0, 0);
+ __cm_ = 0;
+ }
+ return 0;
+}
+
+template <class _Codecvt, class _Elem, class _Tr>
+bool
+wbuffer_convert<_Codecvt, _Elem, _Tr>::__read_mode()
+{
+ if (!(__cm_ & ios_base::in))
+ {
+ this->setp(0, 0);
+ if (__always_noconv_)
+ this->setg((char_type*)__extbuf_,
+ (char_type*)__extbuf_ + __ebs_,
+ (char_type*)__extbuf_ + __ebs_);
+ else
+ this->setg(__intbuf_, __intbuf_ + __ibs_, __intbuf_ + __ibs_);
+ __cm_ = ios_base::in;
+ return true;
+ }
+ return false;
+}
+
+template <class _Codecvt, class _Elem, class _Tr>
+void
+wbuffer_convert<_Codecvt, _Elem, _Tr>::__write_mode()
+{
+ if (!(__cm_ & ios_base::out))
+ {
+ this->setg(0, 0, 0);
+ if (__ebs_ > sizeof(__extbuf_min_))
+ {
+ if (__always_noconv_)
+ this->setp((char_type*)__extbuf_,
+ (char_type*)__extbuf_ + (__ebs_ - 1));
+ else
+ this->setp(__intbuf_, __intbuf_ + (__ibs_ - 1));
+ }
+ else
+ this->setp(0, 0);
+ __cm_ = ios_base::out;
+ }
+}
+
+template <class _Codecvt, class _Elem, class _Tr>
+wbuffer_convert<_Codecvt, _Elem, _Tr>*
+wbuffer_convert<_Codecvt, _Elem, _Tr>::__close()
+{
+ wbuffer_convert* __rt = nullptr;
+ if (__cv_ != nullptr && __bufptr_ != nullptr)
+ {
+ __rt = this;
+ if ((__cm_ & ios_base::out) && sync())
+ __rt = nullptr;
+ }
+ return __rt;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_LOCALE
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/locale.h b/contrib/libs/cxxsupp/libcxxmsvc/include/locale.h
new file mode 100644
index 0000000000..83b4bdfead
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/locale.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_LOCALE_H
+#define _LIBCPP_LOCALE_H
+
+/*
+ locale.h synopsis
+
+Macros:
+
+ LC_ALL
+ LC_COLLATE
+ LC_CTYPE
+ LC_MONETARY
+ LC_NUMERIC
+ LC_TIME
+
+Types:
+
+ lconv
+
+Functions:
+
+ setlocale
+ localeconv
+
+*/
+
+#include <__config>
+
+#if defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# error "The Localization library is not supported since libc++ has been configured with LIBCXX_ENABLE_LOCALIZATION disabled"
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#include Y_UCRT_INCLUDE_NEXT(locale.h)
+#else
+#include_next <locale.h>
+#endif
+
+#endif // _LIBCPP_LOCALE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/map b/contrib/libs/cxxsupp/libcxxmsvc/include/map
new file mode 100644
index 0000000000..9a9826f472
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/map
@@ -0,0 +1,2339 @@
+// -*- 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_MAP
+#define _LIBCPP_MAP
+
+/*
+
+ map synopsis
+
+namespace std
+{
+
+template <class Key, class T, class Compare = less<Key>,
+ class Allocator = allocator<pair<const Key, T>>>
+class map
+{
+public:
+ // types:
+ typedef Key key_type;
+ typedef T mapped_type;
+ typedef pair<const key_type, mapped_type> value_type;
+ typedef Compare key_compare;
+ typedef Allocator allocator_type;
+ typedef typename allocator_type::reference reference;
+ typedef typename allocator_type::const_reference const_reference;
+ typedef typename allocator_type::pointer pointer;
+ typedef typename allocator_type::const_pointer const_pointer;
+ typedef typename allocator_type::size_type size_type;
+ typedef typename allocator_type::difference_type difference_type;
+
+ typedef implementation-defined iterator;
+ typedef implementation-defined const_iterator;
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+ typedef unspecified node_type; // C++17
+ typedef INSERT_RETURN_TYPE<iterator, node_type> insert_return_type; // C++17
+
+ class value_compare
+ {
+ friend class map;
+ 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;
+ };
+
+ // construct/copy/destroy:
+ map()
+ noexcept(
+ is_nothrow_default_constructible<allocator_type>::value &&
+ is_nothrow_default_constructible<key_compare>::value &&
+ is_nothrow_copy_constructible<key_compare>::value);
+ explicit map(const key_compare& comp);
+ map(const key_compare& comp, const allocator_type& a);
+ template <class InputIterator>
+ map(InputIterator first, InputIterator last,
+ const key_compare& comp = key_compare());
+ template <class InputIterator>
+ map(InputIterator first, InputIterator last,
+ const key_compare& comp, const allocator_type& a);
+ map(const map& m);
+ map(map&& m)
+ noexcept(
+ is_nothrow_move_constructible<allocator_type>::value &&
+ is_nothrow_move_constructible<key_compare>::value);
+ explicit map(const allocator_type& a);
+ map(const map& m, const allocator_type& a);
+ map(map&& m, const allocator_type& a);
+ map(initializer_list<value_type> il, const key_compare& comp = key_compare());
+ map(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);
+ template <class InputIterator>
+ map(InputIterator first, InputIterator last, const allocator_type& a)
+ : map(first, last, Compare(), a) {} // C++14
+ map(initializer_list<value_type> il, const allocator_type& a)
+ : map(il, Compare(), a) {} // C++14
+ ~map();
+
+ map& operator=(const map& m);
+ map& operator=(map&& m)
+ noexcept(
+ allocator_type::propagate_on_container_move_assignment::value &&
+ is_nothrow_move_assignable<allocator_type>::value &&
+ is_nothrow_move_assignable<key_compare>::value);
+ map& operator=(initializer_list<value_type> il);
+
+ // iterators:
+ iterator begin() noexcept;
+ const_iterator begin() const noexcept;
+ iterator end() noexcept;
+ const_iterator end() const noexcept;
+
+ reverse_iterator rbegin() noexcept;
+ const_reverse_iterator rbegin() const noexcept;
+ reverse_iterator rend() noexcept;
+ const_reverse_iterator rend() const noexcept;
+
+ const_iterator cbegin() const noexcept;
+ const_iterator cend() const noexcept;
+ const_reverse_iterator crbegin() const noexcept;
+ const_reverse_iterator crend() const noexcept;
+
+ // capacity:
+ bool empty() const noexcept;
+ size_type size() const noexcept;
+ size_type max_size() const noexcept;
+
+ // element access:
+ mapped_type& operator[](const key_type& k);
+ mapped_type& operator[](key_type&& k);
+
+ mapped_type& at(const key_type& k);
+ const mapped_type& at(const key_type& k) const;
+
+ // modifiers:
+ template <class... Args>
+ pair<iterator, bool> emplace(Args&&... args);
+ template <class... Args>
+ iterator emplace_hint(const_iterator position, Args&&... args);
+ pair<iterator, bool> insert(const value_type& v);
+ pair<iterator, bool> insert( value_type&& v); // C++17
+ template <class P>
+ pair<iterator, bool> insert(P&& p);
+ iterator insert(const_iterator position, const value_type& v);
+ iterator insert(const_iterator position, value_type&& v); // C++17
+ template <class P>
+ iterator insert(const_iterator position, P&& p);
+ template <class InputIterator>
+ void insert(InputIterator first, InputIterator last);
+ void insert(initializer_list<value_type> il);
+
+ node_type extract(const_iterator position); // C++17
+ node_type extract(const key_type& x); // C++17
+ insert_return_type insert(node_type&& nh); // C++17
+ iterator insert(const_iterator hint, node_type&& nh); // C++17
+
+ template <class... Args>
+ pair<iterator, bool> try_emplace(const key_type& k, Args&&... args); // C++17
+ template <class... Args>
+ pair<iterator, bool> try_emplace(key_type&& k, Args&&... args); // C++17
+ template <class... Args>
+ iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17
+ template <class... Args>
+ iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args); // C++17
+ template <class M>
+ pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj); // C++17
+ template <class M>
+ pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj); // C++17
+ template <class M>
+ iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj); // C++17
+ template <class M>
+ iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); // C++17
+
+ iterator erase(const_iterator position);
+ iterator erase(iterator position); // C++14
+ size_type erase(const key_type& k);
+ iterator erase(const_iterator first, const_iterator last);
+ void clear() noexcept;
+
+ template<class C2>
+ void merge(map<Key, T, C2, Allocator>& source); // C++17
+ template<class C2>
+ void merge(map<Key, T, C2, Allocator>&& source); // C++17
+ template<class C2>
+ void merge(multimap<Key, T, C2, Allocator>& source); // C++17
+ template<class C2>
+ void merge(multimap<Key, T, C2, Allocator>&& source); // C++17
+
+ void swap(map& m)
+ noexcept(allocator_traits<allocator_type>::is_always_equal::value &&
+ is_nothrow_swappable<key_compare>::value); // C++17
+
+ // observers:
+ allocator_type get_allocator() const noexcept;
+ key_compare key_comp() const;
+ value_compare value_comp() const;
+
+ // map operations:
+ iterator find(const key_type& k);
+ const_iterator find(const key_type& k) const;
+ template<typename K>
+ 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
+ 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>
+ iterator lower_bound(const K& x); // C++14
+ template<typename K>
+ const_iterator lower_bound(const K& x) const; // C++14
+
+ iterator upper_bound(const key_type& k);
+ const_iterator upper_bound(const key_type& k) const;
+ template<typename K>
+ iterator upper_bound(const K& x); // C++14
+ template<typename K>
+ const_iterator upper_bound(const K& x) const; // C++14
+
+ pair<iterator,iterator> equal_range(const key_type& k);
+ pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
+ template<typename K>
+ pair<iterator,iterator> equal_range(const K& x); // C++14
+ template<typename K>
+ pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14
+};
+
+template <class InputIterator,
+ class Compare = less<iter_key_t<InputIterator>>,
+ class Allocator = allocator<iter_to_alloc_t<InputIterator>>>
+map(InputIterator, InputIterator, Compare = Compare(), Allocator = Allocator())
+ -> map<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Compare, Allocator>; // C++17
+
+template<class Key, class T, class Compare = less<Key>,
+ class Allocator = allocator<pair<const Key, T>>>
+map(initializer_list<pair<const Key, T>>, Compare = Compare(), Allocator = Allocator())
+ -> map<Key, T, Compare, Allocator>; // C++17
+
+template <class InputIterator, class Allocator>
+map(InputIterator, InputIterator, Allocator)
+ -> map<iter_key_t<InputIterator>, iter_val_t<InputIterator>, less<iter_key_t<InputIterator>>,
+ Allocator>; // C++17
+
+template<class Key, class T, class Allocator>
+map(initializer_list<pair<const Key, T>>, Allocator) -> map<Key, T, less<Key>, Allocator>; // C++17
+
+template <class Key, class T, class Compare, class Allocator>
+bool
+operator==(const map<Key, T, Compare, Allocator>& x,
+ const map<Key, T, Compare, Allocator>& y);
+
+template <class Key, class T, class Compare, class Allocator>
+bool
+operator< (const map<Key, T, Compare, Allocator>& x,
+ const map<Key, T, Compare, Allocator>& y);
+
+template <class Key, class T, class Compare, class Allocator>
+bool
+operator!=(const map<Key, T, Compare, Allocator>& x,
+ const map<Key, T, Compare, Allocator>& y);
+
+template <class Key, class T, class Compare, class Allocator>
+bool
+operator> (const map<Key, T, Compare, Allocator>& x,
+ const map<Key, T, Compare, Allocator>& y);
+
+template <class Key, class T, class Compare, class Allocator>
+bool
+operator>=(const map<Key, T, Compare, Allocator>& x,
+ const map<Key, T, Compare, Allocator>& y);
+
+template <class Key, class T, class Compare, class Allocator>
+bool
+operator<=(const map<Key, T, Compare, Allocator>& x,
+ const map<Key, T, Compare, Allocator>& y);
+
+// specialized algorithms:
+template <class Key, class T, class Compare, class Allocator>
+void
+swap(map<Key, T, Compare, Allocator>& x, map<Key, T, Compare, Allocator>& y)
+ noexcept(noexcept(x.swap(y)));
+
+template <class Key, class T, class Compare, class Allocator, class Predicate>
+typename map<Key, T, Compare, Allocator>::size_type
+erase_if(map<Key, T, Compare, Allocator>& c, Predicate pred); // C++20
+
+
+template <class Key, class T, class Compare = less<Key>,
+ class Allocator = allocator<pair<const Key, T>>>
+class multimap
+{
+public:
+ // types:
+ typedef Key key_type;
+ typedef T mapped_type;
+ typedef pair<const key_type,mapped_type> value_type;
+ typedef Compare key_compare;
+ typedef Allocator allocator_type;
+ typedef typename allocator_type::reference reference;
+ typedef typename allocator_type::const_reference const_reference;
+ typedef typename allocator_type::size_type size_type;
+ typedef typename allocator_type::difference_type difference_type;
+ typedef typename allocator_type::pointer pointer;
+ typedef typename allocator_type::const_pointer const_pointer;
+
+ typedef implementation-defined iterator;
+ typedef implementation-defined const_iterator;
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+ typedef unspecified node_type; // C++17
+
+ class value_compare
+ {
+ 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;
+ };
+
+ // construct/copy/destroy:
+ multimap()
+ noexcept(
+ is_nothrow_default_constructible<allocator_type>::value &&
+ is_nothrow_default_constructible<key_compare>::value &&
+ is_nothrow_copy_constructible<key_compare>::value);
+ explicit multimap(const key_compare& comp);
+ multimap(const key_compare& comp, const allocator_type& a);
+ template <class InputIterator>
+ multimap(InputIterator first, InputIterator last, const key_compare& comp);
+ template <class InputIterator>
+ multimap(InputIterator first, InputIterator last, const key_compare& comp,
+ const allocator_type& a);
+ multimap(const multimap& m);
+ multimap(multimap&& m)
+ noexcept(
+ is_nothrow_move_constructible<allocator_type>::value &&
+ is_nothrow_move_constructible<key_compare>::value);
+ explicit multimap(const allocator_type& a);
+ multimap(const multimap& m, const allocator_type& a);
+ multimap(multimap&& m, const allocator_type& a);
+ multimap(initializer_list<value_type> il, const key_compare& comp = key_compare());
+ multimap(initializer_list<value_type> il, const key_compare& comp,
+ const allocator_type& a);
+ template <class InputIterator>
+ multimap(InputIterator first, InputIterator last, const allocator_type& a)
+ : multimap(first, last, Compare(), a) {} // C++14
+ multimap(initializer_list<value_type> il, const allocator_type& a)
+ : multimap(il, Compare(), a) {} // C++14
+ ~multimap();
+
+ multimap& operator=(const multimap& m);
+ multimap& operator=(multimap&& m)
+ noexcept(
+ allocator_type::propagate_on_container_move_assignment::value &&
+ is_nothrow_move_assignable<allocator_type>::value &&
+ is_nothrow_move_assignable<key_compare>::value);
+ multimap& operator=(initializer_list<value_type> il);
+
+ // iterators:
+ iterator begin() noexcept;
+ const_iterator begin() const noexcept;
+ iterator end() noexcept;
+ const_iterator end() const noexcept;
+
+ reverse_iterator rbegin() noexcept;
+ const_reverse_iterator rbegin() const noexcept;
+ reverse_iterator rend() noexcept;
+ const_reverse_iterator rend() const noexcept;
+
+ const_iterator cbegin() const noexcept;
+ const_iterator cend() const noexcept;
+ const_reverse_iterator crbegin() const noexcept;
+ const_reverse_iterator crend() const noexcept;
+
+ // capacity:
+ bool empty() const noexcept;
+ size_type size() const noexcept;
+ size_type max_size() const noexcept;
+
+ // modifiers:
+ template <class... Args>
+ iterator emplace(Args&&... args);
+ template <class... Args>
+ iterator emplace_hint(const_iterator position, Args&&... args);
+ iterator insert(const value_type& v);
+ iterator insert( value_type&& v); // C++17
+ template <class P>
+ iterator insert(P&& p);
+ iterator insert(const_iterator position, const value_type& v);
+ iterator insert(const_iterator position, value_type&& v); // C++17
+ template <class P>
+ iterator insert(const_iterator position, P&& p);
+ template <class InputIterator>
+ void insert(InputIterator first, InputIterator last);
+ void insert(initializer_list<value_type> il);
+
+ node_type extract(const_iterator position); // C++17
+ node_type extract(const key_type& x); // C++17
+ iterator insert(node_type&& nh); // C++17
+ iterator insert(const_iterator hint, node_type&& nh); // C++17
+
+ iterator erase(const_iterator position);
+ iterator erase(iterator position); // C++14
+ size_type erase(const key_type& k);
+ iterator erase(const_iterator first, const_iterator last);
+ void clear() noexcept;
+
+ template<class C2>
+ void merge(multimap<Key, T, C2, Allocator>& source); // C++17
+ template<class C2>
+ void merge(multimap<Key, T, C2, Allocator>&& source); // C++17
+ template<class C2>
+ void merge(map<Key, T, C2, Allocator>& source); // C++17
+ template<class C2>
+ void merge(map<Key, T, C2, Allocator>&& source); // C++17
+
+ void swap(multimap& m)
+ noexcept(allocator_traits<allocator_type>::is_always_equal::value &&
+ is_nothrow_swappable<key_compare>::value); // C++17
+
+ // observers:
+ allocator_type get_allocator() const noexcept;
+ key_compare key_comp() const;
+ value_compare value_comp() const;
+
+ // map operations:
+ iterator find(const key_type& k);
+ const_iterator find(const key_type& k) const;
+ template<typename K>
+ 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
+ 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>
+ iterator lower_bound(const K& x); // C++14
+ template<typename K>
+ const_iterator lower_bound(const K& x) const; // C++14
+
+ iterator upper_bound(const key_type& k);
+ const_iterator upper_bound(const key_type& k) const;
+ template<typename K>
+ iterator upper_bound(const K& x); // C++14
+ template<typename K>
+ const_iterator upper_bound(const K& x) const; // C++14
+
+ pair<iterator,iterator> equal_range(const key_type& k);
+ pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
+ template<typename K>
+ pair<iterator,iterator> equal_range(const K& x); // C++14
+ template<typename K>
+ pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14
+};
+
+template <class InputIterator,
+ class Compare = less<iter_key_t<InputIterator>>,
+ class Allocator = allocator<iter_to_alloc_t<InputIterator>>>
+multimap(InputIterator, InputIterator, Compare = Compare(), Allocator = Allocator())
+ -> multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Compare, Allocator>; // C++17
+
+template<class Key, class T, class Compare = less<Key>,
+ class Allocator = allocator<pair<const Key, T>>>
+multimap(initializer_list<pair<const Key, T>>, Compare = Compare(), Allocator = Allocator())
+ -> multimap<Key, T, Compare, Allocator>; // C++17
+
+template <class InputIterator, class Allocator>
+multimap(InputIterator, InputIterator, Allocator)
+ -> multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>,
+ less<iter_key_t<InputIterator>>, Allocator>; // C++17
+
+template<class Key, class T, class Allocator>
+multimap(initializer_list<pair<const Key, T>>, Allocator)
+ -> multimap<Key, T, less<Key>, Allocator>; // C++17
+
+template <class Key, class T, class Compare, class Allocator>
+bool
+operator==(const multimap<Key, T, Compare, Allocator>& x,
+ const multimap<Key, T, Compare, Allocator>& y);
+
+template <class Key, class T, class Compare, class Allocator>
+bool
+operator< (const multimap<Key, T, Compare, Allocator>& x,
+ const multimap<Key, T, Compare, Allocator>& y);
+
+template <class Key, class T, class Compare, class Allocator>
+bool
+operator!=(const multimap<Key, T, Compare, Allocator>& x,
+ const multimap<Key, T, Compare, Allocator>& y);
+
+template <class Key, class T, class Compare, class Allocator>
+bool
+operator> (const multimap<Key, T, Compare, Allocator>& x,
+ const multimap<Key, T, Compare, Allocator>& y);
+
+template <class Key, class T, class Compare, class Allocator>
+bool
+operator>=(const multimap<Key, T, Compare, Allocator>& x,
+ const multimap<Key, T, Compare, Allocator>& y);
+
+template <class Key, class T, class Compare, class Allocator>
+bool
+operator<=(const multimap<Key, T, Compare, Allocator>& x,
+ const multimap<Key, T, Compare, Allocator>& y);
+
+// specialized algorithms:
+template <class Key, class T, class Compare, class Allocator>
+void
+swap(multimap<Key, T, Compare, Allocator>& x,
+ multimap<Key, T, Compare, Allocator>& y)
+ noexcept(noexcept(x.swap(y)));
+
+template <class Key, class T, class Compare, class Allocator, class Predicate>
+typename multimap<Key, T, Compare, Allocator>::size_type
+erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20
+
+} // std
+
+*/
+
+#include <__algorithm/equal.h>
+#include <__algorithm/lexicographical_compare.h>
+#include <__assert>
+#include <__config>
+#include <__functional/is_transparent.h>
+#include <__iterator/iterator_traits.h>
+#include <__node_handle>
+#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)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Key, class _CP, class _Compare,
+ bool = is_empty<_Compare>::value && !__libcpp_is_final<_Compare>::value>
+class __map_value_compare
+ : private _Compare
+{
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ __map_value_compare()
+ _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value)
+ : _Compare() {}
+ _LIBCPP_INLINE_VISIBILITY
+ __map_value_compare(_Compare c)
+ _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value)
+ : _Compare(c) {}
+ _LIBCPP_INLINE_VISIBILITY
+ const _Compare& key_comp() const _NOEXCEPT {return *this;}
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _CP& __x, const _CP& __y) const
+ {return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y.__get_value().first);}
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _CP& __x, const _Key& __y) const
+ {return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y);}
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _Key& __x, const _CP& __y) const
+ {return static_cast<const _Compare&>(*this)(__x, __y.__get_value().first);}
+ void swap(__map_value_compare& __y)
+ _NOEXCEPT_(__is_nothrow_swappable<_Compare>::value)
+ {
+ using _VSTD::swap;
+ swap(static_cast<_Compare&>(*this), static_cast<_Compare&>(__y));
+ }
+
+#if _LIBCPP_STD_VER > 11
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _K2& __x, const _CP& __y) const
+ {return static_cast<const _Compare&>(*this)(__x, __y.__get_value().first);}
+
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _CP& __x, const _K2& __y) const
+ {return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y);}
+#endif
+};
+
+template <class _Key, class _CP, class _Compare>
+class __map_value_compare<_Key, _CP, _Compare, false>
+{
+ _Compare comp;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ __map_value_compare()
+ _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value)
+ : comp() {}
+ _LIBCPP_INLINE_VISIBILITY
+ __map_value_compare(_Compare c)
+ _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value)
+ : comp(c) {}
+ _LIBCPP_INLINE_VISIBILITY
+ const _Compare& key_comp() const _NOEXCEPT {return comp;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _CP& __x, const _CP& __y) const
+ {return comp(__x.__get_value().first, __y.__get_value().first);}
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _CP& __x, const _Key& __y) const
+ {return comp(__x.__get_value().first, __y);}
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _Key& __x, const _CP& __y) const
+ {return comp(__x, __y.__get_value().first);}
+ void swap(__map_value_compare& __y)
+ _NOEXCEPT_(__is_nothrow_swappable<_Compare>::value)
+ {
+ using _VSTD::swap;
+ swap(comp, __y.comp);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _K2& __x, const _CP& __y) const
+ {return comp(__x, __y.__get_value().first);}
+
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _CP& __x, const _K2& __y) const
+ {return comp(__x.__get_value().first, __y);}
+#endif
+};
+
+template <class _Key, class _CP, class _Compare, bool __b>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(__map_value_compare<_Key, _CP, _Compare, __b>& __x,
+ __map_value_compare<_Key, _CP, _Compare, __b>& __y)
+ _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+ __x.swap(__y);
+}
+
+template <class _Allocator>
+class __map_node_destructor
+{
+ typedef _Allocator allocator_type;
+ typedef allocator_traits<allocator_type> __alloc_traits;
+
+public:
+ typedef typename __alloc_traits::pointer pointer;
+
+private:
+ allocator_type& __na_;
+
+ __map_node_destructor& operator=(const __map_node_destructor&);
+
+public:
+ bool __first_constructed;
+ bool __second_constructed;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __map_node_destructor(allocator_type& __na) _NOEXCEPT
+ : __na_(__na),
+ __first_constructed(false),
+ __second_constructed(false)
+ {}
+
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ __map_node_destructor(__tree_node_destructor<allocator_type>&& __x) _NOEXCEPT
+ : __na_(__x.__na_),
+ __first_constructed(__x.__value_constructed),
+ __second_constructed(__x.__value_constructed)
+ {
+ __x.__value_constructed = false;
+ }
+#endif // _LIBCPP_CXX03_LANG
+
+ _LIBCPP_INLINE_VISIBILITY
+ void operator()(pointer __p) _NOEXCEPT
+ {
+ if (__second_constructed)
+ __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__get_value().second));
+ if (__first_constructed)
+ __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__get_value().first));
+ if (__p)
+ __alloc_traits::deallocate(__na_, __p, 1);
+ }
+};
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+ class map;
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+ class multimap;
+template <class _TreeIterator> class __map_const_iterator;
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Key, class _Tp>
+struct _LIBCPP_STANDALONE_DEBUG __value_type
+{
+ typedef _Key key_type;
+ typedef _Tp mapped_type;
+ typedef pair<const key_type, mapped_type> value_type;
+ typedef pair<key_type&, mapped_type&> __nc_ref_pair_type;
+ typedef pair<key_type&&, mapped_type&&> __nc_rref_pair_type;
+
+private:
+ value_type __cc;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ value_type& __get_value()
+ {
+#if _LIBCPP_STD_VER > 14
+ return *_VSTD::launder(_VSTD::addressof(__cc));
+#else
+ return __cc;
+#endif
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ const value_type& __get_value() const
+ {
+#if _LIBCPP_STD_VER > 14
+ return *_VSTD::launder(_VSTD::addressof(__cc));
+#else
+ return __cc;
+#endif
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __nc_ref_pair_type __ref()
+ {
+ value_type& __v = __get_value();
+ return __nc_ref_pair_type(const_cast<key_type&>(__v.first), __v.second);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __nc_rref_pair_type __move()
+ {
+ value_type& __v = __get_value();
+ return __nc_rref_pair_type(
+ _VSTD::move(const_cast<key_type&>(__v.first)),
+ _VSTD::move(__v.second));
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __value_type& operator=(const __value_type& __v)
+ {
+ __ref() = __v.__get_value();
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __value_type& operator=(__value_type&& __v)
+ {
+ __ref() = __v.__move();
+ return *this;
+ }
+
+ template <class _ValueTp,
+ class = typename enable_if<
+ __is_same_uncvref<_ValueTp, value_type>::value
+ >::type
+ >
+ _LIBCPP_INLINE_VISIBILITY
+ __value_type& operator=(_ValueTp&& __v)
+ {
+ __ref() = _VSTD::forward<_ValueTp>(__v);
+ return *this;
+ }
+
+private:
+ __value_type() = delete;
+ ~__value_type() = delete;
+ __value_type(const __value_type&) = delete;
+ __value_type(__value_type&&) = delete;
+};
+
+#else
+
+template <class _Key, class _Tp>
+struct __value_type
+{
+ typedef _Key key_type;
+ typedef _Tp mapped_type;
+ typedef pair<const key_type, mapped_type> value_type;
+
+private:
+ value_type __cc;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ value_type& __get_value() { return __cc; }
+ _LIBCPP_INLINE_VISIBILITY
+ const value_type& __get_value() const { return __cc; }
+
+private:
+ __value_type();
+ __value_type(__value_type const&);
+ __value_type& operator=(__value_type const&);
+ ~__value_type();
+};
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _Tp>
+struct __extract_key_value_types;
+
+template <class _Key, class _Tp>
+struct __extract_key_value_types<__value_type<_Key, _Tp> >
+{
+ typedef _Key const __key_type;
+ typedef _Tp __mapped_type;
+};
+
+template <class _TreeIterator>
+class _LIBCPP_TEMPLATE_VIS __map_iterator
+{
+ typedef typename _TreeIterator::_NodeTypes _NodeTypes;
+ typedef typename _TreeIterator::__pointer_traits __pointer_traits;
+
+ _TreeIterator __i_;
+
+public:
+ typedef bidirectional_iterator_tag iterator_category;
+ typedef typename _NodeTypes::__map_value_type value_type;
+ typedef typename _TreeIterator::difference_type difference_type;
+ typedef value_type& reference;
+ typedef typename _NodeTypes::__map_value_type_pointer pointer;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __map_iterator() _NOEXCEPT {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __map_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ reference operator*() const {return __i_->__get_value();}
+ _LIBCPP_INLINE_VISIBILITY
+ pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__get_value());}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __map_iterator& operator++() {++__i_; return *this;}
+ _LIBCPP_INLINE_VISIBILITY
+ __map_iterator operator++(int)
+ {
+ __map_iterator __t(*this);
+ ++(*this);
+ return __t;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __map_iterator& operator--() {--__i_; return *this;}
+ _LIBCPP_INLINE_VISIBILITY
+ __map_iterator operator--(int)
+ {
+ __map_iterator __t(*this);
+ --(*this);
+ return __t;
+ }
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const __map_iterator& __x, const __map_iterator& __y)
+ {return __x.__i_ == __y.__i_;}
+ friend
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const __map_iterator& __x, const __map_iterator& __y)
+ {return __x.__i_ != __y.__i_;}
+
+ template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS map;
+ template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS multimap;
+ template <class> friend class _LIBCPP_TEMPLATE_VIS __map_const_iterator;
+};
+
+template <class _TreeIterator>
+class _LIBCPP_TEMPLATE_VIS __map_const_iterator
+{
+ typedef typename _TreeIterator::_NodeTypes _NodeTypes;
+ typedef typename _TreeIterator::__pointer_traits __pointer_traits;
+
+ _TreeIterator __i_;
+
+public:
+ typedef bidirectional_iterator_tag iterator_category;
+ typedef typename _NodeTypes::__map_value_type value_type;
+ typedef typename _TreeIterator::difference_type difference_type;
+ typedef const value_type& reference;
+ typedef typename _NodeTypes::__const_map_value_type_pointer pointer;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __map_const_iterator() _NOEXCEPT {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __map_const_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {}
+ _LIBCPP_INLINE_VISIBILITY
+ __map_const_iterator(__map_iterator<
+ typename _TreeIterator::__non_const_iterator> __i) _NOEXCEPT
+ : __i_(__i.__i_) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ reference operator*() const {return __i_->__get_value();}
+ _LIBCPP_INLINE_VISIBILITY
+ pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__get_value());}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __map_const_iterator& operator++() {++__i_; return *this;}
+ _LIBCPP_INLINE_VISIBILITY
+ __map_const_iterator operator++(int)
+ {
+ __map_const_iterator __t(*this);
+ ++(*this);
+ return __t;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __map_const_iterator& operator--() {--__i_; return *this;}
+ _LIBCPP_INLINE_VISIBILITY
+ __map_const_iterator operator--(int)
+ {
+ __map_const_iterator __t(*this);
+ --(*this);
+ return __t;
+ }
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const __map_const_iterator& __x, const __map_const_iterator& __y)
+ {return __x.__i_ == __y.__i_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const __map_const_iterator& __x, const __map_const_iterator& __y)
+ {return __x.__i_ != __y.__i_;}
+
+ template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS map;
+ template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS multimap;
+ template <class, class, class> friend class _LIBCPP_TEMPLATE_VIS __tree_const_iterator;
+};
+
+template <class _Key, class _Tp, class _Compare = less<_Key>,
+ class _Allocator = allocator<pair<const _Key, _Tp> > >
+class _LIBCPP_TEMPLATE_VIS map
+{
+public:
+ // types:
+ typedef _Key key_type;
+ typedef _Tp mapped_type;
+ typedef pair<const key_type, mapped_type> value_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);}
+ };
+
+private:
+
+ typedef _VSTD::__value_type<key_type, mapped_type> __value_type;
+ typedef __map_value_compare<key_type, __value_type, key_compare> __vc;
+ typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
+ __value_type>::type __allocator_type;
+ typedef __tree<__value_type, __vc, __allocator_type> __base;
+ typedef typename __base::__node_traits __node_traits;
+ typedef allocator_traits<allocator_type> __alloc_traits;
+
+ __base __tree_;
+
+public:
+ typedef typename __alloc_traits::pointer pointer;
+ typedef typename __alloc_traits::const_pointer const_pointer;
+ typedef typename __alloc_traits::size_type size_type;
+ typedef typename __alloc_traits::difference_type difference_type;
+ typedef __map_iterator<typename __base::iterator> iterator;
+ typedef __map_const_iterator<typename __base::const_iterator> const_iterator;
+ typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
+ typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
+
+#if _LIBCPP_STD_VER > 14
+ typedef __map_node_handle<typename __base::__node, allocator_type> node_type;
+ typedef __insert_return_type<iterator, node_type> insert_return_type;
+#endif
+
+ template <class _Key2, class _Value2, class _Comp2, class _Alloc2>
+ friend class _LIBCPP_TEMPLATE_VIS map;
+ template <class _Key2, class _Value2, class _Comp2, class _Alloc2>
+ friend class _LIBCPP_TEMPLATE_VIS multimap;
+
+ _LIBCPP_INLINE_VISIBILITY
+ map()
+ _NOEXCEPT_(
+ is_nothrow_default_constructible<allocator_type>::value &&
+ is_nothrow_default_constructible<key_compare>::value &&
+ is_nothrow_copy_constructible<key_compare>::value)
+ : __tree_(__vc(key_compare())) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit map(const key_compare& __comp)
+ _NOEXCEPT_(
+ is_nothrow_default_constructible<allocator_type>::value &&
+ is_nothrow_copy_constructible<key_compare>::value)
+ : __tree_(__vc(__comp)) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit map(const key_compare& __comp, const allocator_type& __a)
+ : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {}
+
+ template <class _InputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ map(_InputIterator __f, _InputIterator __l,
+ const key_compare& __comp = key_compare())
+ : __tree_(__vc(__comp))
+ {
+ insert(__f, __l);
+ }
+
+ template <class _InputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ map(_InputIterator __f, _InputIterator __l,
+ const key_compare& __comp, const allocator_type& __a)
+ : __tree_(__vc(__comp), typename __base::allocator_type(__a))
+ {
+ insert(__f, __l);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ template <class _InputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ map(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
+ : map(__f, __l, key_compare(), __a) {}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ map(const map& __m)
+ : __tree_(__m.__tree_)
+ {
+ insert(__m.begin(), __m.end());
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ map& operator=(const map& __m)
+ {
+#ifndef _LIBCPP_CXX03_LANG
+ __tree_ = __m.__tree_;
+#else
+ if (this != _VSTD::addressof(__m)) {
+ __tree_.clear();
+ __tree_.value_comp() = __m.__tree_.value_comp();
+ __tree_.__copy_assign_alloc(__m.__tree_);
+ insert(__m.begin(), __m.end());
+ }
+#endif
+ return *this;
+ }
+
+#ifndef _LIBCPP_CXX03_LANG
+
+ _LIBCPP_INLINE_VISIBILITY
+ map(map&& __m)
+ _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
+ : __tree_(_VSTD::move(__m.__tree_))
+ {
+ }
+
+ map(map&& __m, const allocator_type& __a);
+
+ _LIBCPP_INLINE_VISIBILITY
+ map& operator=(map&& __m)
+ _NOEXCEPT_(is_nothrow_move_assignable<__base>::value)
+ {
+ __tree_ = _VSTD::move(__m.__tree_);
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ map(initializer_list<value_type> __il, const key_compare& __comp = key_compare())
+ : __tree_(__vc(__comp))
+ {
+ insert(__il.begin(), __il.end());
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ map(initializer_list<value_type> __il, const key_compare& __comp, const allocator_type& __a)
+ : __tree_(__vc(__comp), typename __base::allocator_type(__a))
+ {
+ insert(__il.begin(), __il.end());
+ }
+
+#if _LIBCPP_STD_VER > 11
+ _LIBCPP_INLINE_VISIBILITY
+ map(initializer_list<value_type> __il, const allocator_type& __a)
+ : map(__il, key_compare(), __a) {}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ map& operator=(initializer_list<value_type> __il)
+ {
+ __tree_.__assign_unique(__il.begin(), __il.end());
+ return *this;
+ }
+
+#endif // _LIBCPP_CXX03_LANG
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit map(const allocator_type& __a)
+ : __tree_(typename __base::allocator_type(__a))
+ {
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ map(const map& __m, const allocator_type& __a)
+ : __tree_(__m.__tree_.value_comp(), typename __base::allocator_type(__a))
+ {
+ insert(__m.begin(), __m.end());
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ ~map() {
+ static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), "");
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator begin() _NOEXCEPT {return __tree_.begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator end() _NOEXCEPT {return __tree_.end();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator end() const _NOEXCEPT {return __tree_.end();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator rbegin() const _NOEXCEPT
+ {return const_reverse_iterator(end());}
+ _LIBCPP_INLINE_VISIBILITY
+ reverse_iterator rend() _NOEXCEPT
+ {return reverse_iterator(begin());}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator rend() const _NOEXCEPT
+ {return const_reverse_iterator(begin());}
+
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator cbegin() const _NOEXCEPT {return begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator cend() const _NOEXCEPT {return end();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator crend() const _NOEXCEPT {return rend();}
+
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+ bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type size() const _NOEXCEPT {return __tree_.size();}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
+
+ mapped_type& operator[](const key_type& __k);
+#ifndef _LIBCPP_CXX03_LANG
+ mapped_type& operator[](key_type&& __k);
+#endif
+
+ mapped_type& at(const key_type& __k);
+ const mapped_type& at(const key_type& __k) const;
+
+ _LIBCPP_INLINE_VISIBILITY
+ allocator_type get_allocator() const _NOEXCEPT {return allocator_type(__tree_.__alloc());}
+ _LIBCPP_INLINE_VISIBILITY
+ key_compare key_comp() const {return __tree_.value_comp().key_comp();}
+ _LIBCPP_INLINE_VISIBILITY
+ value_compare value_comp() const {return value_compare(__tree_.value_comp().key_comp());}
+
+#ifndef _LIBCPP_CXX03_LANG
+ template <class ..._Args>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool> emplace(_Args&& ...__args) {
+ return __tree_.__emplace_unique(_VSTD::forward<_Args>(__args)...);
+ }
+
+ template <class ..._Args>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator emplace_hint(const_iterator __p, _Args&& ...__args) {
+ return __tree_.__emplace_hint_unique(__p.__i_, _VSTD::forward<_Args>(__args)...);
+ }
+
+ template <class _Pp,
+ class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool> insert(_Pp&& __p)
+ {return __tree_.__insert_unique(_VSTD::forward<_Pp>(__p));}
+
+ template <class _Pp,
+ class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const_iterator __pos, _Pp&& __p)
+ {return __tree_.__insert_unique(__pos.__i_, _VSTD::forward<_Pp>(__p));}
+
+#endif // _LIBCPP_CXX03_LANG
+
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool>
+ insert(const value_type& __v) {return __tree_.__insert_unique(__v);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator
+ insert(const_iterator __p, const value_type& __v)
+ {return __tree_.__insert_unique(__p.__i_, __v);}
+
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool>
+ insert(value_type&& __v) {return __tree_.__insert_unique(_VSTD::move(__v));}
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const_iterator __p, value_type&& __v)
+ {return __tree_.__insert_unique(__p.__i_, _VSTD::move(__v));}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void insert(initializer_list<value_type> __il)
+ {insert(__il.begin(), __il.end());}
+#endif
+
+ template <class _InputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ void insert(_InputIterator __f, _InputIterator __l)
+ {
+ for (const_iterator __e = cend(); __f != __l; ++__f)
+ insert(__e.__i_, *__f);
+ }
+
+#if _LIBCPP_STD_VER > 14
+
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args)
+ {
+ return __tree_.__emplace_unique_key_args(__k,
+ _VSTD::piecewise_construct,
+ _VSTD::forward_as_tuple(__k),
+ _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
+ }
+
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args)
+ {
+ return __tree_.__emplace_unique_key_args(__k,
+ _VSTD::piecewise_construct,
+ _VSTD::forward_as_tuple(_VSTD::move(__k)),
+ _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
+ }
+
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args)
+ {
+ return __tree_.__emplace_hint_unique_key_args(__h.__i_, __k,
+ _VSTD::piecewise_construct,
+ _VSTD::forward_as_tuple(__k),
+ _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)).first;
+ }
+
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args)
+ {
+ return __tree_.__emplace_hint_unique_key_args(__h.__i_, __k,
+ _VSTD::piecewise_construct,
+ _VSTD::forward_as_tuple(_VSTD::move(__k)),
+ _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)).first;
+ }
+
+ template <class _Vp>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool> insert_or_assign(const key_type& __k, _Vp&& __v)
+ {
+ iterator __p = lower_bound(__k);
+ if ( __p != end() && !key_comp()(__k, __p->first))
+ {
+ __p->second = _VSTD::forward<_Vp>(__v);
+ return _VSTD::make_pair(__p, false);
+ }
+ return _VSTD::make_pair(emplace_hint(__p, __k, _VSTD::forward<_Vp>(__v)), true);
+ }
+
+ template <class _Vp>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool> insert_or_assign(key_type&& __k, _Vp&& __v)
+ {
+ iterator __p = lower_bound(__k);
+ if ( __p != end() && !key_comp()(__k, __p->first))
+ {
+ __p->second = _VSTD::forward<_Vp>(__v);
+ return _VSTD::make_pair(__p, false);
+ }
+ return _VSTD::make_pair(emplace_hint(__p, _VSTD::move(__k), _VSTD::forward<_Vp>(__v)), true);
+ }
+
+ template <class _Vp>
+ _LIBCPP_INLINE_VISIBILITY iterator insert_or_assign(const_iterator __h,
+ const key_type& __k,
+ _Vp&& __v) {
+ auto [__r, __inserted] = __tree_.__emplace_hint_unique_key_args(
+ __h.__i_, __k, __k, _VSTD::forward<_Vp>(__v));
+
+ if (!__inserted)
+ __r->__get_value().second = _VSTD::forward<_Vp>(__v);
+
+ return __r;
+ }
+
+ template <class _Vp>
+ _LIBCPP_INLINE_VISIBILITY iterator insert_or_assign(const_iterator __h,
+ key_type&& __k,
+ _Vp&& __v) {
+ auto [__r, __inserted] = __tree_.__emplace_hint_unique_key_args(
+ __h.__i_, __k, _VSTD::move(__k), _VSTD::forward<_Vp>(__v));
+
+ if (!__inserted)
+ __r->__get_value().second = _VSTD::forward<_Vp>(__v);
+
+ return __r;
+ }
+
+#endif // _LIBCPP_STD_VER > 14
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator erase(const_iterator __p) {return __tree_.erase(__p.__i_);}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator erase(iterator __p) {return __tree_.erase(__p.__i_);}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type erase(const key_type& __k)
+ {return __tree_.__erase_unique(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator erase(const_iterator __f, const_iterator __l)
+ {return __tree_.erase(__f.__i_, __l.__i_);}
+ _LIBCPP_REINITIALIZES_OBJECT _LIBCPP_INLINE_VISIBILITY
+ void clear() _NOEXCEPT {__tree_.clear();}
+
+#if _LIBCPP_STD_VER > 14
+ _LIBCPP_INLINE_VISIBILITY
+ insert_return_type insert(node_type&& __nh)
+ {
+ _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
+ "node_type with incompatible allocator passed to map::insert()");
+ return __tree_.template __node_handle_insert_unique<
+ node_type, insert_return_type>(_VSTD::move(__nh));
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const_iterator __hint, node_type&& __nh)
+ {
+ _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
+ "node_type with incompatible allocator passed to map::insert()");
+ return __tree_.template __node_handle_insert_unique<node_type>(
+ __hint.__i_, _VSTD::move(__nh));
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ node_type extract(key_type const& __key)
+ {
+ return __tree_.template __node_handle_extract<node_type>(__key);
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ node_type extract(const_iterator __it)
+ {
+ return __tree_.template __node_handle_extract<node_type>(__it.__i_);
+ }
+ template <class _Compare2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(map<key_type, mapped_type, _Compare2, allocator_type>& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ __tree_.__node_handle_merge_unique(__source.__tree_);
+ }
+ template <class _Compare2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(map<key_type, mapped_type, _Compare2, allocator_type>&& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ __tree_.__node_handle_merge_unique(__source.__tree_);
+ }
+ template <class _Compare2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ __tree_.__node_handle_merge_unique(__source.__tree_);
+ }
+ template <class _Compare2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>&& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ __tree_.__node_handle_merge_unique(__source.__tree_);
+ }
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(map& __m)
+ _NOEXCEPT_(__is_nothrow_swappable<__base>::value)
+ {__tree_.swap(__m.__tree_);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator find(const key_type& __k) {return __tree_.find(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
+#if _LIBCPP_STD_VER > 11
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ 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 enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
+ find(const _K2& __k) const {return __tree_.find(__k);}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type count(const key_type& __k) const
+ {return __tree_.__count_unique(__k);}
+#if _LIBCPP_STD_VER > 11
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
+ count(const _K2& __k) const {return __tree_.__count_multi(__k);}
+#endif
+
+#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
+ iterator lower_bound(const key_type& __k)
+ {return __tree_.lower_bound(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator lower_bound(const key_type& __k) const
+ {return __tree_.lower_bound(__k);}
+#if _LIBCPP_STD_VER > 11
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ 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 enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
+ lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator upper_bound(const key_type& __k)
+ {return __tree_.upper_bound(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator upper_bound(const key_type& __k) const
+ {return __tree_.upper_bound(__k);}
+#if _LIBCPP_STD_VER > 11
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ 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 enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
+ upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator,iterator> equal_range(const key_type& __k)
+ {return __tree_.__equal_range_unique(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
+ {return __tree_.__equal_range_unique(__k);}
+#if _LIBCPP_STD_VER > 11
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ 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 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
+
+private:
+ typedef typename __base::__node __node;
+ typedef typename __base::__node_allocator __node_allocator;
+ typedef typename __base::__node_pointer __node_pointer;
+ typedef typename __base::__node_base_pointer __node_base_pointer;
+ typedef typename __base::__parent_pointer __parent_pointer;
+
+ typedef __map_node_destructor<__node_allocator> _Dp;
+ typedef unique_ptr<__node, _Dp> __node_holder;
+
+#ifdef _LIBCPP_CXX03_LANG
+ __node_holder __construct_node_with_key(const key_type& __k);
+#endif
+};
+
+#if _LIBCPP_STD_VER >= 17
+template<class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>,
+ class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>,
+ class = enable_if_t<!__is_allocator<_Compare>::value, void>,
+ class = enable_if_t<__is_allocator<_Allocator>::value, void>>
+map(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())
+ -> map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare, _Allocator>;
+
+template<class _Key, class _Tp, class _Compare = less<remove_const_t<_Key>>,
+ class _Allocator = allocator<pair<const _Key, _Tp>>,
+ class = enable_if_t<!__is_allocator<_Compare>::value, void>,
+ class = enable_if_t<__is_allocator<_Allocator>::value, void>>
+map(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare(), _Allocator = _Allocator())
+ -> map<remove_const_t<_Key>, _Tp, _Compare, _Allocator>;
+
+template<class _InputIterator, class _Allocator,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>,
+ class = enable_if_t<__is_allocator<_Allocator>::value, void>>
+map(_InputIterator, _InputIterator, _Allocator)
+ -> map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
+ less<__iter_key_type<_InputIterator>>, _Allocator>;
+
+template<class _Key, class _Tp, class _Allocator,
+ class = enable_if_t<__is_allocator<_Allocator>::value, void>>
+map(initializer_list<pair<_Key, _Tp>>, _Allocator)
+ -> map<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>;
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+map<_Key, _Tp, _Compare, _Allocator>::map(map&& __m, const allocator_type& __a)
+ : __tree_(_VSTD::move(__m.__tree_), typename __base::allocator_type(__a))
+{
+ if (__a != __m.get_allocator())
+ {
+ const_iterator __e = cend();
+ while (!__m.empty())
+ __tree_.__insert_unique(__e.__i_,
+ __m.__tree_.remove(__m.begin().__i_)->__value_.__move());
+ }
+}
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+_Tp&
+map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k)
+{
+ return __tree_.__emplace_unique_key_args(__k,
+ _VSTD::piecewise_construct,
+ _VSTD::forward_as_tuple(__k),
+ _VSTD::forward_as_tuple()).first->__get_value().second;
+}
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+_Tp&
+map<_Key, _Tp, _Compare, _Allocator>::operator[](key_type&& __k)
+{
+ return __tree_.__emplace_unique_key_args(__k,
+ _VSTD::piecewise_construct,
+ _VSTD::forward_as_tuple(_VSTD::move(__k)),
+ _VSTD::forward_as_tuple()).first->__get_value().second;
+}
+
+#else // _LIBCPP_CXX03_LANG
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder
+map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(const key_type& __k)
+{
+ __node_allocator& __na = __tree_.__node_alloc();
+ __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
+ __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().first), __k);
+ __h.get_deleter().__first_constructed = true;
+ __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().second));
+ __h.get_deleter().__second_constructed = true;
+ return __h;
+}
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+_Tp&
+map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k)
+{
+ __parent_pointer __parent;
+ __node_base_pointer& __child = __tree_.__find_equal(__parent, __k);
+ __node_pointer __r = static_cast<__node_pointer>(__child);
+ if (__child == nullptr)
+ {
+ __node_holder __h = __construct_node_with_key(__k);
+ __tree_.__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
+ __r = __h.release();
+ }
+ return __r->__value_.__get_value().second;
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+_Tp&
+map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k)
+{
+ __parent_pointer __parent;
+ __node_base_pointer& __child = __tree_.__find_equal(__parent, __k);
+ if (__child == nullptr)
+ __throw_out_of_range("map::at: key not found");
+ return static_cast<__node_pointer>(__child)->__value_.__get_value().second;
+}
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+const _Tp&
+map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const
+{
+ __parent_pointer __parent;
+ __node_base_pointer __child = __tree_.__find_equal(__parent, __k);
+ if (__child == nullptr)
+ __throw_out_of_range("map::at: key not found");
+ return static_cast<__node_pointer>(__child)->__value_.__get_value().second;
+}
+
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const map<_Key, _Tp, _Compare, _Allocator>& __x,
+ const map<_Key, _Tp, _Compare, _Allocator>& __y)
+{
+ return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
+}
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator< (const map<_Key, _Tp, _Compare, _Allocator>& __x,
+ const map<_Key, _Tp, _Compare, _Allocator>& __y)
+{
+ return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
+}
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const map<_Key, _Tp, _Compare, _Allocator>& __x,
+ const map<_Key, _Tp, _Compare, _Allocator>& __y)
+{
+ return !(__x == __y);
+}
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator> (const map<_Key, _Tp, _Compare, _Allocator>& __x,
+ const map<_Key, _Tp, _Compare, _Allocator>& __y)
+{
+ return __y < __x;
+}
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const map<_Key, _Tp, _Compare, _Allocator>& __x,
+ const map<_Key, _Tp, _Compare, _Allocator>& __y)
+{
+ return !(__x < __y);
+}
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __x,
+ const map<_Key, _Tp, _Compare, _Allocator>& __y)
+{
+ return !(__y < __x);
+}
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(map<_Key, _Tp, _Compare, _Allocator>& __x,
+ map<_Key, _Tp, _Compare, _Allocator>& __y)
+ _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+ __x.swap(__y);
+}
+
+#if _LIBCPP_STD_VER > 17
+template <class _Key, class _Tp, class _Compare, class _Allocator,
+ class _Predicate>
+inline _LIBCPP_INLINE_VISIBILITY
+ typename map<_Key, _Tp, _Compare, _Allocator>::size_type
+ erase_if(map<_Key, _Tp, _Compare, _Allocator>& __c, _Predicate __pred) {
+ return _VSTD::__libcpp_erase_if_container(__c, __pred);
+}
+#endif
+
+
+template <class _Key, class _Tp, class _Compare = less<_Key>,
+ class _Allocator = allocator<pair<const _Key, _Tp> > >
+class _LIBCPP_TEMPLATE_VIS multimap
+{
+public:
+ // types:
+ typedef _Key key_type;
+ typedef _Tp mapped_type;
+ typedef pair<const key_type, mapped_type> value_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;
+
+ _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);}
+ };
+
+private:
+
+ typedef _VSTD::__value_type<key_type, mapped_type> __value_type;
+ typedef __map_value_compare<key_type, __value_type, key_compare> __vc;
+ typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
+ __value_type>::type __allocator_type;
+ typedef __tree<__value_type, __vc, __allocator_type> __base;
+ typedef typename __base::__node_traits __node_traits;
+ typedef allocator_traits<allocator_type> __alloc_traits;
+
+ __base __tree_;
+
+public:
+ typedef typename __alloc_traits::pointer pointer;
+ typedef typename __alloc_traits::const_pointer const_pointer;
+ typedef typename __alloc_traits::size_type size_type;
+ typedef typename __alloc_traits::difference_type difference_type;
+ typedef __map_iterator<typename __base::iterator> iterator;
+ typedef __map_const_iterator<typename __base::const_iterator> const_iterator;
+ typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
+ typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
+
+#if _LIBCPP_STD_VER > 14
+ typedef __map_node_handle<typename __base::__node, allocator_type> node_type;
+#endif
+
+ template <class _Key2, class _Value2, class _Comp2, class _Alloc2>
+ friend class _LIBCPP_TEMPLATE_VIS map;
+ template <class _Key2, class _Value2, class _Comp2, class _Alloc2>
+ friend class _LIBCPP_TEMPLATE_VIS multimap;
+
+ _LIBCPP_INLINE_VISIBILITY
+ multimap()
+ _NOEXCEPT_(
+ is_nothrow_default_constructible<allocator_type>::value &&
+ is_nothrow_default_constructible<key_compare>::value &&
+ is_nothrow_copy_constructible<key_compare>::value)
+ : __tree_(__vc(key_compare())) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit multimap(const key_compare& __comp)
+ _NOEXCEPT_(
+ is_nothrow_default_constructible<allocator_type>::value &&
+ is_nothrow_copy_constructible<key_compare>::value)
+ : __tree_(__vc(__comp)) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit multimap(const key_compare& __comp, const allocator_type& __a)
+ : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {}
+
+ template <class _InputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ multimap(_InputIterator __f, _InputIterator __l,
+ const key_compare& __comp = key_compare())
+ : __tree_(__vc(__comp))
+ {
+ insert(__f, __l);
+ }
+
+ template <class _InputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ multimap(_InputIterator __f, _InputIterator __l,
+ const key_compare& __comp, const allocator_type& __a)
+ : __tree_(__vc(__comp), typename __base::allocator_type(__a))
+ {
+ insert(__f, __l);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ template <class _InputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ multimap(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
+ : multimap(__f, __l, key_compare(), __a) {}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ multimap(const multimap& __m)
+ : __tree_(__m.__tree_.value_comp(),
+ __alloc_traits::select_on_container_copy_construction(__m.__tree_.__alloc()))
+ {
+ insert(__m.begin(), __m.end());
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ multimap& operator=(const multimap& __m)
+ {
+#ifndef _LIBCPP_CXX03_LANG
+ __tree_ = __m.__tree_;
+#else
+ if (this != _VSTD::addressof(__m)) {
+ __tree_.clear();
+ __tree_.value_comp() = __m.__tree_.value_comp();
+ __tree_.__copy_assign_alloc(__m.__tree_);
+ insert(__m.begin(), __m.end());
+ }
+#endif
+ return *this;
+ }
+
+#ifndef _LIBCPP_CXX03_LANG
+
+ _LIBCPP_INLINE_VISIBILITY
+ multimap(multimap&& __m)
+ _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
+ : __tree_(_VSTD::move(__m.__tree_))
+ {
+ }
+
+ multimap(multimap&& __m, const allocator_type& __a);
+
+ _LIBCPP_INLINE_VISIBILITY
+ multimap& operator=(multimap&& __m)
+ _NOEXCEPT_(is_nothrow_move_assignable<__base>::value)
+ {
+ __tree_ = _VSTD::move(__m.__tree_);
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ multimap(initializer_list<value_type> __il, const key_compare& __comp = key_compare())
+ : __tree_(__vc(__comp))
+ {
+ insert(__il.begin(), __il.end());
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ multimap(initializer_list<value_type> __il, const key_compare& __comp, const allocator_type& __a)
+ : __tree_(__vc(__comp), typename __base::allocator_type(__a))
+ {
+ insert(__il.begin(), __il.end());
+ }
+
+#if _LIBCPP_STD_VER > 11
+ _LIBCPP_INLINE_VISIBILITY
+ multimap(initializer_list<value_type> __il, const allocator_type& __a)
+ : multimap(__il, key_compare(), __a) {}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ multimap& operator=(initializer_list<value_type> __il)
+ {
+ __tree_.__assign_multi(__il.begin(), __il.end());
+ return *this;
+ }
+
+#endif // _LIBCPP_CXX03_LANG
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit multimap(const allocator_type& __a)
+ : __tree_(typename __base::allocator_type(__a))
+ {
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ multimap(const multimap& __m, const allocator_type& __a)
+ : __tree_(__m.__tree_.value_comp(), typename __base::allocator_type(__a))
+ {
+ insert(__m.begin(), __m.end());
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ ~multimap() {
+ static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), "");
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator begin() _NOEXCEPT {return __tree_.begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator end() _NOEXCEPT {return __tree_.end();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator end() const _NOEXCEPT {return __tree_.end();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator rbegin() const _NOEXCEPT
+ {return const_reverse_iterator(end());}
+ _LIBCPP_INLINE_VISIBILITY
+ reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator rend() const _NOEXCEPT
+ {return const_reverse_iterator(begin());}
+
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator cbegin() const _NOEXCEPT {return begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator cend() const _NOEXCEPT {return end();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator crend() const _NOEXCEPT {return rend();}
+
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+ bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type size() const _NOEXCEPT {return __tree_.size();}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ allocator_type get_allocator() const _NOEXCEPT {return allocator_type(__tree_.__alloc());}
+ _LIBCPP_INLINE_VISIBILITY
+ key_compare key_comp() const {return __tree_.value_comp().key_comp();}
+ _LIBCPP_INLINE_VISIBILITY
+ value_compare value_comp() const
+ {return value_compare(__tree_.value_comp().key_comp());}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+ template <class ..._Args>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator emplace(_Args&& ...__args) {
+ return __tree_.__emplace_multi(_VSTD::forward<_Args>(__args)...);
+ }
+
+ template <class ..._Args>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator emplace_hint(const_iterator __p, _Args&& ...__args) {
+ return __tree_.__emplace_hint_multi(__p.__i_, _VSTD::forward<_Args>(__args)...);
+ }
+
+ template <class _Pp,
+ class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(_Pp&& __p)
+ {return __tree_.__insert_multi(_VSTD::forward<_Pp>(__p));}
+
+ template <class _Pp,
+ class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const_iterator __pos, _Pp&& __p)
+ {return __tree_.__insert_multi(__pos.__i_, _VSTD::forward<_Pp>(__p));}
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(value_type&& __v)
+ {return __tree_.__insert_multi(_VSTD::move(__v));}
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const_iterator __p, value_type&& __v)
+ {return __tree_.__insert_multi(__p.__i_, _VSTD::move(__v));}
+
+
+ _LIBCPP_INLINE_VISIBILITY
+ void insert(initializer_list<value_type> __il)
+ {insert(__il.begin(), __il.end());}
+
+#endif // _LIBCPP_CXX03_LANG
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const value_type& __v) {return __tree_.__insert_multi(__v);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const_iterator __p, const value_type& __v)
+ {return __tree_.__insert_multi(__p.__i_, __v);}
+
+ template <class _InputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ void insert(_InputIterator __f, _InputIterator __l)
+ {
+ for (const_iterator __e = cend(); __f != __l; ++__f)
+ __tree_.__insert_multi(__e.__i_, *__f);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator erase(const_iterator __p) {return __tree_.erase(__p.__i_);}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator erase(iterator __p) {return __tree_.erase(__p.__i_);}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type erase(const key_type& __k) {return __tree_.__erase_multi(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator erase(const_iterator __f, const_iterator __l)
+ {return __tree_.erase(__f.__i_, __l.__i_);}
+
+#if _LIBCPP_STD_VER > 14
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(node_type&& __nh)
+ {
+ _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
+ "node_type with incompatible allocator passed to multimap::insert()");
+ return __tree_.template __node_handle_insert_multi<node_type>(
+ _VSTD::move(__nh));
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const_iterator __hint, node_type&& __nh)
+ {
+ _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
+ "node_type with incompatible allocator passed to multimap::insert()");
+ return __tree_.template __node_handle_insert_multi<node_type>(
+ __hint.__i_, _VSTD::move(__nh));
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ node_type extract(key_type const& __key)
+ {
+ return __tree_.template __node_handle_extract<node_type>(__key);
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ node_type extract(const_iterator __it)
+ {
+ return __tree_.template __node_handle_extract<node_type>(
+ __it.__i_);
+ }
+ template <class _Compare2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ return __tree_.__node_handle_merge_multi(__source.__tree_);
+ }
+ template <class _Compare2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>&& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ return __tree_.__node_handle_merge_multi(__source.__tree_);
+ }
+ template <class _Compare2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(map<key_type, mapped_type, _Compare2, allocator_type>& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ return __tree_.__node_handle_merge_multi(__source.__tree_);
+ }
+ template <class _Compare2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(map<key_type, mapped_type, _Compare2, allocator_type>&& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ return __tree_.__node_handle_merge_multi(__source.__tree_);
+ }
+#endif
+
+ _LIBCPP_REINITIALIZES_OBJECT _LIBCPP_INLINE_VISIBILITY
+ void clear() _NOEXCEPT {__tree_.clear();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(multimap& __m)
+ _NOEXCEPT_(__is_nothrow_swappable<__base>::value)
+ {__tree_.swap(__m.__tree_);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator find(const key_type& __k) {return __tree_.find(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
+#if _LIBCPP_STD_VER > 11
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ 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 enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
+ find(const _K2& __k) const {return __tree_.find(__k);}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type count(const key_type& __k) const
+ {return __tree_.__count_multi(__k);}
+#if _LIBCPP_STD_VER > 11
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
+ count(const _K2& __k) const {return __tree_.__count_multi(__k);}
+#endif
+
+#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
+ iterator lower_bound(const key_type& __k)
+ {return __tree_.lower_bound(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator lower_bound(const key_type& __k) const
+ {return __tree_.lower_bound(__k);}
+#if _LIBCPP_STD_VER > 11
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ 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 enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
+ lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator upper_bound(const key_type& __k)
+ {return __tree_.upper_bound(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator upper_bound(const key_type& __k) const
+ {return __tree_.upper_bound(__k);}
+#if _LIBCPP_STD_VER > 11
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ 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 enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
+ upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator,iterator> equal_range(const key_type& __k)
+ {return __tree_.__equal_range_multi(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
+ {return __tree_.__equal_range_multi(__k);}
+#if _LIBCPP_STD_VER > 11
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ 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 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
+
+private:
+ typedef typename __base::__node __node;
+ typedef typename __base::__node_allocator __node_allocator;
+ typedef typename __base::__node_pointer __node_pointer;
+
+ typedef __map_node_destructor<__node_allocator> _Dp;
+ typedef unique_ptr<__node, _Dp> __node_holder;
+};
+
+#if _LIBCPP_STD_VER >= 17
+template<class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>,
+ class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>,
+ class = enable_if_t<!__is_allocator<_Compare>::value, void>,
+ class = enable_if_t<__is_allocator<_Allocator>::value, void>>
+multimap(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())
+ -> multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare, _Allocator>;
+
+template<class _Key, class _Tp, class _Compare = less<remove_const_t<_Key>>,
+ class _Allocator = allocator<pair<const _Key, _Tp>>,
+ class = enable_if_t<!__is_allocator<_Compare>::value, void>,
+ class = enable_if_t<__is_allocator<_Allocator>::value, void>>
+multimap(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare(), _Allocator = _Allocator())
+ -> multimap<remove_const_t<_Key>, _Tp, _Compare, _Allocator>;
+
+template<class _InputIterator, class _Allocator,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>,
+ class = enable_if_t<__is_allocator<_Allocator>::value, void>>
+multimap(_InputIterator, _InputIterator, _Allocator)
+ -> multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
+ less<__iter_key_type<_InputIterator>>, _Allocator>;
+
+template<class _Key, class _Tp, class _Allocator,
+ class = enable_if_t<__is_allocator<_Allocator>::value, void>>
+multimap(initializer_list<pair<_Key, _Tp>>, _Allocator)
+ -> multimap<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>;
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+multimap<_Key, _Tp, _Compare, _Allocator>::multimap(multimap&& __m, const allocator_type& __a)
+ : __tree_(_VSTD::move(__m.__tree_), typename __base::allocator_type(__a))
+{
+ if (__a != __m.get_allocator())
+ {
+ const_iterator __e = cend();
+ while (!__m.empty())
+ __tree_.__insert_multi(__e.__i_,
+ _VSTD::move(__m.__tree_.remove(__m.begin().__i_)->__value_.__move()));
+ }
+}
+#endif
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
+ const multimap<_Key, _Tp, _Compare, _Allocator>& __y)
+{
+ return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
+}
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator< (const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
+ const multimap<_Key, _Tp, _Compare, _Allocator>& __y)
+{
+ return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
+}
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
+ const multimap<_Key, _Tp, _Compare, _Allocator>& __y)
+{
+ return !(__x == __y);
+}
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator> (const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
+ const multimap<_Key, _Tp, _Compare, _Allocator>& __y)
+{
+ return __y < __x;
+}
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
+ const multimap<_Key, _Tp, _Compare, _Allocator>& __y)
+{
+ return !(__x < __y);
+}
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
+ const multimap<_Key, _Tp, _Compare, _Allocator>& __y)
+{
+ return !(__y < __x);
+}
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(multimap<_Key, _Tp, _Compare, _Allocator>& __x,
+ multimap<_Key, _Tp, _Compare, _Allocator>& __y)
+ _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+ __x.swap(__y);
+}
+
+#if _LIBCPP_STD_VER > 17
+template <class _Key, class _Tp, class _Compare, class _Allocator,
+ class _Predicate>
+inline _LIBCPP_INLINE_VISIBILITY
+ typename multimap<_Key, _Tp, _Compare, _Allocator>::size_type
+ erase_if(multimap<_Key, _Tp, _Compare, _Allocator>& __c,
+ _Predicate __pred) {
+ return _VSTD::__libcpp_erase_if_container(__c, __pred);
+}
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_MAP
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/math.h b/contrib/libs/cxxsupp/libcxxmsvc/include/math.h
new file mode 100644
index 0000000000..a409b610f3
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/math.h
@@ -0,0 +1,1771 @@
+// -*- 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_MATH_H
+#define _LIBCPP_MATH_H
+
+/*
+ math.h synopsis
+
+Macros:
+
+ HUGE_VAL
+ HUGE_VALF // C99
+ HUGE_VALL // C99
+ INFINITY // C99
+ NAN // C99
+ FP_INFINITE // C99
+ FP_NAN // C99
+ FP_NORMAL // C99
+ FP_SUBNORMAL // C99
+ FP_ZERO // C99
+ FP_FAST_FMA // C99
+ FP_FAST_FMAF // C99
+ FP_FAST_FMAL // C99
+ FP_ILOGB0 // C99
+ FP_ILOGBNAN // C99
+ MATH_ERRNO // C99
+ MATH_ERREXCEPT // C99
+ math_errhandling // C99
+
+Types:
+
+ float_t // C99
+ double_t // C99
+
+// C90
+
+floating_point abs(floating_point x);
+
+floating_point acos (arithmetic x);
+float acosf(float x);
+long double acosl(long double x);
+
+floating_point asin (arithmetic x);
+float asinf(float x);
+long double asinl(long double x);
+
+floating_point atan (arithmetic x);
+float atanf(float x);
+long double atanl(long double x);
+
+floating_point atan2 (arithmetic y, arithmetic x);
+float atan2f(float y, float x);
+long double atan2l(long double y, long double x);
+
+floating_point ceil (arithmetic x);
+float ceilf(float x);
+long double ceill(long double x);
+
+floating_point cos (arithmetic x);
+float cosf(float x);
+long double cosl(long double x);
+
+floating_point cosh (arithmetic x);
+float coshf(float x);
+long double coshl(long double x);
+
+floating_point exp (arithmetic x);
+float expf(float x);
+long double expl(long double x);
+
+floating_point fabs (arithmetic x);
+float fabsf(float x);
+long double fabsl(long double x);
+
+floating_point floor (arithmetic x);
+float floorf(float x);
+long double floorl(long double x);
+
+floating_point fmod (arithmetic x, arithmetic y);
+float fmodf(float x, float y);
+long double fmodl(long double x, long double y);
+
+floating_point frexp (arithmetic value, int* exp);
+float frexpf(float value, int* exp);
+long double frexpl(long double value, int* exp);
+
+floating_point ldexp (arithmetic value, int exp);
+float ldexpf(float value, int exp);
+long double ldexpl(long double value, int exp);
+
+floating_point log (arithmetic x);
+float logf(float x);
+long double logl(long double x);
+
+floating_point log10 (arithmetic x);
+float log10f(float x);
+long double log10l(long double x);
+
+floating_point modf (floating_point value, floating_point* iptr);
+float modff(float value, float* iptr);
+long double modfl(long double value, long double* iptr);
+
+floating_point pow (arithmetic x, arithmetic y);
+float powf(float x, float y);
+long double powl(long double x, long double y);
+
+floating_point sin (arithmetic x);
+float sinf(float x);
+long double sinl(long double x);
+
+floating_point sinh (arithmetic x);
+float sinhf(float x);
+long double sinhl(long double x);
+
+floating_point sqrt (arithmetic x);
+float sqrtf(float x);
+long double sqrtl(long double x);
+
+floating_point tan (arithmetic x);
+float tanf(float x);
+long double tanl(long double x);
+
+floating_point tanh (arithmetic x);
+float tanhf(float x);
+long double tanhl(long double x);
+
+// C99
+
+bool signbit(arithmetic x);
+
+int fpclassify(arithmetic x);
+
+bool isfinite(arithmetic x);
+bool isinf(arithmetic x);
+bool isnan(arithmetic x);
+bool isnormal(arithmetic x);
+
+bool isgreater(arithmetic x, arithmetic y);
+bool isgreaterequal(arithmetic x, arithmetic y);
+bool isless(arithmetic x, arithmetic y);
+bool islessequal(arithmetic x, arithmetic y);
+bool islessgreater(arithmetic x, arithmetic y);
+bool isunordered(arithmetic x, arithmetic y);
+
+floating_point acosh (arithmetic x);
+float acoshf(float x);
+long double acoshl(long double x);
+
+floating_point asinh (arithmetic x);
+float asinhf(float x);
+long double asinhl(long double x);
+
+floating_point atanh (arithmetic x);
+float atanhf(float x);
+long double atanhl(long double x);
+
+floating_point cbrt (arithmetic x);
+float cbrtf(float x);
+long double cbrtl(long double x);
+
+floating_point copysign (arithmetic x, arithmetic y);
+float copysignf(float x, float y);
+long double copysignl(long double x, long double y);
+
+floating_point erf (arithmetic x);
+float erff(float x);
+long double erfl(long double x);
+
+floating_point erfc (arithmetic x);
+float erfcf(float x);
+long double erfcl(long double x);
+
+floating_point exp2 (arithmetic x);
+float exp2f(float x);
+long double exp2l(long double x);
+
+floating_point expm1 (arithmetic x);
+float expm1f(float x);
+long double expm1l(long double x);
+
+floating_point fdim (arithmetic x, arithmetic y);
+float fdimf(float x, float y);
+long double fdiml(long double x, long double y);
+
+floating_point fma (arithmetic x, arithmetic y, arithmetic z);
+float fmaf(float x, float y, float z);
+long double fmal(long double x, long double y, long double z);
+
+floating_point fmax (arithmetic x, arithmetic y);
+float fmaxf(float x, float y);
+long double fmaxl(long double x, long double y);
+
+floating_point fmin (arithmetic x, arithmetic y);
+float fminf(float x, float y);
+long double fminl(long double x, long double y);
+
+floating_point hypot (arithmetic x, arithmetic y);
+float hypotf(float x, float y);
+long double hypotl(long double x, long double y);
+
+int ilogb (arithmetic x);
+int ilogbf(float x);
+int ilogbl(long double x);
+
+floating_point lgamma (arithmetic x);
+float lgammaf(float x);
+long double lgammal(long double x);
+
+long long llrint (arithmetic x);
+long long llrintf(float x);
+long long llrintl(long double x);
+
+long long llround (arithmetic x);
+long long llroundf(float x);
+long long llroundl(long double x);
+
+floating_point log1p (arithmetic x);
+float log1pf(float x);
+long double log1pl(long double x);
+
+floating_point log2 (arithmetic x);
+float log2f(float x);
+long double log2l(long double x);
+
+floating_point logb (arithmetic x);
+float logbf(float x);
+long double logbl(long double x);
+
+long lrint (arithmetic x);
+long lrintf(float x);
+long lrintl(long double x);
+
+long lround (arithmetic x);
+long lroundf(float x);
+long lroundl(long double x);
+
+double nan (const char* str);
+float nanf(const char* str);
+long double nanl(const char* str);
+
+floating_point nearbyint (arithmetic x);
+float nearbyintf(float x);
+long double nearbyintl(long double x);
+
+floating_point nextafter (arithmetic x, arithmetic y);
+float nextafterf(float x, float y);
+long double nextafterl(long double x, long double y);
+
+floating_point nexttoward (arithmetic x, long double y);
+float nexttowardf(float x, long double y);
+long double nexttowardl(long double x, long double y);
+
+floating_point remainder (arithmetic x, arithmetic y);
+float remainderf(float x, float y);
+long double remainderl(long double x, long double y);
+
+floating_point remquo (arithmetic x, arithmetic y, int* pquo);
+float remquof(float x, float y, int* pquo);
+long double remquol(long double x, long double y, int* pquo);
+
+floating_point rint (arithmetic x);
+float rintf(float x);
+long double rintl(long double x);
+
+floating_point round (arithmetic x);
+float roundf(float x);
+long double roundl(long double x);
+
+floating_point scalbln (arithmetic x, long ex);
+float scalblnf(float x, long ex);
+long double scalblnl(long double x, long ex);
+
+floating_point scalbn (arithmetic x, int ex);
+float scalbnf(float x, int ex);
+long double scalbnl(long double x, int ex);
+
+floating_point tgamma (arithmetic x);
+float tgammaf(float x);
+long double tgammal(long double x);
+
+floating_point trunc (arithmetic x);
+float truncf(float x);
+long double truncl(long double x);
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#include Y_UCRT_INCLUDE_NEXT(math.h)
+#else
+#include_next <math.h>
+#endif
+
+#ifdef __cplusplus
+
+// We support including .h headers inside 'extern "C"' contexts, so switch
+// back to C++ linkage before including these C++ headers.
+extern "C++" {
+
+#include <limits>
+#include <stdlib.h>
+#include <type_traits>
+
+// signbit
+
+#ifdef signbit
+
+template <class _A1>
+_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
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
+signbit(_A1 __lcpp_x) _NOEXCEPT
+{
+ return __libcpp_signbit((typename std::__promote<_A1>::type)__lcpp_x);
+}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<
+ std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type
+signbit(_A1 __lcpp_x) _NOEXCEPT
+{ return __lcpp_x < 0; }
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<
+ std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type
+signbit(_A1) _NOEXCEPT
+{ return false; }
+
+#elif defined(_LIBCPP_MSVCRT)
+
+template <typename _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
+signbit(_A1 __lcpp_x) _NOEXCEPT
+{
+ return ::signbit(static_cast<typename std::__promote<_A1>::type>(__lcpp_x));
+}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<
+ std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type
+signbit(_A1 __lcpp_x) _NOEXCEPT
+{ return __lcpp_x < 0; }
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<
+ std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type
+signbit(_A1) _NOEXCEPT
+{ return false; }
+
+#endif // signbit
+
+// fpclassify
+
+#ifdef fpclassify
+
+template <class _A1>
+_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
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_floating_point<_A1>::value, int>::type
+fpclassify(_A1 __lcpp_x) _NOEXCEPT
+{
+ return __libcpp_fpclassify((typename std::__promote<_A1>::type)__lcpp_x);
+}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, int>::type
+fpclassify(_A1 __lcpp_x) _NOEXCEPT
+{ return __lcpp_x == 0 ? FP_ZERO : FP_NORMAL; }
+
+#elif defined(_LIBCPP_MSVCRT)
+
+template <typename _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
+fpclassify(_A1 __lcpp_x) _NOEXCEPT
+{
+ return ::fpclassify(static_cast<typename std::__promote<_A1>::type>(__lcpp_x));
+}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+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
+
+// isfinite
+
+#ifdef isfinite
+
+template <class _A1>
+_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
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<
+ std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity,
+ bool>::type
+isfinite(_A1 __lcpp_x) _NOEXCEPT
+{
+ return __libcpp_isfinite((typename std::__promote<_A1>::type)__lcpp_x);
+}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<
+ std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity,
+ bool>::type
+isfinite(_A1) _NOEXCEPT
+{ return true; }
+
+#endif // isfinite
+
+// isinf
+
+#ifdef isinf
+
+template <class _A1>
+_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
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<
+ std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity,
+ bool>::type
+isinf(_A1 __lcpp_x) _NOEXCEPT
+{
+ return __libcpp_isinf((typename std::__promote<_A1>::type)__lcpp_x);
+}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<
+ std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity,
+ bool>::type
+isinf(_A1) _NOEXCEPT
+{ return false; }
+
+#if defined(_LIBCPP_PREFERRED_OVERLOAD) && !defined(__CUDACC__)
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+isinf(float __lcpp_x) _NOEXCEPT { return __libcpp_isinf(__lcpp_x); }
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+bool
+isinf(double __lcpp_x) _NOEXCEPT { return __libcpp_isinf(__lcpp_x); }
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+isinf(long double __lcpp_x) _NOEXCEPT { return __libcpp_isinf(__lcpp_x); }
+#endif
+
+#endif // isinf
+
+// isnan
+
+#ifdef isnan
+
+template <class _A1>
+_LIBCPP_INLINE_VISIBILITY
+bool
+__libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
+{
+#if __has_builtin(__builtin_isnan)
+ return __builtin_isnan(__lcpp_x);
+#else
+ return isnan(__lcpp_x);
+#endif
+}
+
+#undef isnan
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
+isnan(_A1 __lcpp_x) _NOEXCEPT
+{
+ return __libcpp_isnan((typename std::__promote<_A1>::type)__lcpp_x);
+}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, bool>::type
+isnan(_A1) _NOEXCEPT
+{ return false; }
+
+#if defined(_LIBCPP_PREFERRED_OVERLOAD) && !defined(__CUDACC__)
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+isnan(float __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); }
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+bool
+isnan(double __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); }
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+isnan(long double __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); }
+#endif
+
+#endif // isnan
+
+// isnormal
+
+#ifdef isnormal
+
+template <class _A1>
+_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
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
+isnormal(_A1 __lcpp_x) _NOEXCEPT
+{
+ return __libcpp_isnormal((typename std::__promote<_A1>::type)__lcpp_x);
+}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, bool>::type
+isnormal(_A1 __lcpp_x) _NOEXCEPT
+{ return __lcpp_x != 0; }
+
+#endif // isnormal
+
+// isgreater
+
+#ifdef isgreater
+
+template <class _A1, class _A2>
+_LIBCPP_INLINE_VISIBILITY
+bool
+__libcpp_isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+ return isgreater(__lcpp_x, __lcpp_y);
+}
+
+#undef isgreater
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if
+<
+ std::is_arithmetic<_A1>::value &&
+ std::is_arithmetic<_A2>::value,
+ bool
+>::type
+isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+ typedef typename std::__promote<_A1, _A2>::type type;
+ return __libcpp_isgreater((type)__lcpp_x, (type)__lcpp_y);
+}
+
+#endif // isgreater
+
+// isgreaterequal
+
+#ifdef isgreaterequal
+
+template <class _A1, class _A2>
+_LIBCPP_INLINE_VISIBILITY
+bool
+__libcpp_isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+ return isgreaterequal(__lcpp_x, __lcpp_y);
+}
+
+#undef isgreaterequal
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if
+<
+ std::is_arithmetic<_A1>::value &&
+ std::is_arithmetic<_A2>::value,
+ bool
+>::type
+isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+ typedef typename std::__promote<_A1, _A2>::type type;
+ return __libcpp_isgreaterequal((type)__lcpp_x, (type)__lcpp_y);
+}
+
+#endif // isgreaterequal
+
+// isless
+
+#ifdef isless
+
+template <class _A1, class _A2>
+_LIBCPP_INLINE_VISIBILITY
+bool
+__libcpp_isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+ return isless(__lcpp_x, __lcpp_y);
+}
+
+#undef isless
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if
+<
+ std::is_arithmetic<_A1>::value &&
+ std::is_arithmetic<_A2>::value,
+ bool
+>::type
+isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+ typedef typename std::__promote<_A1, _A2>::type type;
+ return __libcpp_isless((type)__lcpp_x, (type)__lcpp_y);
+}
+
+#endif // isless
+
+// islessequal
+
+#ifdef islessequal
+
+template <class _A1, class _A2>
+_LIBCPP_INLINE_VISIBILITY
+bool
+__libcpp_islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+ return islessequal(__lcpp_x, __lcpp_y);
+}
+
+#undef islessequal
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if
+<
+ std::is_arithmetic<_A1>::value &&
+ std::is_arithmetic<_A2>::value,
+ bool
+>::type
+islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+ typedef typename std::__promote<_A1, _A2>::type type;
+ return __libcpp_islessequal((type)__lcpp_x, (type)__lcpp_y);
+}
+
+#endif // islessequal
+
+// islessgreater
+
+#ifdef islessgreater
+
+template <class _A1, class _A2>
+_LIBCPP_INLINE_VISIBILITY
+bool
+__libcpp_islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+ return islessgreater(__lcpp_x, __lcpp_y);
+}
+
+#undef islessgreater
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if
+<
+ std::is_arithmetic<_A1>::value &&
+ std::is_arithmetic<_A2>::value,
+ bool
+>::type
+islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+ typedef typename std::__promote<_A1, _A2>::type type;
+ return __libcpp_islessgreater((type)__lcpp_x, (type)__lcpp_y);
+}
+
+#endif // islessgreater
+
+// isunordered
+
+#ifdef isunordered
+
+template <class _A1, class _A2>
+_LIBCPP_INLINE_VISIBILITY
+bool
+__libcpp_isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+ return isunordered(__lcpp_x, __lcpp_y);
+}
+
+#undef isunordered
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if
+<
+ std::is_arithmetic<_A1>::value &&
+ std::is_arithmetic<_A2>::value,
+ bool
+>::type
+isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+ typedef typename std::__promote<_A1, _A2>::type type;
+ return __libcpp_isunordered((type)__lcpp_x, (type)__lcpp_y);
+}
+
+#endif // isunordered
+
+// abs
+//
+// handled in stdlib.h
+
+// div
+//
+// handled in stdlib.h
+
+// acos
+
+#if !(defined(_AIX) || defined(__sun__))
+inline _LIBCPP_INLINE_VISIBILITY float acos(float __lcpp_x) _NOEXCEPT {return ::acosf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return ::acosl(__lcpp_x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+acos(_A1 __lcpp_x) _NOEXCEPT {return ::acos((double)__lcpp_x);}
+
+// asin
+
+#if !(defined(_AIX) || defined(__sun__))
+inline _LIBCPP_INLINE_VISIBILITY float asin(float __lcpp_x) _NOEXCEPT {return ::asinf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) _NOEXCEPT {return ::asinl(__lcpp_x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+asin(_A1 __lcpp_x) _NOEXCEPT {return ::asin((double)__lcpp_x);}
+
+// atan
+
+#if !(defined(_AIX) || defined(__sun__))
+inline _LIBCPP_INLINE_VISIBILITY float atan(float __lcpp_x) _NOEXCEPT {return ::atanf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __lcpp_x) _NOEXCEPT {return ::atanl(__lcpp_x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+atan(_A1 __lcpp_x) _NOEXCEPT {return ::atan((double)__lcpp_x);}
+
+// atan2
+
+#if !(defined(_AIX) || defined(__sun__))
+inline _LIBCPP_INLINE_VISIBILITY float atan2(float __lcpp_y, float __lcpp_x) _NOEXCEPT {return ::atan2f(__lcpp_y, __lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long double __lcpp_x) _NOEXCEPT {return ::atan2l(__lcpp_y, __lcpp_x);}
+#endif
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::__enable_if_t
+<
+ std::is_arithmetic<_A1>::value &&
+ std::is_arithmetic<_A2>::value,
+ std::__promote<_A1, _A2>
+>::type
+atan2(_A1 __lcpp_y, _A2 __lcpp_x) _NOEXCEPT
+{
+ typedef typename std::__promote<_A1, _A2>::type __result_type;
+ static_assert((!(std::_IsSame<_A1, __result_type>::value &&
+ std::_IsSame<_A2, __result_type>::value)), "");
+ return ::atan2((__result_type)__lcpp_y, (__result_type)__lcpp_x);
+}
+
+// ceil
+
+#if !(defined(_AIX) || defined(__sun__))
+inline _LIBCPP_INLINE_VISIBILITY float ceil(float __lcpp_x) _NOEXCEPT {return ::ceilf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __lcpp_x) _NOEXCEPT {return ::ceill(__lcpp_x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+ceil(_A1 __lcpp_x) _NOEXCEPT {return ::ceil((double)__lcpp_x);}
+
+// cos
+
+#if !(defined(_AIX) || defined(__sun__))
+inline _LIBCPP_INLINE_VISIBILITY float cos(float __lcpp_x) _NOEXCEPT {return ::cosf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __lcpp_x) _NOEXCEPT {return ::cosl(__lcpp_x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+cos(_A1 __lcpp_x) _NOEXCEPT {return ::cos((double)__lcpp_x);}
+
+// cosh
+
+#if !(defined(_AIX) || defined(__sun__))
+inline _LIBCPP_INLINE_VISIBILITY float cosh(float __lcpp_x) _NOEXCEPT {return ::coshf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __lcpp_x) _NOEXCEPT {return ::coshl(__lcpp_x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+cosh(_A1 __lcpp_x) _NOEXCEPT {return ::cosh((double)__lcpp_x);}
+
+// exp
+
+#if !(defined(_AIX) || defined(__sun__))
+inline _LIBCPP_INLINE_VISIBILITY float exp(float __lcpp_x) _NOEXCEPT {return ::expf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __lcpp_x) _NOEXCEPT {return ::expl(__lcpp_x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+exp(_A1 __lcpp_x) _NOEXCEPT {return ::exp((double)__lcpp_x);}
+
+// fabs
+
+#if !(defined(_AIX) || defined(__sun__))
+inline _LIBCPP_INLINE_VISIBILITY float fabs(float __lcpp_x) _NOEXCEPT {return ::fabsf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __lcpp_x) _NOEXCEPT {return ::fabsl(__lcpp_x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+fabs(_A1 __lcpp_x) _NOEXCEPT {return ::fabs((double)__lcpp_x);}
+
+// floor
+
+#if !(defined(_AIX) || defined(__sun__))
+inline _LIBCPP_INLINE_VISIBILITY float floor(float __lcpp_x) _NOEXCEPT {return ::floorf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __lcpp_x) _NOEXCEPT {return ::floorl(__lcpp_x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+floor(_A1 __lcpp_x) _NOEXCEPT {return ::floor((double)__lcpp_x);}
+
+// fmod
+
+#if !(defined(_AIX) || defined(__sun__))
+inline _LIBCPP_INLINE_VISIBILITY float fmod(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fmodf(__lcpp_x, __lcpp_y);}
+inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fmodl(__lcpp_x, __lcpp_y);}
+#endif
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::__enable_if_t
+<
+ std::is_arithmetic<_A1>::value &&
+ std::is_arithmetic<_A2>::value,
+ std::__promote<_A1, _A2>
+>::type
+fmod(_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)), "");
+ return ::fmod((__result_type)__lcpp_x, (__result_type)__lcpp_y);
+}
+
+// frexp
+
+#if !(defined(_AIX) || defined(__sun__))
+inline _LIBCPP_INLINE_VISIBILITY float frexp(float __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexpf(__lcpp_x, __lcpp_e);}
+inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexpl(__lcpp_x, __lcpp_e);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+frexp(_A1 __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexp((double)__lcpp_x, __lcpp_e);}
+
+// ldexp
+
+#if !(defined(_AIX) || defined(__sun__))
+inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexpf(__lcpp_x, __lcpp_e);}
+inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexpl(__lcpp_x, __lcpp_e);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+ldexp(_A1 __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexp((double)__lcpp_x, __lcpp_e);}
+
+// log
+
+#if !(defined(_AIX) || defined(__sun__))
+inline _LIBCPP_INLINE_VISIBILITY float log(float __lcpp_x) _NOEXCEPT {return ::logf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double log(long double __lcpp_x) _NOEXCEPT {return ::logl(__lcpp_x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+log(_A1 __lcpp_x) _NOEXCEPT {return ::log((double)__lcpp_x);}
+
+// log10
+
+#if !(defined(_AIX) || defined(__sun__))
+inline _LIBCPP_INLINE_VISIBILITY float log10(float __lcpp_x) _NOEXCEPT {return ::log10f(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __lcpp_x) _NOEXCEPT {return ::log10l(__lcpp_x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+log10(_A1 __lcpp_x) _NOEXCEPT {return ::log10((double)__lcpp_x);}
+
+// modf
+
+#if !(defined(_AIX) || defined(__sun__))
+inline _LIBCPP_INLINE_VISIBILITY float modf(float __lcpp_x, float* __lcpp_y) _NOEXCEPT {return ::modff(__lcpp_x, __lcpp_y);}
+inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __lcpp_x, long double* __lcpp_y) _NOEXCEPT {return ::modfl(__lcpp_x, __lcpp_y);}
+#endif
+
+// pow
+
+#if !(defined(_AIX) || defined(__sun__))
+inline _LIBCPP_INLINE_VISIBILITY float pow(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::powf(__lcpp_x, __lcpp_y);}
+inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::powl(__lcpp_x, __lcpp_y);}
+#endif
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::__enable_if_t
+<
+ std::is_arithmetic<_A1>::value &&
+ std::is_arithmetic<_A2>::value,
+ std::__promote<_A1, _A2>
+>::type
+pow(_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)), "");
+ return ::pow((__result_type)__lcpp_x, (__result_type)__lcpp_y);
+}
+
+// sin
+
+#if !(defined(_AIX) || defined(__sun__))
+inline _LIBCPP_INLINE_VISIBILITY float sin(float __lcpp_x) _NOEXCEPT {return ::sinf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __lcpp_x) _NOEXCEPT {return ::sinl(__lcpp_x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+sin(_A1 __lcpp_x) _NOEXCEPT {return ::sin((double)__lcpp_x);}
+
+// sinh
+
+#if !(defined(_AIX) || defined(__sun__))
+inline _LIBCPP_INLINE_VISIBILITY float sinh(float __lcpp_x) _NOEXCEPT {return ::sinhf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __lcpp_x) _NOEXCEPT {return ::sinhl(__lcpp_x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+sinh(_A1 __lcpp_x) _NOEXCEPT {return ::sinh((double)__lcpp_x);}
+
+// sqrt
+
+#if !(defined(_AIX) || defined(__sun__))
+inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __lcpp_x) _NOEXCEPT {return ::sqrtf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __lcpp_x) _NOEXCEPT {return ::sqrtl(__lcpp_x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+sqrt(_A1 __lcpp_x) _NOEXCEPT {return ::sqrt((double)__lcpp_x);}
+
+// tan
+
+#if !(defined(_AIX) || defined(__sun__))
+inline _LIBCPP_INLINE_VISIBILITY float tan(float __lcpp_x) _NOEXCEPT {return ::tanf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __lcpp_x) _NOEXCEPT {return ::tanl(__lcpp_x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+tan(_A1 __lcpp_x) _NOEXCEPT {return ::tan((double)__lcpp_x);}
+
+// tanh
+
+#if !(defined(_AIX) || defined(__sun__))
+inline _LIBCPP_INLINE_VISIBILITY float tanh(float __lcpp_x) _NOEXCEPT {return ::tanhf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __lcpp_x) _NOEXCEPT {return ::tanhl(__lcpp_x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+tanh(_A1 __lcpp_x) _NOEXCEPT {return ::tanh((double)__lcpp_x);}
+
+// acosh
+
+inline _LIBCPP_INLINE_VISIBILITY float acosh(float __lcpp_x) _NOEXCEPT {return ::acoshf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double acosh(long double __lcpp_x) _NOEXCEPT {return ::acoshl(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+acosh(_A1 __lcpp_x) _NOEXCEPT {return ::acosh((double)__lcpp_x);}
+
+// asinh
+
+inline _LIBCPP_INLINE_VISIBILITY float asinh(float __lcpp_x) _NOEXCEPT {return ::asinhf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double asinh(long double __lcpp_x) _NOEXCEPT {return ::asinhl(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+asinh(_A1 __lcpp_x) _NOEXCEPT {return ::asinh((double)__lcpp_x);}
+
+// atanh
+
+inline _LIBCPP_INLINE_VISIBILITY float atanh(float __lcpp_x) _NOEXCEPT {return ::atanhf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double atanh(long double __lcpp_x) _NOEXCEPT {return ::atanhl(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+atanh(_A1 __lcpp_x) _NOEXCEPT {return ::atanh((double)__lcpp_x);}
+
+// cbrt
+
+inline _LIBCPP_INLINE_VISIBILITY float cbrt(float __lcpp_x) _NOEXCEPT {return ::cbrtf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double cbrt(long double __lcpp_x) _NOEXCEPT {return ::cbrtl(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+cbrt(_A1 __lcpp_x) _NOEXCEPT {return ::cbrt((double)__lcpp_x);}
+
+// copysign
+
+#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
+}
+
+#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::__enable_if_t
+<
+ std::is_arithmetic<_A1>::value &&
+ std::is_arithmetic<_A2>::value,
+ std::__promote<_A1, _A2>
+>::type
+__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::__enable_if_t
+<
+ 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
+
+inline _LIBCPP_INLINE_VISIBILITY float erf(float __lcpp_x) _NOEXCEPT {return ::erff(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double erf(long double __lcpp_x) _NOEXCEPT {return ::erfl(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+erf(_A1 __lcpp_x) _NOEXCEPT {return ::erf((double)__lcpp_x);}
+
+// erfc
+
+inline _LIBCPP_INLINE_VISIBILITY float erfc(float __lcpp_x) _NOEXCEPT {return ::erfcf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double erfc(long double __lcpp_x) _NOEXCEPT {return ::erfcl(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+erfc(_A1 __lcpp_x) _NOEXCEPT {return ::erfc((double)__lcpp_x);}
+
+// exp2
+
+inline _LIBCPP_INLINE_VISIBILITY float exp2(float __lcpp_x) _NOEXCEPT {return ::exp2f(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double exp2(long double __lcpp_x) _NOEXCEPT {return ::exp2l(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+exp2(_A1 __lcpp_x) _NOEXCEPT {return ::exp2((double)__lcpp_x);}
+
+// expm1
+
+inline _LIBCPP_INLINE_VISIBILITY float expm1(float __lcpp_x) _NOEXCEPT {return ::expm1f(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double expm1(long double __lcpp_x) _NOEXCEPT {return ::expm1l(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+expm1(_A1 __lcpp_x) _NOEXCEPT {return ::expm1((double)__lcpp_x);}
+
+// fdim
+
+inline _LIBCPP_INLINE_VISIBILITY float fdim(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fdimf(__lcpp_x, __lcpp_y);}
+inline _LIBCPP_INLINE_VISIBILITY long double fdim(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fdiml(__lcpp_x, __lcpp_y);}
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::__enable_if_t
+<
+ std::is_arithmetic<_A1>::value &&
+ std::is_arithmetic<_A2>::value,
+ std::__promote<_A1, _A2>
+>::type
+fdim(_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)), "");
+ return ::fdim((__result_type)__lcpp_x, (__result_type)__lcpp_y);
+}
+
+// fma
+
+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
+typename std::__enable_if_t
+<
+ std::is_arithmetic<_A1>::value &&
+ std::is_arithmetic<_A2>::value &&
+ std::is_arithmetic<_A3>::value,
+ std::__promote<_A1, _A2, _A3>
+>::type
+fma(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
+{
+ typedef typename std::__promote<_A1, _A2, _A3>::type __result_type;
+ 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
+
+inline _LIBCPP_INLINE_VISIBILITY float fmax(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fmaxf(__lcpp_x, __lcpp_y);}
+inline _LIBCPP_INLINE_VISIBILITY long double fmax(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fmaxl(__lcpp_x, __lcpp_y);}
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::__enable_if_t
+<
+ std::is_arithmetic<_A1>::value &&
+ std::is_arithmetic<_A2>::value,
+ std::__promote<_A1, _A2>
+>::type
+fmax(_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)), "");
+ return ::fmax((__result_type)__lcpp_x, (__result_type)__lcpp_y);
+}
+
+// fmin
+
+inline _LIBCPP_INLINE_VISIBILITY float fmin(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fminf(__lcpp_x, __lcpp_y);}
+inline _LIBCPP_INLINE_VISIBILITY long double fmin(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fminl(__lcpp_x, __lcpp_y);}
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::__enable_if_t
+<
+ std::is_arithmetic<_A1>::value &&
+ std::is_arithmetic<_A2>::value,
+ std::__promote<_A1, _A2>
+>::type
+fmin(_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)), "");
+ return ::fmin((__result_type)__lcpp_x, (__result_type)__lcpp_y);
+}
+
+// hypot
+
+inline _LIBCPP_INLINE_VISIBILITY float hypot(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::hypotf(__lcpp_x, __lcpp_y);}
+inline _LIBCPP_INLINE_VISIBILITY long double hypot(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::hypotl(__lcpp_x, __lcpp_y);}
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::__enable_if_t
+<
+ std::is_arithmetic<_A1>::value &&
+ std::is_arithmetic<_A2>::value,
+ std::__promote<_A1, _A2>
+>::type
+hypot(_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)), "");
+ return ::hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y);
+}
+
+// ilogb
+
+inline _LIBCPP_INLINE_VISIBILITY int ilogb(float __lcpp_x) _NOEXCEPT {return ::ilogbf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY int ilogb(long double __lcpp_x) _NOEXCEPT {return ::ilogbl(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, int>::type
+ilogb(_A1 __lcpp_x) _NOEXCEPT {return ::ilogb((double)__lcpp_x);}
+
+// lgamma
+
+inline _LIBCPP_INLINE_VISIBILITY float lgamma(float __lcpp_x) _NOEXCEPT {return ::lgammaf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double lgamma(long double __lcpp_x) _NOEXCEPT {return ::lgammal(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+lgamma(_A1 __lcpp_x) _NOEXCEPT {return ::lgamma((double)__lcpp_x);}
+
+// llrint
+
+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
+{
+#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
+{
+#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
+{
+#if __has_builtin(__builtin_llround)
+ return __builtin_llround((double)__lcpp_x);
+#else
+ return ::llround((double)__lcpp_x);
+#endif
+}
+
+// log1p
+
+inline _LIBCPP_INLINE_VISIBILITY float log1p(float __lcpp_x) _NOEXCEPT {return ::log1pf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double log1p(long double __lcpp_x) _NOEXCEPT {return ::log1pl(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+log1p(_A1 __lcpp_x) _NOEXCEPT {return ::log1p((double)__lcpp_x);}
+
+// log2
+
+inline _LIBCPP_INLINE_VISIBILITY float log2(float __lcpp_x) _NOEXCEPT {return ::log2f(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double log2(long double __lcpp_x) _NOEXCEPT {return ::log2l(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+log2(_A1 __lcpp_x) _NOEXCEPT {return ::log2((double)__lcpp_x);}
+
+// logb
+
+inline _LIBCPP_INLINE_VISIBILITY float logb(float __lcpp_x) _NOEXCEPT {return ::logbf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double logb(long double __lcpp_x) _NOEXCEPT {return ::logbl(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+logb(_A1 __lcpp_x) _NOEXCEPT {return ::logb((double)__lcpp_x);}
+
+// lrint
+
+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
+{
+#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
+{
+#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
+{
+#if __has_builtin(__builtin_lround)
+ return __builtin_lround((double)__lcpp_x);
+#else
+ return ::lround((double)__lcpp_x);
+#endif
+}
+
+// nan
+
+// nearbyint
+
+inline _LIBCPP_INLINE_VISIBILITY float nearbyint(float __lcpp_x) _NOEXCEPT {return ::nearbyintf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double nearbyint(long double __lcpp_x) _NOEXCEPT {return ::nearbyintl(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+nearbyint(_A1 __lcpp_x) _NOEXCEPT {return ::nearbyint((double)__lcpp_x);}
+
+// nextafter
+
+inline _LIBCPP_INLINE_VISIBILITY float nextafter(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::nextafterf(__lcpp_x, __lcpp_y);}
+inline _LIBCPP_INLINE_VISIBILITY long double nextafter(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nextafterl(__lcpp_x, __lcpp_y);}
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::__enable_if_t
+<
+ std::is_arithmetic<_A1>::value &&
+ std::is_arithmetic<_A2>::value,
+ std::__promote<_A1, _A2>
+>::type
+nextafter(_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)), "");
+ return ::nextafter((__result_type)__lcpp_x, (__result_type)__lcpp_y);
+}
+
+// nexttoward
+
+inline _LIBCPP_INLINE_VISIBILITY float nexttoward(float __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nexttowardf(__lcpp_x, __lcpp_y);}
+inline _LIBCPP_INLINE_VISIBILITY long double nexttoward(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nexttowardl(__lcpp_x, __lcpp_y);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+nexttoward(_A1 __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nexttoward((double)__lcpp_x, __lcpp_y);}
+
+// remainder
+
+inline _LIBCPP_INLINE_VISIBILITY float remainder(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::remainderf(__lcpp_x, __lcpp_y);}
+inline _LIBCPP_INLINE_VISIBILITY long double remainder(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::remainderl(__lcpp_x, __lcpp_y);}
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::__enable_if_t
+<
+ std::is_arithmetic<_A1>::value &&
+ std::is_arithmetic<_A2>::value,
+ std::__promote<_A1, _A2>
+>::type
+remainder(_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)), "");
+ return ::remainder((__result_type)__lcpp_x, (__result_type)__lcpp_y);
+}
+
+// remquo
+
+inline _LIBCPP_INLINE_VISIBILITY float remquo(float __lcpp_x, float __lcpp_y, int* __lcpp_z) _NOEXCEPT {return ::remquof(__lcpp_x, __lcpp_y, __lcpp_z);}
+inline _LIBCPP_INLINE_VISIBILITY long double remquo(long double __lcpp_x, long double __lcpp_y, int* __lcpp_z) _NOEXCEPT {return ::remquol(__lcpp_x, __lcpp_y, __lcpp_z);}
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::__enable_if_t
+<
+ std::is_arithmetic<_A1>::value &&
+ std::is_arithmetic<_A2>::value,
+ std::__promote<_A1, _A2>
+>::type
+remquo(_A1 __lcpp_x, _A2 __lcpp_y, int* __lcpp_z) _NOEXCEPT
+{
+ typedef typename std::__promote<_A1, _A2>::type __result_type;
+ static_assert((!(std::_IsSame<_A1, __result_type>::value &&
+ std::_IsSame<_A2, __result_type>::value)), "");
+ return ::remquo((__result_type)__lcpp_x, (__result_type)__lcpp_y, __lcpp_z);
+}
+
+// rint
+
+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
+{
+#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
+{
+#if __has_builtin(__builtin_roundf)
+ return __builtin_roundf(__lcpp_x);
+#else
+ return ::roundf(__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
+{
+#if __has_builtin(__builtin_round)
+ return __builtin_round((double)__lcpp_x);
+#else
+ return ::round((double)__lcpp_x);
+#endif
+}
+
+// scalbln
+
+inline _LIBCPP_INLINE_VISIBILITY float scalbln(float __lcpp_x, long __lcpp_y) _NOEXCEPT {return ::scalblnf(__lcpp_x, __lcpp_y);}
+inline _LIBCPP_INLINE_VISIBILITY long double scalbln(long double __lcpp_x, long __lcpp_y) _NOEXCEPT {return ::scalblnl(__lcpp_x, __lcpp_y);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+scalbln(_A1 __lcpp_x, long __lcpp_y) _NOEXCEPT {return ::scalbln((double)__lcpp_x, __lcpp_y);}
+
+// scalbn
+
+inline _LIBCPP_INLINE_VISIBILITY float scalbn(float __lcpp_x, int __lcpp_y) _NOEXCEPT {return ::scalbnf(__lcpp_x, __lcpp_y);}
+inline _LIBCPP_INLINE_VISIBILITY long double scalbn(long double __lcpp_x, int __lcpp_y) _NOEXCEPT {return ::scalbnl(__lcpp_x, __lcpp_y);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+scalbn(_A1 __lcpp_x, int __lcpp_y) _NOEXCEPT {return ::scalbn((double)__lcpp_x, __lcpp_y);}
+
+// tgamma
+
+inline _LIBCPP_INLINE_VISIBILITY float tgamma(float __lcpp_x) _NOEXCEPT {return ::tgammaf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double tgamma(long double __lcpp_x) _NOEXCEPT {return ::tgammal(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+tgamma(_A1 __lcpp_x) _NOEXCEPT {return ::tgamma((double)__lcpp_x);}
+
+// trunc
+
+inline _LIBCPP_INLINE_VISIBILITY float trunc(float __lcpp_x) _NOEXCEPT
+{
+#if __has_builtin(__builtin_truncf)
+ return __builtin_truncf(__lcpp_x);
+#else
+ return ::truncf(__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
+{
+#if __has_builtin(__builtin_trunc)
+ return __builtin_trunc((double)__lcpp_x);
+#else
+ return ::trunc((double)__lcpp_x);
+#endif
+}
+
+} // extern "C++"
+
+#endif // __cplusplus
+
+#else // _LIBCPP_MATH_H
+
+// This include lives outside the header guard in order to support an MSVC
+// extension which allows users to do:
+//
+// #define _USE_MATH_DEFINES
+// #include <math.h>
+//
+// and receive the definitions of mathematical constants, even if <math.h>
+// has previously been included.
+#if defined(_LIBCPP_MSVCRT) && defined(_USE_MATH_DEFINES)
+#ifdef _LIBCPP_COMPILER_MSVC
+#include Y_UCRT_INCLUDE_NEXT(math.h)
+#else
+#include_next <math.h>
+#endif
+#endif
+
+#endif // _LIBCPP_MATH_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/memory b/contrib/libs/cxxsupp/libcxxmsvc/include/memory
new file mode 100644
index 0000000000..72fa9cf342
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/memory
@@ -0,0 +1,1110 @@
+// -*- 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
+#define _LIBCPP_MEMORY
+
+/*
+ memory synopsis
+
+namespace std
+{
+
+struct allocator_arg_t { };
+inline constexpr allocator_arg_t allocator_arg = allocator_arg_t();
+
+template <class T, class Alloc> struct uses_allocator;
+
+template <class Ptr>
+struct pointer_traits
+{
+ typedef Ptr pointer;
+ typedef <details> element_type;
+ typedef <details> difference_type;
+
+ template <class U> using rebind = <details>;
+
+ static pointer pointer_to(<details>);
+};
+
+template <class T>
+struct pointer_traits<T*>
+{
+ typedef T* pointer;
+ typedef T element_type;
+ typedef ptrdiff_t difference_type;
+
+ template <class U> using rebind = U*;
+
+ static pointer pointer_to(<details>) noexcept; // constexpr in C++20
+};
+
+template <class T> constexpr T* to_address(T* p) noexcept; // C++20
+template <class Ptr> constexpr auto to_address(const Ptr& p) noexcept; // C++20
+
+template <class Alloc>
+struct allocator_traits
+{
+ typedef Alloc allocator_type;
+ typedef typename allocator_type::value_type
+ value_type;
+
+ typedef Alloc::pointer | value_type* pointer;
+ typedef Alloc::const_pointer
+ | pointer_traits<pointer>::rebind<const value_type>
+ const_pointer;
+ typedef Alloc::void_pointer
+ | pointer_traits<pointer>::rebind<void>
+ void_pointer;
+ typedef Alloc::const_void_pointer
+ | pointer_traits<pointer>::rebind<const void>
+ const_void_pointer;
+ typedef Alloc::difference_type
+ | pointer_traits<pointer>::difference_type
+ difference_type;
+ typedef Alloc::size_type
+ | make_unsigned<difference_type>::type
+ size_type;
+ typedef Alloc::propagate_on_container_copy_assignment
+ | false_type propagate_on_container_copy_assignment;
+ typedef Alloc::propagate_on_container_move_assignment
+ | false_type propagate_on_container_move_assignment;
+ typedef Alloc::propagate_on_container_swap
+ | false_type propagate_on_container_swap;
+ typedef Alloc::is_always_equal
+ | is_empty is_always_equal;
+
+ template <class T> using rebind_alloc = Alloc::rebind<T>::other | Alloc<T, Args...>;
+ template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>;
+
+ static pointer allocate(allocator_type& a, size_type n); // constexpr and [[nodiscard]] in C++20
+ static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint); // constexpr and [[nodiscard]] in C++20
+
+ static void deallocate(allocator_type& a, pointer p, size_type n) noexcept; // constexpr in C++20
+
+ template <class T, class... Args>
+ static void construct(allocator_type& a, T* p, Args&&... args); // constexpr in C++20
+
+ template <class T>
+ static void destroy(allocator_type& a, T* p); // constexpr in C++20
+
+ static size_type max_size(const allocator_type& a); // noexcept in C++14, constexpr in C++20
+ static allocator_type select_on_container_copy_construction(const allocator_type& a); // constexpr in C++20
+};
+
+template <>
+class allocator<void> // removed in C++20
+{
+public:
+ typedef void* pointer;
+ typedef const void* const_pointer;
+ typedef void value_type;
+
+ template <class _Up> struct rebind {typedef allocator<_Up> other;};
+};
+
+template <class T>
+class allocator
+{
+public:
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef T* pointer; // deprecated in C++17, removed in C++20
+ typedef const T* const_pointer; // deprecated in C++17, removed in C++20
+ typedef typename add_lvalue_reference<T>::type
+ reference; // deprecated in C++17, removed in C++20
+ typedef typename add_lvalue_reference<const T>::type
+ const_reference; // deprecated in C++17, removed in C++20
+
+ typedef T value_type;
+
+ template <class U> struct rebind {typedef allocator<U> other;}; // deprecated in C++17, removed in C++20
+
+ typedef true_type propagate_on_container_move_assignment;
+ typedef true_type is_always_equal;
+
+ constexpr allocator() noexcept; // constexpr in C++20
+ constexpr allocator(const allocator&) noexcept; // constexpr in C++20
+ template <class U>
+ constexpr allocator(const allocator<U>&) noexcept; // constexpr in C++20
+ ~allocator(); // constexpr in C++20
+ pointer address(reference x) const noexcept; // deprecated in C++17, removed in C++20
+ const_pointer address(const_reference x) const noexcept; // deprecated in C++17, removed in C++20
+ T* allocate(size_t n, const void* hint); // deprecated in C++17, removed in C++20
+ T* allocate(size_t n); // constexpr in C++20
+ void deallocate(T* p, size_t n) noexcept; // constexpr in C++20
+ size_type max_size() const noexcept; // deprecated in C++17, removed in C++20
+ template<class U, class... Args>
+ void construct(U* p, Args&&... args); // deprecated in C++17, removed in C++20
+ template <class U>
+ void destroy(U* p); // deprecated in C++17, removed in C++20
+};
+
+template <class T, class U>
+bool operator==(const allocator<T>&, const allocator<U>&) noexcept; // constexpr in C++20
+
+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 // 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);
+ raw_storage_iterator& operator++();
+ raw_storage_iterator operator++(int);
+};
+
+template <class T> pair<T*,ptrdiff_t> get_temporary_buffer(ptrdiff_t n) noexcept;
+template <class T> void return_temporary_buffer(T* p) noexcept;
+
+template <class T> T* addressof(T& r) noexcept;
+template <class T> T* addressof(const T&& r) noexcept = delete;
+
+template <class InputIterator, class ForwardIterator>
+ForwardIterator
+uninitialized_copy(InputIterator first, InputIterator last, ForwardIterator result);
+
+namespace ranges {
+
+template<class InputIterator, class OutputIterator>
+using uninitialized_copy_result = in_out_result<InputIterator, OutputIterator>; // since C++20
+
+template<input_iterator InputIterator, sentinel-for<InputIterator> Sentinel1, nothrow-forward-iterator OutputIterator, nothrow-sentinel-for<OutputIterator> Sentinel2>
+ requires constructible_from<iter_value_t<OutputIterator>, iter_reference_t<InputIterator>>
+uninitialized_copy_result<InputIterator, OutputIterator>
+uninitialized_copy(InputIterator ifirst, Sentinel1 ilast, OutputIterator ofirst, Sentinel2 olast); // since C++20
+
+template<input_range InputRange, nothrow-forward-range OutputRange>
+ requires constructible_from<range_value_t<OutputRange>, range_reference_t<InputRange>>
+uninitialized_copy_result<borrowed_iterator_t<InputRange>, borrowed_iterator_t<OutputRange>>
+uninitialized_copy(InputRange&& in_range, OutputRange&& out_range); // since C++20
+
+}
+
+template <class InputIterator, class Size, class ForwardIterator>
+ForwardIterator
+uninitialized_copy_n(InputIterator first, Size n, ForwardIterator result);
+
+namespace ranges {
+
+template<class InputIterator, class OutputIterator>
+using uninitialized_copy_n_result = in_out_result<InputIterator, OutputIterator>; // since C++20
+
+template<input_iterator InputIterator, nothrow-forward-iterator OutputIterator, nothrow-sentinel-for<OutputIterator> Sentinel>
+ requires constructible_from<iter_value_t<OutputIterator>, iter_reference_t<InputIterator>>
+uninitialized_copy_n_result<InputIterator, OutputIterator>
+uninitialized_copy_n(InputIterator ifirst, iter_difference_t<InputIterator> n, OutputIterator ofirst, Sentinel olast); // since C++20
+
+}
+
+template <class ForwardIterator, class T>
+void uninitialized_fill(ForwardIterator first, ForwardIterator last, const T& x);
+
+namespace ranges {
+
+template <nothrow-forward-iterator ForwardIterator, nothrow-sentinel-for<ForwardIterator> Sentinel, class T>
+ requires constructible_from<iter_value_t<ForwardIterator>, const T&>
+ForwardIterator uninitialized_fill(ForwardIterator first, Sentinel last, const T& x); // since C++20
+
+template <nothrow-forward-range ForwardRange, class T>
+ requires constructible_from<range_value_t<ForwardRange>, const T&>
+borrowed_iterator_t<ForwardRange> uninitialized_fill(ForwardRange&& range, const T& x); // since C++20
+
+}
+
+template <class ForwardIterator, class Size, class T>
+ForwardIterator
+uninitialized_fill_n(ForwardIterator first, Size n, const T& x);
+
+namespace ranges {
+
+template <nothrow-forward-iterator ForwardIterator, class T>
+ requires constructible_from<iter_value_t<ForwardIterator>, const T&>
+ForwardIterator uninitialized_fill_n(ForwardIterator first, iter_difference_t<ForwardIterator> n); // since C++20
+
+}
+
+template <class T, class ...Args>
+constexpr T* construct_at(T* location, Args&& ...args); // since C++20
+
+namespace ranges {
+ template<class T, class... Args>
+ constexpr T* construct_at(T* location, Args&&... args); // since C++20
+}
+
+template <class T>
+void destroy_at(T* location); // constexpr in C++20
+
+namespace ranges {
+ template<destructible T>
+ constexpr void destroy_at(T* location) noexcept; // since C++20
+}
+
+template <class ForwardIterator>
+void destroy(ForwardIterator first, ForwardIterator last); // constexpr in C++20
+
+namespace ranges {
+ template<nothrow-input-iterator InputIterator, nothrow-sentinel-for<InputIterator> Sentinel>
+ requires destructible<iter_value_t<InputIterator>>
+ constexpr InputIterator destroy(InputIterator first, Sentinel last) noexcept; // since C++20
+ template<nothrow-input-range InputRange>
+ requires destructible<range_value_t<InputRange>>
+ constexpr borrowed_iterator_t<InputRange> destroy(InputRange&& range) noexcept; // since C++20
+}
+
+template <class ForwardIterator, class Size>
+ForwardIterator destroy_n(ForwardIterator first, Size n); // constexpr in C++20
+
+namespace ranges {
+ template<nothrow-input-iterator InputIterator>
+ requires destructible<iter_value_t<InputIterator>>
+ constexpr InputIterator destroy_n(InputIterator first, iter_difference_t<InputIterator> n) noexcept; // since C++20
+}
+
+template <class InputIterator, class ForwardIterator>
+ ForwardIterator uninitialized_move(InputIterator first, InputIterator last, ForwardIterator result);
+
+namespace ranges {
+
+template<class InputIterator, class OutputIterator>
+using uninitialized_move_result = in_out_result<InputIterator, OutputIterator>; // since C++20
+
+template <input_iterator InputIterator, sentinel_for<InputIterator> Sentinel1, nothrow-forward-iterator OutputIterator, nothrow-sentinel-for<O> Sentinel2>
+ requires constructible_from<iter_value_t<OutputIterator>, iter_rvalue_reference_t<InputIterator>>
+uninitialized_move_result<InputIterator, OutputIterator>
+uninitialized_move(InputIterator ifirst, Sentinel1 ilast, OutputIterator ofirst, Sentinel2 olast); // since C++20
+
+template<input_range InputRange, nothrow-forward-range OutputRange>
+ requires constructible_from<range_value_t<OutputRange>, range_rvalue_reference_t<InputRange>>
+uninitialized_move_result<borrowed_iterator_t<InputRange>, borrowed_iterator_t<OutputRange>>
+uninitialized_move(InputRange&& in_range, OutputRange&& out_range); // since C++20
+
+}
+
+template <class InputIterator, class Size, class ForwardIterator>
+ pair<InputIterator,ForwardIterator> uninitialized_move_n(InputIterator first, Size n, ForwardIterator result);
+
+namespace ranges {
+
+template<class InputIterator, class OutputIterator>
+using uninitialized_move_n_result = in_out_result<InputIterator, OutputIterator>; // since C++20
+
+template<input_iterator InputIterator, nothrow-forward-iterator OutputIterator, nothrow-sentinel-for<OutputIterator> Sentinel>
+ requires constructible_from<iter_value_t<OutputIterator>, iter_rvalue_reference_t<InputIterator>>
+uninitialized_move_n_result<InputIterator, OutputIterator>
+uninitialized_move_n(InputIterator ifirst, iter_difference_t<InputIterator> n, OutputIterator ofirst, Sentinel olast); // since C++20
+
+}
+
+template <class ForwardIterator>
+ void uninitialized_value_construct(ForwardIterator first, ForwardIterator last);
+
+namespace ranges {
+
+template <nothrow-forward-iterator ForwardIterator, nothrow-sentinel-for<ForwardIterator> Sentinel>
+ requires default_initializable<iter_value_t<ForwardIterator>>
+ ForwardIterator uninitialized_value_construct(ForwardIterator first, Sentinel last); // since C++20
+
+template <nothrow-forward-range ForwardRange>
+ requires default_initializable<range_value_t<ForwardRange>>
+ borrowed_iterator_t<ForwardRange> uninitialized_value_construct(ForwardRange&& r); // since C++20
+
+}
+
+template <class ForwardIterator, class Size>
+ ForwardIterator uninitialized_value_construct_n(ForwardIterator first, Size n);
+
+namespace ranges {
+
+template <nothrow-forward-iterator ForwardIterator>
+ requires default_initializable<iter_value_t<ForwardIterator>>
+ ForwardIterator uninitialized_value_construct_n(ForwardIterator first, iter_difference_t<ForwardIterator> n); // since C++20
+
+}
+
+template <class ForwardIterator>
+ void uninitialized_default_construct(ForwardIterator first, ForwardIterator last);
+
+namespace ranges {
+
+template <nothrow-forward-iterator ForwardIterator, nothrow-sentinel-for<ForwardIterator> Sentinel>
+ requires default_initializable<iter_value_t<ForwardIterator>>
+ ForwardIterator uninitialized_default_construct(ForwardIterator first, Sentinel last); // since C++20
+
+template <nothrow-forward-range ForwardRange>
+ requires default_initializable<range_value_t<ForwardRange>>
+ borrowed_iterator_t<ForwardRange> uninitialized_default_construct(ForwardRange&& r); // since C++20
+
+}
+
+template <class ForwardIterator, class Size>
+ ForwardIterator uninitialized_default_construct_n(ForwardIterator first, Size n);
+
+namespace ranges {
+
+template <nothrow-forward-iterator ForwardIterator>
+ requires default_initializable<iter_value_t<ForwardIterator>>
+ ForwardIterator uninitialized_default_construct_n(ForwardIterator first, iter_difference_t<ForwardIterator> n); // since C++20
+
+}
+
+template <class Y> struct auto_ptr_ref {}; // deprecated in C++11, removed in C++17
+
+template<class X>
+class auto_ptr // deprecated in C++11, removed in C++17
+{
+public:
+ typedef X element_type;
+
+ explicit auto_ptr(X* p =0) throw();
+ auto_ptr(auto_ptr&) throw();
+ template<class Y> auto_ptr(auto_ptr<Y>&) throw();
+ auto_ptr& operator=(auto_ptr&) throw();
+ template<class Y> auto_ptr& operator=(auto_ptr<Y>&) throw();
+ auto_ptr& operator=(auto_ptr_ref<X> r) throw();
+ ~auto_ptr() throw();
+
+ typename add_lvalue_reference<X>::type operator*() const throw();
+ X* operator->() const throw();
+ X* get() const throw();
+ X* release() throw();
+ void reset(X* p =0) throw();
+
+ auto_ptr(auto_ptr_ref<X>) throw();
+ template<class Y> operator auto_ptr_ref<Y>() throw();
+ template<class Y> operator auto_ptr<Y>() throw();
+};
+
+template <class T>
+struct default_delete
+{
+ constexpr default_delete() noexcept = default;
+ template <class U> default_delete(const default_delete<U>&) noexcept;
+
+ void operator()(T*) const noexcept;
+};
+
+template <class T>
+struct default_delete<T[]>
+{
+ constexpr default_delete() noexcept = default;
+ void operator()(T*) const noexcept;
+ template <class U> void operator()(U*) const = delete;
+};
+
+template <class T, class D = default_delete<T>>
+class unique_ptr
+{
+public:
+ typedef see below pointer;
+ typedef T element_type;
+ typedef D deleter_type;
+
+ // constructors
+ constexpr unique_ptr() noexcept;
+ explicit unique_ptr(pointer p) noexcept;
+ unique_ptr(pointer p, see below d1) noexcept;
+ unique_ptr(pointer p, see below d2) noexcept;
+ unique_ptr(unique_ptr&& u) noexcept;
+ unique_ptr(nullptr_t) noexcept : unique_ptr() { }
+ template <class U, class E>
+ unique_ptr(unique_ptr<U, E>&& u) noexcept;
+ template <class U>
+ unique_ptr(auto_ptr<U>&& u) noexcept; // removed in C++17
+
+ // destructor
+ ~unique_ptr();
+
+ // assignment
+ unique_ptr& operator=(unique_ptr&& u) noexcept;
+ template <class U, class E> unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept;
+ unique_ptr& operator=(nullptr_t) noexcept;
+
+ // observers
+ typename add_lvalue_reference<T>::type operator*() const;
+ pointer operator->() const noexcept;
+ pointer get() const noexcept;
+ deleter_type& get_deleter() noexcept;
+ const deleter_type& get_deleter() const noexcept;
+ explicit operator bool() const noexcept;
+
+ // modifiers
+ pointer release() noexcept;
+ void reset(pointer p = pointer()) noexcept;
+ void swap(unique_ptr& u) noexcept;
+};
+
+template <class T, class D>
+class unique_ptr<T[], D>
+{
+public:
+ typedef implementation-defined pointer;
+ typedef T element_type;
+ typedef D deleter_type;
+
+ // constructors
+ constexpr unique_ptr() noexcept;
+ explicit unique_ptr(pointer p) noexcept;
+ unique_ptr(pointer p, see below d) noexcept;
+ unique_ptr(pointer p, see below d) noexcept;
+ unique_ptr(unique_ptr&& u) noexcept;
+ unique_ptr(nullptr_t) noexcept : unique_ptr() { }
+
+ // destructor
+ ~unique_ptr();
+
+ // assignment
+ unique_ptr& operator=(unique_ptr&& u) noexcept;
+ unique_ptr& operator=(nullptr_t) noexcept;
+
+ // observers
+ T& operator[](size_t i) const;
+ pointer get() const noexcept;
+ deleter_type& get_deleter() noexcept;
+ const deleter_type& get_deleter() const noexcept;
+ explicit operator bool() const noexcept;
+
+ // modifiers
+ pointer release() noexcept;
+ void reset(pointer p = pointer()) noexcept;
+ void reset(nullptr_t) noexcept;
+ template <class U> void reset(U) = delete;
+ void swap(unique_ptr& u) noexcept;
+};
+
+template <class T, class D>
+ void swap(unique_ptr<T, D>& x, unique_ptr<T, D>& y) noexcept;
+
+template <class T1, class D1, class T2, class D2>
+ bool operator==(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+template <class T1, class D1, class T2, class D2>
+ bool operator!=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+template <class T1, class D1, class T2, class D2>
+ bool operator<(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+template <class T1, class D1, class T2, class D2>
+ bool operator<=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+template <class T1, class D1, class T2, class D2>
+ bool operator>(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+template <class T1, class D1, class T2, class D2>
+ bool operator>=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+
+template <class T, class D>
+ bool operator==(const unique_ptr<T, D>& x, nullptr_t) noexcept;
+template <class T, class D>
+ bool operator==(nullptr_t, const unique_ptr<T, D>& y) noexcept;
+template <class T, class D>
+ bool operator!=(const unique_ptr<T, D>& x, nullptr_t) noexcept;
+template <class T, class D>
+ bool operator!=(nullptr_t, const unique_ptr<T, D>& y) noexcept;
+
+template <class T, class D>
+ bool operator<(const unique_ptr<T, D>& x, nullptr_t);
+template <class T, class D>
+ bool operator<(nullptr_t, const unique_ptr<T, D>& y);
+template <class T, class D>
+ bool operator<=(const unique_ptr<T, D>& x, nullptr_t);
+template <class T, class D>
+ bool operator<=(nullptr_t, const unique_ptr<T, D>& y);
+template <class T, class D>
+ bool operator>(const unique_ptr<T, D>& x, nullptr_t);
+template <class T, class D>
+ bool operator>(nullptr_t, const unique_ptr<T, D>& y);
+template <class T, class D>
+ bool operator>=(const unique_ptr<T, D>& x, nullptr_t);
+template <class T, class D>
+ bool operator>=(nullptr_t, const unique_ptr<T, D>& y);
+
+class bad_weak_ptr
+ : public std::exception
+{
+ bad_weak_ptr() noexcept;
+};
+
+template<class T, class... Args> unique_ptr<T> make_unique(Args&&... args); // C++14
+template<class T> unique_ptr<T> make_unique(size_t n); // C++14
+template<class T, class... Args> unspecified make_unique(Args&&...) = delete; // C++14, T == U[N]
+
+template<class E, class T, class Y, class D>
+ basic_ostream<E, T>& operator<< (basic_ostream<E, T>& os, unique_ptr<Y, D> const& p);
+
+template<class T>
+class shared_ptr
+{
+public:
+ typedef T element_type; // until C++17
+ typedef remove_extent_t<T> element_type; // since C++17
+ typedef weak_ptr<T> weak_type; // C++17
+
+ // constructors:
+ constexpr shared_ptr() noexcept;
+ template<class Y> explicit shared_ptr(Y* p);
+ template<class Y, class D> shared_ptr(Y* p, D d);
+ template<class Y, class D, class A> shared_ptr(Y* p, D d, A a);
+ template <class D> shared_ptr(nullptr_t p, D d);
+ template <class D, class A> shared_ptr(nullptr_t p, D d, A a);
+ template<class Y> shared_ptr(const shared_ptr<Y>& r, T *p) noexcept;
+ shared_ptr(const shared_ptr& r) noexcept;
+ template<class Y> shared_ptr(const shared_ptr<Y>& r) noexcept;
+ shared_ptr(shared_ptr&& r) noexcept;
+ template<class Y> shared_ptr(shared_ptr<Y>&& r) noexcept;
+ template<class Y> explicit shared_ptr(const weak_ptr<Y>& r);
+ template<class Y> shared_ptr(auto_ptr<Y>&& r); // removed in C++17
+ template <class Y, class D> shared_ptr(unique_ptr<Y, D>&& r);
+ shared_ptr(nullptr_t) : shared_ptr() { }
+
+ // destructor:
+ ~shared_ptr();
+
+ // assignment:
+ shared_ptr& operator=(const shared_ptr& r) noexcept;
+ template<class Y> shared_ptr& operator=(const shared_ptr<Y>& r) noexcept;
+ shared_ptr& operator=(shared_ptr&& r) noexcept;
+ template<class Y> shared_ptr& operator=(shared_ptr<Y>&& r);
+ template<class Y> shared_ptr& operator=(auto_ptr<Y>&& r); // removed in C++17
+ template <class Y, class D> shared_ptr& operator=(unique_ptr<Y, D>&& r);
+
+ // modifiers:
+ void swap(shared_ptr& r) noexcept;
+ void reset() noexcept;
+ template<class Y> void reset(Y* p);
+ template<class Y, class D> void reset(Y* p, D d);
+ template<class Y, class D, class A> void reset(Y* p, D d, A a);
+
+ // observers:
+ T* get() const noexcept;
+ T& operator*() const noexcept;
+ T* operator->() const noexcept;
+ long use_count() const noexcept;
+ bool unique() const noexcept;
+ explicit operator bool() const noexcept;
+ template<class U> bool owner_before(shared_ptr<U> const& b) const noexcept;
+ template<class U> bool owner_before(weak_ptr<U> const& b) const noexcept;
+};
+
+template<class T>
+shared_ptr(weak_ptr<T>) -> shared_ptr<T>;
+template<class T, class D>
+shared_ptr(unique_ptr<T, D>) -> shared_ptr<T>;
+
+// shared_ptr comparisons:
+template<class T, class U>
+ bool operator==(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
+template<class T, class U>
+ bool operator!=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
+template<class T, class U>
+ bool operator<(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
+template<class T, class U>
+ bool operator>(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
+template<class T, class U>
+ bool operator<=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
+template<class T, class U>
+ bool operator>=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
+
+template <class T>
+ bool operator==(const shared_ptr<T>& x, nullptr_t) noexcept;
+template <class T>
+ bool operator==(nullptr_t, const shared_ptr<T>& y) noexcept;
+template <class T>
+ bool operator!=(const shared_ptr<T>& x, nullptr_t) noexcept;
+template <class T>
+ bool operator!=(nullptr_t, const shared_ptr<T>& y) noexcept;
+template <class T>
+ bool operator<(const shared_ptr<T>& x, nullptr_t) noexcept;
+template <class T>
+bool operator<(nullptr_t, const shared_ptr<T>& y) noexcept;
+template <class T>
+ bool operator<=(const shared_ptr<T>& x, nullptr_t) noexcept;
+template <class T>
+ bool operator<=(nullptr_t, const shared_ptr<T>& y) noexcept;
+template <class T>
+ bool operator>(const shared_ptr<T>& x, nullptr_t) noexcept;
+template <class T>
+ bool operator>(nullptr_t, const shared_ptr<T>& y) noexcept;
+template <class T>
+ bool operator>=(const shared_ptr<T>& x, nullptr_t) noexcept;
+template <class T>
+ bool operator>=(nullptr_t, const shared_ptr<T>& y) noexcept;
+
+// shared_ptr specialized algorithms:
+template<class T> void swap(shared_ptr<T>& a, shared_ptr<T>& b) noexcept;
+
+// shared_ptr casts:
+template<class T, class U>
+ shared_ptr<T> static_pointer_cast(shared_ptr<U> const& r) noexcept;
+template<class T, class U>
+ shared_ptr<T> dynamic_pointer_cast(shared_ptr<U> const& r) noexcept;
+template<class T, class U>
+ shared_ptr<T> const_pointer_cast(shared_ptr<U> const& r) noexcept;
+
+// shared_ptr I/O:
+template<class E, class T, class Y>
+ basic_ostream<E, T>& operator<< (basic_ostream<E, T>& os, shared_ptr<Y> const& p);
+
+// shared_ptr get_deleter:
+template<class D, class T> D* get_deleter(shared_ptr<T> const& p) noexcept;
+
+template<class T, class... Args>
+ shared_ptr<T> make_shared(Args&&... args);
+template<class T, class A, class... Args>
+ shared_ptr<T> allocate_shared(const A& a, Args&&... args);
+
+template<class T>
+class weak_ptr
+{
+public:
+ typedef T element_type; // until C++17
+ typedef remove_extent_t<T> element_type; // since C++17
+
+ // constructors
+ constexpr weak_ptr() noexcept;
+ template<class Y> weak_ptr(shared_ptr<Y> const& r) noexcept;
+ weak_ptr(weak_ptr const& r) noexcept;
+ template<class Y> weak_ptr(weak_ptr<Y> const& r) noexcept;
+ weak_ptr(weak_ptr&& r) noexcept; // C++14
+ template<class Y> weak_ptr(weak_ptr<Y>&& r) noexcept; // C++14
+
+ // destructor
+ ~weak_ptr();
+
+ // assignment
+ weak_ptr& operator=(weak_ptr const& r) noexcept;
+ template<class Y> weak_ptr& operator=(weak_ptr<Y> const& r) noexcept;
+ template<class Y> weak_ptr& operator=(shared_ptr<Y> const& r) noexcept;
+ weak_ptr& operator=(weak_ptr&& r) noexcept; // C++14
+ template<class Y> weak_ptr& operator=(weak_ptr<Y>&& r) noexcept; // C++14
+
+ // modifiers
+ void swap(weak_ptr& r) noexcept;
+ void reset() noexcept;
+
+ // observers
+ long use_count() const noexcept;
+ bool expired() const noexcept;
+ shared_ptr<T> lock() const noexcept;
+ template<class U> bool owner_before(shared_ptr<U> const& b) const noexcept;
+ template<class U> bool owner_before(weak_ptr<U> const& b) const noexcept;
+};
+
+template<class T>
+weak_ptr(shared_ptr<T>) -> weak_ptr<T>;
+
+// weak_ptr specialized algorithms:
+template<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b) noexcept;
+
+// class owner_less:
+template<class T> struct owner_less;
+
+template<class T>
+struct owner_less<shared_ptr<T> >
+ : binary_function<shared_ptr<T>, shared_ptr<T>, bool>
+{
+ typedef bool result_type;
+ bool operator()(shared_ptr<T> const&, shared_ptr<T> const&) const noexcept;
+ bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const noexcept;
+ bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const noexcept;
+};
+
+template<class T>
+struct owner_less<weak_ptr<T> >
+ : binary_function<weak_ptr<T>, weak_ptr<T>, bool>
+{
+ typedef bool result_type;
+ bool operator()(weak_ptr<T> const&, weak_ptr<T> const&) const noexcept;
+ bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const noexcept;
+ bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const noexcept;
+};
+
+template <> // Added in C++14
+struct owner_less<void>
+{
+ template <class _Tp, class _Up>
+ bool operator()( shared_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const noexcept;
+ template <class _Tp, class _Up>
+ bool operator()( shared_ptr<_Tp> const& __x, weak_ptr<_Up> const& __y) const noexcept;
+ template <class _Tp, class _Up>
+ bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const noexcept;
+ template <class _Tp, class _Up>
+ bool operator()( weak_ptr<_Tp> const& __x, weak_ptr<_Up> const& __y) const noexcept;
+
+ typedef void is_transparent;
+};
+
+template<class T>
+class enable_shared_from_this
+{
+protected:
+ constexpr enable_shared_from_this() noexcept;
+ enable_shared_from_this(enable_shared_from_this const&) noexcept;
+ enable_shared_from_this& operator=(enable_shared_from_this const&) noexcept;
+ ~enable_shared_from_this();
+public:
+ shared_ptr<T> shared_from_this();
+ shared_ptr<T const> shared_from_this() const;
+};
+
+template<class T>
+ bool atomic_is_lock_free(const shared_ptr<T>* p);
+template<class T>
+ shared_ptr<T> atomic_load(const shared_ptr<T>* p);
+template<class T>
+ shared_ptr<T> atomic_load_explicit(const shared_ptr<T>* p, memory_order mo);
+template<class T>
+ void atomic_store(shared_ptr<T>* p, shared_ptr<T> r);
+template<class T>
+ void atomic_store_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo);
+template<class T>
+ shared_ptr<T> atomic_exchange(shared_ptr<T>* p, shared_ptr<T> r);
+template<class T>
+ shared_ptr<T>
+ atomic_exchange_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo);
+template<class T>
+ bool
+ atomic_compare_exchange_weak(shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w);
+template<class T>
+ bool
+ atomic_compare_exchange_strong( shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w);
+template<class T>
+ bool
+ atomic_compare_exchange_weak_explicit(shared_ptr<T>* p, shared_ptr<T>* v,
+ shared_ptr<T> w, memory_order success,
+ memory_order failure);
+template<class T>
+ bool
+ atomic_compare_exchange_strong_explicit(shared_ptr<T>* p, shared_ptr<T>* v,
+ shared_ptr<T> w, memory_order success,
+ memory_order failure);
+// Hash support
+template <class T> struct hash;
+template <class T, class D> struct hash<unique_ptr<T, D> >;
+template <class T> struct hash<shared_ptr<T> >;
+
+template <class T, class Alloc>
+ inline constexpr bool uses_allocator_v = uses_allocator<T, Alloc>::value;
+
+void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
+
+} // std
+
+*/
+
+#include <__config>
+#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/concepts.h>
+#include <__memory/construct_at.h>
+#include <__memory/pointer_traits.h>
+#include <__memory/ranges_construct_at.h>
+#include <__memory/ranges_uninitialized_algorithms.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 <cstring>
+#include <iosfwd>
+#include <iterator>
+#include <new>
+#include <stdexcept>
+#include <stlfwd>
+#include <tuple>
+#include <type_traits>
+#include <typeinfo>
+#include <utility>
+#include <version>
+
+// TODO: remove these headers
+#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>
+
+#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_BEGIN_NAMESPACE_STD
+
+template <class _Alloc, class _Ptr>
+_LIBCPP_INLINE_VISIBILITY
+void __construct_forward_with_exception_guarantees(_Alloc& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __begin2) {
+ static_assert(__is_cpp17_move_insertable<_Alloc>::value,
+ "The specified type does not meet the requirements of Cpp17MoveInsertable");
+ typedef allocator_traits<_Alloc> _Traits;
+ for (; __begin1 != __end1; ++__begin1, (void)++__begin2) {
+ _Traits::construct(__a, _VSTD::__to_address(__begin2),
+#ifdef _LIBCPP_NO_EXCEPTIONS
+ _VSTD::move(*__begin1)
+#else
+ _VSTD::move_if_noexcept(*__begin1)
+#endif
+ );
+ }
+}
+
+template <class _Alloc, class _Tp, typename enable_if<
+ (__is_default_allocator<_Alloc>::value || !__has_construct<_Alloc, _Tp*, _Tp>::value) &&
+ is_trivially_move_constructible<_Tp>::value
+>::type>
+_LIBCPP_INLINE_VISIBILITY
+void __construct_forward_with_exception_guarantees(_Alloc&, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2) {
+ ptrdiff_t _Np = __end1 - __begin1;
+ if (_Np > 0) {
+ _VSTD::memcpy(__begin2, __begin1, _Np * sizeof(_Tp));
+ __begin2 += _Np;
+ }
+}
+
+template <class _Alloc, class _Iter, class _Ptr>
+_LIBCPP_INLINE_VISIBILITY
+void __construct_range_forward(_Alloc& __a, _Iter __begin1, _Iter __end1, _Ptr& __begin2) {
+ typedef allocator_traits<_Alloc> _Traits;
+ for (; __begin1 != __end1; ++__begin1, (void) ++__begin2) {
+ _Traits::construct(__a, _VSTD::__to_address(__begin2), *__begin1);
+ }
+}
+
+template <class _Alloc, class _Source, class _Dest,
+ class _RawSource = typename remove_const<_Source>::type,
+ class _RawDest = typename remove_const<_Dest>::type,
+ class =
+ typename enable_if<
+ is_trivially_copy_constructible<_Dest>::value &&
+ is_same<_RawSource, _RawDest>::value &&
+ (__is_default_allocator<_Alloc>::value || !__has_construct<_Alloc, _Dest*, _Source&>::value)
+ >::type>
+_LIBCPP_INLINE_VISIBILITY
+void __construct_range_forward(_Alloc&, _Source* __begin1, _Source* __end1, _Dest*& __begin2) {
+ ptrdiff_t _Np = __end1 - __begin1;
+ if (_Np > 0) {
+ _VSTD::memcpy(const_cast<_RawDest*>(__begin2), __begin1, _Np * sizeof(_Dest));
+ __begin2 += _Np;
+ }
+}
+
+template <class _Alloc, class _Ptr>
+_LIBCPP_INLINE_VISIBILITY
+void __construct_backward_with_exception_guarantees(_Alloc& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __end2) {
+ static_assert(__is_cpp17_move_insertable<_Alloc>::value,
+ "The specified type does not meet the requirements of Cpp17MoveInsertable");
+ typedef allocator_traits<_Alloc> _Traits;
+ while (__end1 != __begin1) {
+ _Traits::construct(__a, _VSTD::__to_address(__end2 - 1),
+#ifdef _LIBCPP_NO_EXCEPTIONS
+ _VSTD::move(*--__end1)
+#else
+ _VSTD::move_if_noexcept(*--__end1)
+#endif
+ );
+ --__end2;
+ }
+}
+
+template <class _Alloc, class _Tp, class = typename enable_if<
+ (__is_default_allocator<_Alloc>::value || !__has_construct<_Alloc, _Tp*, _Tp>::value) &&
+ is_trivially_move_constructible<_Tp>::value
+>::type>
+_LIBCPP_INLINE_VISIBILITY
+void __construct_backward_with_exception_guarantees(_Alloc&, _Tp* __begin1, _Tp* __end1, _Tp*& __end2) {
+ ptrdiff_t _Np = __end1 - __begin1;
+ __end2 -= _Np;
+ if (_Np > 0)
+ _VSTD::memcpy(static_cast<void*>(__end2), static_cast<void const*>(__begin1), _Np * sizeof(_Tp));
+}
+
+struct __destruct_n
+{
+private:
+ size_t __size_;
+
+ template <class _Tp>
+ _LIBCPP_INLINE_VISIBILITY void __process(_Tp* __p, false_type) _NOEXCEPT
+ {for (size_t __i = 0; __i < __size_; ++__i, ++__p) __p->~_Tp();}
+
+ template <class _Tp>
+ _LIBCPP_INLINE_VISIBILITY void __process(_Tp*, true_type) _NOEXCEPT
+ {}
+
+ _LIBCPP_INLINE_VISIBILITY void __incr(false_type) _NOEXCEPT
+ {++__size_;}
+ _LIBCPP_INLINE_VISIBILITY void __incr(true_type) _NOEXCEPT
+ {}
+
+ _LIBCPP_INLINE_VISIBILITY void __set(size_t __s, false_type) _NOEXCEPT
+ {__size_ = __s;}
+ _LIBCPP_INLINE_VISIBILITY void __set(size_t, true_type) _NOEXCEPT
+ {}
+public:
+ _LIBCPP_INLINE_VISIBILITY explicit __destruct_n(size_t __s) _NOEXCEPT
+ : __size_(__s) {}
+
+ template <class _Tp>
+ _LIBCPP_INLINE_VISIBILITY void __incr() _NOEXCEPT
+ {__incr(integral_constant<bool, is_trivially_destructible<_Tp>::value>());}
+
+ template <class _Tp>
+ _LIBCPP_INLINE_VISIBILITY void __set(size_t __s, _Tp*) _NOEXCEPT
+ {__set(__s, integral_constant<bool, is_trivially_destructible<_Tp>::value>());}
+
+ template <class _Tp>
+ _LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __p) _NOEXCEPT
+ {__process(__p, integral_constant<bool, is_trivially_destructible<_Tp>::value>());}
+};
+
+_LIBCPP_FUNC_VIS void* align(size_t __align, size_t __sz, void*& __ptr, size_t& __space);
+
+// --- Helper for container swap --
+template <typename _Alloc>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+void __swap_allocator(_Alloc & __a1, _Alloc & __a2, true_type)
+#if _LIBCPP_STD_VER > 11
+ _NOEXCEPT
+#else
+ _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value)
+#endif
+{
+ using _VSTD::swap;
+ swap(__a1, __a2);
+}
+
+template <typename _Alloc>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+void __swap_allocator(_Alloc &, _Alloc &, false_type) _NOEXCEPT {}
+
+template <typename _Alloc>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+void __swap_allocator(_Alloc & __a1, _Alloc & __a2)
+#if _LIBCPP_STD_VER > 11
+ _NOEXCEPT
+#else
+ _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value)
+#endif
+{
+ _VSTD::__swap_allocator(__a1, __a2,
+ integral_constant<bool, allocator_traits<_Alloc>::propagate_on_container_swap::value>());
+}
+
+template <typename _Alloc, typename _Traits=allocator_traits<_Alloc> >
+struct __noexcept_move_assign_container : public integral_constant<bool,
+ _Traits::propagate_on_container_move_assignment::value
+#if _LIBCPP_STD_VER > 14
+ || _Traits::is_always_equal::value
+#else
+ && is_nothrow_move_assignable<_Alloc>::value
+#endif
+ > {};
+
+
+template <class _Tp, class _Alloc>
+struct __temp_value {
+ typedef allocator_traits<_Alloc> _Traits;
+
+ typename aligned_storage<sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)>::type __v;
+ _Alloc &__a;
+
+ _Tp *__addr() { return reinterpret_cast<_Tp *>(addressof(__v)); }
+ _Tp & get() { return *__addr(); }
+
+ template<class... _Args>
+ _LIBCPP_NO_CFI
+ __temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc) {
+ _Traits::construct(__a, reinterpret_cast<_Tp*>(addressof(__v)),
+ _VSTD::forward<_Args>(__args)...);
+ }
+
+ ~__temp_value() { _Traits::destroy(__a, __addr()); }
+ };
+
+template<typename _Alloc, typename = void, typename = void>
+struct __is_allocator : false_type {};
+
+template<typename _Alloc>
+struct __is_allocator<_Alloc,
+ typename __void_t<typename _Alloc::value_type>::type,
+ typename __void_t<decltype(declval<_Alloc&>().allocate(size_t(0)))>::type
+ >
+ : true_type {};
+
+// __builtin_new_allocator -- A non-templated helper for allocating and
+// deallocating memory using __builtin_operator_new and
+// __builtin_operator_delete. It should be used in preference to
+// `std::allocator<T>` to avoid additional instantiations.
+struct __builtin_new_allocator {
+ struct __builtin_new_deleter {
+ typedef void* pointer_type;
+
+ _LIBCPP_CONSTEXPR explicit __builtin_new_deleter(size_t __size, size_t __align)
+ : __size_(__size), __align_(__align) {}
+
+ void operator()(void* p) const _NOEXCEPT {
+ _VSTD::__libcpp_deallocate(p, __size_, __align_);
+ }
+
+ private:
+ size_t __size_;
+ size_t __align_;
+ };
+
+ typedef unique_ptr<void, __builtin_new_deleter> __holder_t;
+
+ static __holder_t __allocate_bytes(size_t __s, size_t __align) {
+ return __holder_t(_VSTD::__libcpp_allocate(__s, __align),
+ __builtin_new_deleter(__s, __align));
+ }
+
+ static void __deallocate_bytes(void* __p, size_t __s,
+ size_t __align) _NOEXCEPT {
+ _VSTD::__libcpp_deallocate(__p, __s, __align);
+ }
+
+ template <class _Tp>
+ _LIBCPP_NODEBUG _LIBCPP_ALWAYS_INLINE
+ static __holder_t __allocate_type(size_t __n) {
+ return __allocate_bytes(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));
+ }
+
+ template <class _Tp>
+ _LIBCPP_NODEBUG _LIBCPP_ALWAYS_INLINE
+ static void __deallocate_type(void* __p, size_t __n) _NOEXCEPT {
+ __deallocate_bytes(__p, __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));
+ }
+};
+
+
+_LIBCPP_END_NAMESPACE_STD
+
+#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
+//# include <__pstl_memory>
+#endif
+
+#endif // _LIBCPP_MEMORY
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/mutex b/contrib/libs/cxxsupp/libcxxmsvc/include/mutex
new file mode 100644
index 0000000000..1093f55433
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/mutex
@@ -0,0 +1,730 @@
+// -*- 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_MUTEX
+#define _LIBCPP_MUTEX
+
+/*
+ mutex synopsis
+
+namespace std
+{
+
+class mutex
+{
+public:
+ constexpr mutex() noexcept;
+ ~mutex();
+
+ mutex(const mutex&) = delete;
+ mutex& operator=(const mutex&) = delete;
+
+ void lock();
+ bool try_lock();
+ void unlock();
+
+ typedef pthread_mutex_t* native_handle_type;
+ native_handle_type native_handle();
+};
+
+class recursive_mutex
+{
+public:
+ recursive_mutex();
+ ~recursive_mutex();
+
+ recursive_mutex(const recursive_mutex&) = delete;
+ recursive_mutex& operator=(const recursive_mutex&) = delete;
+
+ void lock();
+ bool try_lock() noexcept;
+ void unlock();
+
+ typedef pthread_mutex_t* native_handle_type;
+ native_handle_type native_handle();
+};
+
+class timed_mutex
+{
+public:
+ timed_mutex();
+ ~timed_mutex();
+
+ timed_mutex(const timed_mutex&) = delete;
+ timed_mutex& operator=(const timed_mutex&) = delete;
+
+ void lock();
+ bool try_lock();
+ template <class Rep, class Period>
+ bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+ template <class Clock, class Duration>
+ bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+ void unlock();
+};
+
+class recursive_timed_mutex
+{
+public:
+ recursive_timed_mutex();
+ ~recursive_timed_mutex();
+
+ recursive_timed_mutex(const recursive_timed_mutex&) = delete;
+ recursive_timed_mutex& operator=(const recursive_timed_mutex&) = delete;
+
+ void lock();
+ bool try_lock() noexcept;
+ template <class Rep, class Period>
+ bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+ template <class Clock, class Duration>
+ bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+ void unlock();
+};
+
+struct defer_lock_t { explicit defer_lock_t() = default; };
+struct try_to_lock_t { explicit try_to_lock_t() = default; };
+struct adopt_lock_t { explicit adopt_lock_t() = default; };
+
+inline constexpr defer_lock_t defer_lock{};
+inline constexpr try_to_lock_t try_to_lock{};
+inline constexpr adopt_lock_t adopt_lock{};
+
+template <class Mutex>
+class lock_guard
+{
+public:
+ typedef Mutex mutex_type;
+
+ explicit lock_guard(mutex_type& m);
+ lock_guard(mutex_type& m, adopt_lock_t);
+ ~lock_guard();
+
+ lock_guard(lock_guard const&) = delete;
+ lock_guard& operator=(lock_guard const&) = delete;
+};
+
+template <class... MutexTypes>
+class scoped_lock // C++17
+{
+public:
+ using mutex_type = Mutex; // Only if sizeof...(MutexTypes) == 1
+
+ explicit scoped_lock(MutexTypes&... m);
+ scoped_lock(adopt_lock_t, MutexTypes&... m);
+ ~scoped_lock();
+ scoped_lock(scoped_lock const&) = delete;
+ scoped_lock& operator=(scoped_lock const&) = delete;
+private:
+ tuple<MutexTypes&...> pm; // exposition only
+};
+
+template <class Mutex>
+class unique_lock
+{
+public:
+ typedef Mutex mutex_type;
+ unique_lock() noexcept;
+ explicit unique_lock(mutex_type& m);
+ unique_lock(mutex_type& m, defer_lock_t) noexcept;
+ unique_lock(mutex_type& m, try_to_lock_t);
+ unique_lock(mutex_type& m, adopt_lock_t);
+ template <class Clock, class Duration>
+ unique_lock(mutex_type& m, const chrono::time_point<Clock, Duration>& abs_time);
+ template <class Rep, class Period>
+ unique_lock(mutex_type& m, const chrono::duration<Rep, Period>& rel_time);
+ ~unique_lock();
+
+ unique_lock(unique_lock const&) = delete;
+ unique_lock& operator=(unique_lock const&) = delete;
+
+ unique_lock(unique_lock&& u) noexcept;
+ unique_lock& operator=(unique_lock&& u) noexcept;
+
+ void lock();
+ bool try_lock();
+
+ template <class Rep, class Period>
+ bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+ template <class Clock, class Duration>
+ bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+ void unlock();
+
+ void swap(unique_lock& u) noexcept;
+ mutex_type* release() noexcept;
+
+ bool owns_lock() const noexcept;
+ explicit operator bool () const noexcept;
+ mutex_type* mutex() const noexcept;
+};
+
+template <class Mutex>
+ void swap(unique_lock<Mutex>& x, unique_lock<Mutex>& y) noexcept;
+
+template <class L1, class L2, class... L3>
+ int try_lock(L1&, L2&, L3&...);
+template <class L1, class L2, class... L3>
+ void lock(L1&, L2&, L3&...);
+
+struct once_flag
+{
+ constexpr once_flag() noexcept;
+
+ once_flag(const once_flag&) = delete;
+ once_flag& operator=(const once_flag&) = delete;
+};
+
+template<class Callable, class ...Args>
+ void call_once(once_flag& flag, Callable&& func, Args&&... args);
+
+} // std
+
+*/
+
+#include <__config>
+#include <__mutex_base>
+#include <__threading_support>
+#include <__utility/forward.h>
+#include <cstdint>
+#include <functional>
+#include <memory>
+#ifndef _LIBCPP_CXX03_LANG
+# include <tuple>
+#endif
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_CXX03_LANG)
+#include <atomic>
+#endif
+
+#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_HAS_NO_THREADS
+
+class _LIBCPP_TYPE_VIS recursive_mutex
+{
+ __libcpp_recursive_mutex_t __m_;
+
+public:
+ recursive_mutex();
+ ~recursive_mutex();
+
+ recursive_mutex(const recursive_mutex&) = delete;
+ recursive_mutex& operator=(const recursive_mutex&) = delete;
+
+ void lock();
+ bool try_lock() _NOEXCEPT;
+ void unlock() _NOEXCEPT;
+
+ typedef __libcpp_recursive_mutex_t* native_handle_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ native_handle_type native_handle() {return &__m_;}
+};
+
+class _LIBCPP_TYPE_VIS timed_mutex
+{
+ mutex __m_;
+ condition_variable __cv_;
+ bool __locked_;
+public:
+ timed_mutex();
+ ~timed_mutex();
+
+ timed_mutex(const timed_mutex&) = delete;
+ timed_mutex& operator=(const timed_mutex&) = delete;
+
+public:
+ void lock();
+ bool try_lock() _NOEXCEPT;
+ template <class _Rep, class _Period>
+ _LIBCPP_INLINE_VISIBILITY
+ bool try_lock_for(const chrono::duration<_Rep, _Period>& __d)
+ {return try_lock_until(chrono::steady_clock::now() + __d);}
+ template <class _Clock, class _Duration>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t);
+ void unlock() _NOEXCEPT;
+};
+
+template <class _Clock, class _Duration>
+bool
+timed_mutex::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t)
+{
+ using namespace chrono;
+ unique_lock<mutex> __lk(__m_);
+ bool no_timeout = _Clock::now() < __t;
+ while (no_timeout && __locked_)
+ no_timeout = __cv_.wait_until(__lk, __t) == cv_status::no_timeout;
+ if (!__locked_)
+ {
+ __locked_ = true;
+ return true;
+ }
+ return false;
+}
+
+class _LIBCPP_TYPE_VIS recursive_timed_mutex
+{
+ mutex __m_;
+ condition_variable __cv_;
+ size_t __count_;
+ __thread_id __id_;
+public:
+ recursive_timed_mutex();
+ ~recursive_timed_mutex();
+
+ recursive_timed_mutex(const recursive_timed_mutex&) = delete;
+ recursive_timed_mutex& operator=(const recursive_timed_mutex&) = delete;
+
+ void lock();
+ bool try_lock() _NOEXCEPT;
+ template <class _Rep, class _Period>
+ _LIBCPP_INLINE_VISIBILITY
+ bool try_lock_for(const chrono::duration<_Rep, _Period>& __d)
+ {return try_lock_until(chrono::steady_clock::now() + __d);}
+ template <class _Clock, class _Duration>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t);
+ void unlock() _NOEXCEPT;
+};
+
+template <class _Clock, class _Duration>
+bool
+recursive_timed_mutex::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t)
+{
+ using namespace chrono;
+ __thread_id __id = this_thread::get_id();
+ unique_lock<mutex> lk(__m_);
+ if (__id == __id_)
+ {
+ if (__count_ == numeric_limits<size_t>::max())
+ return false;
+ ++__count_;
+ return true;
+ }
+ bool no_timeout = _Clock::now() < __t;
+ while (no_timeout && __count_ != 0)
+ no_timeout = __cv_.wait_until(lk, __t) == cv_status::no_timeout;
+ if (__count_ == 0)
+ {
+ __count_ = 1;
+ __id_ = __id;
+ return true;
+ }
+ return false;
+}
+
+template <class _L0, class _L1>
+int
+try_lock(_L0& __l0, _L1& __l1)
+{
+ unique_lock<_L0> __u0(__l0, try_to_lock);
+ if (__u0.owns_lock())
+ {
+ if (__l1.try_lock())
+ {
+ __u0.release();
+ return -1;
+ }
+ else
+ return 1;
+ }
+ return 0;
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _L0, class _L1, class _L2, class... _L3>
+int
+try_lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3)
+{
+ int __r = 0;
+ unique_lock<_L0> __u0(__l0, try_to_lock);
+ if (__u0.owns_lock())
+ {
+ __r = try_lock(__l1, __l2, __l3...);
+ if (__r == -1)
+ __u0.release();
+ else
+ ++__r;
+ }
+ return __r;
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _L0, class _L1>
+void
+lock(_L0& __l0, _L1& __l1)
+{
+ while (true)
+ {
+ {
+ unique_lock<_L0> __u0(__l0);
+ if (__l1.try_lock())
+ {
+ __u0.release();
+ break;
+ }
+ }
+ __libcpp_thread_yield();
+ {
+ unique_lock<_L1> __u1(__l1);
+ if (__l0.try_lock())
+ {
+ __u1.release();
+ break;
+ }
+ }
+ __libcpp_thread_yield();
+ }
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _L0, class _L1, class _L2, class ..._L3>
+void
+__lock_first(int __i, _L0& __l0, _L1& __l1, _L2& __l2, _L3& ...__l3)
+{
+ while (true)
+ {
+ switch (__i)
+ {
+ case 0:
+ {
+ unique_lock<_L0> __u0(__l0);
+ __i = try_lock(__l1, __l2, __l3...);
+ if (__i == -1)
+ {
+ __u0.release();
+ return;
+ }
+ }
+ ++__i;
+ __libcpp_thread_yield();
+ break;
+ case 1:
+ {
+ unique_lock<_L1> __u1(__l1);
+ __i = try_lock(__l2, __l3..., __l0);
+ if (__i == -1)
+ {
+ __u1.release();
+ return;
+ }
+ }
+ if (__i == sizeof...(_L3) + 1)
+ __i = 0;
+ else
+ __i += 2;
+ __libcpp_thread_yield();
+ break;
+ default:
+ __lock_first(__i - 2, __l2, __l3..., __l0, __l1);
+ return;
+ }
+ }
+}
+
+template <class _L0, class _L1, class _L2, class ..._L3>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3& ...__l3)
+{
+ __lock_first(0, __l0, __l1, __l2, __l3...);
+}
+
+template <class _L0>
+inline _LIBCPP_INLINE_VISIBILITY
+void __unlock(_L0& __l0) {
+ __l0.unlock();
+}
+
+template <class _L0, class _L1>
+inline _LIBCPP_INLINE_VISIBILITY
+void __unlock(_L0& __l0, _L1& __l1) {
+ __l0.unlock();
+ __l1.unlock();
+}
+
+template <class _L0, class _L1, class _L2, class ..._L3>
+inline _LIBCPP_INLINE_VISIBILITY
+void __unlock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) {
+ __l0.unlock();
+ __l1.unlock();
+ _VSTD::__unlock(__l2, __l3...);
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+#if _LIBCPP_STD_VER > 14
+template <class ..._Mutexes>
+class _LIBCPP_TEMPLATE_VIS scoped_lock;
+
+template <>
+class _LIBCPP_TEMPLATE_VIS scoped_lock<> {
+public:
+ explicit scoped_lock() {}
+ ~scoped_lock() = default;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit scoped_lock(adopt_lock_t) {}
+
+ scoped_lock(scoped_lock const&) = delete;
+ scoped_lock& operator=(scoped_lock const&) = delete;
+};
+
+template <class _Mutex>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(scoped_lockable) scoped_lock<_Mutex> {
+public:
+ typedef _Mutex mutex_type;
+private:
+ mutex_type& __m_;
+public:
+ explicit scoped_lock(mutex_type & __m) _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability(__m))
+ : __m_(__m) {__m_.lock();}
+
+ ~scoped_lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) {__m_.unlock();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit scoped_lock(adopt_lock_t, mutex_type& __m) _LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m))
+ : __m_(__m) {}
+
+ scoped_lock(scoped_lock const&) = delete;
+ scoped_lock& operator=(scoped_lock const&) = delete;
+};
+
+template <class ..._MArgs>
+class _LIBCPP_TEMPLATE_VIS scoped_lock
+{
+ static_assert(sizeof...(_MArgs) > 1, "At least 2 lock types required");
+ typedef tuple<_MArgs&...> _MutexTuple;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit scoped_lock(_MArgs&... __margs)
+ : __t_(__margs...)
+ {
+ _VSTD::lock(__margs...);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ scoped_lock(adopt_lock_t, _MArgs&... __margs)
+ : __t_(__margs...)
+ {
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ ~scoped_lock() {
+ typedef typename __make_tuple_indices<sizeof...(_MArgs)>::type _Indices;
+ __unlock_unpack(_Indices{}, __t_);
+ }
+
+ scoped_lock(scoped_lock const&) = delete;
+ scoped_lock& operator=(scoped_lock const&) = delete;
+
+private:
+ template <size_t ..._Indx>
+ _LIBCPP_INLINE_VISIBILITY
+ static void __unlock_unpack(__tuple_indices<_Indx...>, _MutexTuple& __mt) {
+ _VSTD::__unlock(_VSTD::get<_Indx>(__mt)...);
+ }
+
+ _MutexTuple __t_;
+};
+
+#endif // _LIBCPP_STD_VER > 14
+#endif // !_LIBCPP_HAS_NO_THREADS
+
+struct _LIBCPP_TEMPLATE_VIS once_flag;
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template<class _Callable, class... _Args>
+_LIBCPP_INLINE_VISIBILITY
+void call_once(once_flag&, _Callable&&, _Args&&...);
+
+#else // _LIBCPP_CXX03_LANG
+
+template<class _Callable>
+_LIBCPP_INLINE_VISIBILITY
+void call_once(once_flag&, _Callable&);
+
+template<class _Callable>
+_LIBCPP_INLINE_VISIBILITY
+void call_once(once_flag&, const _Callable&);
+
+#endif // _LIBCPP_CXX03_LANG
+
+struct _LIBCPP_TEMPLATE_VIS once_flag
+{
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR
+ once_flag() _NOEXCEPT : __state_(0) {}
+ once_flag(const once_flag&) = delete;
+ once_flag& operator=(const once_flag&) = delete;
+
+#if defined(_LIBCPP_ABI_MICROSOFT)
+ typedef uintptr_t _State_type;
+#else
+ typedef unsigned long _State_type;
+#endif
+
+private:
+#if defined(_LIBCPP_ABI_MICROSOFT)
+ atomic<_State_type> __state_;
+#else
+ _State_type __state_;
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+ template<class _Callable, class... _Args>
+ friend
+ void call_once(once_flag&, _Callable&&, _Args&&...);
+#else // _LIBCPP_CXX03_LANG
+ template<class _Callable>
+ friend
+ void call_once(once_flag&, _Callable&);
+
+ template<class _Callable>
+ friend
+ void call_once(once_flag&, const _Callable&);
+#endif // _LIBCPP_CXX03_LANG
+};
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Fp>
+class __call_once_param
+{
+ _Fp& __f_;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __call_once_param(_Fp& __f) : __f_(__f) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void operator()()
+ {
+ typedef typename __make_tuple_indices<tuple_size<_Fp>::value, 1>::type _Index;
+ __execute(_Index());
+ }
+
+private:
+ template <size_t ..._Indices>
+ _LIBCPP_INLINE_VISIBILITY
+ void __execute(__tuple_indices<_Indices...>)
+ {
+ _VSTD::__invoke(_VSTD::get<0>(_VSTD::move(__f_)), _VSTD::get<_Indices>(_VSTD::move(__f_))...);
+ }
+};
+
+#else
+
+template <class _Fp>
+class __call_once_param
+{
+ _Fp& __f_;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __call_once_param(_Fp& __f) : __f_(__f) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void operator()()
+ {
+ __f_();
+ }
+};
+
+#endif
+
+template <class _Fp>
+void _LIBCPP_INLINE_VISIBILITY
+__call_once_proxy(void* __vp)
+{
+ __call_once_param<_Fp>* __p = static_cast<__call_once_param<_Fp>*>(__vp);
+ (*__p)();
+}
+
+#ifdef _LIBCPP_ABI_MICROSOFT
+_LIBCPP_FUNC_VIS void __call_once(volatile atomic<once_flag::_State_type>&, void*,
+ void (*)(void*));
+#else
+_LIBCPP_FUNC_VIS void __call_once(volatile once_flag::_State_type&, void*,
+ void (*)(void*));
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template<class _Callable, class... _Args>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+call_once(once_flag& __flag, _Callable&& __func, _Args&&... __args)
+{
+#if defined(_LIBCPP_ABI_MICROSOFT)
+ if (__flag.__state_.load(memory_order_acquire) != ~once_flag::_State_type(0))
+#else
+ if (__libcpp_acquire_load(&__flag.__state_) != ~once_flag::_State_type(0))
+#endif
+ {
+ typedef tuple<_Callable&&, _Args&&...> _Gp;
+ _Gp __f(_VSTD::forward<_Callable>(__func), _VSTD::forward<_Args>(__args)...);
+ __call_once_param<_Gp> __p(__f);
+ __call_once(__flag.__state_, &__p, &__call_once_proxy<_Gp>);
+ }
+}
+
+#else // _LIBCPP_CXX03_LANG
+
+template<class _Callable>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+call_once(once_flag& __flag, _Callable& __func)
+{
+#if defined(_LIBCPP_ABI_MICROSOFT)
+ if (__flag.__state_.load(memory_order_acquire) != ~once_flag::_State_type(0))
+#else
+ if (__libcpp_acquire_load(&__flag.__state_) != ~once_flag::_State_type(0))
+#endif
+ {
+ __call_once_param<_Callable> __p(__func);
+ __call_once(__flag.__state_, &__p, &__call_once_proxy<_Callable>);
+ }
+}
+
+template<class _Callable>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+call_once(once_flag& __flag, const _Callable& __func)
+{
+#if defined(_LIBCPP_ABI_MICROSOFT)
+ if (__flag.__state_.load(memory_order_relaxed) != ~once_flag::_State_type(0))
+#else
+ if (__flag.__state_ != ~once_flag::_State_type(0))
+#endif
+ {
+ __call_once_param<const _Callable> __p(__func);
+ __call_once(__flag.__state_, &__p, &__call_once_proxy<const _Callable>);
+ }
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_MUTEX
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/new b/contrib/libs/cxxsupp/libcxxmsvc/include/new
new file mode 100644
index 0000000000..0d8d43e8d3
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/new
@@ -0,0 +1,364 @@
+// -*- 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_NEW
+#define _LIBCPP_NEW
+
+/*
+ new synopsis
+
+namespace std
+{
+
+class bad_alloc
+ : public exception
+{
+public:
+ bad_alloc() noexcept;
+ bad_alloc(const bad_alloc&) noexcept;
+ bad_alloc& operator=(const bad_alloc&) noexcept;
+ virtual const char* what() const noexcept;
+};
+
+class bad_array_new_length : public bad_alloc // C++14
+{
+public:
+ bad_array_new_length() noexcept;
+};
+
+enum class align_val_t : size_t {}; // C++17
+
+struct destroying_delete_t { // C++20
+ explicit destroying_delete_t() = default;
+};
+inline constexpr destroying_delete_t destroying_delete{}; // C++20
+
+struct nothrow_t { explicit nothrow_t() = default; };
+extern const nothrow_t nothrow;
+typedef void (*new_handler)();
+new_handler set_new_handler(new_handler new_p) noexcept;
+new_handler get_new_handler() noexcept;
+
+// 21.6.4, pointer optimization barrier
+template <class T> constexpr T* launder(T* p) noexcept; // C++17
+} // std
+
+void* operator new(std::size_t size); // replaceable, nodiscard in C++20
+void* operator new(std::size_t size, std::align_val_t alignment); // replaceable, C++17, nodiscard in C++20
+void* operator new(std::size_t size, const std::nothrow_t&) noexcept; // replaceable, nodiscard in C++20
+void* operator new(std::size_t size, std::align_val_t alignment,
+ const std::nothrow_t&) noexcept; // replaceable, C++17, nodiscard in C++20
+void operator delete(void* ptr) noexcept; // replaceable
+void operator delete(void* ptr, std::size_t size) noexcept; // replaceable, C++14
+void operator delete(void* ptr, std::align_val_t alignment) noexcept; // replaceable, C++17
+void operator delete(void* ptr, std::size_t size,
+ std::align_val_t alignment) noexcept; // replaceable, C++17
+void operator delete(void* ptr, const std::nothrow_t&) noexcept; // replaceable
+void operator delete(void* ptr, std:align_val_t alignment,
+ const std::nothrow_t&) noexcept; // replaceable, C++17
+
+void* operator new[](std::size_t size); // replaceable, nodiscard in C++20
+void* operator new[](std::size_t size,
+ std::align_val_t alignment) noexcept; // replaceable, C++17, nodiscard in C++20
+void* operator new[](std::size_t size, const std::nothrow_t&) noexcept; // replaceable, nodiscard in C++20
+void* operator new[](std::size_t size, std::align_val_t alignment,
+ const std::nothrow_t&) noexcept; // replaceable, C++17, nodiscard in C++20
+void operator delete[](void* ptr) noexcept; // replaceable
+void operator delete[](void* ptr, std::size_t size) noexcept; // replaceable, C++14
+void operator delete[](void* ptr,
+ std::align_val_t alignment) noexcept; // replaceable, C++17
+void operator delete[](void* ptr, std::size_t size,
+ std::align_val_t alignment) noexcept; // replaceable, C++17
+void operator delete[](void* ptr, const std::nothrow_t&) noexcept; // replaceable
+void operator delete[](void* ptr, std::align_val_t alignment,
+ const std::nothrow_t&) noexcept; // replaceable, C++17
+
+void* operator new (std::size_t size, void* ptr) noexcept; // nodiscard in C++20
+void* operator new[](std::size_t size, void* ptr) noexcept; // nodiscard in C++20
+void operator delete (void* ptr, void*) noexcept;
+void operator delete[](void* ptr, void*) noexcept;
+
+*/
+
+#include <__availability>
+#include <__config>
+#include <cstddef>
+#include <cstdlib>
+#include <exception>
+#include <type_traits>
+#include <version>
+
+#if defined(_LIBCPP_ABI_VCRUNTIME)
+#include <new.h>
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if !defined(__cpp_sized_deallocation) || __cpp_sized_deallocation < 201309L
+#define _LIBCPP_HAS_NO_LANGUAGE_SIZED_DEALLOCATION
+#endif
+
+#if !defined(_LIBCPP_BUILDING_LIBRARY) && _LIBCPP_STD_VER < 14 && \
+ defined(_LIBCPP_HAS_NO_LANGUAGE_SIZED_DEALLOCATION)
+# define _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION
+#endif
+
+#if defined(_LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION) || \
+ defined(_LIBCPP_HAS_NO_LANGUAGE_SIZED_DEALLOCATION)
+# define _LIBCPP_HAS_NO_SIZED_DEALLOCATION
+#endif
+
+namespace std // purposefully not using versioning namespace
+{
+
+#if !defined(_LIBCPP_ABI_VCRUNTIME)
+struct _LIBCPP_TYPE_VIS nothrow_t { explicit nothrow_t() = default; };
+extern _LIBCPP_FUNC_VIS const nothrow_t nothrow;
+
+class _LIBCPP_EXCEPTION_ABI bad_alloc
+ : public exception
+{
+public:
+ bad_alloc() _NOEXCEPT;
+ virtual ~bad_alloc() _NOEXCEPT;
+ virtual const char* what() const _NOEXCEPT;
+};
+
+class _LIBCPP_EXCEPTION_ABI bad_array_new_length
+ : public bad_alloc
+{
+public:
+ bad_array_new_length() _NOEXCEPT;
+ virtual ~bad_array_new_length() _NOEXCEPT;
+ virtual const char* what() const _NOEXCEPT;
+};
+
+typedef void (*new_handler)();
+_LIBCPP_FUNC_VIS new_handler set_new_handler(new_handler) _NOEXCEPT;
+_LIBCPP_FUNC_VIS new_handler get_new_handler() _NOEXCEPT;
+
+#endif // !_LIBCPP_ABI_VCRUNTIME
+
+_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __throw_bad_alloc(); // not in C++ spec
+
+_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
+void __throw_bad_array_new_length()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw bad_array_new_length();
+#else
+ _VSTD::abort();
+#endif
+}
+
+#if !defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) && \
+ !defined(_LIBCPP_ABI_VCRUNTIME)
+#ifndef _LIBCPP_CXX03_LANG
+enum class _LIBCPP_ENUM_VIS align_val_t : size_t { };
+#else
+enum align_val_t { __zero = 0, __max = (size_t)-1 };
+#endif
+#endif
+
+#if _LIBCPP_STD_VER > 17
+// Enable the declaration even if the compiler doesn't support the language
+// feature.
+struct destroying_delete_t {
+ explicit destroying_delete_t() = default;
+};
+inline constexpr destroying_delete_t destroying_delete{};
+#endif // _LIBCPP_STD_VER > 17
+
+} // namespace std
+
+#if defined(_LIBCPP_CXX03_LANG)
+#define _THROW_BAD_ALLOC throw(std::bad_alloc)
+#else
+#define _THROW_BAD_ALLOC
+#endif
+
+#if !defined(_LIBCPP_ABI_VCRUNTIME)
+
+_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz) _THROW_BAD_ALLOC;
+_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS;
+_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p) _NOEXCEPT;
+_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT;
+#ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION
+_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE void operator delete(void* __p, std::size_t __sz) _NOEXCEPT;
+#endif
+
+_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz) _THROW_BAD_ALLOC;
+_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS;
+_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p) _NOEXCEPT;
+_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT;
+#ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION
+_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE void operator delete[](void* __p, std::size_t __sz) _NOEXCEPT;
+#endif
+
+#ifndef _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
+_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
+_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS;
+_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t) _NOEXCEPT;
+_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
+#ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION
+_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE void operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
+#endif
+
+_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
+_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS;
+_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t) _NOEXCEPT;
+_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
+#ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION
+_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE void operator delete[](void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
+#endif
+#endif
+
+_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY void* operator new (std::size_t, void* __p) _NOEXCEPT {return __p;}
+_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY void* operator new[](std::size_t, void* __p) _NOEXCEPT {return __p;}
+inline _LIBCPP_INLINE_VISIBILITY void operator delete (void*, void*) _NOEXCEPT {}
+inline _LIBCPP_INLINE_VISIBILITY void operator delete[](void*, void*) _NOEXCEPT {}
+
+#endif // !_LIBCPP_ABI_VCRUNTIME
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+_LIBCPP_CONSTEXPR inline _LIBCPP_INLINE_VISIBILITY bool __is_overaligned_for_new(size_t __align) _NOEXCEPT {
+#ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__
+ return __align > __STDCPP_DEFAULT_NEW_ALIGNMENT__;
+#else
+ return __align > alignment_of<max_align_t>::value;
+#endif
+}
+
+template <class ..._Args>
+_LIBCPP_INLINE_VISIBILITY
+void* __libcpp_operator_new(_Args ...__args) {
+#if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete)
+ return __builtin_operator_new(__args...);
+#else
+ return ::operator new(__args...);
+#endif
+}
+
+template <class ..._Args>
+_LIBCPP_INLINE_VISIBILITY
+void __libcpp_operator_delete(_Args ...__args) {
+#if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete)
+ __builtin_operator_delete(__args...);
+#else
+ ::operator delete(__args...);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void *__libcpp_allocate(size_t __size, size_t __align) {
+#ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
+ if (__is_overaligned_for_new(__align)) {
+ const align_val_t __align_val = static_cast<align_val_t>(__align);
+ return __libcpp_operator_new(__size, __align_val);
+ }
+#endif
+
+ (void)__align;
+ return __libcpp_operator_new(__size);
+}
+
+template <class ..._Args>
+_LIBCPP_INLINE_VISIBILITY
+void __do_deallocate_handle_size(void *__ptr, size_t __size, _Args ...__args) {
+#ifdef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
+ (void)__size;
+ return __libcpp_operator_delete(__ptr, __args...);
+#else
+ return __libcpp_operator_delete(__ptr, __size, __args...);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void __libcpp_deallocate(void* __ptr, size_t __size, size_t __align) {
+#if defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)
+ (void)__align;
+ return __do_deallocate_handle_size(__ptr, __size);
+#else
+ if (__is_overaligned_for_new(__align)) {
+ const align_val_t __align_val = static_cast<align_val_t>(__align);
+ return __do_deallocate_handle_size(__ptr, __size, __align_val);
+ } else {
+ return __do_deallocate_handle_size(__ptr, __size);
+ }
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY void __libcpp_deallocate_unsized(void* __ptr, size_t __align) {
+#if defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)
+ (void)__align;
+ return __libcpp_operator_delete(__ptr);
+#else
+ if (__is_overaligned_for_new(__align)) {
+ const align_val_t __align_val = static_cast<align_val_t>(__align);
+ return __libcpp_operator_delete(__ptr, __align_val);
+ } else {
+ return __libcpp_operator_delete(__ptr);
+ }
+#endif
+}
+
+#if !defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION)
+// Low-level helpers to call the aligned allocation and deallocation functions
+// on the target platform. This is used to implement libc++'s own memory
+// allocation routines -- if you need to allocate memory inside the library,
+// chances are that you want to use `__libcpp_allocate` instead.
+//
+// Returns the allocated memory, or `nullptr` on failure.
+inline _LIBCPP_INLINE_VISIBILITY
+void* __libcpp_aligned_alloc(std::size_t __alignment, std::size_t __size) {
+#if defined(_LIBCPP_MSVCRT_LIKE)
+ return ::_aligned_malloc(__size, __alignment);
+#else
+ void* __result = nullptr;
+ (void)::posix_memalign(&__result, __alignment, __size);
+ // If posix_memalign fails, __result is unmodified so we still return `nullptr`.
+ return __result;
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void __libcpp_aligned_free(void* __ptr) {
+#if defined(_LIBCPP_MSVCRT_LIKE)
+ ::_aligned_free(__ptr);
+#else
+ ::free(__ptr);
+#endif
+}
+#endif // !_LIBCPP_HAS_NO_ALIGNED_ALLOCATION
+
+
+template <class _Tp>
+_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_HIDE_FROM_ABI
+_LIBCPP_CONSTEXPR _Tp* __launder(_Tp* __p) _NOEXCEPT
+{
+ static_assert (!(is_function<_Tp>::value), "can't launder functions" );
+ static_assert (!(is_same<void, typename remove_cv<_Tp>::type>::value), "can't launder cv-void" );
+ return __builtin_launder(__p);
+}
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_HIDE_FROM_ABI
+constexpr _Tp* launder(_Tp* __p) noexcept
+{
+ return _VSTD::__launder(__p);
+}
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_NEW
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/numeric b/contrib/libs/cxxsupp/libcxxmsvc/include/numeric
new file mode 100644
index 0000000000..59ac45a761
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/numeric
@@ -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_NUMERIC
+#define _LIBCPP_NUMERIC
+
+/*
+ numeric synopsis
+
+namespace std
+{
+
+template <class InputIterator, class T>
+ constexpr T // constexpr since C++20
+ accumulate(InputIterator first, InputIterator last, T init);
+
+template <class InputIterator, class T, class BinaryOperation>
+ constexpr T // constexpr since C++20
+ accumulate(InputIterator first, InputIterator last, T init, BinaryOperation binary_op);
+
+template<class InputIterator>
+ constexpr typename iterator_traits<InputIterator>::value_type // constexpr since C++20
+ reduce(InputIterator first, InputIterator last); // C++17
+
+template<class InputIterator, class T>
+ constexpr T // constexpr since C++20
+ reduce(InputIterator first, InputIterator last, T init); // C++17
+
+template<class InputIterator, class T, class BinaryOperation>
+ constexpr T // constexpr since C++20
+ reduce(InputIterator first, InputIterator last, T init, BinaryOperation binary_op); // C++17
+
+template <class InputIterator1, class InputIterator2, class T>
+ constexpr T // constexpr since C++20
+ inner_product(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, T init);
+
+template <class InputIterator1, class InputIterator2, class T, class BinaryOperation1, class BinaryOperation2>
+ constexpr T // constexpr since C++20
+ inner_product(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
+ T init, BinaryOperation1 binary_op1, BinaryOperation2 binary_op2);
+
+
+template<class InputIterator1, class InputIterator2, class T>
+ constexpr T // constexpr since C++20
+ transform_reduce(InputIterator1 first1, InputIterator1 last1,
+ InputIterator2 first2, T init); // C++17
+
+template<class InputIterator1, class InputIterator2, class T, class BinaryOperation1, class BinaryOperation2>
+ constexpr T // constexpr since C++20
+ transform_reduce(InputIterator1 first1, InputIterator1 last1,
+ InputIterator2 first2, T init,
+ BinaryOperation1 binary_op1, BinaryOperation2 binary_op2); // C++17
+
+template<class InputIterator, class T, class BinaryOperation, class UnaryOperation>
+ constexpr T // constexpr since C++20
+ transform_reduce(InputIterator first, InputIterator last, T init,
+ BinaryOperation binary_op, UnaryOperation unary_op); // C++17
+
+template <class InputIterator, class OutputIterator>
+ constexpr OutputIterator // constexpr since C++20
+ partial_sum(InputIterator first, InputIterator last, OutputIterator result);
+
+template <class InputIterator, class OutputIterator, class BinaryOperation>
+ constexpr OutputIterator // constexpr since C++20
+ partial_sum(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op);
+
+template<class InputIterator, class OutputIterator, class T>
+ constexpr OutputIterator // constexpr since C++20
+ exclusive_scan(InputIterator first, InputIterator last,
+ OutputIterator result, T init); // C++17
+
+template<class InputIterator, class OutputIterator, class T, class BinaryOperation>
+ constexpr OutputIterator // constexpr since C++20
+ exclusive_scan(InputIterator first, InputIterator last,
+ OutputIterator result, T init, BinaryOperation binary_op); // C++17
+
+template<class InputIterator, class OutputIterator>
+ constexpr OutputIterator // constexpr since C++20
+ inclusive_scan(InputIterator first, InputIterator last, OutputIterator result); // C++17
+
+template<class InputIterator, class OutputIterator, class BinaryOperation>
+ constexpr OutputIterator // constexpr since C++20
+ inclusive_scan(InputIterator first, InputIterator last,
+ OutputIterator result, BinaryOperation binary_op); // C++17
+
+template<class InputIterator, class OutputIterator, class BinaryOperation, class T>
+ constexpr OutputIterator // constexpr since C++20
+ inclusive_scan(InputIterator first, InputIterator last,
+ OutputIterator result, BinaryOperation binary_op, T init); // C++17
+
+template<class InputIterator, class OutputIterator, class T,
+ class BinaryOperation, class UnaryOperation>
+ constexpr OutputIterator // constexpr since C++20
+ transform_exclusive_scan(InputIterator first, InputIterator last,
+ OutputIterator result, T init,
+ BinaryOperation binary_op, UnaryOperation unary_op); // C++17
+
+template<class InputIterator, class OutputIterator,
+ class BinaryOperation, class UnaryOperation>
+ constexpr OutputIterator // constexpr since C++20
+ transform_inclusive_scan(InputIterator first, InputIterator last,
+ OutputIterator result,
+ BinaryOperation binary_op, UnaryOperation unary_op); // C++17
+
+template<class InputIterator, class OutputIterator,
+ class BinaryOperation, class UnaryOperation, class T>
+ constexpr OutputIterator // constexpr since C++20
+ transform_inclusive_scan(InputIterator first, InputIterator last,
+ OutputIterator result,
+ BinaryOperation binary_op, UnaryOperation unary_op,
+ T init); // C++17
+
+template <class InputIterator, class OutputIterator>
+ constexpr OutputIterator // constexpr since C++20
+ adjacent_difference(InputIterator first, InputIterator last, OutputIterator result);
+
+template <class InputIterator, class OutputIterator, class BinaryOperation>
+ constexpr OutputIterator // constexpr since C++20
+ adjacent_difference(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op);
+
+template <class ForwardIterator, class T>
+ constexpr void // constexpr since C++20
+ iota(ForwardIterator first, ForwardIterator last, T value);
+
+template <class M, class N>
+ constexpr common_type_t<M,N> gcd(M m, N n); // C++17
+
+template <class M, class N>
+ constexpr common_type_t<M,N> lcm(M m, N n); // C++17
+
+template<class T>
+ constexpr T midpoint(T a, T b) noexcept; // C++20
+
+template<class T>
+ constexpr T* midpoint(T* a, T* b); // C++20
+
+} // std
+
+*/
+
+#include <__config>
+#include <cmath> // for isnormal
+#include <functional>
+#include <iterator>
+#include <version>
+
+#include <__numeric/accumulate.h>
+#include <__numeric/adjacent_difference.h>
+#include <__numeric/exclusive_scan.h>
+#include <__numeric/gcd_lcm.h>
+#include <__numeric/inclusive_scan.h>
+#include <__numeric/inner_product.h>
+#include <__numeric/iota.h>
+#include <__numeric/midpoint.h>
+#include <__numeric/partial_sum.h>
+#include <__numeric/reduce.h>
+#include <__numeric/transform_exclusive_scan.h>
+#include <__numeric/transform_inclusive_scan.h>
+#include <__numeric/transform_reduce.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
+// # include <__pstl_numeric>
+#endif
+
+#endif // _LIBCPP_NUMERIC
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/optional b/contrib/libs/cxxsupp/libcxxmsvc/include/optional
new file mode 100644
index 0000000000..fd17b0821a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/optional
@@ -0,0 +1,1566 @@
+// -*- 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_OPTIONAL
+#define _LIBCPP_OPTIONAL
+
+/*
+ optional synopsis
+
+// C++1z
+
+namespace std {
+ // 23.6.3, optional for object types
+ template <class T> class optional;
+
+ // 23.6.4, no-value state indicator
+ struct nullopt_t{see below };
+ inline constexpr nullopt_t nullopt(unspecified );
+
+ // 23.6.5, class bad_optional_access
+ class bad_optional_access;
+
+ // 23.6.6, relational operators
+ template <class T, class U>
+ constexpr bool operator==(const optional<T>&, const optional<U>&);
+ template <class T, class U>
+ constexpr bool operator!=(const optional<T>&, const optional<U>&);
+ template <class T, class U>
+ constexpr bool operator<(const optional<T>&, const optional<U>&);
+ template <class T, class U>
+ constexpr bool operator>(const optional<T>&, const optional<U>&);
+ template <class T, class U>
+ constexpr bool operator<=(const optional<T>&, const optional<U>&);
+ template <class T, class U>
+ constexpr bool operator>=(const optional<T>&, const optional<U>&);
+
+ // 23.6.7 comparison with nullopt
+ template <class T> constexpr bool operator==(const optional<T>&, nullopt_t) noexcept;
+ template <class T> constexpr bool operator==(nullopt_t, const optional<T>&) noexcept;
+ template <class T> constexpr bool operator!=(const optional<T>&, nullopt_t) noexcept;
+ template <class T> constexpr bool operator!=(nullopt_t, const optional<T>&) noexcept;
+ template <class T> constexpr bool operator<(const optional<T>&, nullopt_t) noexcept;
+ template <class T> constexpr bool operator<(nullopt_t, const optional<T>&) noexcept;
+ template <class T> constexpr bool operator<=(const optional<T>&, nullopt_t) noexcept;
+ template <class T> constexpr bool operator<=(nullopt_t, const optional<T>&) noexcept;
+ template <class T> constexpr bool operator>(const optional<T>&, nullopt_t) noexcept;
+ template <class T> constexpr bool operator>(nullopt_t, const optional<T>&) noexcept;
+ template <class T> constexpr bool operator>=(const optional<T>&, nullopt_t) noexcept;
+ template <class T> constexpr bool operator>=(nullopt_t, const optional<T>&) noexcept;
+
+ // 23.6.8, comparison with T
+ template <class T, class U> constexpr bool operator==(const optional<T>&, const U&);
+ template <class T, class U> constexpr bool operator==(const T&, const optional<U>&);
+ template <class T, class U> constexpr bool operator!=(const optional<T>&, const U&);
+ template <class T, class U> constexpr bool operator!=(const T&, const optional<U>&);
+ template <class T, class U> constexpr bool operator<(const optional<T>&, const U&);
+ template <class T, class U> constexpr bool operator<(const T&, const optional<U>&);
+ template <class T, class U> constexpr bool operator<=(const optional<T>&, const U&);
+ template <class T, class U> constexpr bool operator<=(const T&, const optional<U>&);
+ template <class T, class U> constexpr bool operator>(const optional<T>&, const U&);
+ template <class T, class U> constexpr bool operator>(const T&, const optional<U>&);
+ template <class T, class U> constexpr bool operator>=(const optional<T>&, const U&);
+ 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 ); // 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);
+ template <class T, class U, class... Args>
+ constexpr optional<T> make_optional(initializer_list<U> il, Args&&... args);
+
+ // 23.6.10, hash support
+ template <class T> struct hash;
+ template <class T> struct hash<optional<T>>;
+
+ template <class T> class optional {
+ public:
+ using value_type = T;
+
+ // 23.6.3.1, constructors
+ constexpr optional() noexcept;
+ constexpr optional(nullopt_t) noexcept;
+ optional(const optional &);
+ optional(optional &&) noexcept(see below);
+ template <class... Args> constexpr explicit optional(in_place_t, Args &&...);
+ template <class U, class... Args>
+ constexpr explicit optional(in_place_t, initializer_list<U>, Args &&...);
+ template <class U = T>
+ constexpr EXPLICIT optional(U &&);
+ template <class U>
+ EXPLICIT optional(const optional<U> &); // constexpr in C++20
+ template <class U>
+ EXPLICIT optional(optional<U> &&); // constexpr in C++20
+
+ // 23.6.3.2, destructor
+ ~optional(); // constexpr in C++20
+
+ // 23.6.3.3, assignment
+ 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 &&...); // constexpr in C++20
+
+ // 23.6.3.4, swap
+ void swap(optional &) noexcept(see below ); // constexpr in C++20
+
+ // 23.6.3.5, observers
+ constexpr T const *operator->() const;
+ constexpr T *operator->();
+ constexpr T const &operator*() const &;
+ constexpr T &operator*() &;
+ constexpr T &&operator*() &&;
+ constexpr const T &&operator*() const &&;
+ constexpr explicit operator bool() const noexcept;
+ constexpr bool has_value() const noexcept;
+ constexpr T const &value() const &;
+ constexpr T &value() &;
+ constexpr T &&value() &&;
+ constexpr const T &&value() const &&;
+ template <class U> constexpr T value_or(U &&) const &;
+ template <class U> constexpr T value_or(U &&) &&;
+
+ // [optional.monadic], monadic operations
+ template<class F> constexpr auto and_then(F&& f) &; // since C++23
+ template<class F> constexpr auto and_then(F&& f) &&; // since C++23
+ template<class F> constexpr auto and_then(F&& f) const&; // since C++23
+ template<class F> constexpr auto and_then(F&& f) const&&; // since C++23
+ template<class F> constexpr auto transform(F&& f) &; // since C++23
+ template<class F> constexpr auto transform(F&& f) &&; // since C++23
+ template<class F> constexpr auto transform(F&& f) const&; // since C++23
+ template<class F> constexpr auto transform(F&& f) const&&; // since C++23
+ template<class F> constexpr optional or_else(F&& f) &&; // since C++23
+ template<class F> constexpr optional or_else(F&& f) const&; // since C++23
+
+ // 23.6.3.6, modifiers
+ void reset() noexcept; // constexpr in C++20
+
+ private:
+ T *val; // exposition only
+ };
+
+template<class T>
+ optional(T) -> optional<T>;
+
+} // namespace std
+
+*/
+
+#include <__assert>
+#include <__availability>
+#include <__concepts/invocable.h>
+#include <__config>
+#include <compare>
+#include <functional>
+#include <initializer_list>
+#include <new>
+#include <stdexcept>
+#include <type_traits>
+#include <utility>
+#include <version>
+
+// TODO: remove these headers
+#include <__memory/allocator_arg_t.h>
+#include <__memory/uses_allocator.h>
+#include <typeinfo>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+namespace std // purposefully not using versioning namespace
+{
+
+class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optional_access
+ : public exception
+{
+public:
+ // Get the key function ~bad_optional_access() into the dylib
+ virtual ~bad_optional_access() _NOEXCEPT;
+ virtual const char* what() const _NOEXCEPT;
+};
+
+} // namespace std
+
+#if _LIBCPP_STD_VER > 14
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+_LIBCPP_NORETURN
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
+void __throw_bad_optional_access() {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw bad_optional_access();
+#else
+ _VSTD::abort();
+#endif
+}
+
+struct nullopt_t
+{
+ struct __secret_tag { _LIBCPP_INLINE_VISIBILITY explicit __secret_tag() = default; };
+ _LIBCPP_INLINE_VISIBILITY constexpr explicit nullopt_t(__secret_tag, __secret_tag) noexcept {}
+};
+
+inline constexpr nullopt_t nullopt{nullopt_t::__secret_tag{}, nullopt_t::__secret_tag{}};
+
+struct __optional_construct_from_invoke_tag {};
+
+template <class _Tp, bool = is_trivially_destructible<_Tp>::value>
+struct __optional_destruct_base;
+
+template <class _Tp>
+struct __optional_destruct_base<_Tp, false>
+{
+ typedef _Tp value_type;
+ static_assert(is_object_v<value_type>,
+ "instantiation of optional with a non-object type is undefined behavior");
+ union
+ {
+ char __null_state_;
+ value_type __val_;
+ };
+ bool __engaged_;
+
+ _LIBCPP_INLINE_VISIBILITY
+ /* _LIBCPP_CONSTEXPR_AFTER_CXX17 */ ~__optional_destruct_base()
+ {
+ if (__engaged_)
+ __val_.~value_type();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr __optional_destruct_base() noexcept
+ : __null_state_(),
+ __engaged_(false) {}
+
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr explicit __optional_destruct_base(in_place_t, _Args&&... __args)
+ : __val_(_VSTD::forward<_Args>(__args)...),
+ __engaged_(true) {}
+
+#if _LIBCPP_STD_VER > 20
+ template <class _Fp, class... _Args>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __optional_destruct_base(__optional_construct_from_invoke_tag, _Fp&& __f, _Args&&... __args)
+ : __val_(_VSTD::invoke(_VSTD::forward<_Fp>(__f), _VSTD::forward<_Args>(__args)...)), __engaged_(true) {}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void reset() noexcept
+ {
+ if (__engaged_)
+ {
+ __val_.~value_type();
+ __engaged_ = false;
+ }
+ }
+};
+
+template <class _Tp>
+struct __optional_destruct_base<_Tp, true>
+{
+ typedef _Tp value_type;
+ static_assert(is_object_v<value_type>,
+ "instantiation of optional with a non-object type is undefined behavior");
+ union
+ {
+ char __null_state_;
+ value_type __val_;
+ };
+ bool __engaged_;
+
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr __optional_destruct_base() noexcept
+ : __null_state_(),
+ __engaged_(false) {}
+
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr explicit __optional_destruct_base(in_place_t, _Args&&... __args)
+ : __val_(_VSTD::forward<_Args>(__args)...),
+ __engaged_(true) {}
+
+#if _LIBCPP_STD_VER > 20
+ template <class _Fp, class... _Args>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __optional_destruct_base(__optional_construct_from_invoke_tag, _Fp&& __f, _Args&&... __args)
+ : __val_(_VSTD::invoke(_VSTD::forward<_Fp>(__f), _VSTD::forward<_Args>(__args)...)), __engaged_(true) {}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void reset() noexcept
+ {
+ if (__engaged_)
+ {
+ __engaged_ = false;
+ }
+ }
+};
+
+template <class _Tp, bool = is_reference<_Tp>::value>
+struct __optional_storage_base : __optional_destruct_base<_Tp>
+{
+ using __base = __optional_destruct_base<_Tp>;
+ using value_type = _Tp;
+ using __base::__base;
+
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr bool has_value() const noexcept
+ {
+ return this->__engaged_;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr value_type& __get() & noexcept
+ {
+ return this->__val_;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr const value_type& __get() const& noexcept
+ {
+ return this->__val_;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr value_type&& __get() && noexcept
+ {
+ return _VSTD::move(this->__val_);
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr const value_type&& __get() const&& noexcept
+ {
+ return _VSTD::move(this->__val_);
+ }
+
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+ _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
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_from(_That&& __opt)
+ {
+ if (__opt.has_value())
+ __construct(_VSTD::forward<_That>(__opt).__get());
+ }
+
+ template <class _That>
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __assign_from(_That&& __opt)
+ {
+ if (this->__engaged_ == __opt.has_value())
+ {
+ if (this->__engaged_)
+ this->__val_ = _VSTD::forward<_That>(__opt).__get();
+ }
+ else
+ {
+ if (this->__engaged_)
+ this->reset();
+ else
+ __construct(_VSTD::forward<_That>(__opt).__get());
+ }
+ }
+};
+
+// optional<T&> is currently required ill-formed, however it may to be in the
+// future. For this reason it has already been implemented to ensure we can
+// make the change in an ABI compatible manner.
+template <class _Tp>
+struct __optional_storage_base<_Tp, true>
+{
+ using value_type = _Tp;
+ using __raw_type = remove_reference_t<_Tp>;
+ __raw_type* __value_;
+
+ template <class _Up>
+ static constexpr bool __can_bind_reference() {
+ using _RawUp = typename remove_reference<_Up>::type;
+ using _UpPtr = _RawUp*;
+ using _RawTp = typename remove_reference<_Tp>::type;
+ using _TpPtr = _RawTp*;
+ using _CheckLValueArg = integral_constant<bool,
+ (is_lvalue_reference<_Up>::value && is_convertible<_UpPtr, _TpPtr>::value)
+ || is_same<_RawUp, reference_wrapper<_RawTp>>::value
+ || is_same<_RawUp, reference_wrapper<typename remove_const<_RawTp>::type>>::value
+ >;
+ return (is_lvalue_reference<_Tp>::value && _CheckLValueArg::value)
+ || (is_rvalue_reference<_Tp>::value && !is_lvalue_reference<_Up>::value &&
+ is_convertible<_UpPtr, _TpPtr>::value);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr __optional_storage_base() noexcept
+ : __value_(nullptr) {}
+
+ template <class _UArg>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr explicit __optional_storage_base(in_place_t, _UArg&& __uarg)
+ : __value_(_VSTD::addressof(__uarg))
+ {
+ static_assert(__can_bind_reference<_UArg>(),
+ "Attempted to construct a reference element in tuple from a "
+ "possible temporary");
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void reset() noexcept { __value_ = nullptr; }
+
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr bool has_value() const noexcept
+ { return __value_ != nullptr; }
+
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr value_type& __get() const& noexcept
+ { return *__value_; }
+
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr value_type&& __get() const&& noexcept
+ { return _VSTD::forward<value_type>(*__value_); }
+
+ template <class _UArg>
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct(_UArg&& __val)
+ {
+ _LIBCPP_ASSERT(!has_value(), "__construct called for engaged __optional_storage");
+ static_assert(__can_bind_reference<_UArg>(),
+ "Attempted to construct a reference element in tuple from a "
+ "possible temporary");
+ __value_ = _VSTD::addressof(__val);
+ }
+
+ template <class _That>
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_from(_That&& __opt)
+ {
+ if (__opt.has_value())
+ __construct(_VSTD::forward<_That>(__opt).__get());
+ }
+
+ template <class _That>
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __assign_from(_That&& __opt)
+ {
+ if (has_value() == __opt.has_value())
+ {
+ if (has_value())
+ *__value_ = _VSTD::forward<_That>(__opt).__get();
+ }
+ else
+ {
+ if (has_value())
+ reset();
+ else
+ __construct(_VSTD::forward<_That>(__opt).__get());
+ }
+ }
+};
+
+template <class _Tp, bool = is_trivially_copy_constructible<_Tp>::value>
+struct __optional_copy_base : __optional_storage_base<_Tp>
+{
+ using __optional_storage_base<_Tp>::__optional_storage_base;
+};
+
+template <class _Tp>
+struct __optional_copy_base<_Tp, false> : __optional_storage_base<_Tp>
+{
+ using __optional_storage_base<_Tp>::__optional_storage_base;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_copy_base() = default;
+
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 __optional_copy_base(const __optional_copy_base& __opt)
+ {
+ this->__construct_from(__opt);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_copy_base(__optional_copy_base&&) = default;
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_copy_base& operator=(const __optional_copy_base&) = default;
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_copy_base& operator=(__optional_copy_base&&) = default;
+};
+
+template <class _Tp, bool = is_trivially_move_constructible<_Tp>::value>
+struct __optional_move_base : __optional_copy_base<_Tp>
+{
+ using __optional_copy_base<_Tp>::__optional_copy_base;
+};
+
+template <class _Tp>
+struct __optional_move_base<_Tp, false> : __optional_copy_base<_Tp>
+{
+ using value_type = _Tp;
+ using __optional_copy_base<_Tp>::__optional_copy_base;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_move_base() = default;
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_move_base(const __optional_move_base&) = default;
+
+ _LIBCPP_INLINE_VISIBILITY
+ _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));
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_move_base& operator=(const __optional_move_base&) = default;
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_move_base& operator=(__optional_move_base&&) = default;
+};
+
+template <class _Tp, bool =
+ is_trivially_destructible<_Tp>::value &&
+ is_trivially_copy_constructible<_Tp>::value &&
+ is_trivially_copy_assignable<_Tp>::value>
+struct __optional_copy_assign_base : __optional_move_base<_Tp>
+{
+ using __optional_move_base<_Tp>::__optional_move_base;
+};
+
+template <class _Tp>
+struct __optional_copy_assign_base<_Tp, false> : __optional_move_base<_Tp>
+{
+ using __optional_move_base<_Tp>::__optional_move_base;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_copy_assign_base() = default;
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_copy_assign_base(const __optional_copy_assign_base&) = default;
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_copy_assign_base(__optional_copy_assign_base&&) = default;
+
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 __optional_copy_assign_base& operator=(const __optional_copy_assign_base& __opt)
+ {
+ this->__assign_from(__opt);
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_copy_assign_base& operator=(__optional_copy_assign_base&&) = default;
+};
+
+template <class _Tp, bool =
+ is_trivially_destructible<_Tp>::value &&
+ is_trivially_move_constructible<_Tp>::value &&
+ is_trivially_move_assignable<_Tp>::value>
+struct __optional_move_assign_base : __optional_copy_assign_base<_Tp>
+{
+ using __optional_copy_assign_base<_Tp>::__optional_copy_assign_base;
+};
+
+template <class _Tp>
+struct __optional_move_assign_base<_Tp, false> : __optional_copy_assign_base<_Tp>
+{
+ using value_type = _Tp;
+ using __optional_copy_assign_base<_Tp>::__optional_copy_assign_base;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_move_assign_base() = default;
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_move_assign_base(const __optional_move_assign_base& __opt) = default;
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_move_assign_base(__optional_move_assign_base&&) = default;
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_move_assign_base& operator=(const __optional_move_assign_base&) = default;
+
+ _LIBCPP_INLINE_VISIBILITY
+ _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>)
+ {
+ this->__assign_from(_VSTD::move(__opt));
+ return *this;
+ }
+};
+
+template <class _Tp>
+using __optional_sfinae_ctor_base_t = __sfinae_ctor_base<
+ is_copy_constructible<_Tp>::value,
+ is_move_constructible<_Tp>::value
+>;
+
+template <class _Tp>
+using __optional_sfinae_assign_base_t = __sfinae_assign_base<
+ (is_copy_constructible<_Tp>::value && is_copy_assignable<_Tp>::value),
+ (is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value)
+>;
+
+template<class _Tp>
+class optional;
+template <class _Tp>
+struct __is_std_optional : false_type {};
+template <class _Tp> struct __is_std_optional<optional<_Tp>> : true_type {};
+
+template <class _Tp>
+class optional
+ : private __optional_move_assign_base<_Tp>
+ , private __optional_sfinae_ctor_base_t<_Tp>
+ , private __optional_sfinae_assign_base_t<_Tp>
+{
+ using __base = __optional_move_assign_base<_Tp>;
+public:
+ using value_type = _Tp;
+
+private:
+ // Disable the reference extension using this static assert.
+ static_assert(!is_same_v<__uncvref_t<value_type>, in_place_t>,
+ "instantiation of optional with in_place_t is ill-formed");
+ static_assert(!is_same_v<__uncvref_t<value_type>, nullopt_t>,
+ "instantiation of optional with nullopt_t is ill-formed");
+ static_assert(!is_reference_v<value_type>,
+ "instantiation of optional with a reference type is ill-formed");
+ static_assert(is_destructible_v<value_type>,
+ "instantiation of optional with a non-destructible type is ill-formed");
+ static_assert(!is_array_v<value_type>,
+ "instantiation of optional with an array type is ill-formed");
+
+ // LWG2756: conditionally explicit conversion from _Up
+ struct _CheckOptionalArgsConstructor {
+ template <class _Up>
+ static constexpr bool __enable_implicit =
+ is_constructible_v<_Tp, _Up&&> &&
+ is_convertible_v<_Up&&, _Tp>;
+
+ template <class _Up>
+ static constexpr bool __enable_explicit =
+ is_constructible_v<_Tp, _Up&&> &&
+ !is_convertible_v<_Up&&, _Tp>;
+ };
+ template <class _Up>
+ using _CheckOptionalArgsCtor = _If<
+ _IsNotSame<__uncvref_t<_Up>, in_place_t>::value &&
+ _IsNotSame<__uncvref_t<_Up>, optional>::value,
+ _CheckOptionalArgsConstructor,
+ __check_tuple_constructor_fail
+ >;
+ template <class _QualUp>
+ struct _CheckOptionalLikeConstructor {
+ template <class _Up, class _Opt = optional<_Up>>
+ using __check_constructible_from_opt = _Or<
+ is_constructible<_Tp, _Opt&>,
+ is_constructible<_Tp, _Opt const&>,
+ is_constructible<_Tp, _Opt&&>,
+ is_constructible<_Tp, _Opt const&&>,
+ is_convertible<_Opt&, _Tp>,
+ is_convertible<_Opt const&, _Tp>,
+ is_convertible<_Opt&&, _Tp>,
+ is_convertible<_Opt const&&, _Tp>
+ >;
+ template <class _Up, class _Opt = optional<_Up>>
+ using __check_assignable_from_opt = _Or<
+ is_assignable<_Tp&, _Opt&>,
+ is_assignable<_Tp&, _Opt const&>,
+ is_assignable<_Tp&, _Opt&&>,
+ is_assignable<_Tp&, _Opt const&&>
+ >;
+ template <class _Up, class _QUp = _QualUp>
+ static constexpr bool __enable_implicit =
+ is_convertible<_QUp, _Tp>::value &&
+ !__check_constructible_from_opt<_Up>::value;
+
+ template <class _Up, class _QUp = _QualUp>
+ static constexpr bool __enable_explicit =
+ !is_convertible<_QUp, _Tp>::value &&
+ !__check_constructible_from_opt<_Up>::value;
+
+ template <class _Up, class _QUp = _QualUp>
+ static constexpr bool __enable_assign =
+ !__check_constructible_from_opt<_Up>::value &&
+ !__check_assignable_from_opt<_Up>::value;
+ };
+
+ template <class _Up, class _QualUp>
+ using _CheckOptionalLikeCtor = _If<
+ _And<
+ _IsNotSame<_Up, _Tp>,
+ is_constructible<_Tp, _QualUp>
+ >::value,
+ _CheckOptionalLikeConstructor<_QualUp>,
+ __check_tuple_constructor_fail
+ >;
+ template <class _Up, class _QualUp>
+ using _CheckOptionalLikeAssign = _If<
+ _And<
+ _IsNotSame<_Up, _Tp>,
+ is_constructible<_Tp, _QualUp>,
+ is_assignable<_Tp&, _QualUp>
+ >::value,
+ _CheckOptionalLikeConstructor<_QualUp>,
+ __check_tuple_constructor_fail
+ >;
+
+public:
+
+ _LIBCPP_INLINE_VISIBILITY constexpr optional() noexcept {}
+ _LIBCPP_INLINE_VISIBILITY constexpr optional(const optional&) = default;
+ _LIBCPP_INLINE_VISIBILITY constexpr optional(optional&&) = default;
+ _LIBCPP_INLINE_VISIBILITY constexpr optional(nullopt_t) noexcept {}
+
+ template <class _InPlaceT, class... _Args, class = enable_if_t<
+ _And<
+ _IsSame<_InPlaceT, in_place_t>,
+ is_constructible<value_type, _Args...>
+ >::value
+ >
+ >
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr explicit optional(_InPlaceT, _Args&&... __args)
+ : __base(in_place, _VSTD::forward<_Args>(__args)...) {}
+
+ template <class _Up, class... _Args, class = enable_if_t<
+ is_constructible_v<value_type, initializer_list<_Up>&, _Args...>>
+ >
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr explicit optional(in_place_t, initializer_list<_Up> __il, _Args&&... __args)
+ : __base(in_place, __il, _VSTD::forward<_Args>(__args)...) {}
+
+ template <class _Up = value_type, enable_if_t<
+ _CheckOptionalArgsCtor<_Up>::template __enable_implicit<_Up>
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr optional(_Up&& __v)
+ : __base(in_place, _VSTD::forward<_Up>(__v)) {}
+
+ template <class _Up, enable_if_t<
+ _CheckOptionalArgsCtor<_Up>::template __enable_explicit<_Up>
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr explicit optional(_Up&& __v)
+ : __base(in_place, _VSTD::forward<_Up>(__v)) {}
+
+ // LWG2756: conditionally explicit conversion from const optional<_Up>&
+ template <class _Up, enable_if_t<
+ _CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_implicit<_Up>
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 optional(const optional<_Up>& __v)
+ {
+ this->__construct_from(__v);
+ }
+ template <class _Up, enable_if_t<
+ _CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_explicit<_Up>
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit optional(const optional<_Up>& __v)
+ {
+ this->__construct_from(__v);
+ }
+
+ // LWG2756: conditionally explicit conversion from optional<_Up>&&
+ template <class _Up, enable_if_t<
+ _CheckOptionalLikeCtor<_Up, _Up &&>::template __enable_implicit<_Up>
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 optional(optional<_Up>&& __v)
+ {
+ this->__construct_from(_VSTD::move(__v));
+ }
+ template <class _Up, enable_if_t<
+ _CheckOptionalLikeCtor<_Up, _Up &&>::template __enable_explicit<_Up>
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit optional(optional<_Up>&& __v)
+ {
+ this->__construct_from(_VSTD::move(__v));
+ }
+
+#if _LIBCPP_STD_VER > 20
+ template<class _Fp, class... _Args>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit optional(__optional_construct_from_invoke_tag, _Fp&& __f, _Args&&... __args)
+ : __base(__optional_construct_from_invoke_tag{}, _VSTD::forward<_Fp>(__f), _VSTD::forward<_Args>(__args)...) {
+ }
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 optional& operator=(nullopt_t) noexcept
+ {
+ reset();
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY optional& operator=(const optional&) = default;
+ _LIBCPP_INLINE_VISIBILITY optional& operator=(optional&&) = default;
+
+ // LWG2756
+ template <class _Up = value_type,
+ class = enable_if_t<
+ _And<
+ _IsNotSame<__uncvref_t<_Up>, optional>,
+ _Or<
+ _IsNotSame<__uncvref_t<_Up>, value_type>,
+ _Not<is_scalar<value_type>>
+ >,
+ is_constructible<value_type, _Up>,
+ is_assignable<value_type&, _Up>
+ >::value>
+ >
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 optional&
+ operator=(_Up&& __v)
+ {
+ if (this->has_value())
+ this->__get() = _VSTD::forward<_Up>(__v);
+ else
+ this->__construct(_VSTD::forward<_Up>(__v));
+ return *this;
+ }
+
+ // LWG2756
+ template <class _Up, enable_if_t<
+ _CheckOptionalLikeAssign<_Up, _Up const&>::template __enable_assign<_Up>
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 optional&
+ operator=(const optional<_Up>& __v)
+ {
+ this->__assign_from(__v);
+ return *this;
+ }
+
+ // LWG2756
+ template <class _Up, enable_if_t<
+ _CheckOptionalLikeCtor<_Up, _Up &&>::template __enable_assign<_Up>
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 optional&
+ operator=(optional<_Up>&& __v)
+ {
+ this->__assign_from(_VSTD::move(__v));
+ return *this;
+ }
+
+ template <class... _Args,
+ class = enable_if_t
+ <
+ is_constructible_v<value_type, _Args...>
+ >
+ >
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp &
+ emplace(_Args&&... __args)
+ {
+ reset();
+ this->__construct(_VSTD::forward<_Args>(__args)...);
+ return this->__get();
+ }
+
+ template <class _Up, class... _Args,
+ class = enable_if_t
+ <
+ is_constructible_v<value_type, initializer_list<_Up>&, _Args...>
+ >
+ >
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp &
+ emplace(initializer_list<_Up> __il, _Args&&... __args)
+ {
+ reset();
+ this->__construct(__il, _VSTD::forward<_Args>(__args)...);
+ return this->__get();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(optional& __opt)
+ noexcept(is_nothrow_move_constructible_v<value_type> &&
+ is_nothrow_swappable_v<value_type>)
+ {
+ if (this->has_value() == __opt.has_value())
+ {
+ using _VSTD::swap;
+ if (this->has_value())
+ swap(this->__get(), __opt.__get());
+ }
+ else
+ {
+ if (this->has_value())
+ {
+ __opt.__construct(_VSTD::move(this->__get()));
+ reset();
+ }
+ else
+ {
+ this->__construct(_VSTD::move(__opt.__get()));
+ __opt.reset();
+ }
+ }
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr
+ add_pointer_t<value_type const>
+ operator->() const
+ {
+ _LIBCPP_ASSERT(this->has_value(), "optional operator-> called on a disengaged value");
+ return _VSTD::addressof(this->__get());
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr
+ add_pointer_t<value_type>
+ operator->()
+ {
+ _LIBCPP_ASSERT(this->has_value(), "optional operator-> called on a disengaged value");
+ return _VSTD::addressof(this->__get());
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr
+ const value_type&
+ operator*() const& noexcept
+ {
+ _LIBCPP_ASSERT(this->has_value(), "optional operator* called on a disengaged value");
+ return this->__get();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr
+ value_type&
+ operator*() & noexcept
+ {
+ _LIBCPP_ASSERT(this->has_value(), "optional operator* called on a disengaged value");
+ return this->__get();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr
+ value_type&&
+ operator*() && noexcept
+ {
+ _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&& noexcept
+ {
+ _LIBCPP_ASSERT(this->has_value(), "optional operator* called on a disengaged value");
+ return _VSTD::move(this->__get());
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr explicit operator bool() const noexcept { return has_value(); }
+
+ using __base::has_value;
+ using __base::__get;
+
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
+ constexpr value_type const& value() const&
+ {
+ if (!this->has_value())
+ __throw_bad_optional_access();
+ return this->__get();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
+ constexpr value_type& value() &
+ {
+ if (!this->has_value())
+ __throw_bad_optional_access();
+ return this->__get();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
+ constexpr value_type&& value() &&
+ {
+ if (!this->has_value())
+ __throw_bad_optional_access();
+ return _VSTD::move(this->__get());
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
+ constexpr value_type const&& value() const&&
+ {
+ if (!this->has_value())
+ __throw_bad_optional_access();
+ return _VSTD::move(this->__get());
+ }
+
+ template <class _Up>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr value_type value_or(_Up&& __v) const&
+ {
+ static_assert(is_copy_constructible_v<value_type>,
+ "optional<T>::value_or: T must be copy constructible");
+ static_assert(is_convertible_v<_Up, value_type>,
+ "optional<T>::value_or: U must be convertible to T");
+ return this->has_value() ? this->__get() :
+ static_cast<value_type>(_VSTD::forward<_Up>(__v));
+ }
+
+ template <class _Up>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr value_type value_or(_Up&& __v) &&
+ {
+ static_assert(is_move_constructible_v<value_type>,
+ "optional<T>::value_or: T must be move constructible");
+ static_assert(is_convertible_v<_Up, value_type>,
+ "optional<T>::value_or: U must be convertible to T");
+ return this->has_value() ? _VSTD::move(this->__get()) :
+ static_cast<value_type>(_VSTD::forward<_Up>(__v));
+ }
+
+#if _LIBCPP_STD_VER > 20
+ template<class _Func>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
+ constexpr auto and_then(_Func&& __f) & {
+ using _Up = invoke_result_t<_Func, value_type&>;
+ static_assert(__is_std_optional<remove_cvref_t<_Up>>::value,
+ "Result of f(value()) must be a specialization of std::optional");
+ if (*this)
+ return _VSTD::invoke(_VSTD::forward<_Func>(__f), value());
+ return remove_cvref_t<_Up>();
+ }
+
+ template<class _Func>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
+ constexpr auto and_then(_Func&& __f) const& {
+ using _Up = invoke_result_t<_Func, const value_type&>;
+ static_assert(__is_std_optional<remove_cvref_t<_Up>>::value,
+ "Result of f(value()) must be a specialization of std::optional");
+ if (*this)
+ return _VSTD::invoke(_VSTD::forward<_Func>(__f), value());
+ return remove_cvref_t<_Up>();
+ }
+
+ template<class _Func>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
+ constexpr auto and_then(_Func&& __f) && {
+ using _Up = invoke_result_t<_Func, value_type&&>;
+ static_assert(__is_std_optional<remove_cvref_t<_Up>>::value,
+ "Result of f(std::move(value())) must be a specialization of std::optional");
+ if (*this)
+ return _VSTD::invoke(_VSTD::forward<_Func>(__f), _VSTD::move(value()));
+ return remove_cvref_t<_Up>();
+ }
+
+ template<class _Func>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto and_then(_Func&& __f) const&& {
+ using _Up = invoke_result_t<_Func, const value_type&&>;
+ static_assert(__is_std_optional<remove_cvref_t<_Up>>::value,
+ "Result of f(std::move(value())) must be a specialization of std::optional");
+ if (*this)
+ return _VSTD::invoke(_VSTD::forward<_Func>(__f), _VSTD::move(value()));
+ return remove_cvref_t<_Up>();
+ }
+
+ template<class _Func>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
+ constexpr auto transform(_Func&& __f) & {
+ using _Up = remove_cv_t<invoke_result_t<_Func, value_type&>>;
+ static_assert(!is_array_v<_Up>, "Result of f(value()) should not be an Array");
+ static_assert(!is_same_v<_Up, in_place_t>,
+ "Result of f(value()) should not be std::in_place_t");
+ static_assert(!is_same_v<_Up, nullopt_t>,
+ "Result of f(value()) should not be std::nullopt_t");
+ static_assert(is_object_v<_Up>, "Result of f(value()) should be an object type");
+ if (*this)
+ return optional<_Up>(__optional_construct_from_invoke_tag{}, _VSTD::forward<_Func>(__f), value());
+ return optional<_Up>();
+ }
+
+ template<class _Func>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
+ constexpr auto transform(_Func&& __f) const& {
+ using _Up = remove_cv_t<invoke_result_t<_Func, const value_type&>>;
+ static_assert(!is_array_v<_Up>, "Result of f(value()) should not be an Array");
+ static_assert(!is_same_v<_Up, in_place_t>,
+ "Result of f(value()) should not be std::in_place_t");
+ static_assert(!is_same_v<_Up, nullopt_t>,
+ "Result of f(value()) should not be std::nullopt_t");
+ static_assert(is_object_v<_Up>, "Result of f(value()) should be an object type");
+ if (*this)
+ return optional<_Up>(__optional_construct_from_invoke_tag{}, _VSTD::forward<_Func>(__f), value());
+ return optional<_Up>();
+ }
+
+ template<class _Func>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
+ constexpr auto transform(_Func&& __f) && {
+ using _Up = remove_cv_t<invoke_result_t<_Func, value_type&&>>;
+ static_assert(!is_array_v<_Up>, "Result of f(std::move(value())) should not be an Array");
+ static_assert(!is_same_v<_Up, in_place_t>,
+ "Result of f(std::move(value())) should not be std::in_place_t");
+ static_assert(!is_same_v<_Up, nullopt_t>,
+ "Result of f(std::move(value())) should not be std::nullopt_t");
+ static_assert(is_object_v<_Up>, "Result of f(std::move(value())) should be an object type");
+ if (*this)
+ return optional<_Up>(__optional_construct_from_invoke_tag{}, _VSTD::forward<_Func>(__f), _VSTD::move(value()));
+ return optional<_Up>();
+ }
+
+ template<class _Func>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
+ constexpr auto transform(_Func&& __f) const&& {
+ using _Up = remove_cvref_t<invoke_result_t<_Func, const value_type&&>>;
+ static_assert(!is_array_v<_Up>, "Result of f(std::move(value())) should not be an Array");
+ static_assert(!is_same_v<_Up, in_place_t>,
+ "Result of f(std::move(value())) should not be std::in_place_t");
+ static_assert(!is_same_v<_Up, nullopt_t>,
+ "Result of f(std::move(value())) should not be std::nullopt_t");
+ static_assert(is_object_v<_Up>, "Result of f(std::move(value())) should be an object type");
+ if (*this)
+ return optional<_Up>(__optional_construct_from_invoke_tag{}, _VSTD::forward<_Func>(__f), _VSTD::move(value()));
+ return optional<_Up>();
+ }
+
+ template<invocable _Func>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr optional or_else(_Func&& __f) const& requires is_copy_constructible_v<value_type> {
+ static_assert(is_same_v<remove_cvref_t<invoke_result_t<_Func>>, optional>,
+ "Result of f() should be the same type as this optional");
+ if (*this)
+ return *this;
+ return _VSTD::forward<_Func>(__f)();
+ }
+
+ template<invocable _Func>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr optional or_else(_Func&& __f) && requires is_move_constructible_v<value_type> {
+ static_assert(is_same_v<remove_cvref_t<invoke_result_t<_Func>>, optional>,
+ "Result of f() should be the same type as this optional");
+ if (*this)
+ return _VSTD::move(*this);
+ return _VSTD::forward<_Func>(__f)();
+ }
+#endif // _LIBCPP_STD_VER > 20
+
+ using __base::reset;
+};
+
+#if _LIBCPP_STD_VER >= 17
+template<class _Tp>
+ optional(_Tp) -> optional<_Tp>;
+#endif
+
+// Comparisons between optionals
+template <class _Tp, class _Up>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<
+ is_convertible_v<decltype(declval<const _Tp&>() ==
+ declval<const _Up&>()), bool>,
+ bool
+>
+operator==(const optional<_Tp>& __x, const optional<_Up>& __y)
+{
+ if (static_cast<bool>(__x) != static_cast<bool>(__y))
+ return false;
+ if (!static_cast<bool>(__x))
+ return true;
+ return *__x == *__y;
+}
+
+template <class _Tp, class _Up>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<
+ is_convertible_v<decltype(declval<const _Tp&>() !=
+ declval<const _Up&>()), bool>,
+ bool
+>
+operator!=(const optional<_Tp>& __x, const optional<_Up>& __y)
+{
+ if (static_cast<bool>(__x) != static_cast<bool>(__y))
+ return true;
+ if (!static_cast<bool>(__x))
+ return false;
+ return *__x != *__y;
+}
+
+template <class _Tp, class _Up>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<
+ is_convertible_v<decltype(declval<const _Tp&>() <
+ declval<const _Up&>()), bool>,
+ bool
+>
+operator<(const optional<_Tp>& __x, const optional<_Up>& __y)
+{
+ if (!static_cast<bool>(__y))
+ return false;
+ if (!static_cast<bool>(__x))
+ return true;
+ return *__x < *__y;
+}
+
+template <class _Tp, class _Up>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<
+ is_convertible_v<decltype(declval<const _Tp&>() >
+ declval<const _Up&>()), bool>,
+ bool
+>
+operator>(const optional<_Tp>& __x, const optional<_Up>& __y)
+{
+ if (!static_cast<bool>(__x))
+ return false;
+ if (!static_cast<bool>(__y))
+ return true;
+ return *__x > *__y;
+}
+
+template <class _Tp, class _Up>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<
+ is_convertible_v<decltype(declval<const _Tp&>() <=
+ declval<const _Up&>()), bool>,
+ bool
+>
+operator<=(const optional<_Tp>& __x, const optional<_Up>& __y)
+{
+ if (!static_cast<bool>(__x))
+ return true;
+ if (!static_cast<bool>(__y))
+ return false;
+ return *__x <= *__y;
+}
+
+template <class _Tp, class _Up>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<
+ is_convertible_v<decltype(declval<const _Tp&>() >=
+ declval<const _Up&>()), bool>,
+ bool
+>
+operator>=(const optional<_Tp>& __x, const optional<_Up>& __y)
+{
+ if (!static_cast<bool>(__y))
+ return true;
+ if (!static_cast<bool>(__x))
+ return false;
+ return *__x >= *__y;
+}
+
+// Comparisons with nullopt
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+bool
+operator==(const optional<_Tp>& __x, nullopt_t) noexcept
+{
+ return !static_cast<bool>(__x);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+bool
+operator==(nullopt_t, const optional<_Tp>& __x) noexcept
+{
+ return !static_cast<bool>(__x);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+bool
+operator!=(const optional<_Tp>& __x, nullopt_t) noexcept
+{
+ return static_cast<bool>(__x);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+bool
+operator!=(nullopt_t, const optional<_Tp>& __x) noexcept
+{
+ return static_cast<bool>(__x);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+bool
+operator<(const optional<_Tp>&, nullopt_t) noexcept
+{
+ return false;
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+bool
+operator<(nullopt_t, const optional<_Tp>& __x) noexcept
+{
+ return static_cast<bool>(__x);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+bool
+operator<=(const optional<_Tp>& __x, nullopt_t) noexcept
+{
+ return !static_cast<bool>(__x);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+bool
+operator<=(nullopt_t, const optional<_Tp>&) noexcept
+{
+ return true;
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+bool
+operator>(const optional<_Tp>& __x, nullopt_t) noexcept
+{
+ return static_cast<bool>(__x);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+bool
+operator>(nullopt_t, const optional<_Tp>&) noexcept
+{
+ return false;
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+bool
+operator>=(const optional<_Tp>&, nullopt_t) noexcept
+{
+ return true;
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+bool
+operator>=(nullopt_t, const optional<_Tp>& __x) noexcept
+{
+ return !static_cast<bool>(__x);
+}
+
+// Comparisons with T
+template <class _Tp, class _Up>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<
+ is_convertible_v<decltype(declval<const _Tp&>() ==
+ declval<const _Up&>()), bool>,
+ bool
+>
+operator==(const optional<_Tp>& __x, const _Up& __v)
+{
+ return static_cast<bool>(__x) ? *__x == __v : false;
+}
+
+template <class _Tp, class _Up>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<
+ is_convertible_v<decltype(declval<const _Tp&>() ==
+ declval<const _Up&>()), bool>,
+ bool
+>
+operator==(const _Tp& __v, const optional<_Up>& __x)
+{
+ return static_cast<bool>(__x) ? __v == *__x : false;
+}
+
+template <class _Tp, class _Up>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<
+ is_convertible_v<decltype(declval<const _Tp&>() !=
+ declval<const _Up&>()), bool>,
+ bool
+>
+operator!=(const optional<_Tp>& __x, const _Up& __v)
+{
+ return static_cast<bool>(__x) ? *__x != __v : true;
+}
+
+template <class _Tp, class _Up>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<
+ is_convertible_v<decltype(declval<const _Tp&>() !=
+ declval<const _Up&>()), bool>,
+ bool
+>
+operator!=(const _Tp& __v, const optional<_Up>& __x)
+{
+ return static_cast<bool>(__x) ? __v != *__x : true;
+}
+
+template <class _Tp, class _Up>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<
+ is_convertible_v<decltype(declval<const _Tp&>() <
+ declval<const _Up&>()), bool>,
+ bool
+>
+operator<(const optional<_Tp>& __x, const _Up& __v)
+{
+ return static_cast<bool>(__x) ? *__x < __v : true;
+}
+
+template <class _Tp, class _Up>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<
+ is_convertible_v<decltype(declval<const _Tp&>() <
+ declval<const _Up&>()), bool>,
+ bool
+>
+operator<(const _Tp& __v, const optional<_Up>& __x)
+{
+ return static_cast<bool>(__x) ? __v < *__x : false;
+}
+
+template <class _Tp, class _Up>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<
+ is_convertible_v<decltype(declval<const _Tp&>() <=
+ declval<const _Up&>()), bool>,
+ bool
+>
+operator<=(const optional<_Tp>& __x, const _Up& __v)
+{
+ return static_cast<bool>(__x) ? *__x <= __v : true;
+}
+
+template <class _Tp, class _Up>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<
+ is_convertible_v<decltype(declval<const _Tp&>() <=
+ declval<const _Up&>()), bool>,
+ bool
+>
+operator<=(const _Tp& __v, const optional<_Up>& __x)
+{
+ return static_cast<bool>(__x) ? __v <= *__x : false;
+}
+
+template <class _Tp, class _Up>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<
+ is_convertible_v<decltype(declval<const _Tp&>() >
+ declval<const _Up&>()), bool>,
+ bool
+>
+operator>(const optional<_Tp>& __x, const _Up& __v)
+{
+ return static_cast<bool>(__x) ? *__x > __v : false;
+}
+
+template <class _Tp, class _Up>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<
+ is_convertible_v<decltype(declval<const _Tp&>() >
+ declval<const _Up&>()), bool>,
+ bool
+>
+operator>(const _Tp& __v, const optional<_Up>& __x)
+{
+ return static_cast<bool>(__x) ? __v > *__x : true;
+}
+
+template <class _Tp, class _Up>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<
+ is_convertible_v<decltype(declval<const _Tp&>() >=
+ declval<const _Up&>()), bool>,
+ bool
+>
+operator>=(const optional<_Tp>& __x, const _Up& __v)
+{
+ return static_cast<bool>(__x) ? *__x >= __v : false;
+}
+
+template <class _Tp, class _Up>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<
+ is_convertible_v<decltype(declval<const _Tp&>() >=
+ declval<const _Up&>()), bool>,
+ bool
+>
+operator>=(const _Tp& __v, const optional<_Up>& __x)
+{
+ return static_cast<bool>(__x) ? __v >= *__x : true;
+}
+
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+enable_if_t<
+ is_move_constructible_v<_Tp> && is_swappable_v<_Tp>,
+ void
+>
+swap(optional<_Tp>& __x, optional<_Tp>& __y) noexcept(noexcept(__x.swap(__y)))
+{
+ __x.swap(__y);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+optional<decay_t<_Tp>> make_optional(_Tp&& __v)
+{
+ return optional<decay_t<_Tp>>(_VSTD::forward<_Tp>(__v));
+}
+
+template <class _Tp, class... _Args>
+_LIBCPP_INLINE_VISIBILITY constexpr
+optional<_Tp> make_optional(_Args&&... __args)
+{
+ return optional<_Tp>(in_place, _VSTD::forward<_Args>(__args)...);
+}
+
+template <class _Tp, class _Up, class... _Args>
+_LIBCPP_INLINE_VISIBILITY constexpr
+optional<_Tp> make_optional(initializer_list<_Up> __il, _Args&&... __args)
+{
+ return optional<_Tp>(in_place, __il, _VSTD::forward<_Args>(__args)...);
+}
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS hash<
+ __enable_hash_helper<optional<_Tp>, remove_const_t<_Tp>>
+>
+{
+#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
+ size_t operator()(const optional<_Tp>& __opt) const
+ {
+ return static_cast<bool>(__opt) ? hash<remove_const_t<_Tp>>()(*__opt) : 0;
+ }
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 14
+
+#endif // _LIBCPP_OPTIONAL
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/ostream b/contrib/libs/cxxsupp/libcxxmsvc/include/ostream
new file mode 100644
index 0000000000..3587c359a4
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/ostream
@@ -0,0 +1,1104 @@
+// -*- 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_OSTREAM
+#define _LIBCPP_OSTREAM
+
+/*
+ ostream synopsis
+
+template <class charT, class traits = char_traits<charT> >
+class basic_ostream
+ : virtual public basic_ios<charT,traits>
+{
+public:
+ // types (inherited from basic_ios (27.5.4)):
+ typedef charT char_type;
+ typedef traits traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+
+ // 27.7.2.2 Constructor/destructor:
+ explicit basic_ostream(basic_streambuf<char_type,traits>* sb);
+ basic_ostream(basic_ostream&& rhs);
+ virtual ~basic_ostream();
+
+ // 27.7.2.3 Assign/swap
+ basic_ostream& operator=(const basic_ostream& rhs) = delete; // C++14
+ basic_ostream& operator=(basic_ostream&& rhs);
+ void swap(basic_ostream& rhs);
+
+ // 27.7.2.4 Prefix/suffix:
+ class sentry;
+
+ // 27.7.2.6 Formatted output:
+ basic_ostream& operator<<(basic_ostream& (*pf)(basic_ostream&));
+ basic_ostream& operator<<(basic_ios<charT, traits>& (*pf)(basic_ios<charT,traits>&));
+ basic_ostream& operator<<(ios_base& (*pf)(ios_base&));
+ basic_ostream& operator<<(bool n);
+ basic_ostream& operator<<(short n);
+ basic_ostream& operator<<(unsigned short n);
+ basic_ostream& operator<<(int n);
+ basic_ostream& operator<<(unsigned int n);
+ basic_ostream& operator<<(long n);
+ basic_ostream& operator<<(unsigned long n);
+ basic_ostream& operator<<(long long n);
+ basic_ostream& operator<<(unsigned long long n);
+ basic_ostream& operator<<(float f);
+ basic_ostream& operator<<(double f);
+ basic_ostream& operator<<(long double f);
+ basic_ostream& operator<<(const void* p);
+ basic_ostream& operator<<(const volatile void* val); // C++23
+ basic_ostream& operator<<(basic_streambuf<char_type,traits>* sb);
+ basic_ostream& operator<<(nullptr_t);
+
+ // 27.7.2.7 Unformatted output:
+ basic_ostream& put(char_type c);
+ basic_ostream& write(const char_type* s, streamsize n);
+ basic_ostream& flush();
+
+ // 27.7.2.5 seeks:
+ pos_type tellp();
+ basic_ostream& seekp(pos_type);
+ basic_ostream& seekp(off_type, ios_base::seekdir);
+protected:
+ basic_ostream(const basic_ostream& rhs) = delete;
+ basic_ostream(basic_ostream&& rhs);
+ // 27.7.3.3 Assign/swap
+ basic_ostream& operator=(basic_ostream& rhs) = delete;
+ basic_ostream& operator=(const basic_ostream&& rhs);
+ void swap(basic_ostream& rhs);
+};
+
+// 27.7.2.6.4 character inserters
+
+template<class charT, class traits>
+ basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, charT);
+
+template<class charT, class traits>
+ basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, char);
+
+template<class traits>
+ basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, char);
+
+// signed and unsigned
+
+template<class traits>
+ basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, signed char);
+
+template<class traits>
+ basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, unsigned char);
+
+// NTBS
+template<class charT, class traits>
+ basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, const charT*);
+
+template<class charT, class traits>
+ basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, const char*);
+
+template<class traits>
+ basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, const char*);
+
+// signed and unsigned
+template<class traits>
+basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, const signed char*);
+
+template<class traits>
+ basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, const unsigned char*);
+
+// swap:
+template <class charT, class traits>
+ void swap(basic_ostream<charT, traits>& x, basic_ostream<charT, traits>& y);
+
+template <class charT, class traits>
+ basic_ostream<charT,traits>& endl(basic_ostream<charT,traits>& os);
+
+template <class charT, class traits>
+ basic_ostream<charT,traits>& ends(basic_ostream<charT,traits>& os);
+
+template <class charT, class traits>
+ basic_ostream<charT,traits>& flush(basic_ostream<charT,traits>& os);
+
+// rvalue stream insertion
+template <class Stream, class T>
+ Stream&& operator<<(Stream&& os, const T& x);
+
+} // std
+
+*/
+
+#include <__config>
+#include <bitset>
+#include <ios>
+#include <iterator>
+#include <locale>
+#include <streambuf>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _CharT, class _Traits>
+class _LIBCPP_TEMPLATE_VIS basic_ostream
+ : virtual public basic_ios<_CharT, _Traits>
+{
+public:
+ // types (inherited from basic_ios (27.5.4)):
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+
+ // 27.7.2.2 Constructor/destructor:
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ explicit basic_ostream(basic_streambuf<char_type, traits_type>* __sb)
+ { this->init(__sb); }
+ virtual ~basic_ostream();
+protected:
+ 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);
+
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ void swap(basic_ostream& __rhs)
+ { basic_ios<char_type, traits_type>::swap(__rhs); }
+
+ basic_ostream (const basic_ostream& __rhs) = delete;
+ basic_ostream& operator=(const basic_ostream& __rhs) = delete;
+
+public:
+ // 27.7.2.4 Prefix/suffix:
+ class _LIBCPP_TEMPLATE_VIS sentry;
+
+ // 27.7.2.6 Formatted output:
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ basic_ostream& operator<<(basic_ostream& (*__pf)(basic_ostream&))
+ { return __pf(*this); }
+
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ basic_ostream& operator<<(basic_ios<char_type, traits_type>&
+ (*__pf)(basic_ios<char_type,traits_type>&))
+ { __pf(*this); return *this; }
+
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ basic_ostream& operator<<(ios_base& (*__pf)(ios_base&))
+ { __pf(*this); return *this; }
+
+ basic_ostream& operator<<(bool __n);
+ basic_ostream& operator<<(short __n);
+ basic_ostream& operator<<(unsigned short __n);
+ basic_ostream& operator<<(int __n);
+ basic_ostream& operator<<(unsigned int __n);
+ basic_ostream& operator<<(long __n);
+ basic_ostream& operator<<(unsigned long __n);
+ basic_ostream& operator<<(long long __n);
+ basic_ostream& operator<<(unsigned long long __n);
+ basic_ostream& operator<<(float __f);
+ basic_ostream& operator<<(double __f);
+ basic_ostream& operator<<(long double __f);
+ basic_ostream& operator<<(const void* __p);
+
+#if _LIBCPP_STD_VER > 20
+ _LIBCPP_HIDE_FROM_ABI
+ basic_ostream& operator<<(const volatile void* __p) {
+ return operator<<(const_cast<const void*>(__p));
+ }
+#endif
+
+ basic_ostream& operator<<(basic_streambuf<char_type, traits_type>* __sb);
+
+ _LIBCPP_INLINE_VISIBILITY
+ basic_ostream& operator<<(nullptr_t)
+ { return *this << "nullptr"; }
+
+ // 27.7.2.7 Unformatted output:
+ basic_ostream& put(char_type __c);
+ basic_ostream& write(const char_type* __s, streamsize __n);
+ basic_ostream& flush();
+
+ // 27.7.2.5 seeks:
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ pos_type tellp();
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ basic_ostream& seekp(pos_type __pos);
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ basic_ostream& seekp(off_type __off, ios_base::seekdir __dir);
+
+protected:
+ _LIBCPP_INLINE_VISIBILITY
+ basic_ostream() {} // extension, intentially does not initialize
+};
+
+template <class _CharT, class _Traits>
+class _LIBCPP_TEMPLATE_VIS basic_ostream<_CharT, _Traits>::sentry
+{
+ bool __ok_;
+ basic_ostream<_CharT, _Traits>& __os_;
+
+public:
+ explicit sentry(basic_ostream<_CharT, _Traits>& __os);
+ ~sentry();
+ sentry(const sentry&) = delete;
+ sentry& operator=(const sentry&) = delete;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit operator bool() const {return __ok_;}
+};
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>::sentry::sentry(basic_ostream<_CharT, _Traits>& __os)
+ : __ok_(false),
+ __os_(__os)
+{
+ if (__os.good())
+ {
+ if (__os.tie())
+ __os.tie()->flush();
+ __ok_ = true;
+ }
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>::sentry::~sentry()
+{
+ if (__os_.rdbuf() && __os_.good() && (__os_.flags() & ios_base::unitbuf)
+ && !uncaught_exception())
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ if (__os_.rdbuf()->pubsync() == -1)
+ __os_.setstate(ios_base::badbit);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ }
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>::basic_ostream(basic_ostream&& __rhs)
+{
+ this->move(__rhs);
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator=(basic_ostream&& __rhs)
+{
+ swap(__rhs);
+ return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>::~basic_ostream()
+{
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator<<(basic_streambuf<char_type, traits_type>* __sb)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ sentry __s(*this);
+ if (__s)
+ {
+ if (__sb)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ typedef istreambuf_iterator<_CharT, _Traits> _Ip;
+ typedef ostreambuf_iterator<_CharT, _Traits> _Op;
+ _Ip __i(__sb);
+ _Ip __eof;
+ _Op __o(*this);
+ size_t __c = 0;
+ for (; __i != __eof; ++__i, ++__o, ++__c)
+ {
+ *__o = *__i;
+ if (__o.failed())
+ break;
+ }
+ if (__c == 0)
+ this->setstate(ios_base::failbit);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ this->__set_failbit_and_consider_rethrow();
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ }
+ else
+ this->setstate(ios_base::badbit);
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ this->__set_badbit_and_consider_rethrow();
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator<<(bool __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ sentry __s(*this);
+ if (__s)
+ {
+ typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
+ const _Fp& __f = use_facet<_Fp>(this->getloc());
+ if (__f.put(*this, *this, this->fill(), __n).failed())
+ this->setstate(ios_base::badbit | ios_base::failbit);
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ this->__set_badbit_and_consider_rethrow();
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator<<(short __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ sentry __s(*this);
+ if (__s)
+ {
+ ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield;
+ typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
+ const _Fp& __f = use_facet<_Fp>(this->getloc());
+ if (__f.put(*this, *this, this->fill(),
+ __flags == ios_base::oct || __flags == ios_base::hex ?
+ static_cast<long>(static_cast<unsigned short>(__n)) :
+ static_cast<long>(__n)).failed())
+ this->setstate(ios_base::badbit | ios_base::failbit);
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ this->__set_badbit_and_consider_rethrow();
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator<<(unsigned short __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ sentry __s(*this);
+ if (__s)
+ {
+ typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
+ const _Fp& __f = use_facet<_Fp>(this->getloc());
+ if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed())
+ this->setstate(ios_base::badbit | ios_base::failbit);
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ this->__set_badbit_and_consider_rethrow();
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator<<(int __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ sentry __s(*this);
+ if (__s)
+ {
+ ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield;
+ typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
+ const _Fp& __f = use_facet<_Fp>(this->getloc());
+ if (__f.put(*this, *this, this->fill(),
+ __flags == ios_base::oct || __flags == ios_base::hex ?
+ static_cast<long>(static_cast<unsigned int>(__n)) :
+ static_cast<long>(__n)).failed())
+ this->setstate(ios_base::badbit | ios_base::failbit);
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ this->__set_badbit_and_consider_rethrow();
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator<<(unsigned int __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ sentry __s(*this);
+ if (__s)
+ {
+ typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
+ const _Fp& __f = use_facet<_Fp>(this->getloc());
+ if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed())
+ this->setstate(ios_base::badbit | ios_base::failbit);
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ this->__set_badbit_and_consider_rethrow();
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator<<(long __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ sentry __s(*this);
+ if (__s)
+ {
+ typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
+ const _Fp& __f = use_facet<_Fp>(this->getloc());
+ if (__f.put(*this, *this, this->fill(), __n).failed())
+ this->setstate(ios_base::badbit | ios_base::failbit);
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ this->__set_badbit_and_consider_rethrow();
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator<<(unsigned long __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ sentry __s(*this);
+ if (__s)
+ {
+ typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
+ const _Fp& __f = use_facet<_Fp>(this->getloc());
+ if (__f.put(*this, *this, this->fill(), __n).failed())
+ this->setstate(ios_base::badbit | ios_base::failbit);
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ this->__set_badbit_and_consider_rethrow();
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator<<(long long __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ sentry __s(*this);
+ if (__s)
+ {
+ typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
+ const _Fp& __f = use_facet<_Fp>(this->getloc());
+ if (__f.put(*this, *this, this->fill(), __n).failed())
+ this->setstate(ios_base::badbit | ios_base::failbit);
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ this->__set_badbit_and_consider_rethrow();
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator<<(unsigned long long __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ sentry __s(*this);
+ if (__s)
+ {
+ typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
+ const _Fp& __f = use_facet<_Fp>(this->getloc());
+ if (__f.put(*this, *this, this->fill(), __n).failed())
+ this->setstate(ios_base::badbit | ios_base::failbit);
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ this->__set_badbit_and_consider_rethrow();
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator<<(float __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ sentry __s(*this);
+ if (__s)
+ {
+ typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
+ const _Fp& __f = use_facet<_Fp>(this->getloc());
+ if (__f.put(*this, *this, this->fill(), static_cast<double>(__n)).failed())
+ this->setstate(ios_base::badbit | ios_base::failbit);
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ this->__set_badbit_and_consider_rethrow();
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator<<(double __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ sentry __s(*this);
+ if (__s)
+ {
+ typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
+ const _Fp& __f = use_facet<_Fp>(this->getloc());
+ if (__f.put(*this, *this, this->fill(), __n).failed())
+ this->setstate(ios_base::badbit | ios_base::failbit);
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ this->__set_badbit_and_consider_rethrow();
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator<<(long double __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ sentry __s(*this);
+ if (__s)
+ {
+ typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
+ const _Fp& __f = use_facet<_Fp>(this->getloc());
+ if (__f.put(*this, *this, this->fill(), __n).failed())
+ this->setstate(ios_base::badbit | ios_base::failbit);
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ this->__set_badbit_and_consider_rethrow();
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator<<(const void* __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ sentry __s(*this);
+ if (__s)
+ {
+ typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
+ const _Fp& __f = use_facet<_Fp>(this->getloc());
+ if (__f.put(*this, *this, this->fill(), __n).failed())
+ this->setstate(ios_base::badbit | ios_base::failbit);
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ this->__set_badbit_and_consider_rethrow();
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ return *this;
+}
+
+template<class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+__put_character_sequence(basic_ostream<_CharT, _Traits>& __os,
+ const _CharT* __str, size_t __len)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
+ if (__s)
+ {
+ typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
+ if (__pad_and_output(_Ip(__os),
+ __str,
+ (__os.flags() & ios_base::adjustfield) == ios_base::left ?
+ __str + __len :
+ __str,
+ __str + __len,
+ __os,
+ __os.fill()).failed())
+ __os.setstate(ios_base::badbit | ios_base::failbit);
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __os.__set_badbit_and_consider_rethrow();
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ return __os;
+}
+
+
+template<class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c)
+{
+ return _VSTD::__put_character_sequence(__os, &__c, 1);
+}
+
+template<class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
+ if (__s)
+ {
+ _CharT __c = __os.widen(__cn);
+ typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
+ if (__pad_and_output(_Ip(__os),
+ &__c,
+ (__os.flags() & ios_base::adjustfield) == ios_base::left ?
+ &__c + 1 :
+ &__c,
+ &__c + 1,
+ __os,
+ __os.fill()).failed())
+ __os.setstate(ios_base::badbit | ios_base::failbit);
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __os.__set_badbit_and_consider_rethrow();
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ return __os;
+}
+
+template<class _Traits>
+basic_ostream<char, _Traits>&
+operator<<(basic_ostream<char, _Traits>& __os, char __c)
+{
+ return _VSTD::__put_character_sequence(__os, &__c, 1);
+}
+
+template<class _Traits>
+basic_ostream<char, _Traits>&
+operator<<(basic_ostream<char, _Traits>& __os, signed char __c)
+{
+ return _VSTD::__put_character_sequence(__os, (char *) &__c, 1);
+}
+
+template<class _Traits>
+basic_ostream<char, _Traits>&
+operator<<(basic_ostream<char, _Traits>& __os, unsigned char __c)
+{
+ return _VSTD::__put_character_sequence(__os, (char *) &__c, 1);
+}
+
+template<class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str)
+{
+ return _VSTD::__put_character_sequence(__os, __str, _Traits::length(__str));
+}
+
+template<class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
+ if (__s)
+ {
+ typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
+ size_t __len = char_traits<char>::length(__strn);
+ const int __bs = 100;
+ _CharT __wbb[__bs];
+ _CharT* __wb = __wbb;
+ unique_ptr<_CharT, void(*)(void*)> __h(0, free);
+ if (__len > __bs)
+ {
+ __wb = (_CharT*)malloc(__len*sizeof(_CharT));
+ if (__wb == 0)
+ __throw_bad_alloc();
+ __h.reset(__wb);
+ }
+ for (_CharT* __p = __wb; *__strn != '\0'; ++__strn, ++__p)
+ *__p = __os.widen(*__strn);
+ if (__pad_and_output(_Ip(__os),
+ __wb,
+ (__os.flags() & ios_base::adjustfield) == ios_base::left ?
+ __wb + __len :
+ __wb,
+ __wb + __len,
+ __os,
+ __os.fill()).failed())
+ __os.setstate(ios_base::badbit | ios_base::failbit);
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __os.__set_badbit_and_consider_rethrow();
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ return __os;
+}
+
+template<class _Traits>
+basic_ostream<char, _Traits>&
+operator<<(basic_ostream<char, _Traits>& __os, const char* __str)
+{
+ return _VSTD::__put_character_sequence(__os, __str, _Traits::length(__str));
+}
+
+template<class _Traits>
+basic_ostream<char, _Traits>&
+operator<<(basic_ostream<char, _Traits>& __os, const signed char* __str)
+{
+ const char *__s = (const char *) __str;
+ return _VSTD::__put_character_sequence(__os, __s, _Traits::length(__s));
+}
+
+template<class _Traits>
+basic_ostream<char, _Traits>&
+operator<<(basic_ostream<char, _Traits>& __os, const unsigned char* __str)
+{
+ const char *__s = (const char *) __str;
+ return _VSTD::__put_character_sequence(__os, __s, _Traits::length(__s));
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::put(char_type __c)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ sentry __s(*this);
+ if (__s)
+ {
+ typedef ostreambuf_iterator<_CharT, _Traits> _Op;
+ _Op __o(*this);
+ *__o = __c;
+ if (__o.failed())
+ this->setstate(ios_base::badbit);
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ this->__set_badbit_and_consider_rethrow();
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::write(const char_type* __s, streamsize __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ sentry __sen(*this);
+ if (__sen && __n)
+ {
+ if (this->rdbuf()->sputn(__s, __n) != __n)
+ this->setstate(ios_base::badbit);
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ this->__set_badbit_and_consider_rethrow();
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::flush()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ if (this->rdbuf())
+ {
+ sentry __s(*this);
+ if (__s)
+ {
+ if (this->rdbuf()->pubsync() == -1)
+ this->setstate(ios_base::badbit);
+ }
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ this->__set_badbit_and_consider_rethrow();
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ return *this;
+}
+
+template <class _CharT, class _Traits>
+typename basic_ostream<_CharT, _Traits>::pos_type
+basic_ostream<_CharT, _Traits>::tellp()
+{
+ if (this->fail())
+ return pos_type(-1);
+ return this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out);
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::seekp(pos_type __pos)
+{
+ sentry __s(*this);
+ if (!this->fail())
+ {
+ if (this->rdbuf()->pubseekpos(__pos, ios_base::out) == pos_type(-1))
+ this->setstate(ios_base::failbit);
+ }
+ return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir)
+{
+ sentry __s(*this);
+ if (!this->fail())
+ {
+ if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::out) == pos_type(-1))
+ this->setstate(ios_base::failbit);
+ }
+ return *this;
+}
+
+template <class _CharT, class _Traits>
+inline
+basic_ostream<_CharT, _Traits>&
+endl(basic_ostream<_CharT, _Traits>& __os)
+{
+ __os.put(__os.widen('\n'));
+ __os.flush();
+ return __os;
+}
+
+template <class _CharT, class _Traits>
+inline
+basic_ostream<_CharT, _Traits>&
+ends(basic_ostream<_CharT, _Traits>& __os)
+{
+ __os.put(_CharT());
+ return __os;
+}
+
+template <class _CharT, class _Traits>
+inline
+basic_ostream<_CharT, _Traits>&
+flush(basic_ostream<_CharT, _Traits>& __os)
+{
+ __os.flush();
+ return __os;
+}
+
+template <class _Stream, class _Tp, class = void>
+struct __is_ostreamable : false_type { };
+
+template <class _Stream, class _Tp>
+struct __is_ostreamable<_Stream, _Tp, decltype(
+ 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
+>::type>
+_LIBCPP_INLINE_VISIBILITY
+_Stream&& operator<<(_Stream&& __os, const _Tp& __x)
+{
+ __os << __x;
+ return _VSTD::move(__os);
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const basic_string<_CharT, _Traits, _Allocator>& __str)
+{
+ return _VSTD::__put_character_sequence(__os, __str.data(), __str.size());
+}
+
+template<class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ basic_string_view<_CharT, _Traits> __sv)
+{
+ return _VSTD::__put_character_sequence(__os, __sv.data(), __sv.size());
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __ec)
+{
+ return __os << __ec.category().name() << ':' << __ec.value();
+}
+
+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)
+{
+ return __os << __p.get();
+}
+
+template<class _CharT, class _Traits, class _Yp, class _Dp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ is_same<void, typename __void_t<decltype((declval<basic_ostream<_CharT, _Traits>&>() << declval<typename unique_ptr<_Yp, _Dp>::pointer>()))>::type>::value,
+ basic_ostream<_CharT, _Traits>&
+>::type
+operator<<(basic_ostream<_CharT, _Traits>& __os, unique_ptr<_Yp, _Dp> const& __p)
+{
+ return __os << __p.get();
+}
+
+template <class _CharT, class _Traits, size_t _Size>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x)
+{
+ return __os << __x.template to_string<_CharT, _Traits>
+ (use_facet<ctype<_CharT> >(__os.getloc()).widen('0'),
+ use_facet<ctype<_CharT> >(__os.getloc()).widen('1'));
+}
+
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<char>)
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>)
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_OSTREAM
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/queue b/contrib/libs/cxxsupp/libcxxmsvc/include/queue
new file mode 100644
index 0000000000..b8b7ec46d9
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/queue
@@ -0,0 +1,955 @@
+// -*- 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_QUEUE
+#define _LIBCPP_QUEUE
+
+/*
+ queue synopsis
+
+namespace std
+{
+
+template <class T, class Container = deque<T>>
+class queue
+{
+public:
+ typedef Container container_type;
+ typedef typename container_type::value_type value_type;
+ typedef typename container_type::reference reference;
+ typedef typename container_type::const_reference const_reference;
+ typedef typename container_type::size_type size_type;
+
+protected:
+ container_type c;
+
+public:
+ queue() = default;
+ ~queue() = default;
+
+ queue(const queue& q) = default;
+ queue(queue&& q) = default;
+
+ queue& operator=(const queue& q) = default;
+ queue& operator=(queue&& q) = default;
+
+ explicit queue(const container_type& c);
+ explicit queue(container_type&& c)
+ template<class InputIterator>
+ queue(InputIterator first, InputIterator last); // since C++23
+ template <class Alloc>
+ explicit queue(const Alloc& a);
+ template <class Alloc>
+ queue(const container_type& c, const Alloc& a);
+ template <class Alloc>
+ queue(container_type&& c, const Alloc& a);
+ template <class Alloc>
+ queue(const queue& q, const Alloc& a);
+ template <class Alloc>
+ queue(queue&& q, const Alloc& a);
+ template <class InputIterator, class Alloc>
+ queue(InputIterator first, InputIterator last, const Alloc&); // since C++23
+
+ bool empty() const;
+ size_type size() const;
+
+ reference front();
+ const_reference front() const;
+ reference back();
+ const_reference back() const;
+
+ void push(const value_type& v);
+ void push(value_type&& v);
+ template <class... Args> reference emplace(Args&&... args); // reference in C++17
+ void pop();
+
+ void swap(queue& q) noexcept(is_nothrow_swappable_v<Container>)
+};
+
+template<class Container>
+ queue(Container) -> queue<typename Container::value_type, Container>; // C++17
+
+template<class InputIterator>
+ queue(InputIterator, InputIterator) -> queue<iter-value-type<InputIterator>>; // since C++23
+
+template<class Container, class Allocator>
+ queue(Container, Allocator) -> queue<typename Container::value_type, Container>; // C++17
+
+template<class InputIterator, class Allocator>
+ queue(InputIterator, InputIterator, Allocator)
+ -> queue<iter-value-type<InputIterator>,
+ deque<iter-value-type<InputIterator>, Allocator>>; // since C++23
+
+template <class T, class Container>
+ bool operator==(const queue<T, Container>& x,const queue<T, Container>& y);
+
+template <class T, class Container>
+ bool operator< (const queue<T, Container>& x,const queue<T, Container>& y);
+
+template <class T, class Container>
+ bool operator!=(const queue<T, Container>& x,const queue<T, Container>& y);
+
+template <class T, class Container>
+ bool operator> (const queue<T, Container>& x,const queue<T, Container>& y);
+
+template <class T, class Container>
+ bool operator>=(const queue<T, Container>& x,const queue<T, Container>& y);
+
+template <class T, class Container>
+ bool operator<=(const queue<T, Container>& x,const queue<T, Container>& y);
+
+template <class T, class Container>
+ void swap(queue<T, Container>& x, queue<T, Container>& y)
+ noexcept(noexcept(x.swap(y)));
+
+template <class T, class Container = vector<T>,
+ class Compare = less<typename Container::value_type>>
+class priority_queue
+{
+public:
+ typedef Container container_type;
+ typedef typename container_type::value_type value_type;
+ typedef typename container_type::reference reference;
+ typedef typename container_type::const_reference const_reference;
+ typedef typename container_type::size_type size_type;
+
+protected:
+ container_type c;
+ Compare comp;
+
+public:
+ priority_queue() : priority_queue(Compare()) {} // C++20
+ explicit priority_queue(const Compare& x) : priority_queue(x, Container()) {}
+ priority_queue(const Compare& x, const Container&);
+ explicit priority_queue(const Compare& x = Compare(), Container&& = Container()); // before C++20
+ priority_queue(const Compare& x, Container&&); // C++20
+ template <class InputIterator>
+ priority_queue(InputIterator first, InputIterator last,
+ const Compare& comp = Compare());
+ template <class InputIterator>
+ priority_queue(InputIterator first, InputIterator last,
+ const Compare& comp, const Container& c);
+ template <class InputIterator>
+ priority_queue(InputIterator first, InputIterator last,
+ const Compare& comp, Container&& c);
+ template <class Alloc>
+ explicit priority_queue(const Alloc& a);
+ template <class Alloc>
+ priority_queue(const Compare& comp, const Alloc& a);
+ template <class Alloc>
+ priority_queue(const Compare& comp, const Container& c,
+ const Alloc& a);
+ template <class Alloc>
+ priority_queue(const Compare& comp, Container&& c,
+ const Alloc& a);
+ template <class InputIterator>
+ priority_queue(InputIterator first, InputIterator last,
+ const Alloc& a);
+ template <class InputIterator>
+ priority_queue(InputIterator first, InputIterator last,
+ const Compare& comp, const Alloc& a);
+ template <class InputIterator>
+ priority_queue(InputIterator first, InputIterator last,
+ const Compare& comp, const Container& c, const Alloc& a);
+ template <class InputIterator>
+ priority_queue(InputIterator first, InputIterator last,
+ const Compare& comp, Container&& c, const Alloc& a);
+ template <class Alloc>
+ priority_queue(const priority_queue& q, const Alloc& a);
+ template <class Alloc>
+ priority_queue(priority_queue&& q, const Alloc& a);
+
+ bool empty() const;
+ size_type size() const;
+ const_reference top() const;
+
+ void push(const value_type& v);
+ void push(value_type&& v);
+ template <class... Args> void emplace(Args&&... args);
+ void pop();
+
+ void swap(priority_queue& q)
+ noexcept(is_nothrow_swappable_v<Container> &&
+ is_nothrow_swappable_v<Comp>)
+};
+
+template <class Compare, class Container>
+priority_queue(Compare, Container)
+ -> priority_queue<typename Container::value_type, Container, Compare>; // C++17
+
+template<class InputIterator,
+ class Compare = less<iter-value-type<InputIterator>>,
+ class Container = vector<iter-value-type<InputIterator>>>
+priority_queue(InputIterator, InputIterator, Compare = Compare(), Container = Container())
+ -> priority_queue<iter-value-type<InputIterator>, Container, Compare>; // C++17
+
+template<class Compare, class Container, class Allocator>
+priority_queue(Compare, Container, Allocator)
+ -> priority_queue<typename Container::value_type, Container, Compare>; // C++17
+
+template<class InputIterator, class Allocator>
+priority_queue(InputIterator, InputIterator, Allocator)
+ -> priority_queue<iter-value-type<InputIterator>,
+ vector<iter-value-type<InputIterator>, Allocator>,
+ less<iter-value-type<InputIterator>>>; // C++17
+
+template<class InputIterator, class Compare, class Allocator>
+priority_queue(InputIterator, InputIterator, Compare, Allocator)
+ -> priority_queue<iter-value-type<InputIterator>,
+ vector<iter-value-type<InputIterator>, Allocator>, Compare>; // C++17
+
+template<class InputIterator, class Compare, class Container, class Allocator>
+priority_queue(InputIterator, InputIterator, Compare, Container, Allocator)
+ -> priority_queue<typename Container::value_type, Container, Compare>; // C++17
+
+template <class T, class Container, class Compare>
+ void swap(priority_queue<T, Container, Compare>& x,
+ priority_queue<T, Container, Compare>& y)
+ noexcept(noexcept(x.swap(y)));
+
+} // std
+
+*/
+
+#include <__algorithm/make_heap.h>
+#include <__algorithm/pop_heap.h>
+#include <__algorithm/push_heap.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <__memory/uses_allocator.h>
+#include <__utility/forward.h>
+#include <compare>
+#include <deque>
+#include <functional>
+#include <type_traits>
+#include <vector>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TEMPLATE_VIS queue;
+
+template <class _Tp, class _Container>
+_LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y);
+
+template <class _Tp, class _Container>
+_LIBCPP_INLINE_VISIBILITY
+bool
+operator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y);
+
+template <class _Tp, class _Container /*= deque<_Tp>*/>
+class _LIBCPP_TEMPLATE_VIS queue
+{
+public:
+ typedef _Container container_type;
+ typedef typename container_type::value_type value_type;
+ typedef typename container_type::reference reference;
+ typedef typename container_type::const_reference const_reference;
+ typedef typename container_type::size_type size_type;
+ static_assert((is_same<_Tp, value_type>::value), "" );
+
+protected:
+ container_type c;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ queue()
+ _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value)
+ : c() {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ queue(const queue& __q) : c(__q.c) {}
+
+#if _LIBCPP_STD_VER > 20
+ template <class _InputIterator,
+ class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>>
+ _LIBCPP_HIDE_FROM_ABI
+ queue(_InputIterator __first, _InputIterator __last) : c(__first, __last) {}
+
+ template <class _InputIterator,
+ class _Alloc,
+ class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>>
+ _LIBCPP_HIDE_FROM_ABI
+ queue(_InputIterator __first, _InputIterator __second, const _Alloc& __alloc) : c(__first, __second, __alloc) {}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ queue& operator=(const queue& __q) {c = __q.c; return *this;}
+
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ queue(queue&& __q)
+ _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value)
+ : c(_VSTD::move(__q.c)) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ queue& operator=(queue&& __q)
+ _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value)
+ {c = _VSTD::move(__q.c); return *this;}
+#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
+ template <class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY
+ explicit queue(const _Alloc& __a,
+ __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
+ : c(__a) {}
+ template <class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY
+ queue(const queue& __q, const _Alloc& __a,
+ __enable_if_t<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,
+ __enable_if_t<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,
+ __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
+ : c(_VSTD::move(__c), __a) {}
+ template <class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY
+ queue(queue&& __q, const _Alloc& __a,
+ __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
+ : c(_VSTD::move(__q.c), __a) {}
+
+#endif // _LIBCPP_CXX03_LANG
+
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+ bool empty() const {return c.empty();}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type size() const {return c.size();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ reference front() {return c.front();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reference front() const {return c.front();}
+ _LIBCPP_INLINE_VISIBILITY
+ reference back() {return c.back();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reference back() const {return c.back();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void push(const value_type& __v) {c.push_back(__v);}
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ void push(value_type&& __v) {c.push_back(_VSTD::move(__v));}
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+#if _LIBCPP_STD_VER > 14
+ decltype(auto) emplace(_Args&&... __args)
+ { return c.emplace_back(_VSTD::forward<_Args>(__args)...);}
+#else
+ void emplace(_Args&&... __args)
+ { c.emplace_back(_VSTD::forward<_Args>(__args)...);}
+#endif
+#endif // _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ void pop() {c.pop_front();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(queue& __q)
+ _NOEXCEPT_(__is_nothrow_swappable<container_type>::value)
+ {
+ using _VSTD::swap;
+ swap(c, __q.c);
+ }
+
+ template <class _T1, class _C1>
+ friend
+ _LIBCPP_INLINE_VISIBILITY
+ bool
+ operator==(const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y);
+
+ template <class _T1, class _C1>
+ friend
+ _LIBCPP_INLINE_VISIBILITY
+ bool
+ operator< (const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y);
+};
+
+#if _LIBCPP_STD_VER > 14
+template<class _Container,
+ class = enable_if_t<!__is_allocator<_Container>::value>
+>
+queue(_Container)
+ -> queue<typename _Container::value_type, _Container>;
+
+template<class _Container,
+ class _Alloc,
+ class = enable_if_t<!__is_allocator<_Container>::value>,
+ class = enable_if_t<uses_allocator<_Container, _Alloc>::value>
+>
+queue(_Container, _Alloc)
+ -> queue<typename _Container::value_type, _Container>;
+#endif
+
+#if _LIBCPP_STD_VER > 20
+template <class _InputIterator,
+ class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>>
+queue(_InputIterator, _InputIterator)
+ -> queue<__iter_value_type<_InputIterator>>;
+
+template <class _InputIterator,
+ class _Alloc,
+ class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = __enable_if_t<__is_allocator<_Alloc>::value>>
+queue(_InputIterator, _InputIterator, _Alloc)
+ -> queue<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>;
+#endif
+
+template <class _Tp, class _Container>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
+{
+ return __x.c == __y.c;
+}
+
+template <class _Tp, class _Container>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
+{
+ return __x.c < __y.c;
+}
+
+template <class _Tp, class _Container>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
+{
+ return !(__x == __y);
+}
+
+template <class _Tp, class _Container>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator> (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
+{
+ return __y < __x;
+}
+
+template <class _Tp, class _Container>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
+{
+ return !(__x < __y);
+}
+
+template <class _Tp, class _Container>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
+{
+ return !(__y < __x);
+}
+
+template <class _Tp, class _Container>
+inline _LIBCPP_INLINE_VISIBILITY
+__enable_if_t<__is_swappable<_Container>::value, void>
+swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y)
+ _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+ __x.swap(__y);
+}
+
+template <class _Tp, class _Container, class _Alloc>
+struct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc>
+ : public uses_allocator<_Container, _Alloc>
+{
+};
+
+template <class _Tp, class _Container = vector<_Tp>,
+ class _Compare = less<typename _Container::value_type> >
+class _LIBCPP_TEMPLATE_VIS priority_queue
+{
+public:
+ typedef _Container container_type;
+ typedef _Compare value_compare;
+ typedef typename container_type::value_type value_type;
+ typedef typename container_type::reference reference;
+ typedef typename container_type::const_reference const_reference;
+ typedef typename container_type::size_type size_type;
+ static_assert((is_same<_Tp, value_type>::value), "" );
+
+protected:
+ container_type c;
+ value_compare comp;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ priority_queue()
+ _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value &&
+ is_nothrow_default_constructible<value_compare>::value)
+ : c(), comp() {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ priority_queue& operator=(const priority_queue& __q)
+ {c = __q.c; comp = __q.comp; return *this;}
+
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ priority_queue(priority_queue&& __q)
+ _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value &&
+ is_nothrow_move_constructible<value_compare>::value)
+ : c(_VSTD::move(__q.c)), comp(_VSTD::move(__q.comp)) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ priority_queue& operator=(priority_queue&& __q)
+ _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
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit priority_queue(const value_compare& __comp)
+ : c(), comp(__comp) {}
+ _LIBCPP_INLINE_VISIBILITY
+ priority_queue(const value_compare& __comp, const container_type& __c);
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ priority_queue(const value_compare& __comp, container_type&& __c);
+#endif
+ template <class _InputIter, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> >
+ _LIBCPP_INLINE_VISIBILITY
+ priority_queue(_InputIter __f, _InputIter __l,
+ const value_compare& __comp = value_compare());
+ template <class _InputIter, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> >
+ _LIBCPP_INLINE_VISIBILITY
+ priority_queue(_InputIter __f, _InputIter __l,
+ const value_compare& __comp, const container_type& __c);
+#ifndef _LIBCPP_CXX03_LANG
+ template <class _InputIter, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> >
+ _LIBCPP_INLINE_VISIBILITY
+ priority_queue(_InputIter __f, _InputIter __l,
+ const value_compare& __comp, container_type&& __c);
+#endif // _LIBCPP_CXX03_LANG
+ template <class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY
+ explicit priority_queue(const _Alloc& __a,
+ __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
+ template <class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY
+ priority_queue(const value_compare& __comp, const _Alloc& __a,
+ __enable_if_t<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,
+ __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
+ template <class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY
+ priority_queue(const priority_queue& __q, const _Alloc& __a,
+ __enable_if_t<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,
+ __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
+ template <class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY
+ priority_queue(priority_queue&& __q, const _Alloc& __a,
+ __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
+#endif // _LIBCPP_CXX03_LANG
+
+ template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> >
+ _LIBCPP_INLINE_VISIBILITY
+ priority_queue(_InputIter __f, _InputIter __l, const _Alloc& __a,
+ __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
+
+ template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> >
+ _LIBCPP_INLINE_VISIBILITY
+ priority_queue(_InputIter __f, _InputIter __l,
+ const value_compare& __comp, const _Alloc& __a,
+ __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
+
+ template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> >
+ _LIBCPP_INLINE_VISIBILITY
+ priority_queue(_InputIter __f, _InputIter __l,
+ const value_compare& __comp, const container_type& __c, const _Alloc& __a,
+ __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
+
+#ifndef _LIBCPP_CXX03_LANG
+ template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> >
+ _LIBCPP_INLINE_VISIBILITY
+ priority_queue(_InputIter __f, _InputIter __l,
+ const value_compare& __comp, container_type&& __c, const _Alloc& __a,
+ __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
+#endif // _LIBCPP_CXX03_LANG
+
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+ bool empty() const {return c.empty();}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type size() const {return c.size();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reference top() const {return c.front();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void push(const value_type& __v);
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ void push(value_type&& __v);
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+ void emplace(_Args&&... __args);
+#endif // _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ void pop();
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(priority_queue& __q)
+ _NOEXCEPT_(__is_nothrow_swappable<container_type>::value &&
+ __is_nothrow_swappable<value_compare>::value);
+};
+
+#if _LIBCPP_STD_VER >= 17
+template <class _Compare,
+ class _Container,
+ class = enable_if_t<!__is_allocator<_Compare>::value>,
+ class = enable_if_t<!__is_allocator<_Container>::value>
+>
+priority_queue(_Compare, _Container)
+ -> priority_queue<typename _Container::value_type, _Container, _Compare>;
+
+template<class _InputIterator,
+ class _Compare = less<__iter_value_type<_InputIterator>>,
+ class _Container = vector<__iter_value_type<_InputIterator>>,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = enable_if_t<!__is_allocator<_Compare>::value>,
+ class = enable_if_t<!__is_allocator<_Container>::value>
+>
+priority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), _Container = _Container())
+ -> priority_queue<__iter_value_type<_InputIterator>, _Container, _Compare>;
+
+template<class _Compare,
+ class _Container,
+ class _Alloc,
+ class = enable_if_t<!__is_allocator<_Compare>::value>,
+ class = enable_if_t<!__is_allocator<_Container>::value>,
+ class = enable_if_t<uses_allocator<_Container, _Alloc>::value>
+>
+priority_queue(_Compare, _Container, _Alloc)
+ -> priority_queue<typename _Container::value_type, _Container, _Compare>;
+
+template<class _InputIterator, class _Allocator,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = enable_if_t<__is_allocator<_Allocator>::value>
+>
+priority_queue(_InputIterator, _InputIterator, _Allocator)
+ -> priority_queue<__iter_value_type<_InputIterator>,
+ vector<__iter_value_type<_InputIterator>, _Allocator>,
+ less<__iter_value_type<_InputIterator>>>;
+
+template<class _InputIterator, class _Compare, class _Allocator,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = enable_if_t<!__is_allocator<_Compare>::value>,
+ class = enable_if_t<__is_allocator<_Allocator>::value>
+>
+priority_queue(_InputIterator, _InputIterator, _Compare, _Allocator)
+ -> priority_queue<__iter_value_type<_InputIterator>,
+ vector<__iter_value_type<_InputIterator>, _Allocator>, _Compare>;
+
+template<class _InputIterator, class _Compare, class _Container, class _Alloc,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = enable_if_t<!__is_allocator<_Compare>::value>,
+ class = enable_if_t<!__is_allocator<_Container>::value>,
+ class = enable_if_t<uses_allocator<_Container, _Alloc>::value>
+>
+priority_queue(_InputIterator, _InputIterator, _Compare, _Container, _Alloc)
+ -> priority_queue<typename _Container::value_type, _Container, _Compare>;
+#endif
+
+template <class _Tp, class _Container, class _Compare>
+inline
+priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp,
+ const container_type& __c)
+ : c(__c),
+ comp(__comp)
+{
+ _VSTD::make_heap(c.begin(), c.end(), comp);
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Container, class _Compare>
+inline
+priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
+ container_type&& __c)
+ : c(_VSTD::move(__c)),
+ comp(__comp)
+{
+ _VSTD::make_heap(c.begin(), c.end(), comp);
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Container, class _Compare>
+template <class _InputIter, class>
+inline
+priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
+ const value_compare& __comp)
+ : c(__f, __l),
+ comp(__comp)
+{
+ _VSTD::make_heap(c.begin(), c.end(), comp);
+}
+
+template <class _Tp, class _Container, class _Compare>
+template <class _InputIter, class>
+inline
+priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
+ const value_compare& __comp,
+ const container_type& __c)
+ : c(__c),
+ comp(__comp)
+{
+ c.insert(c.end(), __f, __l);
+ _VSTD::make_heap(c.begin(), c.end(), comp);
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Container, class _Compare>
+template <class _InputIter, class>
+inline
+priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
+ const value_compare& __comp,
+ container_type&& __c)
+ : c(_VSTD::move(__c)),
+ comp(__comp)
+{
+ c.insert(c.end(), __f, __l);
+ _VSTD::make_heap(c.begin(), c.end(), comp);
+}
+
+#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,
+ __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
+ : c(__a)
+{
+}
+
+template <class _Tp, class _Container, class _Compare>
+template <class _Alloc>
+inline
+priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
+ const _Alloc& __a,
+ __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
+ : c(__a),
+ comp(__comp)
+{
+}
+
+template <class _Tp, class _Container, class _Compare>
+template <class _Alloc>
+inline
+priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
+ const container_type& __c,
+ const _Alloc& __a,
+ __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
+ : c(__c, __a),
+ comp(__comp)
+{
+ _VSTD::make_heap(c.begin(), c.end(), comp);
+}
+
+template <class _Tp, class _Container, class _Compare>
+template <class _Alloc>
+inline
+priority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q,
+ const _Alloc& __a,
+ __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
+ : c(__q.c, __a),
+ comp(__q.comp)
+{
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Container, class _Compare>
+template <class _Alloc>
+inline
+priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
+ container_type&& __c,
+ const _Alloc& __a,
+ __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
+ : c(_VSTD::move(__c), __a),
+ comp(__comp)
+{
+ _VSTD::make_heap(c.begin(), c.end(), comp);
+}
+
+template <class _Tp, class _Container, class _Compare>
+template <class _Alloc>
+inline
+priority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q,
+ const _Alloc& __a,
+ __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
+ : c(_VSTD::move(__q.c), __a),
+ comp(_VSTD::move(__q.comp))
+{
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Container, class _Compare>
+template <class _InputIter, class _Alloc, class>
+inline
+priority_queue<_Tp, _Container, _Compare>::priority_queue(
+ _InputIter __f, _InputIter __l, const _Alloc& __a,
+ __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
+ : c(__f, __l, __a),
+ comp()
+{
+ _VSTD::make_heap(c.begin(), c.end(), comp);
+}
+
+template <class _Tp, class _Container, class _Compare>
+template <class _InputIter, class _Alloc, class>
+inline
+priority_queue<_Tp, _Container, _Compare>::priority_queue(
+ _InputIter __f, _InputIter __l,
+ const value_compare& __comp, const _Alloc& __a,
+ __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
+ : c(__f, __l, __a),
+ comp(__comp)
+{
+ _VSTD::make_heap(c.begin(), c.end(), comp);
+}
+
+template <class _Tp, class _Container, class _Compare>
+template <class _InputIter, class _Alloc, class>
+inline
+priority_queue<_Tp, _Container, _Compare>::priority_queue(
+ _InputIter __f, _InputIter __l,
+ const value_compare& __comp, const container_type& __c, const _Alloc& __a,
+ __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
+ : c(__c, __a),
+ comp(__comp)
+{
+ c.insert(c.end(), __f, __l);
+ _VSTD::make_heap(c.begin(), c.end(), comp);
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+template <class _Tp, class _Container, class _Compare>
+template <class _InputIter, class _Alloc, class>
+inline
+priority_queue<_Tp, _Container, _Compare>::priority_queue(
+ _InputIter __f, _InputIter __l, const value_compare& __comp,
+ container_type&& __c, const _Alloc& __a,
+ __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
+ : c(_VSTD::move(__c), __a),
+ comp(__comp)
+{
+ c.insert(c.end(), __f, __l);
+ _VSTD::make_heap(c.begin(), c.end(), comp);
+}
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Container, class _Compare>
+inline
+void
+priority_queue<_Tp, _Container, _Compare>::push(const value_type& __v)
+{
+ c.push_back(__v);
+ _VSTD::push_heap(c.begin(), c.end(), comp);
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Container, class _Compare>
+inline
+void
+priority_queue<_Tp, _Container, _Compare>::push(value_type&& __v)
+{
+ c.push_back(_VSTD::move(__v));
+ _VSTD::push_heap(c.begin(), c.end(), comp);
+}
+
+template <class _Tp, class _Container, class _Compare>
+template <class... _Args>
+inline
+void
+priority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args)
+{
+ c.emplace_back(_VSTD::forward<_Args>(__args)...);
+ _VSTD::push_heap(c.begin(), c.end(), comp);
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Container, class _Compare>
+inline
+void
+priority_queue<_Tp, _Container, _Compare>::pop()
+{
+ _VSTD::pop_heap(c.begin(), c.end(), comp);
+ c.pop_back();
+}
+
+template <class _Tp, class _Container, class _Compare>
+inline
+void
+priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q)
+ _NOEXCEPT_(__is_nothrow_swappable<container_type>::value &&
+ __is_nothrow_swappable<value_compare>::value)
+{
+ using _VSTD::swap;
+ swap(c, __q.c);
+ swap(comp, __q.comp);
+}
+
+template <class _Tp, class _Container, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+__enable_if_t<
+ __is_swappable<_Container>::value && __is_swappable<_Compare>::value,
+ void
+>
+swap(priority_queue<_Tp, _Container, _Compare>& __x,
+ priority_queue<_Tp, _Container, _Compare>& __y)
+ _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+ __x.swap(__y);
+}
+
+template <class _Tp, class _Container, class _Compare, class _Alloc>
+struct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc>
+ : public uses_allocator<_Container, _Alloc>
+{
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_QUEUE
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/random b/contrib/libs/cxxsupp/libcxxmsvc/include/random
new file mode 100644
index 0000000000..cf1ac2443a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/random
@@ -0,0 +1,1734 @@
+// -*- 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_RANDOM
+#define _LIBCPP_RANDOM
+
+/*
+ random synopsis
+
+#include <initializer_list>
+
+namespace std
+{
+// [rand.req.urng], uniform random bit generator requirements
+template<class G>
+concept uniform_random_bit_generator = see below; // C++20
+
+// Engines
+
+template <class UIntType, UIntType a, UIntType c, UIntType m>
+class linear_congruential_engine
+{
+public:
+ // types
+ typedef UIntType result_type;
+
+ // engine characteristics
+ static constexpr result_type multiplier = a;
+ static constexpr result_type increment = c;
+ static constexpr result_type modulus = m;
+ static constexpr result_type min() { return c == 0u ? 1u: 0u;}
+ static constexpr result_type max() { return m - 1u;}
+ static constexpr result_type default_seed = 1u;
+
+ // constructors and seeding functions
+ explicit linear_congruential_engine(result_type s = default_seed); // before C++20
+ linear_congruential_engine() : linear_congruential_engine(default_seed) {} // C++20
+ explicit linear_congruential_engine(result_type s); // C++20
+ template<class Sseq> explicit linear_congruential_engine(Sseq& q);
+ void seed(result_type s = default_seed);
+ template<class Sseq> void seed(Sseq& q);
+
+ // generating functions
+ result_type operator()();
+ void discard(unsigned long long z);
+};
+
+template <class UIntType, UIntType a, UIntType c, UIntType m>
+bool
+operator==(const linear_congruential_engine<UIntType, a, c, m>& x,
+ const linear_congruential_engine<UIntType, a, c, m>& y);
+
+template <class UIntType, UIntType a, UIntType c, UIntType m>
+bool
+operator!=(const linear_congruential_engine<UIntType, a, c, m>& x,
+ const linear_congruential_engine<UIntType, a, c, m>& y);
+
+template <class charT, class traits,
+ class UIntType, UIntType a, UIntType c, UIntType m>
+basic_ostream<charT, traits>&
+operator<<(basic_ostream<charT, traits>& os,
+ const linear_congruential_engine<UIntType, a, c, m>& x);
+
+template <class charT, class traits,
+ class UIntType, UIntType a, UIntType c, UIntType m>
+basic_istream<charT, traits>&
+operator>>(basic_istream<charT, traits>& is,
+ linear_congruential_engine<UIntType, a, c, m>& x);
+
+template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+ UIntType a, size_t u, UIntType d, size_t s,
+ UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+class mersenne_twister_engine
+{
+public:
+ // types
+ typedef UIntType result_type;
+
+ // engine characteristics
+ static constexpr size_t word_size = w;
+ static constexpr size_t state_size = n;
+ static constexpr size_t shift_size = m;
+ static constexpr size_t mask_bits = r;
+ static constexpr result_type xor_mask = a;
+ static constexpr size_t tempering_u = u;
+ static constexpr result_type tempering_d = d;
+ static constexpr size_t tempering_s = s;
+ static constexpr result_type tempering_b = b;
+ static constexpr size_t tempering_t = t;
+ static constexpr result_type tempering_c = c;
+ static constexpr size_t tempering_l = l;
+ static constexpr result_type initialization_multiplier = f;
+ static constexpr result_type min () { return 0; }
+ static constexpr result_type max() { return 2^w - 1; }
+ static constexpr result_type default_seed = 5489u;
+
+ // constructors and seeding functions
+ explicit mersenne_twister_engine(result_type s = default_seed); // before C++20
+ mersenne_twister_engine() : mersenne_twister_engine(default_seed) {} // C++20
+ explicit mersenne_twister_engine(result_type s); // C++20
+ template<class Sseq> explicit mersenne_twister_engine(Sseq& q);
+ void seed(result_type value = default_seed);
+ template<class Sseq> void seed(Sseq& q);
+
+ // generating functions
+ result_type operator()();
+ void discard(unsigned long long z);
+};
+
+template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+ UIntType a, size_t u, UIntType d, size_t s,
+ UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+bool
+operator==(
+ const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x,
+ const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& y);
+
+template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+ UIntType a, size_t u, UIntType d, size_t s,
+ UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+bool
+operator!=(
+ const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x,
+ const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& y);
+
+template <class charT, class traits,
+ class UIntType, size_t w, size_t n, size_t m, size_t r,
+ UIntType a, size_t u, UIntType d, size_t s,
+ UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+basic_ostream<charT, traits>&
+operator<<(basic_ostream<charT, traits>& os,
+ const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x);
+
+template <class charT, class traits,
+ class UIntType, size_t w, size_t n, size_t m, size_t r,
+ UIntType a, size_t u, UIntType d, size_t s,
+ UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+basic_istream<charT, traits>&
+operator>>(basic_istream<charT, traits>& is,
+ mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x);
+
+template<class UIntType, size_t w, size_t s, size_t r>
+class subtract_with_carry_engine
+{
+public:
+ // types
+ typedef UIntType result_type;
+
+ // engine characteristics
+ static constexpr size_t word_size = w;
+ static constexpr size_t short_lag = s;
+ static constexpr size_t long_lag = r;
+ static constexpr result_type min() { return 0; }
+ static constexpr result_type max() { return m-1; }
+ static constexpr result_type default_seed = 19780503u;
+
+ // constructors and seeding functions
+ explicit subtract_with_carry_engine(result_type value = default_seed); // before C++20
+ subtract_with_carry_engine() : subtract_with_carry_engine(default_seed) {} // C++20
+ explicit subtract_with_carry_engine(result_type value); // C++20
+ template<class Sseq> explicit subtract_with_carry_engine(Sseq& q);
+ void seed(result_type value = default_seed);
+ template<class Sseq> void seed(Sseq& q);
+
+ // generating functions
+ result_type operator()();
+ void discard(unsigned long long z);
+};
+
+template<class UIntType, size_t w, size_t s, size_t r>
+bool
+operator==(
+ const subtract_with_carry_engine<UIntType, w, s, r>& x,
+ const subtract_with_carry_engine<UIntType, w, s, r>& y);
+
+template<class UIntType, size_t w, size_t s, size_t r>
+bool
+operator!=(
+ const subtract_with_carry_engine<UIntType, w, s, r>& x,
+ const subtract_with_carry_engine<UIntType, w, s, r>& y);
+
+template <class charT, class traits,
+ class UIntType, size_t w, size_t s, size_t r>
+basic_ostream<charT, traits>&
+operator<<(basic_ostream<charT, traits>& os,
+ const subtract_with_carry_engine<UIntType, w, s, r>& x);
+
+template <class charT, class traits,
+ class UIntType, size_t w, size_t s, size_t r>
+basic_istream<charT, traits>&
+operator>>(basic_istream<charT, traits>& is,
+ subtract_with_carry_engine<UIntType, w, s, r>& x);
+
+template<class Engine, size_t p, size_t r>
+class discard_block_engine
+{
+public:
+ // types
+ typedef typename Engine::result_type result_type;
+
+ // engine characteristics
+ static constexpr size_t block_size = p;
+ static constexpr size_t used_block = r;
+ static constexpr result_type min() { return Engine::min(); }
+ static constexpr result_type max() { return Engine::max(); }
+
+ // constructors and seeding functions
+ discard_block_engine();
+ explicit discard_block_engine(const Engine& e);
+ explicit discard_block_engine(Engine&& e);
+ explicit discard_block_engine(result_type s);
+ template<class Sseq> explicit discard_block_engine(Sseq& q);
+ void seed();
+ void seed(result_type s);
+ template<class Sseq> void seed(Sseq& q);
+
+ // generating functions
+ result_type operator()();
+ void discard(unsigned long long z);
+
+ // property functions
+ const Engine& base() const noexcept;
+};
+
+template<class Engine, size_t p, size_t r>
+bool
+operator==(
+ const discard_block_engine<Engine, p, r>& x,
+ const discard_block_engine<Engine, p, r>& y);
+
+template<class Engine, size_t p, size_t r>
+bool
+operator!=(
+ const discard_block_engine<Engine, p, r>& x,
+ const discard_block_engine<Engine, p, r>& y);
+
+template <class charT, class traits,
+ class Engine, size_t p, size_t r>
+basic_ostream<charT, traits>&
+operator<<(basic_ostream<charT, traits>& os,
+ const discard_block_engine<Engine, p, r>& x);
+
+template <class charT, class traits,
+ class Engine, size_t p, size_t r>
+basic_istream<charT, traits>&
+operator>>(basic_istream<charT, traits>& is,
+ discard_block_engine<Engine, p, r>& x);
+
+template<class Engine, size_t w, class UIntType>
+class independent_bits_engine
+{
+public:
+ // types
+ typedef UIntType result_type;
+
+ // engine characteristics
+ static constexpr result_type min() { return 0; }
+ static constexpr result_type max() { return 2^w - 1; }
+
+ // constructors and seeding functions
+ independent_bits_engine();
+ explicit independent_bits_engine(const Engine& e);
+ explicit independent_bits_engine(Engine&& e);
+ explicit independent_bits_engine(result_type s);
+ template<class Sseq> explicit independent_bits_engine(Sseq& q);
+ void seed();
+ void seed(result_type s);
+ template<class Sseq> void seed(Sseq& q);
+
+ // generating functions
+ result_type operator()(); void discard(unsigned long long z);
+
+ // property functions
+ const Engine& base() const noexcept;
+};
+
+template<class Engine, size_t w, class UIntType>
+bool
+operator==(
+ const independent_bits_engine<Engine, w, UIntType>& x,
+ const independent_bits_engine<Engine, w, UIntType>& y);
+
+template<class Engine, size_t w, class UIntType>
+bool
+operator!=(
+ const independent_bits_engine<Engine, w, UIntType>& x,
+ const independent_bits_engine<Engine, w, UIntType>& y);
+
+template <class charT, class traits,
+ class Engine, size_t w, class UIntType>
+basic_ostream<charT, traits>&
+operator<<(basic_ostream<charT, traits>& os,
+ const independent_bits_engine<Engine, w, UIntType>& x);
+
+template <class charT, class traits,
+ class Engine, size_t w, class UIntType>
+basic_istream<charT, traits>&
+operator>>(basic_istream<charT, traits>& is,
+ independent_bits_engine<Engine, w, UIntType>& x);
+
+template<class Engine, size_t k>
+class shuffle_order_engine
+{
+public:
+ // types
+ typedef typename Engine::result_type result_type;
+
+ // engine characteristics
+ static constexpr size_t table_size = k;
+ static constexpr result_type min() { return Engine::min; }
+ static constexpr result_type max() { return Engine::max; }
+
+ // constructors and seeding functions
+ shuffle_order_engine();
+ explicit shuffle_order_engine(const Engine& e);
+ explicit shuffle_order_engine(Engine&& e);
+ explicit shuffle_order_engine(result_type s);
+ template<class Sseq> explicit shuffle_order_engine(Sseq& q);
+ void seed();
+ void seed(result_type s);
+ template<class Sseq> void seed(Sseq& q);
+
+ // generating functions
+ result_type operator()();
+ void discard(unsigned long long z);
+
+ // property functions
+ const Engine& base() const noexcept;
+};
+
+template<class Engine, size_t k>
+bool
+operator==(
+ const shuffle_order_engine<Engine, k>& x,
+ const shuffle_order_engine<Engine, k>& y);
+
+template<class Engine, size_t k>
+bool
+operator!=(
+ const shuffle_order_engine<Engine, k>& x,
+ const shuffle_order_engine<Engine, k>& y);
+
+template <class charT, class traits,
+ class Engine, size_t k>
+basic_ostream<charT, traits>&
+operator<<(basic_ostream<charT, traits>& os,
+ const shuffle_order_engine<Engine, k>& x);
+
+template <class charT, class traits,
+ class Engine, size_t k>
+basic_istream<charT, traits>&
+operator>>(basic_istream<charT, traits>& is,
+ shuffle_order_engine<Engine, k>& x);
+
+typedef linear_congruential_engine<uint_fast32_t, 16807, 0, 2147483647>
+ minstd_rand0;
+typedef linear_congruential_engine<uint_fast32_t, 48271, 0, 2147483647>
+ minstd_rand;
+typedef mersenne_twister_engine<uint_fast32_t, 32, 624, 397, 31,
+ 0x9908b0df,
+ 11, 0xffffffff,
+ 7, 0x9d2c5680,
+ 15, 0xefc60000,
+ 18, 1812433253> mt19937;
+typedef mersenne_twister_engine<uint_fast64_t, 64, 312, 156, 31,
+ 0xb5026f5aa96619e9,
+ 29, 0x5555555555555555,
+ 17, 0x71d67fffeda60000,
+ 37, 0xfff7eee000000000,
+ 43, 6364136223846793005> mt19937_64;
+typedef subtract_with_carry_engine<uint_fast32_t, 24, 10, 24> ranlux24_base;
+typedef subtract_with_carry_engine<uint_fast64_t, 48, 5, 12> ranlux48_base;
+typedef discard_block_engine<ranlux24_base, 223, 23> ranlux24;
+typedef discard_block_engine<ranlux48_base, 389, 11> ranlux48;
+typedef shuffle_order_engine<minstd_rand0, 256> knuth_b;
+typedef minstd_rand default_random_engine;
+
+// Generators
+
+class random_device
+{
+public:
+ // types
+ typedef unsigned int result_type;
+
+ // generator characteristics
+ static constexpr result_type min() { return numeric_limits<result_type>::min(); }
+ static constexpr result_type max() { return numeric_limits<result_type>::max(); }
+
+ // constructors
+ explicit random_device(const string& token = implementation-defined); // before C++20
+ random_device() : random_device(implementation-defined) {} // C++20
+ explicit random_device(const string& token); // C++20
+
+ // generating functions
+ result_type operator()();
+
+ // property functions
+ double entropy() const noexcept;
+
+ // no copy functions
+ random_device(const random_device& ) = delete;
+ void operator=(const random_device& ) = delete;
+};
+
+// Utilities
+
+class seed_seq
+{
+public:
+ // types
+ typedef uint_least32_t result_type;
+
+ // constructors
+ seed_seq();
+ template<class T>
+ seed_seq(initializer_list<T> il);
+ template<class InputIterator>
+ seed_seq(InputIterator begin, InputIterator end);
+
+ // generating functions
+ template<class RandomAccessIterator>
+ void generate(RandomAccessIterator begin, RandomAccessIterator end);
+
+ // property functions
+ size_t size() const;
+ template<class OutputIterator>
+ void param(OutputIterator dest) const;
+
+ // no copy functions
+ seed_seq(const seed_seq&) = delete;
+ void operator=(const seed_seq& ) = delete;
+};
+
+template<class RealType, size_t bits, class URNG>
+ RealType generate_canonical(URNG& g);
+
+// Distributions
+
+template<class IntType = int>
+class uniform_int_distribution
+{
+public:
+ // types
+ typedef IntType result_type;
+
+ class param_type
+ {
+ public:
+ typedef uniform_int_distribution distribution_type;
+
+ explicit param_type(IntType a = 0,
+ IntType b = numeric_limits<IntType>::max());
+
+ result_type a() const;
+ result_type b() const;
+
+ friend bool operator==(const param_type& x, const param_type& y);
+ friend bool operator!=(const param_type& x, const param_type& y);
+ };
+
+ // constructors and reset functions
+ explicit uniform_int_distribution(IntType a = 0,
+ IntType b = numeric_limits<IntType>::max()); // before C++20
+ uniform_int_distribution() : uniform_int_distribution(0) {} // C++20
+ explicit uniform_int_distribution(IntType a,
+ IntType b = numeric_limits<IntType>::max()); // C++20
+ explicit uniform_int_distribution(const param_type& parm);
+ void reset();
+
+ // generating functions
+ template<class URNG> result_type operator()(URNG& g);
+ template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+ // property functions
+ result_type a() const;
+ result_type b() const;
+
+ param_type param() const;
+ void param(const param_type& parm);
+
+ result_type min() const;
+ result_type max() const;
+
+ friend bool operator==(const uniform_int_distribution& x,
+ const uniform_int_distribution& y);
+ friend bool operator!=(const uniform_int_distribution& x,
+ const uniform_int_distribution& y);
+
+ template <class charT, class traits>
+ friend
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os,
+ const uniform_int_distribution& x);
+
+ template <class charT, class traits>
+ friend
+ basic_istream<charT, traits>&
+ operator>>(basic_istream<charT, traits>& is,
+ uniform_int_distribution& x);
+};
+
+template<class RealType = double>
+class uniform_real_distribution
+{
+public:
+ // types
+ typedef RealType result_type;
+
+ class param_type
+ {
+ public:
+ typedef uniform_real_distribution distribution_type;
+
+ explicit param_type(RealType a = 0,
+ RealType b = 1);
+
+ result_type a() const;
+ result_type b() const;
+
+ friend bool operator==(const param_type& x, const param_type& y);
+ friend bool operator!=(const param_type& x, const param_type& y);
+ };
+
+ // constructors and reset functions
+ explicit uniform_real_distribution(RealType a = 0.0, RealType b = 1.0); // before C++20
+ uniform_real_distribution() : uniform_real_distribution(0.0) {} // C++20
+ explicit uniform_real_distribution(RealType a, RealType b = 1.0); // C++20
+ explicit uniform_real_distribution(const param_type& parm);
+ void reset();
+
+ // generating functions
+ template<class URNG> result_type operator()(URNG& g);
+ template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+ // property functions
+ result_type a() const;
+ result_type b() const;
+
+ param_type param() const;
+ void param(const param_type& parm);
+
+ result_type min() const;
+ result_type max() const;
+
+ friend bool operator==(const uniform_real_distribution& x,
+ const uniform_real_distribution& y);
+ friend bool operator!=(const uniform_real_distribution& x,
+ const uniform_real_distribution& y);
+
+ template <class charT, class traits>
+ friend
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os,
+ const uniform_real_distribution& x);
+
+ template <class charT, class traits>
+ friend
+ basic_istream<charT, traits>&
+ operator>>(basic_istream<charT, traits>& is,
+ uniform_real_distribution& x);
+};
+
+class bernoulli_distribution
+{
+public:
+ // types
+ typedef bool result_type;
+
+ class param_type
+ {
+ public:
+ typedef bernoulli_distribution distribution_type;
+
+ explicit param_type(double p = 0.5);
+
+ double p() const;
+
+ friend bool operator==(const param_type& x, const param_type& y);
+ friend bool operator!=(const param_type& x, const param_type& y);
+ };
+
+ // constructors and reset functions
+ explicit bernoulli_distribution(double p = 0.5); // before C++20
+ bernoulli_distribution() : bernoulli_distribution(0.5) {} // C++20
+ explicit bernoulli_distribution(double p); // C++20
+ explicit bernoulli_distribution(const param_type& parm);
+ void reset();
+
+ // generating functions
+ template<class URNG> result_type operator()(URNG& g);
+ template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+ // property functions
+ double p() const;
+
+ param_type param() const;
+ void param(const param_type& parm);
+
+ result_type min() const;
+ result_type max() const;
+
+ friend bool operator==(const bernoulli_distribution& x,
+ const bernoulli_distribution& y);
+ friend bool operator!=(const bernoulli_distribution& x,
+ const bernoulli_distribution& y);
+
+ template <class charT, class traits>
+ friend
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os,
+ const bernoulli_distribution& x);
+
+ template <class charT, class traits>
+ friend
+ basic_istream<charT, traits>&
+ operator>>(basic_istream<charT, traits>& is,
+ bernoulli_distribution& x);
+};
+
+template<class IntType = int>
+class binomial_distribution
+{
+public:
+ // types
+ typedef IntType result_type;
+
+ class param_type
+ {
+ public:
+ typedef binomial_distribution distribution_type;
+
+ explicit param_type(IntType t = 1, double p = 0.5);
+
+ IntType t() const;
+ double p() const;
+
+ friend bool operator==(const param_type& x, const param_type& y);
+ friend bool operator!=(const param_type& x, const param_type& y);
+ };
+
+ // constructors and reset functions
+ explicit binomial_distribution(IntType t = 1, double p = 0.5); // before C++20
+ binomial_distribution() : binomial_distribution(1) {} // C++20
+ explicit binomial_distribution(IntType t, double p = 0.5); // C++20
+ explicit binomial_distribution(const param_type& parm);
+ void reset();
+
+ // generating functions
+ template<class URNG> result_type operator()(URNG& g);
+ template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+ // property functions
+ IntType t() const;
+ double p() const;
+
+ param_type param() const;
+ void param(const param_type& parm);
+
+ result_type min() const;
+ result_type max() const;
+
+ friend bool operator==(const binomial_distribution& x,
+ const binomial_distribution& y);
+ friend bool operator!=(const binomial_distribution& x,
+ const binomial_distribution& y);
+
+ template <class charT, class traits>
+ friend
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os,
+ const binomial_distribution& x);
+
+ template <class charT, class traits>
+ friend
+ basic_istream<charT, traits>&
+ operator>>(basic_istream<charT, traits>& is,
+ binomial_distribution& x);
+};
+
+template<class IntType = int>
+class geometric_distribution
+{
+public:
+ // types
+ typedef IntType result_type;
+
+ class param_type
+ {
+ public:
+ typedef geometric_distribution distribution_type;
+
+ explicit param_type(double p = 0.5);
+
+ double p() const;
+
+ friend bool operator==(const param_type& x, const param_type& y);
+ friend bool operator!=(const param_type& x, const param_type& y);
+ };
+
+ // constructors and reset functions
+ explicit geometric_distribution(double p = 0.5); // before C++20
+ geometric_distribution() : geometric_distribution(0.5) {} // C++20
+ explicit geometric_distribution(double p); // C++20
+ explicit geometric_distribution(const param_type& parm);
+ void reset();
+
+ // generating functions
+ template<class URNG> result_type operator()(URNG& g);
+ template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+ // property functions
+ double p() const;
+
+ param_type param() const;
+ void param(const param_type& parm);
+
+ result_type min() const;
+ result_type max() const;
+
+ friend bool operator==(const geometric_distribution& x,
+ const geometric_distribution& y);
+ friend bool operator!=(const geometric_distribution& x,
+ const geometric_distribution& y);
+
+ template <class charT, class traits>
+ friend
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os,
+ const geometric_distribution& x);
+
+ template <class charT, class traits>
+ friend
+ basic_istream<charT, traits>&
+ operator>>(basic_istream<charT, traits>& is,
+ geometric_distribution& x);
+};
+
+template<class IntType = int>
+class negative_binomial_distribution
+{
+public:
+ // types
+ typedef IntType result_type;
+
+ class param_type
+ {
+ public:
+ typedef negative_binomial_distribution distribution_type;
+
+ explicit param_type(result_type k = 1, double p = 0.5);
+
+ result_type k() const;
+ double p() const;
+
+ friend bool operator==(const param_type& x, const param_type& y);
+ friend bool operator!=(const param_type& x, const param_type& y);
+ };
+
+ // constructor and reset functions
+ explicit negative_binomial_distribution(IntType k = 1, double p = 0.5); // before C++20
+ negative_binomial_distribution() : negative_binomial_distribution(1) {} // C++20
+ explicit negative_binomial_distribution(IntType k, double p = 0.5); // C++20
+ explicit negative_binomial_distribution(const param_type& parm);
+ void reset();
+
+ // generating functions
+ template<class URNG> result_type operator()(URNG& g);
+ template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+ // property functions
+ result_type k() const;
+ double p() const;
+
+ param_type param() const;
+ void param(const param_type& parm);
+
+ result_type min() const;
+ result_type max() const;
+
+ friend bool operator==(const negative_binomial_distribution& x,
+ const negative_binomial_distribution& y);
+ friend bool operator!=(const negative_binomial_distribution& x,
+ const negative_binomial_distribution& y);
+
+ template <class charT, class traits>
+ friend
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os,
+ const negative_binomial_distribution& x);
+
+ template <class charT, class traits>
+ friend
+ basic_istream<charT, traits>&
+ operator>>(basic_istream<charT, traits>& is,
+ negative_binomial_distribution& x);
+};
+
+template<class IntType = int>
+class poisson_distribution
+{
+public:
+ // types
+ typedef IntType result_type;
+
+ class param_type
+ {
+ public:
+ typedef poisson_distribution distribution_type;
+
+ explicit param_type(double mean = 1.0);
+
+ double mean() const;
+
+ friend bool operator==(const param_type& x, const param_type& y);
+ friend bool operator!=(const param_type& x, const param_type& y);
+ };
+
+ // constructors and reset functions
+ explicit poisson_distribution(double mean = 1.0); // before C++20
+ poisson_distribution() : poisson_distribution(1.0) {} // C++20
+ explicit poisson_distribution(double mean); // C++20
+ explicit poisson_distribution(const param_type& parm);
+ void reset();
+
+ // generating functions
+ template<class URNG> result_type operator()(URNG& g);
+ template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+ // property functions
+ double mean() const;
+
+ param_type param() const;
+ void param(const param_type& parm);
+
+ result_type min() const;
+ result_type max() const;
+
+ friend bool operator==(const poisson_distribution& x,
+ const poisson_distribution& y);
+ friend bool operator!=(const poisson_distribution& x,
+ const poisson_distribution& y);
+
+ template <class charT, class traits>
+ friend
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os,
+ const poisson_distribution& x);
+
+ template <class charT, class traits>
+ friend
+ basic_istream<charT, traits>&
+ operator>>(basic_istream<charT, traits>& is,
+ poisson_distribution& x);
+};
+
+template<class RealType = double>
+class exponential_distribution
+{
+public:
+ // types
+ typedef RealType result_type;
+
+ class param_type
+ {
+ public:
+ typedef exponential_distribution distribution_type;
+
+ explicit param_type(result_type lambda = 1.0);
+
+ result_type lambda() const;
+
+ friend bool operator==(const param_type& x, const param_type& y);
+ friend bool operator!=(const param_type& x, const param_type& y);
+ };
+
+ // constructors and reset functions
+ explicit exponential_distribution(RealType lambda = 1.0); // before C++20
+ exponential_distribution() : exponential_distribution(1.0) {} // C++20
+ explicit exponential_distribution(RealType lambda); // C++20
+ explicit exponential_distribution(const param_type& parm);
+ void reset();
+
+ // generating functions
+ template<class URNG> result_type operator()(URNG& g);
+ template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+ // property functions
+ result_type lambda() const;
+
+ param_type param() const;
+ void param(const param_type& parm);
+
+ result_type min() const;
+ result_type max() const;
+
+ friend bool operator==(const exponential_distribution& x,
+ const exponential_distribution& y);
+ friend bool operator!=(const exponential_distribution& x,
+ const exponential_distribution& y);
+
+ template <class charT, class traits>
+ friend
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os,
+ const exponential_distribution& x);
+
+ template <class charT, class traits>
+ friend
+ basic_istream<charT, traits>&
+ operator>>(basic_istream<charT, traits>& is,
+ exponential_distribution& x);
+};
+
+template<class RealType = double>
+class gamma_distribution
+{
+public:
+ // types
+ typedef RealType result_type;
+
+ class param_type
+ {
+ public:
+ typedef gamma_distribution distribution_type;
+
+ explicit param_type(result_type alpha = 1, result_type beta = 1);
+
+ result_type alpha() const;
+ result_type beta() const;
+
+ friend bool operator==(const param_type& x, const param_type& y);
+ friend bool operator!=(const param_type& x, const param_type& y);
+ };
+
+ // constructors and reset functions
+ explicit gamma_distribution(RealType alpha = 0.0, RealType beta = 1.0); // before C++20
+ gamma_distribution() : gamma_distribution(0.0) {} // C++20
+ explicit gamma_distribution(RealType alpha, RealType beta = 1.0); // C++20
+ explicit gamma_distribution(const param_type& parm);
+ void reset();
+
+ // generating functions
+ template<class URNG> result_type operator()(URNG& g);
+ template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+ // property functions
+ result_type alpha() const;
+ result_type beta() const;
+
+ param_type param() const;
+ void param(const param_type& parm);
+
+ result_type min() const;
+ result_type max() const;
+
+ friend bool operator==(const gamma_distribution& x,
+ const gamma_distribution& y);
+ friend bool operator!=(const gamma_distribution& x,
+ const gamma_distribution& y);
+
+ template <class charT, class traits>
+ friend
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os,
+ const gamma_distribution& x);
+
+ template <class charT, class traits>
+ friend
+ basic_istream<charT, traits>&
+ operator>>(basic_istream<charT, traits>& is,
+ gamma_distribution& x);
+};
+
+template<class RealType = double>
+class weibull_distribution
+{
+public:
+ // types
+ typedef RealType result_type;
+
+ class param_type
+ {
+ public:
+ typedef weibull_distribution distribution_type;
+
+ explicit param_type(result_type alpha = 1, result_type beta = 1);
+
+ result_type a() const;
+ result_type b() const;
+
+ friend bool operator==(const param_type& x, const param_type& y);
+ friend bool operator!=(const param_type& x, const param_type& y);
+ };
+
+ // constructor and reset functions
+ explicit weibull_distribution(RealType a = 1.0, RealType b = 1.0); // before C++20
+ weibull_distribution() : weibull_distribution(1.0) {} // C++20
+ explicit weibull_distribution(RealType a, RealType b = 1.0); // C++20
+ explicit weibull_distribution(const param_type& parm);
+ void reset();
+
+ // generating functions
+ template<class URNG> result_type operator()(URNG& g);
+ template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+ // property functions
+ result_type a() const;
+ result_type b() const;
+
+ param_type param() const;
+ void param(const param_type& parm);
+
+ result_type min() const;
+ result_type max() const;
+
+ friend bool operator==(const weibull_distribution& x,
+ const weibull_distribution& y);
+ friend bool operator!=(const weibull_distribution& x,
+ const weibull_distribution& y);
+
+ template <class charT, class traits>
+ friend
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os,
+ const weibull_distribution& x);
+
+ template <class charT, class traits>
+ friend
+ basic_istream<charT, traits>&
+ operator>>(basic_istream<charT, traits>& is,
+ weibull_distribution& x);
+};
+
+template<class RealType = double>
+class extreme_value_distribution
+{
+public:
+ // types
+ typedef RealType result_type;
+
+ class param_type
+ {
+ public:
+ typedef extreme_value_distribution distribution_type;
+
+ explicit param_type(result_type a = 0, result_type b = 1);
+
+ result_type a() const;
+ result_type b() const;
+
+ friend bool operator==(const param_type& x, const param_type& y);
+ friend bool operator!=(const param_type& x, const param_type& y);
+ };
+
+ // constructor and reset functions
+ explicit extreme_value_distribution(RealType a = 0.0, RealType b = 1.0); // before C++20
+ extreme_value_distribution() : extreme_value_distribution(0.0) {} // C++20
+ explicit extreme_value_distribution(RealType a, RealType b = 1.0); // C++20
+ explicit extreme_value_distribution(const param_type& parm);
+ void reset();
+
+ // generating functions
+ template<class URNG> result_type operator()(URNG& g);
+ template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+ // property functions
+ result_type a() const;
+ result_type b() const;
+
+ param_type param() const;
+ void param(const param_type& parm);
+
+ result_type min() const;
+ result_type max() const;
+
+ friend bool operator==(const extreme_value_distribution& x,
+ const extreme_value_distribution& y);
+ friend bool operator!=(const extreme_value_distribution& x,
+ const extreme_value_distribution& y);
+
+ template <class charT, class traits>
+ friend
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os,
+ const extreme_value_distribution& x);
+
+ template <class charT, class traits>
+ friend
+ basic_istream<charT, traits>&
+ operator>>(basic_istream<charT, traits>& is,
+ extreme_value_distribution& x);
+};
+
+template<class RealType = double>
+class normal_distribution
+{
+public:
+ // types
+ typedef RealType result_type;
+
+ class param_type
+ {
+ public:
+ typedef normal_distribution distribution_type;
+
+ explicit param_type(result_type mean = 0, result_type stddev = 1);
+
+ result_type mean() const;
+ result_type stddev() const;
+
+ friend bool operator==(const param_type& x, const param_type& y);
+ friend bool operator!=(const param_type& x, const param_type& y);
+ };
+
+ // constructors and reset functions
+ explicit normal_distribution(RealType mean = 0.0, RealType stddev = 1.0); // before C++20
+ normal_distribution() : normal_distribution(0.0) {} // C++20
+ explicit normal_distribution(RealType mean, RealType stddev = 1.0); // C++20
+ explicit normal_distribution(const param_type& parm);
+ void reset();
+
+ // generating functions
+ template<class URNG> result_type operator()(URNG& g);
+ template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+ // property functions
+ result_type mean() const;
+ result_type stddev() const;
+
+ param_type param() const;
+ void param(const param_type& parm);
+
+ result_type min() const;
+ result_type max() const;
+
+ friend bool operator==(const normal_distribution& x,
+ const normal_distribution& y);
+ friend bool operator!=(const normal_distribution& x,
+ const normal_distribution& y);
+
+ template <class charT, class traits>
+ friend
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os,
+ const normal_distribution& x);
+
+ template <class charT, class traits>
+ friend
+ basic_istream<charT, traits>&
+ operator>>(basic_istream<charT, traits>& is,
+ normal_distribution& x);
+};
+
+template<class RealType = double>
+class lognormal_distribution
+{
+public:
+ // types
+ typedef RealType result_type;
+
+ class param_type
+ {
+ public:
+ typedef lognormal_distribution distribution_type;
+
+ explicit param_type(result_type m = 0, result_type s = 1);
+
+ result_type m() const;
+ result_type s() const;
+
+ friend bool operator==(const param_type& x, const param_type& y);
+ friend bool operator!=(const param_type& x, const param_type& y);
+ };
+
+ // constructor and reset functions
+ explicit lognormal_distribution(RealType mean = 0.0, RealType stddev = 1.0); // before C++20
+ lognormal_distribution() : lognormal_distribution(0.0) {} // C++20
+ explicit lognormal_distribution(RealType mean, RealType stddev = 1.0); // C++20
+ explicit lognormal_distribution(const param_type& parm);
+ void reset();
+
+ // generating functions
+ template<class URNG> result_type operator()(URNG& g);
+ template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+ // property functions
+ result_type m() const;
+ result_type s() const;
+
+ param_type param() const;
+ void param(const param_type& parm);
+
+ result_type min() const;
+ result_type max() const;
+
+ friend bool operator==(const lognormal_distribution& x,
+ const lognormal_distribution& y);
+ friend bool operator!=(const lognormal_distribution& x,
+ const lognormal_distribution& y);
+
+ template <class charT, class traits>
+ friend
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os,
+ const lognormal_distribution& x);
+
+ template <class charT, class traits>
+ friend
+ basic_istream<charT, traits>&
+ operator>>(basic_istream<charT, traits>& is,
+ lognormal_distribution& x);
+};
+
+template<class RealType = double>
+class chi_squared_distribution
+{
+public:
+ // types
+ typedef RealType result_type;
+
+ class param_type
+ {
+ public:
+ typedef chi_squared_distribution distribution_type;
+
+ explicit param_type(result_type n = 1);
+
+ result_type n() const;
+
+ friend bool operator==(const param_type& x, const param_type& y);
+ friend bool operator!=(const param_type& x, const param_type& y);
+ };
+
+ // constructor and reset functions
+ explicit chi_squared_distribution(RealType n = 1.0); // before C++20
+ chi_squared_distribution() : chi_squared_distribution(1.0) {} // C++20
+ explicit chi_squared_distribution(RealType n); // C++20
+ explicit chi_squared_distribution(const param_type& parm);
+ void reset();
+
+ // generating functions
+ template<class URNG> result_type operator()(URNG& g);
+ template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+ // property functions
+ result_type n() const;
+
+ param_type param() const;
+ void param(const param_type& parm);
+
+ result_type min() const;
+ result_type max() const;
+
+ friend bool operator==(const chi_squared_distribution& x,
+ const chi_squared_distribution& y);
+ friend bool operator!=(const chi_squared_distribution& x,
+ const chi_squared_distribution& y);
+
+ template <class charT, class traits>
+ friend
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os,
+ const chi_squared_distribution& x);
+
+ template <class charT, class traits>
+ friend
+ basic_istream<charT, traits>&
+ operator>>(basic_istream<charT, traits>& is,
+ chi_squared_distribution& x);
+};
+
+template<class RealType = double>
+class cauchy_distribution
+{
+public:
+ // types
+ typedef RealType result_type;
+
+ class param_type
+ {
+ public:
+ typedef cauchy_distribution distribution_type;
+
+ explicit param_type(result_type a = 0, result_type b = 1);
+
+ result_type a() const;
+ result_type b() const;
+
+ friend bool operator==(const param_type& x, const param_type& y);
+ friend bool operator!=(const param_type& x, const param_type& y);
+ };
+
+ // constructor and reset functions
+ explicit cauchy_distribution(RealType a = 0.0, RealType b = 1.0); // before C++20
+ cauchy_distribution() : cauchy_distribution(0.0) {} // C++20
+ explicit cauchy_distribution(RealType a, RealType b = 1.0); // C++20
+ explicit cauchy_distribution(const param_type& parm);
+ void reset();
+
+ // generating functions
+ template<class URNG> result_type operator()(URNG& g);
+ template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+ // property functions
+ result_type a() const;
+ result_type b() const;
+
+ param_type param() const;
+ void param(const param_type& parm);
+
+ result_type min() const;
+ result_type max() const;
+
+ friend bool operator==(const cauchy_distribution& x,
+ const cauchy_distribution& y);
+ friend bool operator!=(const cauchy_distribution& x,
+ const cauchy_distribution& y);
+
+ template <class charT, class traits>
+ friend
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os,
+ const cauchy_distribution& x);
+
+ template <class charT, class traits>
+ friend
+ basic_istream<charT, traits>&
+ operator>>(basic_istream<charT, traits>& is,
+ cauchy_distribution& x);
+};
+
+template<class RealType = double>
+class fisher_f_distribution
+{
+public:
+ // types
+ typedef RealType result_type;
+
+ class param_type
+ {
+ public:
+ typedef fisher_f_distribution distribution_type;
+
+ explicit param_type(result_type m = 1, result_type n = 1);
+
+ result_type m() const;
+ result_type n() const;
+
+ friend bool operator==(const param_type& x, const param_type& y);
+ friend bool operator!=(const param_type& x, const param_type& y);
+ };
+
+ // constructor and reset functions
+ explicit fisher_f_distribution(RealType m = 1.0, RealType n = 1.0); // before C++20
+ fisher_f_distribution() : fisher_f_distribution(1.0) {} // C++20
+ explicit fisher_f_distribution(RealType m, RealType n = 1.0); // C++20
+ explicit fisher_f_distribution(const param_type& parm);
+ void reset();
+
+ // generating functions
+ template<class URNG> result_type operator()(URNG& g);
+ template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+ // property functions
+ result_type m() const;
+ result_type n() const;
+
+ param_type param() const;
+ void param(const param_type& parm);
+
+ result_type min() const;
+ result_type max() const;
+
+ friend bool operator==(const fisher_f_distribution& x,
+ const fisher_f_distribution& y);
+ friend bool operator!=(const fisher_f_distribution& x,
+ const fisher_f_distribution& y);
+
+ template <class charT, class traits>
+ friend
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os,
+ const fisher_f_distribution& x);
+
+ template <class charT, class traits>
+ friend
+ basic_istream<charT, traits>&
+ operator>>(basic_istream<charT, traits>& is,
+ fisher_f_distribution& x);
+};
+
+template<class RealType = double>
+class student_t_distribution
+{
+public:
+ // types
+ typedef RealType result_type;
+
+ class param_type
+ {
+ public:
+ typedef student_t_distribution distribution_type;
+
+ explicit param_type(result_type n = 1);
+
+ result_type n() const;
+
+ friend bool operator==(const param_type& x, const param_type& y);
+ friend bool operator!=(const param_type& x, const param_type& y);
+ };
+
+ // constructor and reset functions
+ explicit student_t_distribution(RealType n = 1.0); // before C++20
+ student_t_distribution() : student_t_distribution(1.0) {} // C++20
+ explicit student_t_distribution(RealType n); // C++20
+ explicit student_t_distribution(const param_type& parm);
+ void reset();
+
+ // generating functions
+ template<class URNG> result_type operator()(URNG& g);
+ template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+ // property functions
+ result_type n() const;
+
+ param_type param() const;
+ void param(const param_type& parm);
+
+ result_type min() const;
+ result_type max() const;
+
+ friend bool operator==(const student_t_distribution& x,
+ const student_t_distribution& y);
+ friend bool operator!=(const student_t_distribution& x,
+ const student_t_distribution& y);
+
+ template <class charT, class traits>
+ friend
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os,
+ const student_t_distribution& x);
+
+ template <class charT, class traits>
+ friend
+ basic_istream<charT, traits>&
+ operator>>(basic_istream<charT, traits>& is,
+ student_t_distribution& x);
+};
+
+template<class IntType = int>
+class discrete_distribution
+{
+public:
+ // types
+ typedef IntType result_type;
+
+ class param_type
+ {
+ public:
+ typedef discrete_distribution distribution_type;
+
+ param_type();
+ template<class InputIterator>
+ param_type(InputIterator firstW, InputIterator lastW);
+ param_type(initializer_list<double> wl);
+ template<class UnaryOperation>
+ param_type(size_t nw, double xmin, double xmax, UnaryOperation fw);
+
+ vector<double> probabilities() const;
+
+ friend bool operator==(const param_type& x, const param_type& y);
+ friend bool operator!=(const param_type& x, const param_type& y);
+ };
+
+ // constructor and reset functions
+ discrete_distribution();
+ template<class InputIterator>
+ discrete_distribution(InputIterator firstW, InputIterator lastW);
+ discrete_distribution(initializer_list<double> wl);
+ template<class UnaryOperation>
+ discrete_distribution(size_t nw, double xmin, double xmax,
+ UnaryOperation fw);
+ explicit discrete_distribution(const param_type& parm);
+ void reset();
+
+ // generating functions
+ template<class URNG> result_type operator()(URNG& g);
+ template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+ // property functions
+ vector<double> probabilities() const;
+
+ param_type param() const;
+ void param(const param_type& parm);
+
+ result_type min() const;
+ result_type max() const;
+
+ friend bool operator==(const discrete_distribution& x,
+ const discrete_distribution& y);
+ friend bool operator!=(const discrete_distribution& x,
+ const discrete_distribution& y);
+
+ template <class charT, class traits>
+ friend
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os,
+ const discrete_distribution& x);
+
+ template <class charT, class traits>
+ friend
+ basic_istream<charT, traits>&
+ operator>>(basic_istream<charT, traits>& is,
+ discrete_distribution& x);
+};
+
+template<class RealType = double>
+class piecewise_constant_distribution
+{
+ // types
+ typedef RealType result_type;
+
+ class param_type
+ {
+ public:
+ typedef piecewise_constant_distribution distribution_type;
+
+ param_type();
+ template<class InputIteratorB, class InputIteratorW>
+ param_type(InputIteratorB firstB, InputIteratorB lastB,
+ InputIteratorW firstW);
+ template<class UnaryOperation>
+ param_type(initializer_list<result_type> bl, UnaryOperation fw);
+ template<class UnaryOperation>
+ param_type(size_t nw, result_type xmin, result_type xmax,
+ UnaryOperation fw);
+
+ vector<result_type> intervals() const;
+ vector<result_type> densities() const;
+
+ friend bool operator==(const param_type& x, const param_type& y);
+ friend bool operator!=(const param_type& x, const param_type& y);
+ };
+
+ // constructor and reset functions
+ piecewise_constant_distribution();
+ template<class InputIteratorB, class InputIteratorW>
+ piecewise_constant_distribution(InputIteratorB firstB,
+ InputIteratorB lastB,
+ InputIteratorW firstW);
+ template<class UnaryOperation>
+ piecewise_constant_distribution(initializer_list<result_type> bl,
+ UnaryOperation fw);
+ template<class UnaryOperation>
+ piecewise_constant_distribution(size_t nw, result_type xmin,
+ result_type xmax, UnaryOperation fw);
+ explicit piecewise_constant_distribution(const param_type& parm);
+ void reset();
+
+ // generating functions
+ template<class URNG> result_type operator()(URNG& g);
+ template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+ // property functions
+ vector<result_type> intervals() const;
+ vector<result_type> densities() const;
+
+ param_type param() const;
+ void param(const param_type& parm);
+
+ result_type min() const;
+ result_type max() const;
+
+ friend bool operator==(const piecewise_constant_distribution& x,
+ const piecewise_constant_distribution& y);
+ friend bool operator!=(const piecewise_constant_distribution& x,
+ const piecewise_constant_distribution& y);
+
+ template <class charT, class traits>
+ friend
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os,
+ const piecewise_constant_distribution& x);
+
+ template <class charT, class traits>
+ friend
+ basic_istream<charT, traits>&
+ operator>>(basic_istream<charT, traits>& is,
+ piecewise_constant_distribution& x);
+};
+
+template<class RealType = double>
+class piecewise_linear_distribution
+{
+ // types
+ typedef RealType result_type;
+
+ class param_type
+ {
+ public:
+ typedef piecewise_linear_distribution distribution_type;
+
+ param_type();
+ template<class InputIteratorB, class InputIteratorW>
+ param_type(InputIteratorB firstB, InputIteratorB lastB,
+ InputIteratorW firstW);
+ template<class UnaryOperation>
+ param_type(initializer_list<result_type> bl, UnaryOperation fw);
+ template<class UnaryOperation>
+ param_type(size_t nw, result_type xmin, result_type xmax,
+ UnaryOperation fw);
+
+ vector<result_type> intervals() const;
+ vector<result_type> densities() const;
+
+ friend bool operator==(const param_type& x, const param_type& y);
+ friend bool operator!=(const param_type& x, const param_type& y);
+ };
+
+ // constructor and reset functions
+ piecewise_linear_distribution();
+ template<class InputIteratorB, class InputIteratorW>
+ piecewise_linear_distribution(InputIteratorB firstB,
+ InputIteratorB lastB,
+ InputIteratorW firstW);
+
+ template<class UnaryOperation>
+ piecewise_linear_distribution(initializer_list<result_type> bl,
+ UnaryOperation fw);
+
+ template<class UnaryOperation>
+ piecewise_linear_distribution(size_t nw, result_type xmin,
+ result_type xmax, UnaryOperation fw);
+
+ explicit piecewise_linear_distribution(const param_type& parm);
+ void reset();
+
+ // generating functions
+ template<class URNG> result_type operator()(URNG& g);
+ template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+ // property functions
+ vector<result_type> intervals() const;
+ vector<result_type> densities() const;
+
+ param_type param() const;
+ void param(const param_type& parm);
+
+ result_type min() const;
+ result_type max() const;
+
+ friend bool operator==(const piecewise_linear_distribution& x,
+ const piecewise_linear_distribution& y);
+ friend bool operator!=(const piecewise_linear_distribution& x,
+ const piecewise_linear_distribution& y);
+
+ template <class charT, class traits>
+ friend
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os,
+ const piecewise_linear_distribution& x);
+
+ template <class charT, class traits>
+ friend
+ basic_istream<charT, traits>&
+ operator>>(basic_istream<charT, traits>& is,
+ piecewise_linear_distribution& x);
+};
+
+} // std
+*/
+
+#include <__config>
+#include <__random/bernoulli_distribution.h>
+#include <__random/binomial_distribution.h>
+#include <__random/cauchy_distribution.h>
+#include <__random/chi_squared_distribution.h>
+#include <__random/clamp_to_integral.h>
+#include <__random/default_random_engine.h>
+#include <__random/discard_block_engine.h>
+#include <__random/discrete_distribution.h>
+#include <__random/exponential_distribution.h>
+#include <__random/extreme_value_distribution.h>
+#include <__random/fisher_f_distribution.h>
+#include <__random/gamma_distribution.h>
+#include <__random/generate_canonical.h>
+#include <__random/geometric_distribution.h>
+#include <__random/independent_bits_engine.h>
+#include <__random/is_seed_sequence.h>
+#include <__random/knuth_b.h>
+#include <__random/linear_congruential_engine.h>
+#include <__random/log2.h>
+#include <__random/lognormal_distribution.h>
+#include <__random/mersenne_twister_engine.h>
+#include <__random/negative_binomial_distribution.h>
+#include <__random/normal_distribution.h>
+#include <__random/piecewise_constant_distribution.h>
+#include <__random/piecewise_linear_distribution.h>
+#include <__random/poisson_distribution.h>
+#include <__random/random_device.h>
+#include <__random/ranlux.h>
+#include <__random/seed_seq.h>
+#include <__random/shuffle_order_engine.h>
+#include <__random/student_t_distribution.h>
+#include <__random/subtract_with_carry_engine.h>
+#include <__random/uniform_int_distribution.h>
+#include <__random/uniform_random_bit_generator.h>
+#include <__random/uniform_real_distribution.h>
+#include <__random/weibull_distribution.h>
+#include <initializer_list>
+#include <version>
+
+#include <cmath> // for backward compatibility; TODO remove it
+#include <cstddef> // for backward compatibility; TODO remove it
+#include <cstdint> // for backward compatibility; TODO remove it
+#include <iosfwd> // for backward compatibility; TODO remove it
+#include <limits> // for backward compatibility; TODO remove it
+#include <numeric> // for backward compatibility; TODO remove it
+#include <string> // for backward compatibility; TODO remove it
+#include <type_traits> // for backward compatibility; TODO remove it
+#include <vector> // for backward compatibility; TODO remove it
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#endif // _LIBCPP_RANDOM
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/ranges b/contrib/libs/cxxsupp/libcxxmsvc/include/ranges
new file mode 100644
index 0000000000..25ed65ba1e
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/ranges
@@ -0,0 +1,269 @@
+// -*- 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
+#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<T&>()));
+ 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;
+
+ template<range R>
+ requires see below
+ class owning_view;
+
+ template<class T>
+ inline constexpr bool enable_borrowed_range<owning_view<T>> = enable_borrowed_range<T>;
+
+ // [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.counted], counted view
+ namespace views { inline constexpr unspecified counted = unspecified; }
+
+ // [range.common], common view
+ template<view V>
+ requires (!common_range<V> && copyable<iterator_t<V>>)
+ class common_view;
+
+ // [range.reverse], reverse view
+ template<view V>
+ requires bidirectional_range<V>
+ class reverse_view;
+
+ template<class T>
+ inline constexpr bool enable_borrowed_range<reverse_view<T>> = enable_borrowed_range<T>;
+
+ template<class T>
+ inline constexpr bool enable_borrowed_range<common_view<T>> = enable_borrowed_range<T>;
+
+ // [range.take], take view
+ template<view> class take_view;
+
+ template<class T>
+ inline constexpr bool enable_borrowed_range<take_view<T>> = enable_borrowed_range<T>;
+
+ template<copy_constructible T>
+ requires is_object_v<T>
+ class single_view;
+
+ template<weakly_incrementable W, semiregular Bound = unreachable_sentinel_t>
+ requires weakly-equality-comparable-with<W, Bound> && copyable<W>
+ class iota_view;
+
+ template<class W, class Bound>
+ inline constexpr bool enable_borrowed_range<iota_view<W, Bound>> = true;
+
+ // [range.join], join view
+ template<input_range V>
+ requires view<V> && input_range<range_reference_t<V>>
+ class join_view;
+}
+
+namespace std {
+ namespace views = ranges::views;
+
+ template<class T> struct tuple_size;
+ template<size_t I, class T> struct tuple_element;
+
+ template<class I, class S, ranges::subrange_kind K>
+ struct tuple_size<ranges::subrange<I, S, K>>
+ : integral_constant<size_t, 2> {};
+
+ template<class I, class S, ranges::subrange_kind K>
+ struct tuple_element<0, ranges::subrange<I, S, K>> {
+ using type = I;
+ };
+
+ template<class I, class S, ranges::subrange_kind K>
+ struct tuple_element<1, ranges::subrange<I, S, K>> {
+ using type = S;
+ };
+
+ template<class I, class S, ranges::subrange_kind K>
+ struct tuple_element<0, const ranges::subrange<I, S, K>> {
+ using type = I;
+ };
+
+ template<class I, class S, ranges::subrange_kind K>
+ struct tuple_element<1, const ranges::subrange<I, S, K>> {
+ using type = S;
+ };
+}
+*/
+
+#include <__config>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/common_view.h>
+#include <__ranges/concepts.h>
+#include <__ranges/counted.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/iota_view.h>
+#include <__ranges/join_view.h>
+#include <__ranges/rbegin.h>
+#include <__ranges/ref_view.h>
+#include <__ranges/rend.h>
+#include <__ranges/reverse_view.h>
+#include <__ranges/single_view.h>
+#include <__ranges/size.h>
+#include <__ranges/subrange.h>
+#include <__ranges/take_view.h>
+#include <__ranges/transform_view.h>
+#include <__ranges/view_interface.h>
+#include <__ranges/views.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_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#endif // _LIBCPP_RANGES
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/ratio b/contrib/libs/cxxsupp/libcxxmsvc/include/ratio
new file mode 100644
index 0000000000..8970ba3693
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/ratio
@@ -0,0 +1,527 @@
+// -*- 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_RATIO
+#define _LIBCPP_RATIO
+
+/*
+ ratio synopsis
+
+namespace std
+{
+
+template <intmax_t N, intmax_t D = 1>
+class ratio
+{
+public:
+ static constexpr intmax_t num;
+ static constexpr intmax_t den;
+ typedef ratio<num, den> type;
+};
+
+// ratio arithmetic
+template <class R1, class R2> using ratio_add = ...;
+template <class R1, class R2> using ratio_subtract = ...;
+template <class R1, class R2> using ratio_multiply = ...;
+template <class R1, class R2> using ratio_divide = ...;
+
+// ratio comparison
+template <class R1, class R2> struct ratio_equal;
+template <class R1, class R2> struct ratio_not_equal;
+template <class R1, class R2> struct ratio_less;
+template <class R1, class R2> struct ratio_less_equal;
+template <class R1, class R2> struct ratio_greater;
+template <class R1, class R2> struct ratio_greater_equal;
+
+// convenience SI typedefs
+typedef ratio<1, 1000000000000000000000000> yocto; // not supported
+typedef ratio<1, 1000000000000000000000> zepto; // not supported
+typedef ratio<1, 1000000000000000000> atto;
+typedef ratio<1, 1000000000000000> femto;
+typedef ratio<1, 1000000000000> pico;
+typedef ratio<1, 1000000000> nano;
+typedef ratio<1, 1000000> micro;
+typedef ratio<1, 1000> milli;
+typedef ratio<1, 100> centi;
+typedef ratio<1, 10> deci;
+typedef ratio< 10, 1> deca;
+typedef ratio< 100, 1> hecto;
+typedef ratio< 1000, 1> kilo;
+typedef ratio< 1000000, 1> mega;
+typedef ratio< 1000000000, 1> giga;
+typedef ratio< 1000000000000, 1> tera;
+typedef ratio< 1000000000000000, 1> peta;
+typedef ratio< 1000000000000000000, 1> exa;
+typedef ratio< 1000000000000000000000, 1> zetta; // not supported
+typedef ratio<1000000000000000000000000, 1> yotta; // not supported
+
+ // 20.11.5, ratio comparison
+ template <class R1, class R2> inline constexpr bool ratio_equal_v
+ = ratio_equal<R1, R2>::value; // C++17
+ template <class R1, class R2> inline constexpr bool ratio_not_equal_v
+ = ratio_not_equal<R1, R2>::value; // C++17
+ template <class R1, class R2> inline constexpr bool ratio_less_v
+ = ratio_less<R1, R2>::value; // C++17
+ template <class R1, class R2> inline constexpr bool ratio_less_equal_v
+ = ratio_less_equal<R1, R2>::value; // C++17
+ template <class R1, class R2> inline constexpr bool ratio_greater_v
+ = ratio_greater<R1, R2>::value; // C++17
+ template <class R1, class R2> inline constexpr bool ratio_greater_equal_v
+ = ratio_greater_equal<R1, R2>::value; // C++17
+}
+*/
+
+#include <__config>
+#include <climits>
+#include <cstdint>
+#include <type_traits>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// __static_gcd
+
+template <intmax_t _Xp, intmax_t _Yp>
+struct __static_gcd
+{
+ static const intmax_t value = __static_gcd<_Yp, _Xp % _Yp>::value;
+};
+
+template <intmax_t _Xp>
+struct __static_gcd<_Xp, 0>
+{
+ static const intmax_t value = _Xp;
+};
+
+template <>
+struct __static_gcd<0, 0>
+{
+ static const intmax_t value = 1;
+};
+
+// __static_lcm
+
+template <intmax_t _Xp, intmax_t _Yp>
+struct __static_lcm
+{
+ static const intmax_t value = _Xp / __static_gcd<_Xp, _Yp>::value * _Yp;
+};
+
+template <intmax_t _Xp>
+struct __static_abs
+{
+ static const intmax_t value = _Xp < 0 ? -_Xp : _Xp;
+};
+
+template <intmax_t _Xp>
+struct __static_sign
+{
+ static const intmax_t value = _Xp == 0 ? 0 : (_Xp < 0 ? -1 : 1);
+};
+
+template <intmax_t _Xp, intmax_t _Yp, intmax_t = __static_sign<_Yp>::value>
+class __ll_add;
+
+template <intmax_t _Xp, intmax_t _Yp>
+class __ll_add<_Xp, _Yp, 1>
+{
+ static const intmax_t min = (1LL << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1;
+ static const intmax_t max = -min;
+
+ static_assert(_Xp <= max - _Yp, "overflow in __ll_add");
+public:
+ static const intmax_t value = _Xp + _Yp;
+};
+
+template <intmax_t _Xp, intmax_t _Yp>
+class __ll_add<_Xp, _Yp, 0>
+{
+public:
+ static const intmax_t value = _Xp;
+};
+
+template <intmax_t _Xp, intmax_t _Yp>
+class __ll_add<_Xp, _Yp, -1>
+{
+ static const intmax_t min = (1LL << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1;
+ static const intmax_t max = -min;
+
+ static_assert(min - _Yp <= _Xp, "overflow in __ll_add");
+public:
+ static const intmax_t value = _Xp + _Yp;
+};
+
+template <intmax_t _Xp, intmax_t _Yp, intmax_t = __static_sign<_Yp>::value>
+class __ll_sub;
+
+template <intmax_t _Xp, intmax_t _Yp>
+class __ll_sub<_Xp, _Yp, 1>
+{
+ static const intmax_t min = (1LL << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1;
+ static const intmax_t max = -min;
+
+ static_assert(min + _Yp <= _Xp, "overflow in __ll_sub");
+public:
+ static const intmax_t value = _Xp - _Yp;
+};
+
+template <intmax_t _Xp, intmax_t _Yp>
+class __ll_sub<_Xp, _Yp, 0>
+{
+public:
+ static const intmax_t value = _Xp;
+};
+
+template <intmax_t _Xp, intmax_t _Yp>
+class __ll_sub<_Xp, _Yp, -1>
+{
+ static const intmax_t min = (1LL << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1;
+ static const intmax_t max = -min;
+
+ static_assert(_Xp <= max + _Yp, "overflow in __ll_sub");
+public:
+ static const intmax_t value = _Xp - _Yp;
+};
+
+template <intmax_t _Xp, intmax_t _Yp>
+class __ll_mul
+{
+ static const intmax_t nan = (1LL << (sizeof(intmax_t) * CHAR_BIT - 1));
+ static const intmax_t min = nan + 1;
+ static const intmax_t max = -min;
+ static const intmax_t __a_x = __static_abs<_Xp>::value;
+ static const intmax_t __a_y = __static_abs<_Yp>::value;
+
+ static_assert(_Xp != nan && _Yp != nan && __a_x <= max / __a_y, "overflow in __ll_mul");
+public:
+ static const intmax_t value = _Xp * _Yp;
+};
+
+template <intmax_t _Yp>
+class __ll_mul<0, _Yp>
+{
+public:
+ static const intmax_t value = 0;
+};
+
+template <intmax_t _Xp>
+class __ll_mul<_Xp, 0>
+{
+public:
+ static const intmax_t value = 0;
+};
+
+template <>
+class __ll_mul<0, 0>
+{
+public:
+ static const intmax_t value = 0;
+};
+
+// Not actually used but left here in case needed in future maintenance
+template <intmax_t _Xp, intmax_t _Yp>
+class __ll_div
+{
+ static const intmax_t nan = (1LL << (sizeof(intmax_t) * CHAR_BIT - 1));
+ static const intmax_t min = nan + 1;
+ static const intmax_t max = -min;
+
+ static_assert(_Xp != nan && _Yp != nan && _Yp != 0, "overflow in __ll_div");
+public:
+ static const intmax_t value = _Xp / _Yp;
+};
+
+template <intmax_t _Num, intmax_t _Den = 1>
+class _LIBCPP_TEMPLATE_VIS ratio
+{
+ static_assert(__static_abs<_Num>::value >= 0, "ratio numerator is out of range");
+ static_assert(_Den != 0, "ratio divide by 0");
+ static_assert(__static_abs<_Den>::value > 0, "ratio denominator is out of range");
+ static _LIBCPP_CONSTEXPR const intmax_t __na = __static_abs<_Num>::value;
+ static _LIBCPP_CONSTEXPR const intmax_t __da = __static_abs<_Den>::value;
+ static _LIBCPP_CONSTEXPR const intmax_t __s = __static_sign<_Num>::value * __static_sign<_Den>::value;
+ static _LIBCPP_CONSTEXPR const intmax_t __gcd = __static_gcd<__na, __da>::value;
+public:
+ static _LIBCPP_CONSTEXPR const intmax_t num = __s * __na / __gcd;
+ static _LIBCPP_CONSTEXPR const intmax_t den = __da / __gcd;
+
+ typedef ratio<num, den> type;
+};
+
+template <intmax_t _Num, intmax_t _Den>
+_LIBCPP_CONSTEXPR const intmax_t ratio<_Num, _Den>::num;
+
+template <intmax_t _Num, intmax_t _Den>
+_LIBCPP_CONSTEXPR const intmax_t ratio<_Num, _Den>::den;
+
+template <class _Tp> struct __is_ratio : false_type {};
+template <intmax_t _Num, intmax_t _Den> struct __is_ratio<ratio<_Num, _Den> > : true_type {};
+
+typedef ratio<1LL, 1000000000000000000LL> atto;
+typedef ratio<1LL, 1000000000000000LL> femto;
+typedef ratio<1LL, 1000000000000LL> pico;
+typedef ratio<1LL, 1000000000LL> nano;
+typedef ratio<1LL, 1000000LL> micro;
+typedef ratio<1LL, 1000LL> milli;
+typedef ratio<1LL, 100LL> centi;
+typedef ratio<1LL, 10LL> deci;
+typedef ratio< 10LL, 1LL> deca;
+typedef ratio< 100LL, 1LL> hecto;
+typedef ratio< 1000LL, 1LL> kilo;
+typedef ratio< 1000000LL, 1LL> mega;
+typedef ratio< 1000000000LL, 1LL> giga;
+typedef ratio< 1000000000000LL, 1LL> tera;
+typedef ratio< 1000000000000000LL, 1LL> peta;
+typedef ratio<1000000000000000000LL, 1LL> exa;
+
+template <class _R1, class _R2>
+struct __ratio_multiply
+{
+private:
+ static const intmax_t __gcd_n1_d2 = __static_gcd<_R1::num, _R2::den>::value;
+ static const intmax_t __gcd_d1_n2 = __static_gcd<_R1::den, _R2::num>::value;
+public:
+ typedef typename ratio
+ <
+ __ll_mul<_R1::num / __gcd_n1_d2, _R2::num / __gcd_d1_n2>::value,
+ __ll_mul<_R2::den / __gcd_n1_d2, _R1::den / __gcd_d1_n2>::value
+ >::type type;
+};
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _R1, class _R2> using ratio_multiply
+ = typename __ratio_multiply<_R1, _R2>::type;
+
+#else // _LIBCPP_CXX03_LANG
+
+template <class _R1, class _R2>
+struct _LIBCPP_TEMPLATE_VIS ratio_multiply
+ : public __ratio_multiply<_R1, _R2>::type {};
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _R1, class _R2>
+struct __ratio_divide
+{
+private:
+ static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value;
+ static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value;
+public:
+ typedef typename ratio
+ <
+ __ll_mul<_R1::num / __gcd_n1_n2, _R2::den / __gcd_d1_d2>::value,
+ __ll_mul<_R2::num / __gcd_n1_n2, _R1::den / __gcd_d1_d2>::value
+ >::type type;
+};
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _R1, class _R2> using ratio_divide
+ = typename __ratio_divide<_R1, _R2>::type;
+
+#else // _LIBCPP_CXX03_LANG
+
+template <class _R1, class _R2>
+struct _LIBCPP_TEMPLATE_VIS ratio_divide
+ : public __ratio_divide<_R1, _R2>::type {};
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _R1, class _R2>
+struct __ratio_add
+{
+private:
+ static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value;
+ static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value;
+public:
+ typedef typename ratio_multiply
+ <
+ ratio<__gcd_n1_n2, _R1::den / __gcd_d1_d2>,
+ ratio
+ <
+ __ll_add
+ <
+ __ll_mul<_R1::num / __gcd_n1_n2, _R2::den / __gcd_d1_d2>::value,
+ __ll_mul<_R2::num / __gcd_n1_n2, _R1::den / __gcd_d1_d2>::value
+ >::value,
+ _R2::den
+ >
+ >::type type;
+};
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _R1, class _R2> using ratio_add
+ = typename __ratio_add<_R1, _R2>::type;
+
+#else // _LIBCPP_CXX03_LANG
+
+template <class _R1, class _R2>
+struct _LIBCPP_TEMPLATE_VIS ratio_add
+ : public __ratio_add<_R1, _R2>::type {};
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _R1, class _R2>
+struct __ratio_subtract
+{
+private:
+ static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value;
+ static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value;
+public:
+ typedef typename ratio_multiply
+ <
+ ratio<__gcd_n1_n2, _R1::den / __gcd_d1_d2>,
+ ratio
+ <
+ __ll_sub
+ <
+ __ll_mul<_R1::num / __gcd_n1_n2, _R2::den / __gcd_d1_d2>::value,
+ __ll_mul<_R2::num / __gcd_n1_n2, _R1::den / __gcd_d1_d2>::value
+ >::value,
+ _R2::den
+ >
+ >::type type;
+};
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _R1, class _R2> using ratio_subtract
+ = typename __ratio_subtract<_R1, _R2>::type;
+
+#else // _LIBCPP_CXX03_LANG
+
+template <class _R1, class _R2>
+struct _LIBCPP_TEMPLATE_VIS ratio_subtract
+ : public __ratio_subtract<_R1, _R2>::type {};
+
+#endif // _LIBCPP_CXX03_LANG
+
+// ratio_equal
+
+template <class _R1, class _R2>
+struct _LIBCPP_TEMPLATE_VIS ratio_equal
+ : public _LIBCPP_BOOL_CONSTANT((_R1::num == _R2::num && _R1::den == _R2::den)) {};
+
+template <class _R1, class _R2>
+struct _LIBCPP_TEMPLATE_VIS ratio_not_equal
+ : public _LIBCPP_BOOL_CONSTANT((!ratio_equal<_R1, _R2>::value)) {};
+
+// ratio_less
+
+template <class _R1, class _R2, bool _Odd = false,
+ intmax_t _Q1 = _R1::num / _R1::den, intmax_t _M1 = _R1::num % _R1::den,
+ intmax_t _Q2 = _R2::num / _R2::den, intmax_t _M2 = _R2::num % _R2::den>
+struct __ratio_less1
+{
+ static const bool value = _Odd ? _Q2 < _Q1 : _Q1 < _Q2;
+};
+
+template <class _R1, class _R2, bool _Odd, intmax_t _Qp>
+struct __ratio_less1<_R1, _R2, _Odd, _Qp, 0, _Qp, 0>
+{
+ static const bool value = false;
+};
+
+template <class _R1, class _R2, bool _Odd, intmax_t _Qp, intmax_t _M2>
+struct __ratio_less1<_R1, _R2, _Odd, _Qp, 0, _Qp, _M2>
+{
+ static const bool value = !_Odd;
+};
+
+template <class _R1, class _R2, bool _Odd, intmax_t _Qp, intmax_t _M1>
+struct __ratio_less1<_R1, _R2, _Odd, _Qp, _M1, _Qp, 0>
+{
+ static const bool value = _Odd;
+};
+
+template <class _R1, class _R2, bool _Odd, intmax_t _Qp, intmax_t _M1,
+ intmax_t _M2>
+struct __ratio_less1<_R1, _R2, _Odd, _Qp, _M1, _Qp, _M2>
+{
+ static const bool value = __ratio_less1<ratio<_R1::den, _M1>,
+ ratio<_R2::den, _M2>, !_Odd>::value;
+};
+
+template <class _R1, class _R2, intmax_t _S1 = __static_sign<_R1::num>::value,
+ intmax_t _S2 = __static_sign<_R2::num>::value>
+struct __ratio_less
+{
+ static const bool value = _S1 < _S2;
+};
+
+template <class _R1, class _R2>
+struct __ratio_less<_R1, _R2, 1LL, 1LL>
+{
+ static const bool value = __ratio_less1<_R1, _R2>::value;
+};
+
+template <class _R1, class _R2>
+struct __ratio_less<_R1, _R2, -1LL, -1LL>
+{
+ static const bool value = __ratio_less1<ratio<-_R2::num, _R2::den>, ratio<-_R1::num, _R1::den> >::value;
+};
+
+template <class _R1, class _R2>
+struct _LIBCPP_TEMPLATE_VIS ratio_less
+ : public _LIBCPP_BOOL_CONSTANT((__ratio_less<_R1, _R2>::value)) {};
+
+template <class _R1, class _R2>
+struct _LIBCPP_TEMPLATE_VIS ratio_less_equal
+ : public _LIBCPP_BOOL_CONSTANT((!ratio_less<_R2, _R1>::value)) {};
+
+template <class _R1, class _R2>
+struct _LIBCPP_TEMPLATE_VIS ratio_greater
+ : public _LIBCPP_BOOL_CONSTANT((ratio_less<_R2, _R1>::value)) {};
+
+template <class _R1, class _R2>
+struct _LIBCPP_TEMPLATE_VIS ratio_greater_equal
+ : public _LIBCPP_BOOL_CONSTANT((!ratio_less<_R1, _R2>::value)) {};
+
+template <class _R1, class _R2>
+struct __ratio_gcd
+{
+ typedef ratio<__static_gcd<_R1::num, _R2::num>::value,
+ __static_lcm<_R1::den, _R2::den>::value> type;
+};
+
+#if _LIBCPP_STD_VER > 14
+template <class _R1, class _R2>
+inline constexpr bool ratio_equal_v = ratio_equal<_R1, _R2>::value;
+
+template <class _R1, class _R2>
+inline constexpr bool ratio_not_equal_v = ratio_not_equal<_R1, _R2>::value;
+
+template <class _R1, class _R2>
+inline constexpr bool ratio_less_v = ratio_less<_R1, _R2>::value;
+
+template <class _R1, class _R2>
+inline constexpr bool ratio_less_equal_v = ratio_less_equal<_R1, _R2>::value;
+
+template <class _R1, class _R2>
+inline constexpr bool ratio_greater_v = ratio_greater<_R1, _R2>::value;
+
+template <class _R1, class _R2>
+inline constexpr bool ratio_greater_equal_v = ratio_greater_equal<_R1, _R2>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_RATIO
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/regex b/contrib/libs/cxxsupp/libcxxmsvc/include/regex
new file mode 100644
index 0000000000..68922f66e4
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/regex
@@ -0,0 +1,6834 @@
+// -*- 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_REGEX
+#define _LIBCPP_REGEX
+
+/*
+ regex synopsis
+
+#include <initializer_list>
+
+namespace std
+{
+
+namespace regex_constants
+{
+
+enum syntax_option_type
+{
+ icase = unspecified,
+ nosubs = unspecified,
+ optimize = unspecified,
+ collate = unspecified,
+ ECMAScript = unspecified,
+ basic = unspecified,
+ extended = unspecified,
+ awk = unspecified,
+ grep = unspecified,
+ egrep = unspecified,
+ multiline = unspecified
+};
+
+constexpr syntax_option_type operator~(syntax_option_type f);
+constexpr syntax_option_type operator&(syntax_option_type lhs, syntax_option_type rhs);
+constexpr syntax_option_type operator|(syntax_option_type lhs, syntax_option_type rhs);
+
+enum match_flag_type
+{
+ match_default = 0,
+ match_not_bol = unspecified,
+ match_not_eol = unspecified,
+ match_not_bow = unspecified,
+ match_not_eow = unspecified,
+ match_any = unspecified,
+ match_not_null = unspecified,
+ match_continuous = unspecified,
+ match_prev_avail = unspecified,
+ format_default = 0,
+ format_sed = unspecified,
+ format_no_copy = unspecified,
+ format_first_only = unspecified
+};
+
+constexpr match_flag_type operator~(match_flag_type f);
+constexpr match_flag_type operator&(match_flag_type lhs, match_flag_type rhs);
+constexpr match_flag_type operator|(match_flag_type lhs, match_flag_type rhs);
+
+enum error_type
+{
+ error_collate = unspecified,
+ error_ctype = unspecified,
+ error_escape = unspecified,
+ error_backref = unspecified,
+ error_brack = unspecified,
+ error_paren = unspecified,
+ error_brace = unspecified,
+ error_badbrace = unspecified,
+ error_range = unspecified,
+ error_space = unspecified,
+ error_badrepeat = unspecified,
+ error_complexity = unspecified,
+ error_stack = unspecified
+};
+
+} // regex_constants
+
+class regex_error
+ : public runtime_error
+{
+public:
+ explicit regex_error(regex_constants::error_type ecode);
+ regex_constants::error_type code() const;
+};
+
+template <class charT>
+struct regex_traits
+{
+public:
+ typedef charT char_type;
+ typedef basic_string<char_type> string_type;
+ typedef locale locale_type;
+ typedef /bitmask_type/ char_class_type;
+
+ regex_traits();
+
+ static size_t length(const char_type* p);
+ charT translate(charT c) const;
+ charT translate_nocase(charT c) const;
+ template <class ForwardIterator>
+ string_type
+ transform(ForwardIterator first, ForwardIterator last) const;
+ template <class ForwardIterator>
+ string_type
+ transform_primary( ForwardIterator first, ForwardIterator last) const;
+ template <class ForwardIterator>
+ string_type
+ lookup_collatename(ForwardIterator first, ForwardIterator last) const;
+ template <class ForwardIterator>
+ char_class_type
+ lookup_classname(ForwardIterator first, ForwardIterator last,
+ bool icase = false) const;
+ bool isctype(charT c, char_class_type f) const;
+ int value(charT ch, int radix) const;
+ locale_type imbue(locale_type l);
+ locale_type getloc()const;
+};
+
+template <class charT, class traits = regex_traits<charT>>
+class basic_regex
+{
+public:
+ // types:
+ typedef charT value_type;
+ typedef traits traits_type;
+ typedef typename traits::string_type string_type;
+ typedef regex_constants::syntax_option_type flag_type;
+ typedef typename traits::locale_type locale_type;
+
+ // constants:
+ static constexpr regex_constants::syntax_option_type icase = regex_constants::icase;
+ static constexpr regex_constants::syntax_option_type nosubs = regex_constants::nosubs;
+ static constexpr regex_constants::syntax_option_type optimize = regex_constants::optimize;
+ static constexpr regex_constants::syntax_option_type collate = regex_constants::collate;
+ static constexpr regex_constants::syntax_option_type ECMAScript = regex_constants::ECMAScript;
+ static constexpr regex_constants::syntax_option_type basic = regex_constants::basic;
+ static constexpr regex_constants::syntax_option_type extended = regex_constants::extended;
+ static constexpr regex_constants::syntax_option_type awk = regex_constants::awk;
+ static constexpr regex_constants::syntax_option_type grep = regex_constants::grep;
+ static constexpr regex_constants::syntax_option_type egrep = regex_constants::egrep;
+ static constexpr regex_constants::syntax_option_type multiline = regex_constants::multiline;
+
+ // construct/copy/destroy:
+ basic_regex();
+ explicit basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript);
+ basic_regex(const charT* p, size_t len, flag_type f = regex_constants::ECMAScript);
+ basic_regex(const basic_regex&);
+ basic_regex(basic_regex&&) noexcept;
+ template <class ST, class SA>
+ explicit basic_regex(const basic_string<charT, ST, SA>& p,
+ flag_type f = regex_constants::ECMAScript);
+ template <class ForwardIterator>
+ basic_regex(ForwardIterator first, ForwardIterator last,
+ flag_type f = regex_constants::ECMAScript);
+ basic_regex(initializer_list<charT>, flag_type = regex_constants::ECMAScript);
+
+ ~basic_regex();
+
+ basic_regex& operator=(const basic_regex&);
+ basic_regex& operator=(basic_regex&&) noexcept;
+ basic_regex& operator=(const charT* ptr);
+ basic_regex& operator=(initializer_list<charT> il);
+ template <class ST, class SA>
+ basic_regex& operator=(const basic_string<charT, ST, SA>& p);
+
+ // assign:
+ basic_regex& assign(const basic_regex& that);
+ basic_regex& assign(basic_regex&& that) noexcept;
+ basic_regex& assign(const charT* ptr, flag_type f = regex_constants::ECMAScript);
+ basic_regex& assign(const charT* p, size_t len, flag_type f = regex_constants::ECMAScript);
+ template <class string_traits, class A>
+ basic_regex& assign(const basic_string<charT, string_traits, A>& s,
+ flag_type f = regex_constants::ECMAScript);
+ template <class InputIterator>
+ basic_regex& assign(InputIterator first, InputIterator last,
+ flag_type f = regex_constants::ECMAScript);
+ basic_regex& assign(initializer_list<charT>, flag_type f = regex_constants::ECMAScript);
+
+ // const operations:
+ unsigned mark_count() const;
+ flag_type flags() const;
+
+ // locale:
+ locale_type imbue(locale_type loc);
+ locale_type getloc() const;
+
+ // swap:
+ void swap(basic_regex&);
+};
+
+template<class ForwardIterator>
+basic_regex(ForwardIterator, ForwardIterator,
+ regex_constants::syntax_option_type = regex_constants::ECMAScript)
+ -> basic_regex<typename iterator_traits<ForwardIterator>::value_type>; // C++17
+
+typedef basic_regex<char> regex;
+typedef basic_regex<wchar_t> wregex;
+
+template <class charT, class traits>
+ void swap(basic_regex<charT, traits>& e1, basic_regex<charT, traits>& e2);
+
+template <class BidirectionalIterator>
+class sub_match
+ : public pair<BidirectionalIterator, BidirectionalIterator>
+{
+public:
+ typedef typename iterator_traits<BidirectionalIterator>::value_type value_type;
+ typedef typename iterator_traits<BidirectionalIterator>::difference_type difference_type;
+ typedef BidirectionalIterator iterator;
+ typedef basic_string<value_type> string_type;
+
+ bool matched;
+
+ constexpr sub_match();
+
+ difference_type length() const;
+ operator string_type() const;
+ string_type str() const;
+
+ int compare(const sub_match& s) const;
+ int compare(const string_type& s) const;
+ int compare(const value_type* s) const;
+};
+
+typedef sub_match<const char*> csub_match;
+typedef sub_match<const wchar_t*> wcsub_match;
+typedef sub_match<string::const_iterator> ssub_match;
+typedef sub_match<wstring::const_iterator> wssub_match;
+
+template <class BiIter>
+ bool
+ operator==(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+ bool
+ operator!=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+ bool
+ operator<(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+ bool
+ operator<=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+ bool
+ operator>=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+ bool
+ operator>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
+
+template <class BiIter, class ST, class SA>
+ bool
+ operator==(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
+ const sub_match<BiIter>& rhs);
+
+template <class BiIter, class ST, class SA>
+ bool
+ operator!=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
+ const sub_match<BiIter>& rhs);
+
+template <class BiIter, class ST, class SA>
+ bool
+ operator<(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
+ const sub_match<BiIter>& rhs);
+
+template <class BiIter, class ST, class SA>
+ bool
+ operator>(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
+ const sub_match<BiIter>& rhs);
+
+template <class BiIter, class ST, class SA>
+ bool operator>=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
+ const sub_match<BiIter>& rhs);
+
+template <class BiIter, class ST, class SA>
+ bool
+ operator<=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
+ const sub_match<BiIter>& rhs);
+
+template <class BiIter, class ST, class SA>
+ bool
+ operator==(const sub_match<BiIter>& lhs,
+ const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
+
+template <class BiIter, class ST, class SA>
+ bool
+ operator!=(const sub_match<BiIter>& lhs,
+ const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
+
+template <class BiIter, class ST, class SA>
+ bool
+ operator<(const sub_match<BiIter>& lhs,
+ const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
+
+template <class BiIter, class ST, class SA>
+ bool operator>(const sub_match<BiIter>& lhs,
+ const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
+
+template <class BiIter, class ST, class SA>
+ bool
+ operator>=(const sub_match<BiIter>& lhs,
+ const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
+
+template <class BiIter, class ST, class SA>
+ bool
+ operator<=(const sub_match<BiIter>& lhs,
+ const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
+
+template <class BiIter>
+ bool
+ operator==(typename iterator_traits<BiIter>::value_type const* lhs,
+ const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+ bool
+ operator!=(typename iterator_traits<BiIter>::value_type const* lhs,
+ const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+ bool
+ operator<(typename iterator_traits<BiIter>::value_type const* lhs,
+ const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+ bool
+ operator>(typename iterator_traits<BiIter>::value_type const* lhs,
+ const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+ bool
+ operator>=(typename iterator_traits<BiIter>::value_type const* lhs,
+ const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+ bool
+ operator<=(typename iterator_traits<BiIter>::value_type const* lhs,
+ const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+ bool
+ operator==(const sub_match<BiIter>& lhs,
+ typename iterator_traits<BiIter>::value_type const* rhs);
+
+template <class BiIter>
+ bool
+ operator!=(const sub_match<BiIter>& lhs,
+ typename iterator_traits<BiIter>::value_type const* rhs);
+
+template <class BiIter>
+ bool
+ operator<(const sub_match<BiIter>& lhs,
+ typename iterator_traits<BiIter>::value_type const* rhs);
+
+template <class BiIter>
+ bool
+ operator>(const sub_match<BiIter>& lhs,
+ typename iterator_traits<BiIter>::value_type const* rhs);
+
+template <class BiIter>
+ bool
+ operator>=(const sub_match<BiIter>& lhs,
+ typename iterator_traits<BiIter>::value_type const* rhs);
+
+template <class BiIter>
+ bool
+ operator<=(const sub_match<BiIter>& lhs,
+ typename iterator_traits<BiIter>::value_type const* rhs);
+
+template <class BiIter>
+ bool
+ operator==(typename iterator_traits<BiIter>::value_type const& lhs,
+ const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+ bool
+ operator!=(typename iterator_traits<BiIter>::value_type const& lhs,
+ const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+ bool
+ operator<(typename iterator_traits<BiIter>::value_type const& lhs,
+ const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+ bool
+ operator>(typename iterator_traits<BiIter>::value_type const& lhs,
+ const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+ bool
+ operator>=(typename iterator_traits<BiIter>::value_type const& lhs,
+ const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+ bool
+ operator<=(typename iterator_traits<BiIter>::value_type const& lhs,
+ const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+ bool
+ operator==(const sub_match<BiIter>& lhs,
+ typename iterator_traits<BiIter>::value_type const& rhs);
+
+template <class BiIter>
+ bool
+ operator!=(const sub_match<BiIter>& lhs,
+ typename iterator_traits<BiIter>::value_type const& rhs);
+
+template <class BiIter>
+ bool
+ operator<(const sub_match<BiIter>& lhs,
+ typename iterator_traits<BiIter>::value_type const& rhs);
+
+template <class BiIter>
+ bool
+ operator>(const sub_match<BiIter>& lhs,
+ typename iterator_traits<BiIter>::value_type const& rhs);
+
+template <class BiIter>
+ bool
+ operator>=(const sub_match<BiIter>& lhs,
+ typename iterator_traits<BiIter>::value_type const& rhs);
+
+template <class BiIter>
+ bool
+ operator<=(const sub_match<BiIter>& lhs,
+ typename iterator_traits<BiIter>::value_type const& rhs);
+
+template <class charT, class ST, class BiIter>
+ basic_ostream<charT, ST>&
+ operator<<(basic_ostream<charT, ST>& os, const sub_match<BiIter>& m);
+
+template <class BidirectionalIterator,
+ class Allocator = allocator<sub_match<BidirectionalIterator>>>
+class match_results
+{
+public:
+ typedef sub_match<BidirectionalIterator> value_type;
+ typedef const value_type& const_reference;
+ typedef value_type& reference;
+ typedef /implementation-defined/ const_iterator;
+ typedef const_iterator iterator;
+ typedef typename iterator_traits<BidirectionalIterator>::difference_type difference_type;
+ typedef typename allocator_traits<Allocator>::size_type size_type;
+ typedef Allocator allocator_type;
+ typedef typename iterator_traits<BidirectionalIterator>::value_type char_type;
+ typedef basic_string<char_type> string_type;
+
+ // construct/copy/destroy:
+ explicit match_results(const Allocator& a = Allocator()); // before C++20
+ match_results() : match_results(Allocator()) {} // C++20
+ explicit match_results(const Allocator& a); // C++20
+ match_results(const match_results& m);
+ match_results(match_results&& m) noexcept;
+ match_results& operator=(const match_results& m);
+ match_results& operator=(match_results&& m);
+ ~match_results();
+
+ bool ready() const;
+
+ // size:
+ size_type size() const;
+ size_type max_size() const;
+ bool empty() const;
+
+ // element access:
+ difference_type length(size_type sub = 0) const;
+ difference_type position(size_type sub = 0) const;
+ string_type str(size_type sub = 0) const;
+ const_reference operator[](size_type n) const;
+
+ const_reference prefix() const;
+ const_reference suffix() const;
+
+ const_iterator begin() const;
+ const_iterator end() const;
+ const_iterator cbegin() const;
+ const_iterator cend() const;
+
+ // format:
+ template <class OutputIter>
+ OutputIter
+ format(OutputIter out, const char_type* fmt_first,
+ const char_type* fmt_last,
+ regex_constants::match_flag_type flags = regex_constants::format_default) const;
+ template <class OutputIter, class ST, class SA>
+ OutputIter
+ format(OutputIter out, const basic_string<char_type, ST, SA>& fmt,
+ regex_constants::match_flag_type flags = regex_constants::format_default) const;
+ template <class ST, class SA>
+ basic_string<char_type, ST, SA>
+ format(const basic_string<char_type, ST, SA>& fmt,
+ regex_constants::match_flag_type flags = regex_constants::format_default) const;
+ string_type
+ format(const char_type* fmt,
+ regex_constants::match_flag_type flags = regex_constants::format_default) const;
+
+ // allocator:
+ allocator_type get_allocator() const;
+
+ // swap:
+ void swap(match_results& that);
+};
+
+typedef match_results<const char*> cmatch;
+typedef match_results<const wchar_t*> wcmatch;
+typedef match_results<string::const_iterator> smatch;
+typedef match_results<wstring::const_iterator> wsmatch;
+
+template <class BidirectionalIterator, class Allocator>
+ bool
+ operator==(const match_results<BidirectionalIterator, Allocator>& m1,
+ const match_results<BidirectionalIterator, Allocator>& m2);
+
+template <class BidirectionalIterator, class Allocator>
+ bool
+ operator!=(const match_results<BidirectionalIterator, Allocator>& m1,
+ const match_results<BidirectionalIterator, Allocator>& m2);
+
+template <class BidirectionalIterator, class Allocator>
+ void
+ swap(match_results<BidirectionalIterator, Allocator>& m1,
+ match_results<BidirectionalIterator, Allocator>& m2);
+
+template <class BidirectionalIterator, class Allocator, class charT, class traits>
+ bool
+ regex_match(BidirectionalIterator first, BidirectionalIterator last,
+ match_results<BidirectionalIterator, Allocator>& m,
+ const basic_regex<charT, traits>& e,
+ regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class BidirectionalIterator, class charT, class traits>
+ bool
+ regex_match(BidirectionalIterator first, BidirectionalIterator last,
+ const basic_regex<charT, traits>& e,
+ regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class charT, class Allocator, class traits>
+ bool
+ regex_match(const charT* str, match_results<const charT*, Allocator>& m,
+ const basic_regex<charT, traits>& e,
+ regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class ST, class SA, class Allocator, class charT, class traits>
+ bool
+ regex_match(const basic_string<charT, ST, SA>& s,
+ match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
+ const basic_regex<charT, traits>& e,
+ regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class ST, class SA, class Allocator, class charT, class traits>
+ bool
+ regex_match(const basic_string<charT, ST, SA>&& s,
+ match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
+ const basic_regex<charT, traits>& e,
+ regex_constants::match_flag_type flags = regex_constants::match_default) = delete; // C++14
+
+template <class charT, class traits>
+ bool
+ regex_match(const charT* str, const basic_regex<charT, traits>& e,
+ regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class ST, class SA, class charT, class traits>
+ bool
+ regex_match(const basic_string<charT, ST, SA>& s,
+ const basic_regex<charT, traits>& e,
+ regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class BidirectionalIterator, class Allocator, class charT, class traits>
+ bool
+ regex_search(BidirectionalIterator first, BidirectionalIterator last,
+ match_results<BidirectionalIterator, Allocator>& m,
+ const basic_regex<charT, traits>& e,
+ regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class BidirectionalIterator, class charT, class traits>
+ bool
+ regex_search(BidirectionalIterator first, BidirectionalIterator last,
+ const basic_regex<charT, traits>& e,
+ regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class charT, class Allocator, class traits>
+ bool
+ regex_search(const charT* str, match_results<const charT*, Allocator>& m,
+ const basic_regex<charT, traits>& e,
+ regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class charT, class traits>
+ bool
+ regex_search(const charT* str, const basic_regex<charT, traits>& e,
+ regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class ST, class SA, class charT, class traits>
+ bool
+ regex_search(const basic_string<charT, ST, SA>& s,
+ const basic_regex<charT, traits>& e,
+ regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class ST, class SA, class Allocator, class charT, class traits>
+ bool
+ regex_search(const basic_string<charT, ST, SA>& s,
+ match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
+ const basic_regex<charT, traits>& e,
+ regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class ST, class SA, class Allocator, class charT, class traits>
+ bool
+ regex_search(const basic_string<charT, ST, SA>&& s,
+ match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
+ const basic_regex<charT, traits>& e,
+ regex_constants::match_flag_type flags = regex_constants::match_default) = delete; // C++14
+
+template <class OutputIterator, class BidirectionalIterator,
+ class traits, class charT, class ST, class SA>
+ OutputIterator
+ regex_replace(OutputIterator out,
+ BidirectionalIterator first, BidirectionalIterator last,
+ const basic_regex<charT, traits>& e,
+ const basic_string<charT, ST, SA>& fmt,
+ regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class OutputIterator, class BidirectionalIterator,
+ class traits, class charT>
+ OutputIterator
+ regex_replace(OutputIterator out,
+ BidirectionalIterator first, BidirectionalIterator last,
+ const basic_regex<charT, traits>& e, const charT* fmt,
+ regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class traits, class charT, class ST, class SA, class FST, class FSA>
+ basic_string<charT, ST, SA>
+ regex_replace(const basic_string<charT, ST, SA>& s,
+ const basic_regex<charT, traits>& e,
+ const basic_string<charT, FST, FSA>& fmt,
+ regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class traits, class charT, class ST, class SA>
+ basic_string<charT, ST, SA>
+ regex_replace(const basic_string<charT, ST, SA>& s,
+ const basic_regex<charT, traits>& e, const charT* fmt,
+ regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class traits, class charT, class ST, class SA>
+ basic_string<charT>
+ regex_replace(const charT* s,
+ const basic_regex<charT, traits>& e,
+ const basic_string<charT, ST, SA>& fmt,
+ regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class traits, class charT>
+ basic_string<charT>
+ regex_replace(const charT* s,
+ const basic_regex<charT, traits>& e,
+ const charT* fmt,
+ regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class BidirectionalIterator,
+ class charT = typename iterator_traits< BidirectionalIterator>::value_type,
+ class traits = regex_traits<charT>>
+class regex_iterator
+{
+public:
+ typedef basic_regex<charT, traits> regex_type;
+ typedef match_results<BidirectionalIterator> value_type;
+ typedef ptrdiff_t difference_type;
+ typedef const value_type* pointer;
+ typedef const value_type& reference;
+ typedef forward_iterator_tag iterator_category;
+
+ regex_iterator();
+ regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
+ const regex_type& re,
+ regex_constants::match_flag_type m = regex_constants::match_default);
+ regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
+ const regex_type&& re,
+ regex_constants::match_flag_type m
+ = regex_constants::match_default) = delete; // C++14
+ regex_iterator(const regex_iterator&);
+ regex_iterator& operator=(const regex_iterator&);
+
+ bool operator==(const regex_iterator&) const;
+ bool operator!=(const regex_iterator&) const;
+
+ const value_type& operator*() const;
+ const value_type* operator->() const;
+
+ regex_iterator& operator++();
+ regex_iterator operator++(int);
+};
+
+typedef regex_iterator<const char*> cregex_iterator;
+typedef regex_iterator<const wchar_t*> wcregex_iterator;
+typedef regex_iterator<string::const_iterator> sregex_iterator;
+typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
+
+template <class BidirectionalIterator,
+ class charT = typename iterator_traits<BidirectionalIterator>::value_type,
+ class traits = regex_traits<charT>>
+class regex_token_iterator
+{
+public:
+ typedef basic_regex<charT, traits> regex_type;
+ typedef sub_match<BidirectionalIterator> value_type;
+ typedef ptrdiff_t difference_type;
+ typedef const value_type* pointer;
+ typedef const value_type& reference;
+ typedef forward_iterator_tag iterator_category;
+
+ regex_token_iterator();
+ regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+ const regex_type& re, int submatch = 0,
+ regex_constants::match_flag_type m = regex_constants::match_default);
+ regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+ const regex_type&& re, int submatch = 0,
+ regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14
+ regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+ const regex_type& re, const vector<int>& submatches,
+ regex_constants::match_flag_type m = regex_constants::match_default);
+ regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+ const regex_type&& re, const vector<int>& submatches,
+ regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14
+ regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+ const regex_type& re, initializer_list<int> submatches,
+ regex_constants::match_flag_type m = regex_constants::match_default);
+ regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+ const regex_type&& re, initializer_list<int> submatches,
+ regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14
+ template <size_t N>
+ regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+ const regex_type& re, const int (&submatches)[N],
+ regex_constants::match_flag_type m = regex_constants::match_default);
+ template <size_t N>
+ regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+ const regex_type&& re, const int (&submatches)[N],
+ regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14
+ regex_token_iterator(const regex_token_iterator&);
+ regex_token_iterator& operator=(const regex_token_iterator&);
+
+ bool operator==(const regex_token_iterator&) const;
+ bool operator!=(const regex_token_iterator&) const;
+
+ const value_type& operator*() const;
+ const value_type* operator->() const;
+
+ regex_token_iterator& operator++();
+ regex_token_iterator operator++(int);
+};
+
+typedef regex_token_iterator<const char*> cregex_token_iterator;
+typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
+typedef regex_token_iterator<string::const_iterator> sregex_token_iterator;
+typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
+
+} // std
+*/
+
+#include <__algorithm/find.h>
+#include <__assert>
+#include <__config>
+#include <__iterator/wrap_iter.h>
+#include <__locale>
+#include <compare>
+#include <deque>
+#include <initializer_list>
+#include <iterator>
+#include <memory>
+#include <stdexcept>
+#include <string>
+#include <utility>
+#include <vector>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+
+#define _LIBCPP_REGEX_COMPLEXITY_FACTOR 4096
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace regex_constants
+{
+
+// syntax_option_type
+
+enum syntax_option_type
+{
+ icase = 1 << 0,
+ nosubs = 1 << 1,
+ optimize = 1 << 2,
+ collate = 1 << 3,
+#ifdef _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
+ ECMAScript = 1 << 9,
+#else
+ ECMAScript = 0,
+#endif
+ basic = 1 << 4,
+ extended = 1 << 5,
+ awk = 1 << 6,
+ grep = 1 << 7,
+ egrep = 1 << 8,
+ // 1 << 9 may be used by ECMAScript
+ multiline = 1 << 10
+};
+
+inline _LIBCPP_CONSTEXPR
+syntax_option_type __get_grammar(syntax_option_type __g)
+{
+#ifdef _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
+ return static_cast<syntax_option_type>(__g & 0x3F0);
+#else
+ return static_cast<syntax_option_type>(__g & 0x1F0);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+syntax_option_type
+operator~(syntax_option_type __x)
+{
+ return syntax_option_type(~int(__x) & 0x1FF);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+syntax_option_type
+operator&(syntax_option_type __x, syntax_option_type __y)
+{
+ return syntax_option_type(int(__x) & int(__y));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+syntax_option_type
+operator|(syntax_option_type __x, syntax_option_type __y)
+{
+ return syntax_option_type(int(__x) | int(__y));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+syntax_option_type
+operator^(syntax_option_type __x, syntax_option_type __y)
+{
+ return syntax_option_type(int(__x) ^ int(__y));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+syntax_option_type&
+operator&=(syntax_option_type& __x, syntax_option_type __y)
+{
+ __x = __x & __y;
+ return __x;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+syntax_option_type&
+operator|=(syntax_option_type& __x, syntax_option_type __y)
+{
+ __x = __x | __y;
+ return __x;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+syntax_option_type&
+operator^=(syntax_option_type& __x, syntax_option_type __y)
+{
+ __x = __x ^ __y;
+ return __x;
+}
+
+// match_flag_type
+
+enum match_flag_type
+{
+ match_default = 0,
+ match_not_bol = 1 << 0,
+ match_not_eol = 1 << 1,
+ match_not_bow = 1 << 2,
+ match_not_eow = 1 << 3,
+ match_any = 1 << 4,
+ match_not_null = 1 << 5,
+ match_continuous = 1 << 6,
+ match_prev_avail = 1 << 7,
+ format_default = 0,
+ format_sed = 1 << 8,
+ format_no_copy = 1 << 9,
+ format_first_only = 1 << 10,
+ __no_update_pos = 1 << 11,
+ __full_match = 1 << 12
+};
+
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+match_flag_type
+operator~(match_flag_type __x)
+{
+ return match_flag_type(~int(__x) & 0x0FFF);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+match_flag_type
+operator&(match_flag_type __x, match_flag_type __y)
+{
+ return match_flag_type(int(__x) & int(__y));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+match_flag_type
+operator|(match_flag_type __x, match_flag_type __y)
+{
+ return match_flag_type(int(__x) | int(__y));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+match_flag_type
+operator^(match_flag_type __x, match_flag_type __y)
+{
+ return match_flag_type(int(__x) ^ int(__y));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+match_flag_type&
+operator&=(match_flag_type& __x, match_flag_type __y)
+{
+ __x = __x & __y;
+ return __x;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+match_flag_type&
+operator|=(match_flag_type& __x, match_flag_type __y)
+{
+ __x = __x | __y;
+ return __x;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+match_flag_type&
+operator^=(match_flag_type& __x, match_flag_type __y)
+{
+ __x = __x ^ __y;
+ return __x;
+}
+
+enum error_type
+{
+ error_collate = 1,
+ error_ctype,
+ error_escape,
+ error_backref,
+ error_brack,
+ error_paren,
+ error_brace,
+ error_badbrace,
+ error_range,
+ error_space,
+ error_badrepeat,
+ error_complexity,
+ error_stack,
+ __re_err_grammar,
+ __re_err_empty,
+ __re_err_unknown,
+ __re_err_parse
+};
+
+} // namespace regex_constants
+
+class _LIBCPP_EXCEPTION_ABI regex_error
+ : public runtime_error
+{
+ regex_constants::error_type __code_;
+public:
+ explicit regex_error(regex_constants::error_type __ecode);
+ regex_error(const regex_error&) _NOEXCEPT = default;
+ virtual ~regex_error() _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ regex_constants::error_type code() const {return __code_;}
+};
+
+template <regex_constants::error_type _Ev>
+_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
+void __throw_regex_error()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw regex_error(_Ev);
+#else
+ _VSTD::abort();
+#endif
+}
+
+template <class _CharT>
+struct _LIBCPP_TEMPLATE_VIS regex_traits
+{
+public:
+ typedef _CharT char_type;
+ typedef basic_string<char_type> string_type;
+ typedef locale locale_type;
+#ifdef __BIONIC__
+ // Originally bionic's ctype_base used its own ctype masks because the
+ // builtin ctype implementation wasn't in libc++ yet. Bionic's ctype mask
+ // was only 8 bits wide and already saturated, so it used a wider type here
+ // to make room for __regex_word (then a part of this class rather than
+ // ctype_base). Bionic has since moved to the builtin ctype_base
+ // implementation, but this was not updated to match. Since then Android has
+ // needed to maintain a stable libc++ ABI, and this can't be changed without
+ // an ABI break.
+ typedef uint16_t char_class_type;
+#else
+ typedef ctype_base::mask char_class_type;
+#endif
+
+ static const char_class_type __regex_word = ctype_base::__regex_word;
+private:
+ locale __loc_;
+ const ctype<char_type>* __ct_;
+ const collate<char_type>* __col_;
+
+public:
+ regex_traits();
+
+ _LIBCPP_INLINE_VISIBILITY
+ static size_t length(const char_type* __p)
+ {return char_traits<char_type>::length(__p);}
+ _LIBCPP_INLINE_VISIBILITY
+ char_type translate(char_type __c) const {return __c;}
+ char_type translate_nocase(char_type __c) const;
+ template <class _ForwardIterator>
+ string_type
+ transform(_ForwardIterator __f, _ForwardIterator __l) const;
+ template <class _ForwardIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ string_type
+ transform_primary( _ForwardIterator __f, _ForwardIterator __l) const
+ {return __transform_primary(__f, __l, char_type());}
+ template <class _ForwardIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ string_type
+ lookup_collatename(_ForwardIterator __f, _ForwardIterator __l) const
+ {return __lookup_collatename(__f, __l, char_type());}
+ template <class _ForwardIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ char_class_type
+ lookup_classname(_ForwardIterator __f, _ForwardIterator __l,
+ bool __icase = false) const
+ {return __lookup_classname(__f, __l, __icase, char_type());}
+ bool isctype(char_type __c, char_class_type __m) const;
+ _LIBCPP_INLINE_VISIBILITY
+ int value(char_type __ch, int __radix) const
+ {return __regex_traits_value(__ch, __radix);}
+ locale_type imbue(locale_type __l);
+ _LIBCPP_INLINE_VISIBILITY
+ locale_type getloc()const {return __loc_;}
+
+private:
+ void __init();
+
+ template <class _ForwardIterator>
+ string_type
+ __transform_primary(_ForwardIterator __f, _ForwardIterator __l, char) const;
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ template <class _ForwardIterator>
+ string_type
+ __transform_primary(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const;
+#endif
+ template <class _ForwardIterator>
+ string_type
+ __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, char) const;
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ template <class _ForwardIterator>
+ string_type
+ __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const;
+#endif
+ template <class _ForwardIterator>
+ char_class_type
+ __lookup_classname(_ForwardIterator __f, _ForwardIterator __l,
+ bool __icase, char) const;
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ template <class _ForwardIterator>
+ char_class_type
+ __lookup_classname(_ForwardIterator __f, _ForwardIterator __l,
+ bool __icase, wchar_t) const;
+#endif
+
+ static int __regex_traits_value(unsigned char __ch, int __radix);
+ _LIBCPP_INLINE_VISIBILITY
+ int __regex_traits_value(char __ch, int __radix) const
+ {return __regex_traits_value(static_cast<unsigned char>(__ch), __radix);}
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ _LIBCPP_INLINE_VISIBILITY
+ int __regex_traits_value(wchar_t __ch, int __radix) const;
+#endif
+};
+
+template <class _CharT>
+const typename regex_traits<_CharT>::char_class_type
+regex_traits<_CharT>::__regex_word;
+
+template <class _CharT>
+regex_traits<_CharT>::regex_traits()
+{
+ __init();
+}
+
+template <class _CharT>
+typename regex_traits<_CharT>::char_type
+regex_traits<_CharT>::translate_nocase(char_type __c) const
+{
+ return __ct_->tolower(__c);
+}
+
+template <class _CharT>
+template <class _ForwardIterator>
+typename regex_traits<_CharT>::string_type
+regex_traits<_CharT>::transform(_ForwardIterator __f, _ForwardIterator __l) const
+{
+ string_type __s(__f, __l);
+ return __col_->transform(__s.data(), __s.data() + __s.size());
+}
+
+template <class _CharT>
+void
+regex_traits<_CharT>::__init()
+{
+ __ct_ = &use_facet<ctype<char_type> >(__loc_);
+ __col_ = &use_facet<collate<char_type> >(__loc_);
+}
+
+template <class _CharT>
+typename regex_traits<_CharT>::locale_type
+regex_traits<_CharT>::imbue(locale_type __l)
+{
+ locale __r = __loc_;
+ __loc_ = __l;
+ __init();
+ return __r;
+}
+
+// transform_primary is very FreeBSD-specific
+
+template <class _CharT>
+template <class _ForwardIterator>
+typename regex_traits<_CharT>::string_type
+regex_traits<_CharT>::__transform_primary(_ForwardIterator __f,
+ _ForwardIterator __l, char) const
+{
+ const string_type __s(__f, __l);
+ string_type __d = __col_->transform(__s.data(), __s.data() + __s.size());
+ switch (__d.size())
+ {
+ case 1:
+ break;
+ case 12:
+ __d[11] = __d[3];
+ break;
+ default:
+ __d.clear();
+ break;
+ }
+ return __d;
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <class _CharT>
+template <class _ForwardIterator>
+typename regex_traits<_CharT>::string_type
+regex_traits<_CharT>::__transform_primary(_ForwardIterator __f,
+ _ForwardIterator __l, wchar_t) const
+{
+ const string_type __s(__f, __l);
+ string_type __d = __col_->transform(__s.data(), __s.data() + __s.size());
+ switch (__d.size())
+ {
+ case 1:
+ break;
+ case 3:
+ __d[2] = __d[0];
+ break;
+ default:
+ __d.clear();
+ break;
+ }
+ return __d;
+}
+#endif
+
+// lookup_collatename is very FreeBSD-specific
+
+_LIBCPP_FUNC_VIS string __get_collation_name(const char* __s);
+
+template <class _CharT>
+template <class _ForwardIterator>
+typename regex_traits<_CharT>::string_type
+regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f,
+ _ForwardIterator __l, char) const
+{
+ string_type __s(__f, __l);
+ string_type __r;
+ if (!__s.empty())
+ {
+ __r = __get_collation_name(__s.c_str());
+ if (__r.empty() && __s.size() <= 2)
+ {
+ __r = __col_->transform(__s.data(), __s.data() + __s.size());
+ if (__r.size() == 1 || __r.size() == 12)
+ __r = __s;
+ else
+ __r.clear();
+ }
+ }
+ return __r;
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <class _CharT>
+template <class _ForwardIterator>
+typename regex_traits<_CharT>::string_type
+regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f,
+ _ForwardIterator __l, wchar_t) const
+{
+ string_type __s(__f, __l);
+ string __n;
+ __n.reserve(__s.size());
+ for (typename string_type::const_iterator __i = __s.begin(), __e = __s.end();
+ __i != __e; ++__i)
+ {
+ if (static_cast<unsigned>(*__i) >= 127)
+ return string_type();
+ __n.push_back(char(*__i));
+ }
+ string_type __r;
+ if (!__s.empty())
+ {
+ __n = __get_collation_name(__n.c_str());
+ if (!__n.empty())
+ __r.assign(__n.begin(), __n.end());
+ else if (__s.size() <= 2)
+ {
+ __r = __col_->transform(__s.data(), __s.data() + __s.size());
+ if (__r.size() == 1 || __r.size() == 3)
+ __r = __s;
+ else
+ __r.clear();
+ }
+ }
+ return __r;
+}
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+// lookup_classname
+
+regex_traits<char>::char_class_type _LIBCPP_FUNC_VIS
+__get_classname(const char* __s, bool __icase);
+
+template <class _CharT>
+template <class _ForwardIterator>
+typename regex_traits<_CharT>::char_class_type
+regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f,
+ _ForwardIterator __l,
+ bool __icase, char) const
+{
+ string_type __s(__f, __l);
+ __ct_->tolower(&__s[0], &__s[0] + __s.size());
+ return __get_classname(__s.c_str(), __icase);
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <class _CharT>
+template <class _ForwardIterator>
+typename regex_traits<_CharT>::char_class_type
+regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f,
+ _ForwardIterator __l,
+ bool __icase, wchar_t) const
+{
+ string_type __s(__f, __l);
+ __ct_->tolower(&__s[0], &__s[0] + __s.size());
+ string __n;
+ __n.reserve(__s.size());
+ for (typename string_type::const_iterator __i = __s.begin(), __e = __s.end();
+ __i != __e; ++__i)
+ {
+ if (static_cast<unsigned>(*__i) >= 127)
+ return char_class_type();
+ __n.push_back(char(*__i));
+ }
+ return __get_classname(__n.c_str(), __icase);
+}
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+template <class _CharT>
+bool
+regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const
+{
+ if (__ct_->is(__m, __c))
+ return true;
+ return (__c == '_' && (__m & __regex_word));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool __is_07(unsigned char c)
+{
+ return (c & 0xF8u) ==
+#if defined(__MVS__) && !defined(__NATIVE_ASCII_F)
+ 0xF0;
+#else
+ 0x30;
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool __is_89(unsigned char c)
+{
+ return (c & 0xFEu) ==
+#if defined(__MVS__) && !defined(__NATIVE_ASCII_F)
+ 0xF8;
+#else
+ 0x38;
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned char __to_lower(unsigned char c)
+{
+#if defined(__MVS__) && !defined(__NATIVE_ASCII_F)
+ return c & 0xBF;
+#else
+ return c | 0x20;
+#endif
+}
+
+template <class _CharT>
+int
+regex_traits<_CharT>::__regex_traits_value(unsigned char __ch, int __radix)
+{
+ if (__is_07(__ch)) // '0' <= __ch && __ch <= '7'
+ return __ch - '0';
+ if (__radix != 8)
+ {
+ if (__is_89(__ch)) // '8' <= __ch && __ch <= '9'
+ return __ch - '0';
+ if (__radix == 16)
+ {
+ __ch = __to_lower(__ch); // tolower
+ if ('a' <= __ch && __ch <= 'f')
+ return __ch - ('a' - 10);
+ }
+ }
+ return -1;
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <class _CharT>
+inline
+int
+regex_traits<_CharT>::__regex_traits_value(wchar_t __ch, int __radix) const
+{
+ return __regex_traits_value(static_cast<unsigned char>(__ct_->narrow(__ch, char_type())), __radix);
+}
+#endif
+
+template <class _CharT> class __node;
+
+template <class _BidirectionalIterator> class _LIBCPP_TEMPLATE_VIS sub_match;
+
+template <class _BidirectionalIterator,
+ class _Allocator = allocator<sub_match<_BidirectionalIterator> > >
+class _LIBCPP_TEMPLATE_VIS match_results;
+
+template <class _CharT>
+struct __state
+{
+ enum
+ {
+ __end_state = -1000,
+ __consume_input, // -999
+ __begin_marked_expr, // -998
+ __end_marked_expr, // -997
+ __pop_state, // -996
+ __accept_and_consume, // -995
+ __accept_but_not_consume, // -994
+ __reject, // -993
+ __split,
+ __repeat
+ };
+
+ int __do_;
+ const _CharT* __first_;
+ const _CharT* __current_;
+ const _CharT* __last_;
+ vector<sub_match<const _CharT*> > __sub_matches_;
+ vector<pair<size_t, const _CharT*> > __loop_data_;
+ const __node<_CharT>* __node_;
+ regex_constants::match_flag_type __flags_;
+ bool __at_first_;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __state()
+ : __do_(0), __first_(nullptr), __current_(nullptr), __last_(nullptr),
+ __node_(nullptr), __flags_() {}
+};
+
+// __node
+
+template <class _CharT>
+class __node
+{
+ __node(const __node&);
+ __node& operator=(const __node&);
+public:
+ typedef _VSTD::__state<_CharT> __state;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __node() {}
+ _LIBCPP_INLINE_VISIBILITY
+ virtual ~__node() {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ virtual void __exec(__state&) const {}
+ _LIBCPP_INLINE_VISIBILITY
+ virtual void __exec_split(bool, __state&) const {}
+};
+
+// __end_state
+
+template <class _CharT>
+class __end_state
+ : public __node<_CharT>
+{
+public:
+ typedef _VSTD::__state<_CharT> __state;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __end_state() {}
+
+ virtual void __exec(__state&) const;
+};
+
+template <class _CharT>
+void
+__end_state<_CharT>::__exec(__state& __s) const
+{
+ __s.__do_ = __state::__end_state;
+}
+
+// __has_one_state
+
+template <class _CharT>
+class __has_one_state
+ : public __node<_CharT>
+{
+ __node<_CharT>* __first_;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __has_one_state(__node<_CharT>* __s)
+ : __first_(__s) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __node<_CharT>* first() const {return __first_;}
+ _LIBCPP_INLINE_VISIBILITY
+ __node<_CharT>*& first() {return __first_;}
+};
+
+// __owns_one_state
+
+template <class _CharT>
+class __owns_one_state
+ : public __has_one_state<_CharT>
+{
+ typedef __has_one_state<_CharT> base;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __owns_one_state(__node<_CharT>* __s)
+ : base(__s) {}
+
+ virtual ~__owns_one_state();
+};
+
+template <class _CharT>
+__owns_one_state<_CharT>::~__owns_one_state()
+{
+ delete this->first();
+}
+
+// __empty_state
+
+template <class _CharT>
+class __empty_state
+ : public __owns_one_state<_CharT>
+{
+ typedef __owns_one_state<_CharT> base;
+
+public:
+ typedef _VSTD::__state<_CharT> __state;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __empty_state(__node<_CharT>* __s)
+ : base(__s) {}
+
+ virtual void __exec(__state&) const;
+};
+
+template <class _CharT>
+void
+__empty_state<_CharT>::__exec(__state& __s) const
+{
+ __s.__do_ = __state::__accept_but_not_consume;
+ __s.__node_ = this->first();
+}
+
+// __empty_non_own_state
+
+template <class _CharT>
+class __empty_non_own_state
+ : public __has_one_state<_CharT>
+{
+ typedef __has_one_state<_CharT> base;
+
+public:
+ typedef _VSTD::__state<_CharT> __state;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __empty_non_own_state(__node<_CharT>* __s)
+ : base(__s) {}
+
+ virtual void __exec(__state&) const;
+};
+
+template <class _CharT>
+void
+__empty_non_own_state<_CharT>::__exec(__state& __s) const
+{
+ __s.__do_ = __state::__accept_but_not_consume;
+ __s.__node_ = this->first();
+}
+
+// __repeat_one_loop
+
+template <class _CharT>
+class __repeat_one_loop
+ : public __has_one_state<_CharT>
+{
+ typedef __has_one_state<_CharT> base;
+
+public:
+ typedef _VSTD::__state<_CharT> __state;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __repeat_one_loop(__node<_CharT>* __s)
+ : base(__s) {}
+
+ virtual void __exec(__state&) const;
+};
+
+template <class _CharT>
+void
+__repeat_one_loop<_CharT>::__exec(__state& __s) const
+{
+ __s.__do_ = __state::__repeat;
+ __s.__node_ = this->first();
+}
+
+// __owns_two_states
+
+template <class _CharT>
+class __owns_two_states
+ : public __owns_one_state<_CharT>
+{
+ typedef __owns_one_state<_CharT> base;
+
+ base* __second_;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __owns_two_states(__node<_CharT>* __s1, base* __s2)
+ : base(__s1), __second_(__s2) {}
+
+ virtual ~__owns_two_states();
+
+ _LIBCPP_INLINE_VISIBILITY
+ base* second() const {return __second_;}
+ _LIBCPP_INLINE_VISIBILITY
+ base*& second() {return __second_;}
+};
+
+template <class _CharT>
+__owns_two_states<_CharT>::~__owns_two_states()
+{
+ delete __second_;
+}
+
+// __loop
+
+template <class _CharT>
+class __loop
+ : public __owns_two_states<_CharT>
+{
+ typedef __owns_two_states<_CharT> base;
+
+ size_t __min_;
+ size_t __max_;
+ unsigned __loop_id_;
+ unsigned __mexp_begin_;
+ unsigned __mexp_end_;
+ bool __greedy_;
+
+public:
+ typedef _VSTD::__state<_CharT> __state;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __loop(unsigned __loop_id,
+ __node<_CharT>* __s1, __owns_one_state<_CharT>* __s2,
+ unsigned __mexp_begin, unsigned __mexp_end,
+ bool __greedy = true,
+ size_t __min = 0,
+ size_t __max = numeric_limits<size_t>::max())
+ : base(__s1, __s2), __min_(__min), __max_(__max), __loop_id_(__loop_id),
+ __mexp_begin_(__mexp_begin), __mexp_end_(__mexp_end),
+ __greedy_(__greedy) {}
+
+ virtual void __exec(__state& __s) const;
+ virtual void __exec_split(bool __second, __state& __s) const;
+
+private:
+ _LIBCPP_INLINE_VISIBILITY
+ void __init_repeat(__state& __s) const
+ {
+ __s.__loop_data_[__loop_id_].second = __s.__current_;
+ for (size_t __i = __mexp_begin_-1; __i != __mexp_end_-1; ++__i)
+ {
+ __s.__sub_matches_[__i].first = __s.__last_;
+ __s.__sub_matches_[__i].second = __s.__last_;
+ __s.__sub_matches_[__i].matched = false;
+ }
+ }
+};
+
+template <class _CharT>
+void
+__loop<_CharT>::__exec(__state& __s) const
+{
+ if (__s.__do_ == __state::__repeat)
+ {
+ bool __do_repeat = ++__s.__loop_data_[__loop_id_].first < __max_;
+ bool __do_alt = __s.__loop_data_[__loop_id_].first >= __min_;
+ if (__do_repeat && __do_alt &&
+ __s.__loop_data_[__loop_id_].second == __s.__current_)
+ __do_repeat = false;
+ if (__do_repeat && __do_alt)
+ __s.__do_ = __state::__split;
+ else if (__do_repeat)
+ {
+ __s.__do_ = __state::__accept_but_not_consume;
+ __s.__node_ = this->first();
+ __init_repeat(__s);
+ }
+ else
+ {
+ __s.__do_ = __state::__accept_but_not_consume;
+ __s.__node_ = this->second();
+ }
+ }
+ else
+ {
+ __s.__loop_data_[__loop_id_].first = 0;
+ bool __do_repeat = 0 < __max_;
+ bool __do_alt = 0 >= __min_;
+ if (__do_repeat && __do_alt)
+ __s.__do_ = __state::__split;
+ else if (__do_repeat)
+ {
+ __s.__do_ = __state::__accept_but_not_consume;
+ __s.__node_ = this->first();
+ __init_repeat(__s);
+ }
+ else
+ {
+ __s.__do_ = __state::__accept_but_not_consume;
+ __s.__node_ = this->second();
+ }
+ }
+}
+
+template <class _CharT>
+void
+__loop<_CharT>::__exec_split(bool __second, __state& __s) const
+{
+ __s.__do_ = __state::__accept_but_not_consume;
+ if (__greedy_ != __second)
+ {
+ __s.__node_ = this->first();
+ __init_repeat(__s);
+ }
+ else
+ __s.__node_ = this->second();
+}
+
+// __alternate
+
+template <class _CharT>
+class __alternate
+ : public __owns_two_states<_CharT>
+{
+ typedef __owns_two_states<_CharT> base;
+
+public:
+ typedef _VSTD::__state<_CharT> __state;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __alternate(__owns_one_state<_CharT>* __s1,
+ __owns_one_state<_CharT>* __s2)
+ : base(__s1, __s2) {}
+
+ virtual void __exec(__state& __s) const;
+ virtual void __exec_split(bool __second, __state& __s) const;
+};
+
+template <class _CharT>
+void
+__alternate<_CharT>::__exec(__state& __s) const
+{
+ __s.__do_ = __state::__split;
+}
+
+template <class _CharT>
+void
+__alternate<_CharT>::__exec_split(bool __second, __state& __s) const
+{
+ __s.__do_ = __state::__accept_but_not_consume;
+ if (__second)
+ __s.__node_ = this->second();
+ else
+ __s.__node_ = this->first();
+}
+
+// __begin_marked_subexpression
+
+template <class _CharT>
+class __begin_marked_subexpression
+ : public __owns_one_state<_CharT>
+{
+ typedef __owns_one_state<_CharT> base;
+
+ unsigned __mexp_;
+public:
+ typedef _VSTD::__state<_CharT> __state;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __begin_marked_subexpression(unsigned __mexp, __node<_CharT>* __s)
+ : base(__s), __mexp_(__mexp) {}
+
+ virtual void __exec(__state&) const;
+};
+
+template <class _CharT>
+void
+__begin_marked_subexpression<_CharT>::__exec(__state& __s) const
+{
+ __s.__do_ = __state::__accept_but_not_consume;
+ __s.__sub_matches_[__mexp_-1].first = __s.__current_;
+ __s.__node_ = this->first();
+}
+
+// __end_marked_subexpression
+
+template <class _CharT>
+class __end_marked_subexpression
+ : public __owns_one_state<_CharT>
+{
+ typedef __owns_one_state<_CharT> base;
+
+ unsigned __mexp_;
+public:
+ typedef _VSTD::__state<_CharT> __state;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __end_marked_subexpression(unsigned __mexp, __node<_CharT>* __s)
+ : base(__s), __mexp_(__mexp) {}
+
+ virtual void __exec(__state&) const;
+};
+
+template <class _CharT>
+void
+__end_marked_subexpression<_CharT>::__exec(__state& __s) const
+{
+ __s.__do_ = __state::__accept_but_not_consume;
+ __s.__sub_matches_[__mexp_-1].second = __s.__current_;
+ __s.__sub_matches_[__mexp_-1].matched = true;
+ __s.__node_ = this->first();
+}
+
+// __back_ref
+
+template <class _CharT>
+class __back_ref
+ : public __owns_one_state<_CharT>
+{
+ typedef __owns_one_state<_CharT> base;
+
+ unsigned __mexp_;
+public:
+ typedef _VSTD::__state<_CharT> __state;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __back_ref(unsigned __mexp, __node<_CharT>* __s)
+ : base(__s), __mexp_(__mexp) {}
+
+ virtual void __exec(__state&) const;
+};
+
+template <class _CharT>
+void
+__back_ref<_CharT>::__exec(__state& __s) const
+{
+ if (__mexp_ > __s.__sub_matches_.size())
+ __throw_regex_error<regex_constants::error_backref>();
+ sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_-1];
+ if (__sm.matched)
+ {
+ ptrdiff_t __len = __sm.second - __sm.first;
+ if (__s.__last_ - __s.__current_ >= __len &&
+ _VSTD::equal(__sm.first, __sm.second, __s.__current_))
+ {
+ __s.__do_ = __state::__accept_but_not_consume;
+ __s.__current_ += __len;
+ __s.__node_ = this->first();
+ }
+ else
+ {
+ __s.__do_ = __state::__reject;
+ __s.__node_ = nullptr;
+ }
+ }
+ else
+ {
+ __s.__do_ = __state::__reject;
+ __s.__node_ = nullptr;
+ }
+}
+
+// __back_ref_icase
+
+template <class _CharT, class _Traits>
+class __back_ref_icase
+ : public __owns_one_state<_CharT>
+{
+ typedef __owns_one_state<_CharT> base;
+
+ _Traits __traits_;
+ unsigned __mexp_;
+public:
+ typedef _VSTD::__state<_CharT> __state;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __back_ref_icase(const _Traits& __traits, unsigned __mexp,
+ __node<_CharT>* __s)
+ : base(__s), __traits_(__traits), __mexp_(__mexp) {}
+
+ virtual void __exec(__state&) const;
+};
+
+template <class _CharT, class _Traits>
+void
+__back_ref_icase<_CharT, _Traits>::__exec(__state& __s) const
+{
+ sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_-1];
+ if (__sm.matched)
+ {
+ ptrdiff_t __len = __sm.second - __sm.first;
+ if (__s.__last_ - __s.__current_ >= __len)
+ {
+ for (ptrdiff_t __i = 0; __i < __len; ++__i)
+ {
+ if (__traits_.translate_nocase(__sm.first[__i]) !=
+ __traits_.translate_nocase(__s.__current_[__i]))
+ goto __not_equal;
+ }
+ __s.__do_ = __state::__accept_but_not_consume;
+ __s.__current_ += __len;
+ __s.__node_ = this->first();
+ }
+ else
+ {
+ __s.__do_ = __state::__reject;
+ __s.__node_ = nullptr;
+ }
+ }
+ else
+ {
+__not_equal:
+ __s.__do_ = __state::__reject;
+ __s.__node_ = nullptr;
+ }
+}
+
+// __back_ref_collate
+
+template <class _CharT, class _Traits>
+class __back_ref_collate
+ : public __owns_one_state<_CharT>
+{
+ typedef __owns_one_state<_CharT> base;
+
+ _Traits __traits_;
+ unsigned __mexp_;
+public:
+ typedef _VSTD::__state<_CharT> __state;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __back_ref_collate(const _Traits& __traits, unsigned __mexp,
+ __node<_CharT>* __s)
+ : base(__s), __traits_(__traits), __mexp_(__mexp) {}
+
+ virtual void __exec(__state&) const;
+};
+
+template <class _CharT, class _Traits>
+void
+__back_ref_collate<_CharT, _Traits>::__exec(__state& __s) const
+{
+ sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_-1];
+ if (__sm.matched)
+ {
+ ptrdiff_t __len = __sm.second - __sm.first;
+ if (__s.__last_ - __s.__current_ >= __len)
+ {
+ for (ptrdiff_t __i = 0; __i < __len; ++__i)
+ {
+ if (__traits_.translate(__sm.first[__i]) !=
+ __traits_.translate(__s.__current_[__i]))
+ goto __not_equal;
+ }
+ __s.__do_ = __state::__accept_but_not_consume;
+ __s.__current_ += __len;
+ __s.__node_ = this->first();
+ }
+ else
+ {
+ __s.__do_ = __state::__reject;
+ __s.__node_ = nullptr;
+ }
+ }
+ else
+ {
+__not_equal:
+ __s.__do_ = __state::__reject;
+ __s.__node_ = nullptr;
+ }
+}
+
+// __word_boundary
+
+template <class _CharT, class _Traits>
+class __word_boundary
+ : public __owns_one_state<_CharT>
+{
+ typedef __owns_one_state<_CharT> base;
+
+ _Traits __traits_;
+ bool __invert_;
+public:
+ typedef _VSTD::__state<_CharT> __state;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __word_boundary(const _Traits& __traits, bool __invert,
+ __node<_CharT>* __s)
+ : base(__s), __traits_(__traits), __invert_(__invert) {}
+
+ virtual void __exec(__state&) const;
+};
+
+template <class _CharT, class _Traits>
+void
+__word_boundary<_CharT, _Traits>::__exec(__state& __s) const
+{
+ bool __is_word_b = false;
+ if (__s.__first_ != __s.__last_)
+ {
+ if (__s.__current_ == __s.__last_)
+ {
+ if (!(__s.__flags_ & regex_constants::match_not_eow))
+ {
+ _CharT __c = __s.__current_[-1];
+ __is_word_b = __c == '_' ||
+ __traits_.isctype(__c, ctype_base::alnum);
+ }
+ }
+ else if (__s.__current_ == __s.__first_ &&
+ !(__s.__flags_ & regex_constants::match_prev_avail))
+ {
+ if (!(__s.__flags_ & regex_constants::match_not_bow))
+ {
+ _CharT __c = *__s.__current_;
+ __is_word_b = __c == '_' ||
+ __traits_.isctype(__c, ctype_base::alnum);
+ }
+ }
+ else
+ {
+ _CharT __c1 = __s.__current_[-1];
+ _CharT __c2 = *__s.__current_;
+ bool __is_c1_b = __c1 == '_' ||
+ __traits_.isctype(__c1, ctype_base::alnum);
+ bool __is_c2_b = __c2 == '_' ||
+ __traits_.isctype(__c2, ctype_base::alnum);
+ __is_word_b = __is_c1_b != __is_c2_b;
+ }
+ }
+ if (__is_word_b != __invert_)
+ {
+ __s.__do_ = __state::__accept_but_not_consume;
+ __s.__node_ = this->first();
+ }
+ else
+ {
+ __s.__do_ = __state::__reject;
+ __s.__node_ = nullptr;
+ }
+}
+
+// __l_anchor
+
+template <class _CharT>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+bool __is_eol(_CharT c)
+{
+ return c == '\r' || c == '\n';
+}
+
+template <class _CharT>
+class __l_anchor_multiline
+ : public __owns_one_state<_CharT>
+{
+ typedef __owns_one_state<_CharT> base;
+
+ bool __multiline_;
+
+public:
+ typedef _VSTD::__state<_CharT> __state;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __l_anchor_multiline(bool __multiline, __node<_CharT>* __s)
+ : base(__s), __multiline_(__multiline) {}
+
+ virtual void __exec(__state&) const;
+};
+
+template <class _CharT>
+void
+__l_anchor_multiline<_CharT>::__exec(__state& __s) const
+{
+ if (__s.__at_first_ && __s.__current_ == __s.__first_ &&
+ !(__s.__flags_ & regex_constants::match_not_bol))
+ {
+ __s.__do_ = __state::__accept_but_not_consume;
+ __s.__node_ = this->first();
+ }
+ else if (__multiline_ &&
+ !__s.__at_first_ &&
+ __is_eol(*_VSTD::prev(__s.__current_)))
+ {
+ __s.__do_ = __state::__accept_but_not_consume;
+ __s.__node_ = this->first();
+ }
+ else
+ {
+ __s.__do_ = __state::__reject;
+ __s.__node_ = nullptr;
+ }
+}
+
+// __r_anchor
+
+template <class _CharT>
+class __r_anchor_multiline
+ : public __owns_one_state<_CharT>
+{
+ typedef __owns_one_state<_CharT> base;
+
+ bool __multiline;
+
+public:
+ typedef _VSTD::__state<_CharT> __state;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __r_anchor_multiline(bool __multiline, __node<_CharT>* __s)
+ : base(__s), __multiline(__multiline) {}
+
+ virtual void __exec(__state&) const;
+};
+
+template <class _CharT>
+void
+__r_anchor_multiline<_CharT>::__exec(__state& __s) const
+{
+ if (__s.__current_ == __s.__last_ &&
+ !(__s.__flags_ & regex_constants::match_not_eol))
+ {
+ __s.__do_ = __state::__accept_but_not_consume;
+ __s.__node_ = this->first();
+ }
+ else if (__multiline && __is_eol(*__s.__current_))
+ {
+ __s.__do_ = __state::__accept_but_not_consume;
+ __s.__node_ = this->first();
+ }
+ else
+ {
+ __s.__do_ = __state::__reject;
+ __s.__node_ = nullptr;
+ }
+}
+
+// __match_any
+
+template <class _CharT>
+class __match_any
+ : public __owns_one_state<_CharT>
+{
+ typedef __owns_one_state<_CharT> base;
+
+public:
+ typedef _VSTD::__state<_CharT> __state;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __match_any(__node<_CharT>* __s)
+ : base(__s) {}
+
+ virtual void __exec(__state&) const;
+};
+
+template <class _CharT>
+void
+__match_any<_CharT>::__exec(__state& __s) const
+{
+ if (__s.__current_ != __s.__last_ && *__s.__current_ != 0)
+ {
+ __s.__do_ = __state::__accept_and_consume;
+ ++__s.__current_;
+ __s.__node_ = this->first();
+ }
+ else
+ {
+ __s.__do_ = __state::__reject;
+ __s.__node_ = nullptr;
+ }
+}
+
+// __match_any_but_newline
+
+template <class _CharT>
+class __match_any_but_newline
+ : public __owns_one_state<_CharT>
+{
+ typedef __owns_one_state<_CharT> base;
+
+public:
+ typedef _VSTD::__state<_CharT> __state;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __match_any_but_newline(__node<_CharT>* __s)
+ : base(__s) {}
+
+ virtual void __exec(__state&) const;
+};
+
+template <> _LIBCPP_FUNC_VIS void __match_any_but_newline<char>::__exec(__state&) const;
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <> _LIBCPP_FUNC_VIS void __match_any_but_newline<wchar_t>::__exec(__state&) const;
+#endif
+
+// __match_char
+
+template <class _CharT>
+class __match_char
+ : public __owns_one_state<_CharT>
+{
+ typedef __owns_one_state<_CharT> base;
+
+ _CharT __c_;
+
+ __match_char(const __match_char&);
+ __match_char& operator=(const __match_char&);
+public:
+ typedef _VSTD::__state<_CharT> __state;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __match_char(_CharT __c, __node<_CharT>* __s)
+ : base(__s), __c_(__c) {}
+
+ virtual void __exec(__state&) const;
+};
+
+template <class _CharT>
+void
+__match_char<_CharT>::__exec(__state& __s) const
+{
+ if (__s.__current_ != __s.__last_ && *__s.__current_ == __c_)
+ {
+ __s.__do_ = __state::__accept_and_consume;
+ ++__s.__current_;
+ __s.__node_ = this->first();
+ }
+ else
+ {
+ __s.__do_ = __state::__reject;
+ __s.__node_ = nullptr;
+ }
+}
+
+// __match_char_icase
+
+template <class _CharT, class _Traits>
+class __match_char_icase
+ : public __owns_one_state<_CharT>
+{
+ typedef __owns_one_state<_CharT> base;
+
+ _Traits __traits_;
+ _CharT __c_;
+
+ __match_char_icase(const __match_char_icase&);
+ __match_char_icase& operator=(const __match_char_icase&);
+public:
+ typedef _VSTD::__state<_CharT> __state;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __match_char_icase(const _Traits& __traits, _CharT __c, __node<_CharT>* __s)
+ : base(__s), __traits_(__traits), __c_(__traits.translate_nocase(__c)) {}
+
+ virtual void __exec(__state&) const;
+};
+
+template <class _CharT, class _Traits>
+void
+__match_char_icase<_CharT, _Traits>::__exec(__state& __s) const
+{
+ if (__s.__current_ != __s.__last_ &&
+ __traits_.translate_nocase(*__s.__current_) == __c_)
+ {
+ __s.__do_ = __state::__accept_and_consume;
+ ++__s.__current_;
+ __s.__node_ = this->first();
+ }
+ else
+ {
+ __s.__do_ = __state::__reject;
+ __s.__node_ = nullptr;
+ }
+}
+
+// __match_char_collate
+
+template <class _CharT, class _Traits>
+class __match_char_collate
+ : public __owns_one_state<_CharT>
+{
+ typedef __owns_one_state<_CharT> base;
+
+ _Traits __traits_;
+ _CharT __c_;
+
+ __match_char_collate(const __match_char_collate&);
+ __match_char_collate& operator=(const __match_char_collate&);
+public:
+ typedef _VSTD::__state<_CharT> __state;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __match_char_collate(const _Traits& __traits, _CharT __c, __node<_CharT>* __s)
+ : base(__s), __traits_(__traits), __c_(__traits.translate(__c)) {}
+
+ virtual void __exec(__state&) const;
+};
+
+template <class _CharT, class _Traits>
+void
+__match_char_collate<_CharT, _Traits>::__exec(__state& __s) const
+{
+ if (__s.__current_ != __s.__last_ &&
+ __traits_.translate(*__s.__current_) == __c_)
+ {
+ __s.__do_ = __state::__accept_and_consume;
+ ++__s.__current_;
+ __s.__node_ = this->first();
+ }
+ else
+ {
+ __s.__do_ = __state::__reject;
+ __s.__node_ = nullptr;
+ }
+}
+
+// __bracket_expression
+
+template <class _CharT, class _Traits>
+class __bracket_expression
+ : public __owns_one_state<_CharT>
+{
+ typedef __owns_one_state<_CharT> base;
+ typedef typename _Traits::string_type string_type;
+
+ _Traits __traits_;
+ vector<_CharT> __chars_;
+ vector<_CharT> __neg_chars_;
+ vector<pair<string_type, string_type> > __ranges_;
+ vector<pair<_CharT, _CharT> > __digraphs_;
+ vector<string_type> __equivalences_;
+ typename regex_traits<_CharT>::char_class_type __mask_;
+ typename regex_traits<_CharT>::char_class_type __neg_mask_;
+ bool __negate_;
+ bool __icase_;
+ bool __collate_;
+ bool __might_have_digraph_;
+
+ __bracket_expression(const __bracket_expression&);
+ __bracket_expression& operator=(const __bracket_expression&);
+public:
+ typedef _VSTD::__state<_CharT> __state;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __bracket_expression(const _Traits& __traits, __node<_CharT>* __s,
+ bool __negate, bool __icase, bool __collate)
+ : base(__s), __traits_(__traits), __mask_(), __neg_mask_(),
+ __negate_(__negate), __icase_(__icase), __collate_(__collate),
+ __might_have_digraph_(__traits_.getloc().name() != "C") {}
+
+ virtual void __exec(__state&) const;
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool __negated() const {return __negate_;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __add_char(_CharT __c)
+ {
+ if (__icase_)
+ __chars_.push_back(__traits_.translate_nocase(__c));
+ else if (__collate_)
+ __chars_.push_back(__traits_.translate(__c));
+ else
+ __chars_.push_back(__c);
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ void __add_neg_char(_CharT __c)
+ {
+ if (__icase_)
+ __neg_chars_.push_back(__traits_.translate_nocase(__c));
+ else if (__collate_)
+ __neg_chars_.push_back(__traits_.translate(__c));
+ else
+ __neg_chars_.push_back(__c);
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ void __add_range(string_type __b, string_type __e)
+ {
+ if (__collate_)
+ {
+ if (__icase_)
+ {
+ for (size_t __i = 0; __i < __b.size(); ++__i)
+ __b[__i] = __traits_.translate_nocase(__b[__i]);
+ for (size_t __i = 0; __i < __e.size(); ++__i)
+ __e[__i] = __traits_.translate_nocase(__e[__i]);
+ }
+ else
+ {
+ for (size_t __i = 0; __i < __b.size(); ++__i)
+ __b[__i] = __traits_.translate(__b[__i]);
+ for (size_t __i = 0; __i < __e.size(); ++__i)
+ __e[__i] = __traits_.translate(__e[__i]);
+ }
+ __ranges_.push_back(make_pair(
+ __traits_.transform(__b.begin(), __b.end()),
+ __traits_.transform(__e.begin(), __e.end())));
+ }
+ else
+ {
+ if (__b.size() != 1 || __e.size() != 1)
+ __throw_regex_error<regex_constants::error_range>();
+ if (__icase_)
+ {
+ __b[0] = __traits_.translate_nocase(__b[0]);
+ __e[0] = __traits_.translate_nocase(__e[0]);
+ }
+ __ranges_.push_back(make_pair(_VSTD::move(__b), _VSTD::move(__e)));
+ }
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ void __add_digraph(_CharT __c1, _CharT __c2)
+ {
+ if (__icase_)
+ __digraphs_.push_back(make_pair(__traits_.translate_nocase(__c1),
+ __traits_.translate_nocase(__c2)));
+ else if (__collate_)
+ __digraphs_.push_back(make_pair(__traits_.translate(__c1),
+ __traits_.translate(__c2)));
+ else
+ __digraphs_.push_back(make_pair(__c1, __c2));
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ void __add_equivalence(const string_type& __s)
+ {__equivalences_.push_back(__s);}
+ _LIBCPP_INLINE_VISIBILITY
+ void __add_class(typename regex_traits<_CharT>::char_class_type __mask)
+ {__mask_ |= __mask;}
+ _LIBCPP_INLINE_VISIBILITY
+ void __add_neg_class(typename regex_traits<_CharT>::char_class_type __mask)
+ {__neg_mask_ |= __mask;}
+};
+
+template <class _CharT, class _Traits>
+void
+__bracket_expression<_CharT, _Traits>::__exec(__state& __s) const
+{
+ bool __found = false;
+ unsigned __consumed = 0;
+ if (__s.__current_ != __s.__last_)
+ {
+ ++__consumed;
+ if (__might_have_digraph_)
+ {
+ const _CharT* __next = _VSTD::next(__s.__current_);
+ if (__next != __s.__last_)
+ {
+ pair<_CharT, _CharT> __ch2(*__s.__current_, *__next);
+ if (__icase_)
+ {
+ __ch2.first = __traits_.translate_nocase(__ch2.first);
+ __ch2.second = __traits_.translate_nocase(__ch2.second);
+ }
+ else if (__collate_)
+ {
+ __ch2.first = __traits_.translate(__ch2.first);
+ __ch2.second = __traits_.translate(__ch2.second);
+ }
+ if (!__traits_.lookup_collatename(&__ch2.first, &__ch2.first+2).empty())
+ {
+ // __ch2 is a digraph in this locale
+ ++__consumed;
+ for (size_t __i = 0; __i < __digraphs_.size(); ++__i)
+ {
+ if (__ch2 == __digraphs_[__i])
+ {
+ __found = true;
+ goto __exit;
+ }
+ }
+ if (__collate_ && !__ranges_.empty())
+ {
+ string_type __s2 = __traits_.transform(&__ch2.first,
+ &__ch2.first + 2);
+ for (size_t __i = 0; __i < __ranges_.size(); ++__i)
+ {
+ if (__ranges_[__i].first <= __s2 &&
+ __s2 <= __ranges_[__i].second)
+ {
+ __found = true;
+ goto __exit;
+ }
+ }
+ }
+ if (!__equivalences_.empty())
+ {
+ string_type __s2 = __traits_.transform_primary(&__ch2.first,
+ &__ch2.first + 2);
+ for (size_t __i = 0; __i < __equivalences_.size(); ++__i)
+ {
+ if (__s2 == __equivalences_[__i])
+ {
+ __found = true;
+ goto __exit;
+ }
+ }
+ }
+ if (__traits_.isctype(__ch2.first, __mask_) &&
+ __traits_.isctype(__ch2.second, __mask_))
+ {
+ __found = true;
+ goto __exit;
+ }
+ if (!__traits_.isctype(__ch2.first, __neg_mask_) &&
+ !__traits_.isctype(__ch2.second, __neg_mask_))
+ {
+ __found = true;
+ goto __exit;
+ }
+ goto __exit;
+ }
+ }
+ }
+ // test *__s.__current_ as not a digraph
+ _CharT __ch = *__s.__current_;
+ if (__icase_)
+ __ch = __traits_.translate_nocase(__ch);
+ else if (__collate_)
+ __ch = __traits_.translate(__ch);
+ for (size_t __i = 0; __i < __chars_.size(); ++__i)
+ {
+ if (__ch == __chars_[__i])
+ {
+ __found = true;
+ goto __exit;
+ }
+ }
+ // When there's at least one of __neg_chars_ and __neg_mask_, the set
+ // of "__found" chars is
+ // union(complement(union(__neg_chars_, __neg_mask_)),
+ // other cases...)
+ //
+ // It doesn't make sense to check this when there are no __neg_chars_
+ // and no __neg_mask_.
+ if (!(__neg_mask_ == 0 && __neg_chars_.empty()))
+ {
+ const bool __in_neg_mask = __traits_.isctype(__ch, __neg_mask_);
+ const bool __in_neg_chars =
+ _VSTD::find(__neg_chars_.begin(), __neg_chars_.end(), __ch) !=
+ __neg_chars_.end();
+ if (!(__in_neg_mask || __in_neg_chars))
+ {
+ __found = true;
+ goto __exit;
+ }
+ }
+ if (!__ranges_.empty())
+ {
+ string_type __s2 = __collate_ ?
+ __traits_.transform(&__ch, &__ch + 1) :
+ string_type(1, __ch);
+ for (size_t __i = 0; __i < __ranges_.size(); ++__i)
+ {
+ if (__ranges_[__i].first <= __s2 && __s2 <= __ranges_[__i].second)
+ {
+ __found = true;
+ goto __exit;
+ }
+ }
+ }
+ if (!__equivalences_.empty())
+ {
+ string_type __s2 = __traits_.transform_primary(&__ch, &__ch + 1);
+ for (size_t __i = 0; __i < __equivalences_.size(); ++__i)
+ {
+ if (__s2 == __equivalences_[__i])
+ {
+ __found = true;
+ goto __exit;
+ }
+ }
+ }
+ if (__traits_.isctype(__ch, __mask_))
+ {
+ __found = true;
+ goto __exit;
+ }
+ }
+ else
+ __found = __negate_; // force reject
+__exit:
+ if (__found != __negate_)
+ {
+ __s.__do_ = __state::__accept_and_consume;
+ __s.__current_ += __consumed;
+ __s.__node_ = this->first();
+ }
+ else
+ {
+ __s.__do_ = __state::__reject;
+ __s.__node_ = nullptr;
+ }
+}
+
+template <class _CharT, class _Traits> class __lookahead;
+
+template <class _CharT, class _Traits = regex_traits<_CharT> >
+ class _LIBCPP_TEMPLATE_VIS basic_regex;
+
+typedef basic_regex<char> regex;
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+typedef basic_regex<wchar_t> wregex;
+#endif
+
+template <class _CharT, class _Traits>
+class
+ _LIBCPP_TEMPLATE_VIS
+ _LIBCPP_PREFERRED_NAME(regex)
+ _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wregex))
+ basic_regex
+{
+public:
+ // types:
+ typedef _CharT value_type;
+ typedef _Traits traits_type;
+ typedef typename _Traits::string_type string_type;
+ typedef regex_constants::syntax_option_type flag_type;
+ typedef typename _Traits::locale_type locale_type;
+
+private:
+ _Traits __traits_;
+ flag_type __flags_;
+ unsigned __marked_count_;
+ unsigned __loop_count_;
+ int __open_count_;
+ shared_ptr<__empty_state<_CharT> > __start_;
+ __owns_one_state<_CharT>* __end_;
+
+ typedef _VSTD::__state<_CharT> __state;
+ typedef _VSTD::__node<_CharT> __node;
+
+public:
+ // constants:
+ static const regex_constants::syntax_option_type icase = regex_constants::icase;
+ static const regex_constants::syntax_option_type nosubs = regex_constants::nosubs;
+ static const regex_constants::syntax_option_type optimize = regex_constants::optimize;
+ static const regex_constants::syntax_option_type collate = regex_constants::collate;
+ static const regex_constants::syntax_option_type ECMAScript = regex_constants::ECMAScript;
+ static const regex_constants::syntax_option_type basic = regex_constants::basic;
+ static const regex_constants::syntax_option_type extended = regex_constants::extended;
+ static const regex_constants::syntax_option_type awk = regex_constants::awk;
+ static const regex_constants::syntax_option_type grep = regex_constants::grep;
+ static const regex_constants::syntax_option_type egrep = regex_constants::egrep;
+ static const regex_constants::syntax_option_type multiline = regex_constants::multiline;
+
+ // construct/copy/destroy:
+ _LIBCPP_INLINE_VISIBILITY
+ basic_regex()
+ : __flags_(regex_constants::ECMAScript), __marked_count_(0), __loop_count_(0), __open_count_(0),
+ __end_(nullptr)
+ {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit basic_regex(const value_type* __p, flag_type __f = regex_constants::ECMAScript)
+ : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
+ __end_(nullptr)
+ {
+ __init(__p, __p + __traits_.length(__p));
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ basic_regex(const value_type* __p, size_t __len, flag_type __f = regex_constants::ECMAScript)
+ : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
+ __end_(nullptr)
+ {
+ __init(__p, __p + __len);
+ }
+
+// basic_regex(const basic_regex&) = default;
+// basic_regex(basic_regex&&) = default;
+ template <class _ST, class _SA>
+ _LIBCPP_INLINE_VISIBILITY
+ explicit basic_regex(const basic_string<value_type, _ST, _SA>& __p,
+ flag_type __f = regex_constants::ECMAScript)
+ : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
+ __end_(nullptr)
+ {
+ __init(__p.begin(), __p.end());
+ }
+
+ template <class _ForwardIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ basic_regex(_ForwardIterator __first, _ForwardIterator __last,
+ flag_type __f = regex_constants::ECMAScript)
+ : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
+ __end_(nullptr)
+ {
+ __init(__first, __last);
+ }
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ basic_regex(initializer_list<value_type> __il,
+ flag_type __f = regex_constants::ECMAScript)
+ : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
+ __end_(nullptr)
+ {
+ __init(__il.begin(), __il.end());
+ }
+#endif // _LIBCPP_CXX03_LANG
+
+// ~basic_regex() = default;
+
+// basic_regex& operator=(const basic_regex&) = default;
+// basic_regex& operator=(basic_regex&&) = default;
+ _LIBCPP_INLINE_VISIBILITY
+ basic_regex& operator=(const value_type* __p)
+ {return assign(__p);}
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ basic_regex& operator=(initializer_list<value_type> __il)
+ {return assign(__il);}
+#endif // _LIBCPP_CXX03_LANG
+ template <class _ST, class _SA>
+ _LIBCPP_INLINE_VISIBILITY
+ basic_regex& operator=(const basic_string<value_type, _ST, _SA>& __p)
+ {return assign(__p);}
+
+ // assign:
+ _LIBCPP_INLINE_VISIBILITY
+ basic_regex& assign(const basic_regex& __that)
+ {return *this = __that;}
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ basic_regex& assign(basic_regex&& __that) _NOEXCEPT
+ {return *this = _VSTD::move(__that);}
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ basic_regex& assign(const value_type* __p, flag_type __f = regex_constants::ECMAScript)
+ {return assign(__p, __p + __traits_.length(__p), __f);}
+ _LIBCPP_INLINE_VISIBILITY
+ basic_regex& assign(const value_type* __p, size_t __len, flag_type __f = regex_constants::ECMAScript)
+ {return assign(__p, __p + __len, __f);}
+ template <class _ST, class _SA>
+ _LIBCPP_INLINE_VISIBILITY
+ basic_regex& assign(const basic_string<value_type, _ST, _SA>& __s,
+ flag_type __f = regex_constants::ECMAScript)
+ {return assign(__s.begin(), __s.end(), __f);}
+
+ template <class _InputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if
+ <
+ __is_cpp17_input_iterator <_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value,
+ basic_regex&
+ >::type
+ assign(_InputIterator __first, _InputIterator __last,
+ flag_type __f = regex_constants::ECMAScript)
+ {
+ basic_string<_CharT> __t(__first, __last);
+ return assign(__t.begin(), __t.end(), __f);
+ }
+
+private:
+ _LIBCPP_INLINE_VISIBILITY
+ void __member_init(flag_type __f)
+ {
+ __flags_ = __f;
+ __marked_count_ = 0;
+ __loop_count_ = 0;
+ __open_count_ = 0;
+ __end_ = nullptr;
+ }
+public:
+
+ template <class _ForwardIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if
+ <
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
+ basic_regex&
+ >::type
+ assign(_ForwardIterator __first, _ForwardIterator __last,
+ flag_type __f = regex_constants::ECMAScript)
+ {
+ return assign(basic_regex(__first, __last, __f));
+ }
+
+#ifndef _LIBCPP_CXX03_LANG
+
+ _LIBCPP_INLINE_VISIBILITY
+ basic_regex& assign(initializer_list<value_type> __il,
+ flag_type __f = regex_constants::ECMAScript)
+ {return assign(__il.begin(), __il.end(), __f);}
+
+#endif // _LIBCPP_CXX03_LANG
+
+ // const operations:
+ _LIBCPP_INLINE_VISIBILITY
+ unsigned mark_count() const {return __marked_count_;}
+ _LIBCPP_INLINE_VISIBILITY
+ flag_type flags() const {return __flags_;}
+
+ // locale:
+ _LIBCPP_INLINE_VISIBILITY
+ locale_type imbue(locale_type __loc)
+ {
+ __member_init(ECMAScript);
+ __start_.reset();
+ return __traits_.imbue(__loc);
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ locale_type getloc() const {return __traits_.getloc();}
+
+ // swap:
+ void swap(basic_regex& __r);
+
+private:
+ _LIBCPP_INLINE_VISIBILITY
+ unsigned __loop_count() const {return __loop_count_;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool __use_multiline() const
+ {
+ return __get_grammar(__flags_) == ECMAScript && (__flags_ & multiline);
+ }
+
+ template <class _ForwardIterator>
+ void
+ __init(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_basic_reg_exp(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_RE_expression(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_simple_RE(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_nondupl_RE(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_one_char_or_coll_elem_RE(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_Back_open_paren(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_Back_close_paren(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_Back_open_brace(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_Back_close_brace(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_BACKREF(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_ORD_CHAR(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_QUOTED_CHAR(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_RE_dupl_symbol(_ForwardIterator __first, _ForwardIterator __last,
+ __owns_one_state<_CharT>* __s,
+ unsigned __mexp_begin, unsigned __mexp_end);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_ERE_dupl_symbol(_ForwardIterator __first, _ForwardIterator __last,
+ __owns_one_state<_CharT>* __s,
+ unsigned __mexp_begin, unsigned __mexp_end);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_bracket_expression(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_follow_list(_ForwardIterator __first, _ForwardIterator __last,
+ __bracket_expression<_CharT, _Traits>* __ml);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_expression_term(_ForwardIterator __first, _ForwardIterator __last,
+ __bracket_expression<_CharT, _Traits>* __ml);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_equivalence_class(_ForwardIterator __first, _ForwardIterator __last,
+ __bracket_expression<_CharT, _Traits>* __ml);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_character_class(_ForwardIterator __first, _ForwardIterator __last,
+ __bracket_expression<_CharT, _Traits>* __ml);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_collating_symbol(_ForwardIterator __first, _ForwardIterator __last,
+ basic_string<_CharT>& __col_sym);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_DUP_COUNT(_ForwardIterator __first, _ForwardIterator __last, int& __c);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_extended_reg_exp(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_ERE_branch(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_ERE_expression(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_one_char_or_coll_elem_ERE(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_ORD_CHAR_ERE(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_QUOTED_CHAR_ERE(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_ecma_exp(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_alternative(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_term(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_assertion(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_atom(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_atom_escape(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_decimal_escape(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_character_class_escape(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_character_escape(_ForwardIterator __first, _ForwardIterator __last,
+ basic_string<_CharT>* __str = nullptr);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_pattern_character(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_grep(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_egrep(_ForwardIterator __first, _ForwardIterator __last);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_class_escape(_ForwardIterator __first, _ForwardIterator __last,
+ basic_string<_CharT>& __str,
+ __bracket_expression<_CharT, _Traits>* __ml);
+ template <class _ForwardIterator>
+ _ForwardIterator
+ __parse_awk_escape(_ForwardIterator __first, _ForwardIterator __last,
+ basic_string<_CharT>* __str = nullptr);
+
+ bool __test_back_ref(_CharT c);
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __push_l_anchor();
+ void __push_r_anchor();
+ void __push_match_any();
+ void __push_match_any_but_newline();
+ _LIBCPP_INLINE_VISIBILITY
+ void __push_greedy_inf_repeat(size_t __min, __owns_one_state<_CharT>* __s,
+ unsigned __mexp_begin = 0, unsigned __mexp_end = 0)
+ {__push_loop(__min, numeric_limits<size_t>::max(), __s,
+ __mexp_begin, __mexp_end);}
+ _LIBCPP_INLINE_VISIBILITY
+ void __push_nongreedy_inf_repeat(size_t __min, __owns_one_state<_CharT>* __s,
+ unsigned __mexp_begin = 0, unsigned __mexp_end = 0)
+ {__push_loop(__min, numeric_limits<size_t>::max(), __s,
+ __mexp_begin, __mexp_end, false);}
+ void __push_loop(size_t __min, size_t __max, __owns_one_state<_CharT>* __s,
+ size_t __mexp_begin = 0, size_t __mexp_end = 0,
+ bool __greedy = true);
+ __bracket_expression<_CharT, _Traits>* __start_matching_list(bool __negate);
+ void __push_char(value_type __c);
+ void __push_back_ref(int __i);
+ void __push_alternation(__owns_one_state<_CharT>* __sa,
+ __owns_one_state<_CharT>* __sb);
+ void __push_begin_marked_subexpression();
+ void __push_end_marked_subexpression(unsigned);
+ void __push_empty();
+ void __push_word_boundary(bool);
+ void __push_lookahead(const basic_regex&, bool, unsigned);
+
+ template <class _Allocator>
+ bool
+ __search(const _CharT* __first, const _CharT* __last,
+ match_results<const _CharT*, _Allocator>& __m,
+ regex_constants::match_flag_type __flags) const;
+
+ template <class _Allocator>
+ bool
+ __match_at_start(const _CharT* __first, const _CharT* __last,
+ match_results<const _CharT*, _Allocator>& __m,
+ regex_constants::match_flag_type __flags, bool) const;
+ template <class _Allocator>
+ bool
+ __match_at_start_ecma(const _CharT* __first, const _CharT* __last,
+ match_results<const _CharT*, _Allocator>& __m,
+ regex_constants::match_flag_type __flags, bool) const;
+ template <class _Allocator>
+ bool
+ __match_at_start_posix_nosubs(const _CharT* __first, const _CharT* __last,
+ match_results<const _CharT*, _Allocator>& __m,
+ regex_constants::match_flag_type __flags, bool) const;
+ template <class _Allocator>
+ bool
+ __match_at_start_posix_subs(const _CharT* __first, const _CharT* __last,
+ match_results<const _CharT*, _Allocator>& __m,
+ regex_constants::match_flag_type __flags, bool) const;
+
+ template <class _Bp, class _Ap, class _Cp, class _Tp>
+ friend
+ bool
+ regex_search(_Bp, _Bp, match_results<_Bp, _Ap>&, const basic_regex<_Cp, _Tp>&,
+ regex_constants::match_flag_type);
+
+ template <class _Ap, class _Cp, class _Tp>
+ friend
+ bool
+ regex_search(const _Cp*, const _Cp*, match_results<const _Cp*, _Ap>&,
+ const basic_regex<_Cp, _Tp>&, regex_constants::match_flag_type);
+
+ template <class _Bp, class _Cp, class _Tp>
+ friend
+ bool
+ regex_search(_Bp, _Bp, const basic_regex<_Cp, _Tp>&,
+ regex_constants::match_flag_type);
+
+ template <class _Cp, class _Tp>
+ friend
+ bool
+ regex_search(const _Cp*, const _Cp*,
+ const basic_regex<_Cp, _Tp>&, regex_constants::match_flag_type);
+
+ template <class _Cp, class _Ap, class _Tp>
+ friend
+ bool
+ regex_search(const _Cp*, match_results<const _Cp*, _Ap>&, const basic_regex<_Cp, _Tp>&,
+ regex_constants::match_flag_type);
+
+ template <class _ST, class _SA, class _Cp, class _Tp>
+ friend
+ bool
+ regex_search(const basic_string<_Cp, _ST, _SA>& __s,
+ const basic_regex<_Cp, _Tp>& __e,
+ regex_constants::match_flag_type __flags);
+
+ template <class _ST, class _SA, class _Ap, class _Cp, class _Tp>
+ friend
+ bool
+ regex_search(const basic_string<_Cp, _ST, _SA>& __s,
+ match_results<typename basic_string<_Cp, _ST, _SA>::const_iterator, _Ap>&,
+ const basic_regex<_Cp, _Tp>& __e,
+ regex_constants::match_flag_type __flags);
+
+ template <class _Iter, class _Ap, class _Cp, class _Tp>
+ friend
+ bool
+ regex_search(__wrap_iter<_Iter> __first,
+ __wrap_iter<_Iter> __last,
+ match_results<__wrap_iter<_Iter>, _Ap>& __m,
+ const basic_regex<_Cp, _Tp>& __e,
+ regex_constants::match_flag_type __flags);
+
+ template <class, class> friend class __lookahead;
+};
+
+#if _LIBCPP_STD_VER >= 17
+template <class _ForwardIterator,
+ class = typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value, nullptr_t>::type
+>
+basic_regex(_ForwardIterator, _ForwardIterator,
+ regex_constants::syntax_option_type = regex_constants::ECMAScript)
+ -> basic_regex<typename iterator_traits<_ForwardIterator>::value_type>;
+#endif
+
+template <class _CharT, class _Traits>
+ const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::icase;
+template <class _CharT, class _Traits>
+ const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::nosubs;
+template <class _CharT, class _Traits>
+ const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::optimize;
+template <class _CharT, class _Traits>
+ const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::collate;
+template <class _CharT, class _Traits>
+ const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::ECMAScript;
+template <class _CharT, class _Traits>
+ const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::basic;
+template <class _CharT, class _Traits>
+ const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::extended;
+template <class _CharT, class _Traits>
+ const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::awk;
+template <class _CharT, class _Traits>
+ const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::grep;
+template <class _CharT, class _Traits>
+ const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::egrep;
+
+template <class _CharT, class _Traits>
+void
+basic_regex<_CharT, _Traits>::swap(basic_regex& __r)
+{
+ using _VSTD::swap;
+ swap(__traits_, __r.__traits_);
+ swap(__flags_, __r.__flags_);
+ swap(__marked_count_, __r.__marked_count_);
+ swap(__loop_count_, __r.__loop_count_);
+ swap(__open_count_, __r.__open_count_);
+ swap(__start_, __r.__start_);
+ swap(__end_, __r.__end_);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(basic_regex<_CharT, _Traits>& __x, basic_regex<_CharT, _Traits>& __y)
+{
+ return __x.swap(__y);
+}
+
+// __lookahead
+
+template <class _CharT, class _Traits>
+class __lookahead
+ : public __owns_one_state<_CharT>
+{
+ typedef __owns_one_state<_CharT> base;
+
+ basic_regex<_CharT, _Traits> __exp_;
+ unsigned __mexp_;
+ bool __invert_;
+
+ __lookahead(const __lookahead&);
+ __lookahead& operator=(const __lookahead&);
+public:
+ typedef _VSTD::__state<_CharT> __state;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __lookahead(const basic_regex<_CharT, _Traits>& __exp, bool __invert, __node<_CharT>* __s, unsigned __mexp)
+ : base(__s), __exp_(__exp), __mexp_(__mexp), __invert_(__invert) {}
+
+ virtual void __exec(__state&) const;
+};
+
+template <class _CharT, class _Traits>
+void
+__lookahead<_CharT, _Traits>::__exec(__state& __s) const
+{
+ match_results<const _CharT*> __m;
+ __m.__init(1 + __exp_.mark_count(), __s.__current_, __s.__last_);
+ bool __matched = __exp_.__match_at_start_ecma(
+ __s.__current_, __s.__last_,
+ __m,
+ (__s.__flags_ | regex_constants::match_continuous) &
+ ~regex_constants::__full_match,
+ __s.__at_first_ && __s.__current_ == __s.__first_);
+ if (__matched != __invert_)
+ {
+ __s.__do_ = __state::__accept_but_not_consume;
+ __s.__node_ = this->first();
+ for (unsigned __i = 1; __i < __m.size(); ++__i) {
+ __s.__sub_matches_[__mexp_ + __i - 1] = __m.__matches_[__i];
+ }
+ }
+ else
+ {
+ __s.__do_ = __state::__reject;
+ __s.__node_ = nullptr;
+ }
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+void
+basic_regex<_CharT, _Traits>::__init(_ForwardIterator __first, _ForwardIterator __last)
+{
+ if (__get_grammar(__flags_) == 0) __flags_ |= regex_constants::ECMAScript;
+ _ForwardIterator __temp = __parse(__first, __last);
+ if ( __temp != __last)
+ __throw_regex_error<regex_constants::__re_err_parse>();
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse(_ForwardIterator __first,
+ _ForwardIterator __last)
+{
+ {
+ unique_ptr<__node> __h(new __end_state<_CharT>);
+ __start_.reset(new __empty_state<_CharT>(__h.get()));
+ __h.release();
+ __end_ = __start_.get();
+ }
+ switch (__get_grammar(__flags_))
+ {
+ case ECMAScript:
+ __first = __parse_ecma_exp(__first, __last);
+ break;
+ case basic:
+ __first = __parse_basic_reg_exp(__first, __last);
+ break;
+ case extended:
+ case awk:
+ __first = __parse_extended_reg_exp(__first, __last);
+ break;
+ case grep:
+ __first = __parse_grep(__first, __last);
+ break;
+ case egrep:
+ __first = __parse_egrep(__first, __last);
+ break;
+ default:
+ __throw_regex_error<regex_constants::__re_err_grammar>();
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_basic_reg_exp(_ForwardIterator __first,
+ _ForwardIterator __last)
+{
+ if (__first != __last)
+ {
+ if (*__first == '^')
+ {
+ __push_l_anchor();
+ ++__first;
+ }
+ if (__first != __last)
+ {
+ __first = __parse_RE_expression(__first, __last);
+ if (__first != __last)
+ {
+ _ForwardIterator __temp = _VSTD::next(__first);
+ if (__temp == __last && *__first == '$')
+ {
+ __push_r_anchor();
+ ++__first;
+ }
+ }
+ }
+ if (__first != __last)
+ __throw_regex_error<regex_constants::__re_err_empty>();
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_extended_reg_exp(_ForwardIterator __first,
+ _ForwardIterator __last)
+{
+ __owns_one_state<_CharT>* __sa = __end_;
+ _ForwardIterator __temp = __parse_ERE_branch(__first, __last);
+ if (__temp == __first)
+ __throw_regex_error<regex_constants::__re_err_empty>();
+ __first = __temp;
+ while (__first != __last && *__first == '|')
+ {
+ __owns_one_state<_CharT>* __sb = __end_;
+ __temp = __parse_ERE_branch(++__first, __last);
+ if (__temp == __first)
+ __throw_regex_error<regex_constants::__re_err_empty>();
+ __push_alternation(__sa, __sb);
+ __first = __temp;
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_ERE_branch(_ForwardIterator __first,
+ _ForwardIterator __last)
+{
+ _ForwardIterator __temp = __parse_ERE_expression(__first, __last);
+ if (__temp == __first)
+ __throw_regex_error<regex_constants::__re_err_empty>();
+ do
+ {
+ __first = __temp;
+ __temp = __parse_ERE_expression(__first, __last);
+ } while (__temp != __first);
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_ERE_expression(_ForwardIterator __first,
+ _ForwardIterator __last)
+{
+ __owns_one_state<_CharT>* __e = __end_;
+ unsigned __mexp_begin = __marked_count_;
+ _ForwardIterator __temp = __parse_one_char_or_coll_elem_ERE(__first, __last);
+ if (__temp == __first && __temp != __last)
+ {
+ switch (*__temp)
+ {
+ case '^':
+ __push_l_anchor();
+ ++__temp;
+ break;
+ case '$':
+ __push_r_anchor();
+ ++__temp;
+ break;
+ case '(':
+ __push_begin_marked_subexpression();
+ unsigned __temp_count = __marked_count_;
+ ++__open_count_;
+ __temp = __parse_extended_reg_exp(++__temp, __last);
+ if (__temp == __last || *__temp != ')')
+ __throw_regex_error<regex_constants::error_paren>();
+ __push_end_marked_subexpression(__temp_count);
+ --__open_count_;
+ ++__temp;
+ break;
+ }
+ }
+ if (__temp != __first)
+ __temp = __parse_ERE_dupl_symbol(__temp, __last, __e, __mexp_begin+1,
+ __marked_count_+1);
+ __first = __temp;
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_RE_expression(_ForwardIterator __first,
+ _ForwardIterator __last)
+{
+ while (true)
+ {
+ _ForwardIterator __temp = __parse_simple_RE(__first, __last);
+ if (__temp == __first)
+ break;
+ __first = __temp;
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_simple_RE(_ForwardIterator __first,
+ _ForwardIterator __last)
+{
+ if (__first != __last)
+ {
+ __owns_one_state<_CharT>* __e = __end_;
+ unsigned __mexp_begin = __marked_count_;
+ _ForwardIterator __temp = __parse_nondupl_RE(__first, __last);
+ if (__temp != __first)
+ __first = __parse_RE_dupl_symbol(__temp, __last, __e,
+ __mexp_begin+1, __marked_count_+1);
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_nondupl_RE(_ForwardIterator __first,
+ _ForwardIterator __last)
+{
+ _ForwardIterator __temp = __first;
+ __first = __parse_one_char_or_coll_elem_RE(__first, __last);
+ if (__temp == __first)
+ {
+ __temp = __parse_Back_open_paren(__first, __last);
+ if (__temp != __first)
+ {
+ __push_begin_marked_subexpression();
+ unsigned __temp_count = __marked_count_;
+ __first = __parse_RE_expression(__temp, __last);
+ __temp = __parse_Back_close_paren(__first, __last);
+ if (__temp == __first)
+ __throw_regex_error<regex_constants::error_paren>();
+ __push_end_marked_subexpression(__temp_count);
+ __first = __temp;
+ }
+ else
+ __first = __parse_BACKREF(__first, __last);
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_one_char_or_coll_elem_RE(
+ _ForwardIterator __first,
+ _ForwardIterator __last)
+{
+ _ForwardIterator __temp = __parse_ORD_CHAR(__first, __last);
+ if (__temp == __first)
+ {
+ __temp = __parse_QUOTED_CHAR(__first, __last);
+ if (__temp == __first)
+ {
+ if (__temp != __last && *__temp == '.')
+ {
+ __push_match_any();
+ ++__temp;
+ }
+ else
+ __temp = __parse_bracket_expression(__first, __last);
+ }
+ }
+ __first = __temp;
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_one_char_or_coll_elem_ERE(
+ _ForwardIterator __first,
+ _ForwardIterator __last)
+{
+ _ForwardIterator __temp = __parse_ORD_CHAR_ERE(__first, __last);
+ if (__temp == __first)
+ {
+ __temp = __parse_QUOTED_CHAR_ERE(__first, __last);
+ if (__temp == __first)
+ {
+ if (__temp != __last && *__temp == '.')
+ {
+ __push_match_any();
+ ++__temp;
+ }
+ else
+ __temp = __parse_bracket_expression(__first, __last);
+ }
+ }
+ __first = __temp;
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_Back_open_paren(_ForwardIterator __first,
+ _ForwardIterator __last)
+{
+ if (__first != __last)
+ {
+ _ForwardIterator __temp = _VSTD::next(__first);
+ if (__temp != __last)
+ {
+ if (*__first == '\\' && *__temp == '(')
+ __first = ++__temp;
+ }
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_Back_close_paren(_ForwardIterator __first,
+ _ForwardIterator __last)
+{
+ if (__first != __last)
+ {
+ _ForwardIterator __temp = _VSTD::next(__first);
+ if (__temp != __last)
+ {
+ if (*__first == '\\' && *__temp == ')')
+ __first = ++__temp;
+ }
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_Back_open_brace(_ForwardIterator __first,
+ _ForwardIterator __last)
+{
+ if (__first != __last)
+ {
+ _ForwardIterator __temp = _VSTD::next(__first);
+ if (__temp != __last)
+ {
+ if (*__first == '\\' && *__temp == '{')
+ __first = ++__temp;
+ }
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_Back_close_brace(_ForwardIterator __first,
+ _ForwardIterator __last)
+{
+ if (__first != __last)
+ {
+ _ForwardIterator __temp = _VSTD::next(__first);
+ if (__temp != __last)
+ {
+ if (*__first == '\\' && *__temp == '}')
+ __first = ++__temp;
+ }
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_BACKREF(_ForwardIterator __first,
+ _ForwardIterator __last)
+{
+ if (__first != __last)
+ {
+ _ForwardIterator __temp = _VSTD::next(__first);
+ if (__temp != __last && *__first == '\\' && __test_back_ref(*__temp))
+ __first = ++__temp;
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_ORD_CHAR(_ForwardIterator __first,
+ _ForwardIterator __last)
+{
+ if (__first != __last)
+ {
+ _ForwardIterator __temp = _VSTD::next(__first);
+ if (__temp == __last && *__first == '$')
+ return __first;
+ // Not called inside a bracket
+ if (*__first == '.' || *__first == '\\' || *__first == '[')
+ return __first;
+ __push_char(*__first);
+ ++__first;
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_ORD_CHAR_ERE(_ForwardIterator __first,
+ _ForwardIterator __last)
+{
+ if (__first != __last)
+ {
+ switch (*__first)
+ {
+ case '^':
+ case '.':
+ case '[':
+ case '$':
+ case '(':
+ case '|':
+ case '*':
+ case '+':
+ case '?':
+ case '{':
+ case '\\':
+ break;
+ case ')':
+ if (__open_count_ == 0)
+ {
+ __push_char(*__first);
+ ++__first;
+ }
+ break;
+ default:
+ __push_char(*__first);
+ ++__first;
+ break;
+ }
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_QUOTED_CHAR(_ForwardIterator __first,
+ _ForwardIterator __last)
+{
+ if (__first != __last)
+ {
+ _ForwardIterator __temp = _VSTD::next(__first);
+ if (__temp != __last)
+ {
+ if (*__first == '\\')
+ {
+ switch (*__temp)
+ {
+ case '^':
+ case '.':
+ case '*':
+ case '[':
+ case '$':
+ case '\\':
+ __push_char(*__temp);
+ __first = ++__temp;
+ break;
+ }
+ }
+ }
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_QUOTED_CHAR_ERE(_ForwardIterator __first,
+ _ForwardIterator __last)
+{
+ if (__first != __last)
+ {
+ _ForwardIterator __temp = _VSTD::next(__first);
+ if (__temp != __last)
+ {
+ if (*__first == '\\')
+ {
+ switch (*__temp)
+ {
+ case '^':
+ case '.':
+ case '*':
+ case '[':
+ case '$':
+ case '\\':
+ case '(':
+ case ')':
+ case '|':
+ case '+':
+ case '?':
+ case '{':
+ case '}':
+ __push_char(*__temp);
+ __first = ++__temp;
+ break;
+ default:
+ if (__get_grammar(__flags_) == awk)
+ __first = __parse_awk_escape(++__first, __last);
+ else if(__test_back_ref(*__temp))
+ __first = ++__temp;
+ break;
+ }
+ }
+ }
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_RE_dupl_symbol(_ForwardIterator __first,
+ _ForwardIterator __last,
+ __owns_one_state<_CharT>* __s,
+ unsigned __mexp_begin,
+ unsigned __mexp_end)
+{
+ if (__first != __last)
+ {
+ if (*__first == '*')
+ {
+ __push_greedy_inf_repeat(0, __s, __mexp_begin, __mexp_end);
+ ++__first;
+ }
+ else
+ {
+ _ForwardIterator __temp = __parse_Back_open_brace(__first, __last);
+ if (__temp != __first)
+ {
+ int __min = 0;
+ __first = __temp;
+ __temp = __parse_DUP_COUNT(__first, __last, __min);
+ if (__temp == __first)
+ __throw_regex_error<regex_constants::error_badbrace>();
+ __first = __temp;
+ if (__first == __last)
+ __throw_regex_error<regex_constants::error_brace>();
+ if (*__first != ',')
+ {
+ __temp = __parse_Back_close_brace(__first, __last);
+ if (__temp == __first)
+ __throw_regex_error<regex_constants::error_brace>();
+ __push_loop(__min, __min, __s, __mexp_begin, __mexp_end,
+ true);
+ __first = __temp;
+ }
+ else
+ {
+ ++__first; // consume ','
+ int __max = -1;
+ __first = __parse_DUP_COUNT(__first, __last, __max);
+ __temp = __parse_Back_close_brace(__first, __last);
+ if (__temp == __first)
+ __throw_regex_error<regex_constants::error_brace>();
+ if (__max == -1)
+ __push_greedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end);
+ else
+ {
+ if (__max < __min)
+ __throw_regex_error<regex_constants::error_badbrace>();
+ __push_loop(__min, __max, __s, __mexp_begin, __mexp_end,
+ true);
+ }
+ __first = __temp;
+ }
+ }
+ }
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first,
+ _ForwardIterator __last,
+ __owns_one_state<_CharT>* __s,
+ unsigned __mexp_begin,
+ unsigned __mexp_end)
+{
+ if (__first != __last)
+ {
+ unsigned __grammar = __get_grammar(__flags_);
+ switch (*__first)
+ {
+ case '*':
+ ++__first;
+ if (__grammar == ECMAScript && __first != __last && *__first == '?')
+ {
+ ++__first;
+ __push_nongreedy_inf_repeat(0, __s, __mexp_begin, __mexp_end);
+ }
+ else
+ __push_greedy_inf_repeat(0, __s, __mexp_begin, __mexp_end);
+ break;
+ case '+':
+ ++__first;
+ if (__grammar == ECMAScript && __first != __last && *__first == '?')
+ {
+ ++__first;
+ __push_nongreedy_inf_repeat(1, __s, __mexp_begin, __mexp_end);
+ }
+ else
+ __push_greedy_inf_repeat(1, __s, __mexp_begin, __mexp_end);
+ break;
+ case '?':
+ ++__first;
+ if (__grammar == ECMAScript && __first != __last && *__first == '?')
+ {
+ ++__first;
+ __push_loop(0, 1, __s, __mexp_begin, __mexp_end, false);
+ }
+ else
+ __push_loop(0, 1, __s, __mexp_begin, __mexp_end);
+ break;
+ case '{':
+ {
+ int __min;
+ _ForwardIterator __temp = __parse_DUP_COUNT(++__first, __last, __min);
+ if (__temp == __first)
+ __throw_regex_error<regex_constants::error_badbrace>();
+ __first = __temp;
+ if (__first == __last)
+ __throw_regex_error<regex_constants::error_brace>();
+ switch (*__first)
+ {
+ case '}':
+ ++__first;
+ if (__grammar == ECMAScript && __first != __last && *__first == '?')
+ {
+ ++__first;
+ __push_loop(__min, __min, __s, __mexp_begin, __mexp_end, false);
+ }
+ else
+ __push_loop(__min, __min, __s, __mexp_begin, __mexp_end);
+ break;
+ case ',':
+ ++__first;
+ if (__first == __last)
+ __throw_regex_error<regex_constants::error_badbrace>();
+ if (*__first == '}')
+ {
+ ++__first;
+ if (__grammar == ECMAScript && __first != __last && *__first == '?')
+ {
+ ++__first;
+ __push_nongreedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end);
+ }
+ else
+ __push_greedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end);
+ }
+ else
+ {
+ int __max = -1;
+ __temp = __parse_DUP_COUNT(__first, __last, __max);
+ if (__temp == __first)
+ __throw_regex_error<regex_constants::error_brace>();
+ __first = __temp;
+ if (__first == __last || *__first != '}')
+ __throw_regex_error<regex_constants::error_brace>();
+ ++__first;
+ if (__max < __min)
+ __throw_regex_error<regex_constants::error_badbrace>();
+ if (__grammar == ECMAScript && __first != __last && *__first == '?')
+ {
+ ++__first;
+ __push_loop(__min, __max, __s, __mexp_begin, __mexp_end, false);
+ }
+ else
+ __push_loop(__min, __max, __s, __mexp_begin, __mexp_end);
+ }
+ break;
+ default:
+ __throw_regex_error<regex_constants::error_badbrace>();
+ }
+ }
+ break;
+ }
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_bracket_expression(_ForwardIterator __first,
+ _ForwardIterator __last)
+{
+ if (__first != __last && *__first == '[')
+ {
+ ++__first;
+ if (__first == __last)
+ __throw_regex_error<regex_constants::error_brack>();
+ bool __negate = false;
+ if (*__first == '^')
+ {
+ ++__first;
+ __negate = true;
+ }
+ __bracket_expression<_CharT, _Traits>* __ml = __start_matching_list(__negate);
+ // __ml owned by *this
+ if (__first == __last)
+ __throw_regex_error<regex_constants::error_brack>();
+ if (__get_grammar(__flags_) != ECMAScript && *__first == ']')
+ {
+ __ml->__add_char(']');
+ ++__first;
+ }
+ __first = __parse_follow_list(__first, __last, __ml);
+ if (__first == __last)
+ __throw_regex_error<regex_constants::error_brack>();
+ if (*__first == '-')
+ {
+ __ml->__add_char('-');
+ ++__first;
+ }
+ if (__first == __last || *__first != ']')
+ __throw_regex_error<regex_constants::error_brack>();
+ ++__first;
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_follow_list(_ForwardIterator __first,
+ _ForwardIterator __last,
+ __bracket_expression<_CharT, _Traits>* __ml)
+{
+ if (__first != __last)
+ {
+ while (true)
+ {
+ _ForwardIterator __temp = __parse_expression_term(__first, __last,
+ __ml);
+ if (__temp == __first)
+ break;
+ __first = __temp;
+ }
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_expression_term(_ForwardIterator __first,
+ _ForwardIterator __last,
+ __bracket_expression<_CharT, _Traits>* __ml)
+{
+ if (__first != __last && *__first != ']')
+ {
+ _ForwardIterator __temp = _VSTD::next(__first);
+ basic_string<_CharT> __start_range;
+ if (__temp != __last && *__first == '[')
+ {
+ if (*__temp == '=')
+ return __parse_equivalence_class(++__temp, __last, __ml);
+ else if (*__temp == ':')
+ return __parse_character_class(++__temp, __last, __ml);
+ else if (*__temp == '.')
+ __first = __parse_collating_symbol(++__temp, __last, __start_range);
+ }
+ unsigned __grammar = __get_grammar(__flags_);
+ if (__start_range.empty())
+ {
+ if ((__grammar == ECMAScript || __grammar == awk) && *__first == '\\')
+ {
+ if (__grammar == ECMAScript)
+ __first = __parse_class_escape(++__first, __last, __start_range, __ml);
+ else
+ __first = __parse_awk_escape(++__first, __last, &__start_range);
+ }
+ else
+ {
+ __start_range = *__first;
+ ++__first;
+ }
+ }
+ if (__first != __last && *__first != ']')
+ {
+ __temp = _VSTD::next(__first);
+ if (__temp != __last && *__first == '-' && *__temp != ']')
+ {
+ // parse a range
+ basic_string<_CharT> __end_range;
+ __first = __temp;
+ ++__temp;
+ if (__temp != __last && *__first == '[' && *__temp == '.')
+ __first = __parse_collating_symbol(++__temp, __last, __end_range);
+ else
+ {
+ if ((__grammar == ECMAScript || __grammar == awk) && *__first == '\\')
+ {
+ if (__grammar == ECMAScript)
+ __first = __parse_class_escape(++__first, __last,
+ __end_range, __ml);
+ else
+ __first = __parse_awk_escape(++__first, __last,
+ &__end_range);
+ }
+ else
+ {
+ __end_range = *__first;
+ ++__first;
+ }
+ }
+ __ml->__add_range(_VSTD::move(__start_range), _VSTD::move(__end_range));
+ }
+ else if (!__start_range.empty())
+ {
+ if (__start_range.size() == 1)
+ __ml->__add_char(__start_range[0]);
+ else
+ __ml->__add_digraph(__start_range[0], __start_range[1]);
+ }
+ }
+ else if (!__start_range.empty())
+ {
+ if (__start_range.size() == 1)
+ __ml->__add_char(__start_range[0]);
+ else
+ __ml->__add_digraph(__start_range[0], __start_range[1]);
+ }
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_class_escape(_ForwardIterator __first,
+ _ForwardIterator __last,
+ basic_string<_CharT>& __str,
+ __bracket_expression<_CharT, _Traits>* __ml)
+{
+ if (__first == __last)
+ __throw_regex_error<regex_constants::error_escape>();
+ switch (*__first)
+ {
+ case 0:
+ __str = *__first;
+ return ++__first;
+ case 'b':
+ __str = _CharT(8);
+ return ++__first;
+ case 'd':
+ __ml->__add_class(ctype_base::digit);
+ return ++__first;
+ case 'D':
+ __ml->__add_neg_class(ctype_base::digit);
+ return ++__first;
+ case 's':
+ __ml->__add_class(ctype_base::space);
+ return ++__first;
+ case 'S':
+ __ml->__add_neg_class(ctype_base::space);
+ return ++__first;
+ case 'w':
+ __ml->__add_class(ctype_base::alnum);
+ __ml->__add_char('_');
+ return ++__first;
+ case 'W':
+ __ml->__add_neg_class(ctype_base::alnum);
+ __ml->__add_neg_char('_');
+ return ++__first;
+ }
+ __first = __parse_character_escape(__first, __last, &__str);
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_awk_escape(_ForwardIterator __first,
+ _ForwardIterator __last,
+ basic_string<_CharT>* __str)
+{
+ if (__first == __last)
+ __throw_regex_error<regex_constants::error_escape>();
+ switch (*__first)
+ {
+ case '\\':
+ case '"':
+ case '/':
+ if (__str)
+ *__str = *__first;
+ else
+ __push_char(*__first);
+ return ++__first;
+ case 'a':
+ if (__str)
+ *__str = _CharT(7);
+ else
+ __push_char(_CharT(7));
+ return ++__first;
+ case 'b':
+ if (__str)
+ *__str = _CharT(8);
+ else
+ __push_char(_CharT(8));
+ return ++__first;
+ case 'f':
+ if (__str)
+ *__str = _CharT(0xC);
+ else
+ __push_char(_CharT(0xC));
+ return ++__first;
+ case 'n':
+ if (__str)
+ *__str = _CharT(0xA);
+ else
+ __push_char(_CharT(0xA));
+ return ++__first;
+ case 'r':
+ if (__str)
+ *__str = _CharT(0xD);
+ else
+ __push_char(_CharT(0xD));
+ return ++__first;
+ case 't':
+ if (__str)
+ *__str = _CharT(0x9);
+ else
+ __push_char(_CharT(0x9));
+ return ++__first;
+ case 'v':
+ if (__str)
+ *__str = _CharT(0xB);
+ else
+ __push_char(_CharT(0xB));
+ return ++__first;
+ }
+ if ('0' <= *__first && *__first <= '7')
+ {
+ unsigned __val = *__first - '0';
+ if (++__first != __last && ('0' <= *__first && *__first <= '7'))
+ {
+ __val = 8 * __val + *__first - '0';
+ if (++__first != __last && ('0' <= *__first && *__first <= '7'))
+ __val = 8 * __val + *__first++ - '0';
+ }
+ if (__str)
+ *__str = _CharT(__val);
+ else
+ __push_char(_CharT(__val));
+ }
+ else
+ __throw_regex_error<regex_constants::error_escape>();
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_equivalence_class(_ForwardIterator __first,
+ _ForwardIterator __last,
+ __bracket_expression<_CharT, _Traits>* __ml)
+{
+ // Found [=
+ // This means =] must exist
+ value_type _Equal_close[2] = {'=', ']'};
+ _ForwardIterator __temp = _VSTD::search(__first, __last, _Equal_close,
+ _Equal_close+2);
+ if (__temp == __last)
+ __throw_regex_error<regex_constants::error_brack>();
+ // [__first, __temp) contains all text in [= ... =]
+ string_type __collate_name =
+ __traits_.lookup_collatename(__first, __temp);
+ if (__collate_name.empty())
+ __throw_regex_error<regex_constants::error_collate>();
+ string_type __equiv_name =
+ __traits_.transform_primary(__collate_name.begin(),
+ __collate_name.end());
+ if (!__equiv_name.empty())
+ __ml->__add_equivalence(__equiv_name);
+ else
+ {
+ switch (__collate_name.size())
+ {
+ case 1:
+ __ml->__add_char(__collate_name[0]);
+ break;
+ case 2:
+ __ml->__add_digraph(__collate_name[0], __collate_name[1]);
+ break;
+ default:
+ __throw_regex_error<regex_constants::error_collate>();
+ }
+ }
+ __first = _VSTD::next(__temp, 2);
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_character_class(_ForwardIterator __first,
+ _ForwardIterator __last,
+ __bracket_expression<_CharT, _Traits>* __ml)
+{
+ // Found [:
+ // This means :] must exist
+ value_type _Colon_close[2] = {':', ']'};
+ _ForwardIterator __temp = _VSTD::search(__first, __last, _Colon_close,
+ _Colon_close+2);
+ if (__temp == __last)
+ __throw_regex_error<regex_constants::error_brack>();
+ // [__first, __temp) contains all text in [: ... :]
+ typedef typename _Traits::char_class_type char_class_type;
+ char_class_type __class_type =
+ __traits_.lookup_classname(__first, __temp, __flags_ & icase);
+ if (__class_type == 0)
+ __throw_regex_error<regex_constants::error_ctype>();
+ __ml->__add_class(__class_type);
+ __first = _VSTD::next(__temp, 2);
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_collating_symbol(_ForwardIterator __first,
+ _ForwardIterator __last,
+ basic_string<_CharT>& __col_sym)
+{
+ // Found [.
+ // This means .] must exist
+ value_type _Dot_close[2] = {'.', ']'};
+ _ForwardIterator __temp = _VSTD::search(__first, __last, _Dot_close,
+ _Dot_close+2);
+ if (__temp == __last)
+ __throw_regex_error<regex_constants::error_brack>();
+ // [__first, __temp) contains all text in [. ... .]
+ __col_sym = __traits_.lookup_collatename(__first, __temp);
+ switch (__col_sym.size())
+ {
+ case 1:
+ case 2:
+ break;
+ default:
+ __throw_regex_error<regex_constants::error_collate>();
+ }
+ __first = _VSTD::next(__temp, 2);
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_DUP_COUNT(_ForwardIterator __first,
+ _ForwardIterator __last,
+ int& __c)
+{
+ if (__first != __last )
+ {
+ int __val = __traits_.value(*__first, 10);
+ if ( __val != -1 )
+ {
+ __c = __val;
+ for (++__first;
+ __first != __last && ( __val = __traits_.value(*__first, 10)) != -1;
+ ++__first)
+ {
+ if (__c >= numeric_limits<int>::max() / 10)
+ __throw_regex_error<regex_constants::error_badbrace>();
+ __c *= 10;
+ __c += __val;
+ }
+ }
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_ecma_exp(_ForwardIterator __first,
+ _ForwardIterator __last)
+{
+ __owns_one_state<_CharT>* __sa = __end_;
+ _ForwardIterator __temp = __parse_alternative(__first, __last);
+ if (__temp == __first)
+ __push_empty();
+ __first = __temp;
+ while (__first != __last && *__first == '|')
+ {
+ __owns_one_state<_CharT>* __sb = __end_;
+ __temp = __parse_alternative(++__first, __last);
+ if (__temp == __first)
+ __push_empty();
+ __push_alternation(__sa, __sb);
+ __first = __temp;
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_alternative(_ForwardIterator __first,
+ _ForwardIterator __last)
+{
+ while (true)
+ {
+ _ForwardIterator __temp = __parse_term(__first, __last);
+ if (__temp == __first)
+ break;
+ __first = __temp;
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_term(_ForwardIterator __first,
+ _ForwardIterator __last)
+{
+ _ForwardIterator __temp = __parse_assertion(__first, __last);
+ if (__temp == __first)
+ {
+ __owns_one_state<_CharT>* __e = __end_;
+ unsigned __mexp_begin = __marked_count_;
+ __temp = __parse_atom(__first, __last);
+ if (__temp != __first)
+ __first = __parse_ERE_dupl_symbol(__temp, __last, __e,
+ __mexp_begin+1, __marked_count_+1);
+ }
+ else
+ __first = __temp;
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterator __first,
+ _ForwardIterator __last)
+{
+ if (__first != __last)
+ {
+ switch (*__first)
+ {
+ case '^':
+ __push_l_anchor();
+ ++__first;
+ break;
+ case '$':
+ __push_r_anchor();
+ ++__first;
+ break;
+ case '\\':
+ {
+ _ForwardIterator __temp = _VSTD::next(__first);
+ if (__temp != __last)
+ {
+ if (*__temp == 'b')
+ {
+ __push_word_boundary(false);
+ __first = ++__temp;
+ }
+ else if (*__temp == 'B')
+ {
+ __push_word_boundary(true);
+ __first = ++__temp;
+ }
+ }
+ }
+ break;
+ case '(':
+ {
+ _ForwardIterator __temp = _VSTD::next(__first);
+ if (__temp != __last && *__temp == '?')
+ {
+ if (++__temp != __last)
+ {
+ switch (*__temp)
+ {
+ case '=':
+ {
+ basic_regex __exp;
+ __exp.__flags_ = __flags_;
+ __temp = __exp.__parse(++__temp, __last);
+ unsigned __mexp = __exp.__marked_count_;
+ __push_lookahead(_VSTD::move(__exp), false, __marked_count_);
+ __marked_count_ += __mexp;
+ if (__temp == __last || *__temp != ')')
+ __throw_regex_error<regex_constants::error_paren>();
+ __first = ++__temp;
+ }
+ break;
+ case '!':
+ {
+ basic_regex __exp;
+ __exp.__flags_ = __flags_;
+ __temp = __exp.__parse(++__temp, __last);
+ unsigned __mexp = __exp.__marked_count_;
+ __push_lookahead(_VSTD::move(__exp), true, __marked_count_);
+ __marked_count_ += __mexp;
+ if (__temp == __last || *__temp != ')')
+ __throw_regex_error<regex_constants::error_paren>();
+ __first = ++__temp;
+ }
+ break;
+ }
+ }
+ }
+ }
+ break;
+ }
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __first,
+ _ForwardIterator __last)
+{
+ if (__first != __last)
+ {
+ switch (*__first)
+ {
+ case '.':
+ __push_match_any_but_newline();
+ ++__first;
+ break;
+ case '\\':
+ __first = __parse_atom_escape(__first, __last);
+ break;
+ case '[':
+ __first = __parse_bracket_expression(__first, __last);
+ break;
+ case '(':
+ {
+ ++__first;
+ if (__first == __last)
+ __throw_regex_error<regex_constants::error_paren>();
+ _ForwardIterator __temp = _VSTD::next(__first);
+ if (__temp != __last && *__first == '?' && *__temp == ':')
+ {
+ ++__open_count_;
+ __first = __parse_ecma_exp(++__temp, __last);
+ if (__first == __last || *__first != ')')
+ __throw_regex_error<regex_constants::error_paren>();
+ --__open_count_;
+ ++__first;
+ }
+ else
+ {
+ __push_begin_marked_subexpression();
+ unsigned __temp_count = __marked_count_;
+ ++__open_count_;
+ __first = __parse_ecma_exp(__first, __last);
+ if (__first == __last || *__first != ')')
+ __throw_regex_error<regex_constants::error_paren>();
+ __push_end_marked_subexpression(__temp_count);
+ --__open_count_;
+ ++__first;
+ }
+ }
+ break;
+ case '*':
+ case '+':
+ case '?':
+ case '{':
+ __throw_regex_error<regex_constants::error_badrepeat>();
+ break;
+ default:
+ __first = __parse_pattern_character(__first, __last);
+ break;
+ }
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_atom_escape(_ForwardIterator __first,
+ _ForwardIterator __last)
+{
+ if (__first != __last && *__first == '\\')
+ {
+ _ForwardIterator __t1 = _VSTD::next(__first);
+ if (__t1 == __last)
+ __throw_regex_error<regex_constants::error_escape>();
+
+ _ForwardIterator __t2 = __parse_decimal_escape(__t1, __last);
+ if (__t2 != __t1)
+ __first = __t2;
+ else
+ {
+ __t2 = __parse_character_class_escape(__t1, __last);
+ if (__t2 != __t1)
+ __first = __t2;
+ else
+ {
+ __t2 = __parse_character_escape(__t1, __last);
+ if (__t2 != __t1)
+ __first = __t2;
+ }
+ }
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_decimal_escape(_ForwardIterator __first,
+ _ForwardIterator __last)
+{
+ if (__first != __last)
+ {
+ if (*__first == '0')
+ {
+ __push_char(_CharT());
+ ++__first;
+ }
+ else if ('1' <= *__first && *__first <= '9')
+ {
+ unsigned __v = *__first - '0';
+ for (++__first;
+ __first != __last && '0' <= *__first && *__first <= '9'; ++__first)
+ {
+ if (__v >= numeric_limits<unsigned>::max() / 10)
+ __throw_regex_error<regex_constants::error_backref>();
+ __v = 10 * __v + *__first - '0';
+ }
+ if (__v == 0 || __v > mark_count())
+ __throw_regex_error<regex_constants::error_backref>();
+ __push_back_ref(__v);
+ }
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_character_class_escape(_ForwardIterator __first,
+ _ForwardIterator __last)
+{
+ if (__first != __last)
+ {
+ __bracket_expression<_CharT, _Traits>* __ml;
+ switch (*__first)
+ {
+ case 'd':
+ __ml = __start_matching_list(false);
+ __ml->__add_class(ctype_base::digit);
+ ++__first;
+ break;
+ case 'D':
+ __ml = __start_matching_list(true);
+ __ml->__add_class(ctype_base::digit);
+ ++__first;
+ break;
+ case 's':
+ __ml = __start_matching_list(false);
+ __ml->__add_class(ctype_base::space);
+ ++__first;
+ break;
+ case 'S':
+ __ml = __start_matching_list(true);
+ __ml->__add_class(ctype_base::space);
+ ++__first;
+ break;
+ case 'w':
+ __ml = __start_matching_list(false);
+ __ml->__add_class(ctype_base::alnum);
+ __ml->__add_char('_');
+ ++__first;
+ break;
+ case 'W':
+ __ml = __start_matching_list(true);
+ __ml->__add_class(ctype_base::alnum);
+ __ml->__add_char('_');
+ ++__first;
+ break;
+ }
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first,
+ _ForwardIterator __last,
+ basic_string<_CharT>* __str)
+{
+ if (__first != __last)
+ {
+ _ForwardIterator __t;
+ unsigned __sum = 0;
+ int __hd;
+ switch (*__first)
+ {
+ case 'f':
+ if (__str)
+ *__str = _CharT(0xC);
+ else
+ __push_char(_CharT(0xC));
+ ++__first;
+ break;
+ case 'n':
+ if (__str)
+ *__str = _CharT(0xA);
+ else
+ __push_char(_CharT(0xA));
+ ++__first;
+ break;
+ case 'r':
+ if (__str)
+ *__str = _CharT(0xD);
+ else
+ __push_char(_CharT(0xD));
+ ++__first;
+ break;
+ case 't':
+ if (__str)
+ *__str = _CharT(0x9);
+ else
+ __push_char(_CharT(0x9));
+ ++__first;
+ break;
+ case 'v':
+ if (__str)
+ *__str = _CharT(0xB);
+ else
+ __push_char(_CharT(0xB));
+ ++__first;
+ break;
+ case 'c':
+ if ((__t = _VSTD::next(__first)) != __last)
+ {
+ if (('A' <= *__t && *__t <= 'Z') ||
+ ('a' <= *__t && *__t <= 'z'))
+ {
+ if (__str)
+ *__str = _CharT(*__t % 32);
+ else
+ __push_char(_CharT(*__t % 32));
+ __first = ++__t;
+ }
+ else
+ __throw_regex_error<regex_constants::error_escape>();
+ }
+ else
+ __throw_regex_error<regex_constants::error_escape>();
+ break;
+ case 'u':
+ ++__first;
+ if (__first == __last)
+ __throw_regex_error<regex_constants::error_escape>();
+ __hd = __traits_.value(*__first, 16);
+ if (__hd == -1)
+ __throw_regex_error<regex_constants::error_escape>();
+ __sum = 16 * __sum + static_cast<unsigned>(__hd);
+ ++__first;
+ if (__first == __last)
+ __throw_regex_error<regex_constants::error_escape>();
+ __hd = __traits_.value(*__first, 16);
+ if (__hd == -1)
+ __throw_regex_error<regex_constants::error_escape>();
+ __sum = 16 * __sum + static_cast<unsigned>(__hd);
+ // fallthrough
+ case 'x':
+ ++__first;
+ if (__first == __last)
+ __throw_regex_error<regex_constants::error_escape>();
+ __hd = __traits_.value(*__first, 16);
+ if (__hd == -1)
+ __throw_regex_error<regex_constants::error_escape>();
+ __sum = 16 * __sum + static_cast<unsigned>(__hd);
+ ++__first;
+ if (__first == __last)
+ __throw_regex_error<regex_constants::error_escape>();
+ __hd = __traits_.value(*__first, 16);
+ if (__hd == -1)
+ __throw_regex_error<regex_constants::error_escape>();
+ __sum = 16 * __sum + static_cast<unsigned>(__hd);
+ if (__str)
+ *__str = _CharT(__sum);
+ else
+ __push_char(_CharT(__sum));
+ ++__first;
+ break;
+ case '0':
+ if (__str)
+ *__str = _CharT(0);
+ else
+ __push_char(_CharT(0));
+ ++__first;
+ break;
+ default:
+ if (*__first != '_' && !__traits_.isctype(*__first, ctype_base::alnum))
+ {
+ if (__str)
+ *__str = *__first;
+ else
+ __push_char(*__first);
+ ++__first;
+ }
+ else
+ __throw_regex_error<regex_constants::error_escape>();
+ break;
+ }
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_pattern_character(_ForwardIterator __first,
+ _ForwardIterator __last)
+{
+ if (__first != __last)
+ {
+ switch (*__first)
+ {
+ case '^':
+ case '$':
+ case '\\':
+ case '.':
+ case '*':
+ case '+':
+ case '?':
+ case '(':
+ case ')':
+ case '[':
+ case ']':
+ case '{':
+ case '}':
+ case '|':
+ break;
+ default:
+ __push_char(*__first);
+ ++__first;
+ break;
+ }
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_grep(_ForwardIterator __first,
+ _ForwardIterator __last)
+{
+ __owns_one_state<_CharT>* __sa = __end_;
+ _ForwardIterator __t1 = _VSTD::find(__first, __last, _CharT('\n'));
+ if (__t1 != __first)
+ __parse_basic_reg_exp(__first, __t1);
+ else
+ __push_empty();
+ __first = __t1;
+ if (__first != __last)
+ ++__first;
+ while (__first != __last)
+ {
+ __t1 = _VSTD::find(__first, __last, _CharT('\n'));
+ __owns_one_state<_CharT>* __sb = __end_;
+ if (__t1 != __first)
+ __parse_basic_reg_exp(__first, __t1);
+ else
+ __push_empty();
+ __push_alternation(__sa, __sb);
+ __first = __t1;
+ if (__first != __last)
+ ++__first;
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_egrep(_ForwardIterator __first,
+ _ForwardIterator __last)
+{
+ __owns_one_state<_CharT>* __sa = __end_;
+ _ForwardIterator __t1 = _VSTD::find(__first, __last, _CharT('\n'));
+ if (__t1 != __first)
+ __parse_extended_reg_exp(__first, __t1);
+ else
+ __push_empty();
+ __first = __t1;
+ if (__first != __last)
+ ++__first;
+ while (__first != __last)
+ {
+ __t1 = _VSTD::find(__first, __last, _CharT('\n'));
+ __owns_one_state<_CharT>* __sb = __end_;
+ if (__t1 != __first)
+ __parse_extended_reg_exp(__first, __t1);
+ else
+ __push_empty();
+ __push_alternation(__sa, __sb);
+ __first = __t1;
+ if (__first != __last)
+ ++__first;
+ }
+ return __first;
+}
+
+template <class _CharT, class _Traits>
+bool
+basic_regex<_CharT, _Traits>::__test_back_ref(_CharT c)
+{
+ unsigned __val = __traits_.value(c, 10);
+ if (__val >= 1 && __val <= 9)
+ {
+ if (__val > mark_count())
+ __throw_regex_error<regex_constants::error_backref>();
+ __push_back_ref(__val);
+ return true;
+ }
+
+ return false;
+}
+
+template <class _CharT, class _Traits>
+void
+basic_regex<_CharT, _Traits>::__push_loop(size_t __min, size_t __max,
+ __owns_one_state<_CharT>* __s, size_t __mexp_begin, size_t __mexp_end,
+ bool __greedy)
+{
+ unique_ptr<__empty_state<_CharT> > __e1(new __empty_state<_CharT>(__end_->first()));
+ __end_->first() = nullptr;
+ unique_ptr<__loop<_CharT> > __e2(new __loop<_CharT>(__loop_count_,
+ __s->first(), __e1.get(), __mexp_begin, __mexp_end, __greedy,
+ __min, __max));
+ __s->first() = nullptr;
+ __e1.release();
+ __end_->first() = new __repeat_one_loop<_CharT>(__e2.get());
+ __end_ = __e2->second();
+ __s->first() = __e2.release();
+ ++__loop_count_;
+}
+
+template <class _CharT, class _Traits>
+void
+basic_regex<_CharT, _Traits>::__push_char(value_type __c)
+{
+ if (flags() & icase)
+ __end_->first() = new __match_char_icase<_CharT, _Traits>
+ (__traits_, __c, __end_->first());
+ else if (flags() & collate)
+ __end_->first() = new __match_char_collate<_CharT, _Traits>
+ (__traits_, __c, __end_->first());
+ else
+ __end_->first() = new __match_char<_CharT>(__c, __end_->first());
+ __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
+}
+
+template <class _CharT, class _Traits>
+void
+basic_regex<_CharT, _Traits>::__push_begin_marked_subexpression()
+{
+ if (!(__flags_ & nosubs))
+ {
+ __end_->first() =
+ new __begin_marked_subexpression<_CharT>(++__marked_count_,
+ __end_->first());
+ __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
+ }
+}
+
+template <class _CharT, class _Traits>
+void
+basic_regex<_CharT, _Traits>::__push_end_marked_subexpression(unsigned __sub)
+{
+ if (!(__flags_ & nosubs))
+ {
+ __end_->first() =
+ new __end_marked_subexpression<_CharT>(__sub, __end_->first());
+ __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
+ }
+}
+
+template <class _CharT, class _Traits>
+void
+basic_regex<_CharT, _Traits>::__push_l_anchor()
+{
+ __end_->first() = new __l_anchor_multiline<_CharT>(__use_multiline(), __end_->first());
+ __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
+}
+
+template <class _CharT, class _Traits>
+void
+basic_regex<_CharT, _Traits>::__push_r_anchor()
+{
+ __end_->first() = new __r_anchor_multiline<_CharT>(__use_multiline(), __end_->first());
+ __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
+}
+
+template <class _CharT, class _Traits>
+void
+basic_regex<_CharT, _Traits>::__push_match_any()
+{
+ __end_->first() = new __match_any<_CharT>(__end_->first());
+ __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
+}
+
+template <class _CharT, class _Traits>
+void
+basic_regex<_CharT, _Traits>::__push_match_any_but_newline()
+{
+ __end_->first() = new __match_any_but_newline<_CharT>(__end_->first());
+ __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
+}
+
+template <class _CharT, class _Traits>
+void
+basic_regex<_CharT, _Traits>::__push_empty()
+{
+ __end_->first() = new __empty_state<_CharT>(__end_->first());
+ __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
+}
+
+template <class _CharT, class _Traits>
+void
+basic_regex<_CharT, _Traits>::__push_word_boundary(bool __invert)
+{
+ __end_->first() = new __word_boundary<_CharT, _Traits>(__traits_, __invert,
+ __end_->first());
+ __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
+}
+
+template <class _CharT, class _Traits>
+void
+basic_regex<_CharT, _Traits>::__push_back_ref(int __i)
+{
+ if (flags() & icase)
+ __end_->first() = new __back_ref_icase<_CharT, _Traits>
+ (__traits_, __i, __end_->first());
+ else if (flags() & collate)
+ __end_->first() = new __back_ref_collate<_CharT, _Traits>
+ (__traits_, __i, __end_->first());
+ else
+ __end_->first() = new __back_ref<_CharT>(__i, __end_->first());
+ __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
+}
+
+template <class _CharT, class _Traits>
+void
+basic_regex<_CharT, _Traits>::__push_alternation(__owns_one_state<_CharT>* __sa,
+ __owns_one_state<_CharT>* __ea)
+{
+ __sa->first() = new __alternate<_CharT>(
+ static_cast<__owns_one_state<_CharT>*>(__sa->first()),
+ static_cast<__owns_one_state<_CharT>*>(__ea->first()));
+ __ea->first() = nullptr;
+ __ea->first() = new __empty_state<_CharT>(__end_->first());
+ __end_->first() = nullptr;
+ __end_->first() = new __empty_non_own_state<_CharT>(__ea->first());
+ __end_ = static_cast<__owns_one_state<_CharT>*>(__ea->first());
+}
+
+template <class _CharT, class _Traits>
+__bracket_expression<_CharT, _Traits>*
+basic_regex<_CharT, _Traits>::__start_matching_list(bool __negate)
+{
+ __bracket_expression<_CharT, _Traits>* __r =
+ new __bracket_expression<_CharT, _Traits>(__traits_, __end_->first(),
+ __negate, __flags_ & icase,
+ __flags_ & collate);
+ __end_->first() = __r;
+ __end_ = __r;
+ return __r;
+}
+
+template <class _CharT, class _Traits>
+void
+basic_regex<_CharT, _Traits>::__push_lookahead(const basic_regex& __exp,
+ bool __invert,
+ unsigned __mexp)
+{
+ __end_->first() = new __lookahead<_CharT, _Traits>(__exp, __invert,
+ __end_->first(), __mexp);
+ __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
+}
+
+// sub_match
+
+typedef sub_match<const char*> csub_match;
+typedef sub_match<string::const_iterator> ssub_match;
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+typedef sub_match<const wchar_t*> wcsub_match;
+typedef sub_match<wstring::const_iterator> wssub_match;
+#endif
+
+template <class _BidirectionalIterator>
+class
+ _LIBCPP_TEMPLATE_VIS
+ _LIBCPP_PREFERRED_NAME(csub_match)
+ _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcsub_match))
+ _LIBCPP_PREFERRED_NAME(ssub_match)
+ _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wssub_match))
+ sub_match
+ : public pair<_BidirectionalIterator, _BidirectionalIterator>
+{
+public:
+ typedef _BidirectionalIterator iterator;
+ typedef typename iterator_traits<iterator>::value_type value_type;
+ typedef typename iterator_traits<iterator>::difference_type difference_type;
+ typedef basic_string<value_type> string_type;
+
+ bool matched;
+
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR sub_match() : matched() {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ difference_type length() const
+ {return matched ? _VSTD::distance(this->first, this->second) : 0;}
+ _LIBCPP_INLINE_VISIBILITY
+ string_type str() const
+ {return matched ? string_type(this->first, this->second) : string_type();}
+ _LIBCPP_INLINE_VISIBILITY
+ operator string_type() const
+ {return str();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ int compare(const sub_match& __s) const
+ {return str().compare(__s.str());}
+ _LIBCPP_INLINE_VISIBILITY
+ int compare(const string_type& __s) const
+ {return str().compare(__s);}
+ _LIBCPP_INLINE_VISIBILITY
+ int compare(const value_type* __s) const
+ {return str().compare(__s);}
+};
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
+{
+ return __x.compare(__y) == 0;
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
+{
+ return !(__x == __y);
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
+{
+ return __x.compare(__y) < 0;
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
+{
+ return !(__y < __x);
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
+{
+ return !(__x < __y);
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
+{
+ return __y < __x;
+}
+
+template <class _BiIter, class _ST, class _SA>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
+ const sub_match<_BiIter>& __y)
+{
+ return __y.compare(typename sub_match<_BiIter>::string_type(__x.data(), __x.size())) == 0;
+}
+
+template <class _BiIter, class _ST, class _SA>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
+ const sub_match<_BiIter>& __y)
+{
+ return !(__x == __y);
+}
+
+template <class _BiIter, class _ST, class _SA>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
+ const sub_match<_BiIter>& __y)
+{
+ return __y.compare(typename sub_match<_BiIter>::string_type(__x.data(), __x.size())) > 0;
+}
+
+template <class _BiIter, class _ST, class _SA>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
+ const sub_match<_BiIter>& __y)
+{
+ return __y < __x;
+}
+
+template <class _BiIter, class _ST, class _SA>
+inline _LIBCPP_INLINE_VISIBILITY
+bool operator>=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
+ const sub_match<_BiIter>& __y)
+{
+ return !(__x < __y);
+}
+
+template <class _BiIter, class _ST, class _SA>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
+ const sub_match<_BiIter>& __y)
+{
+ return !(__y < __x);
+}
+
+template <class _BiIter, class _ST, class _SA>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const sub_match<_BiIter>& __x,
+ const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
+{
+ return __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) == 0;
+}
+
+template <class _BiIter, class _ST, class _SA>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const sub_match<_BiIter>& __x,
+ const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
+{
+ return !(__x == __y);
+}
+
+template <class _BiIter, class _ST, class _SA>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<(const sub_match<_BiIter>& __x,
+ const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
+{
+ return __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) < 0;
+}
+
+template <class _BiIter, class _ST, class _SA>
+inline _LIBCPP_INLINE_VISIBILITY
+bool operator>(const sub_match<_BiIter>& __x,
+ const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
+{
+ return __y < __x;
+}
+
+template <class _BiIter, class _ST, class _SA>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const sub_match<_BiIter>& __x,
+ const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
+{
+ return !(__x < __y);
+}
+
+template <class _BiIter, class _ST, class _SA>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const sub_match<_BiIter>& __x,
+ const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
+{
+ return !(__y < __x);
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(typename iterator_traits<_BiIter>::value_type const* __x,
+ const sub_match<_BiIter>& __y)
+{
+ return __y.compare(__x) == 0;
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(typename iterator_traits<_BiIter>::value_type const* __x,
+ const sub_match<_BiIter>& __y)
+{
+ return !(__x == __y);
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<(typename iterator_traits<_BiIter>::value_type const* __x,
+ const sub_match<_BiIter>& __y)
+{
+ return __y.compare(__x) > 0;
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>(typename iterator_traits<_BiIter>::value_type const* __x,
+ const sub_match<_BiIter>& __y)
+{
+ return __y < __x;
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(typename iterator_traits<_BiIter>::value_type const* __x,
+ const sub_match<_BiIter>& __y)
+{
+ return !(__x < __y);
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(typename iterator_traits<_BiIter>::value_type const* __x,
+ const sub_match<_BiIter>& __y)
+{
+ return !(__y < __x);
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const sub_match<_BiIter>& __x,
+ typename iterator_traits<_BiIter>::value_type const* __y)
+{
+ return __x.compare(__y) == 0;
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const sub_match<_BiIter>& __x,
+ typename iterator_traits<_BiIter>::value_type const* __y)
+{
+ return !(__x == __y);
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<(const sub_match<_BiIter>& __x,
+ typename iterator_traits<_BiIter>::value_type const* __y)
+{
+ return __x.compare(__y) < 0;
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>(const sub_match<_BiIter>& __x,
+ typename iterator_traits<_BiIter>::value_type const* __y)
+{
+ return __y < __x;
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const sub_match<_BiIter>& __x,
+ typename iterator_traits<_BiIter>::value_type const* __y)
+{
+ return !(__x < __y);
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const sub_match<_BiIter>& __x,
+ typename iterator_traits<_BiIter>::value_type const* __y)
+{
+ return !(__y < __x);
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(typename iterator_traits<_BiIter>::value_type const& __x,
+ const sub_match<_BiIter>& __y)
+{
+ typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type;
+ return __y.compare(string_type(1, __x)) == 0;
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(typename iterator_traits<_BiIter>::value_type const& __x,
+ const sub_match<_BiIter>& __y)
+{
+ return !(__x == __y);
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<(typename iterator_traits<_BiIter>::value_type const& __x,
+ const sub_match<_BiIter>& __y)
+{
+ typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type;
+ return __y.compare(string_type(1, __x)) > 0;
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>(typename iterator_traits<_BiIter>::value_type const& __x,
+ const sub_match<_BiIter>& __y)
+{
+ return __y < __x;
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(typename iterator_traits<_BiIter>::value_type const& __x,
+ const sub_match<_BiIter>& __y)
+{
+ return !(__x < __y);
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(typename iterator_traits<_BiIter>::value_type const& __x,
+ const sub_match<_BiIter>& __y)
+{
+ return !(__y < __x);
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const sub_match<_BiIter>& __x,
+ typename iterator_traits<_BiIter>::value_type const& __y)
+{
+ typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type;
+ return __x.compare(string_type(1, __y)) == 0;
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const sub_match<_BiIter>& __x,
+ typename iterator_traits<_BiIter>::value_type const& __y)
+{
+ return !(__x == __y);
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<(const sub_match<_BiIter>& __x,
+ typename iterator_traits<_BiIter>::value_type const& __y)
+{
+ typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type;
+ return __x.compare(string_type(1, __y)) < 0;
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>(const sub_match<_BiIter>& __x,
+ typename iterator_traits<_BiIter>::value_type const& __y)
+{
+ return __y < __x;
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const sub_match<_BiIter>& __x,
+ typename iterator_traits<_BiIter>::value_type const& __y)
+{
+ return !(__x < __y);
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const sub_match<_BiIter>& __x,
+ typename iterator_traits<_BiIter>::value_type const& __y)
+{
+ return !(__y < __x);
+}
+
+template <class _CharT, class _ST, class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _ST>&
+operator<<(basic_ostream<_CharT, _ST>& __os, const sub_match<_BiIter>& __m)
+{
+ return __os << __m.str();
+}
+
+typedef match_results<const char*> cmatch;
+typedef match_results<string::const_iterator> smatch;
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+typedef match_results<const wchar_t*> wcmatch;
+typedef match_results<wstring::const_iterator> wsmatch;
+#endif
+
+template <class _BidirectionalIterator, class _Allocator>
+class
+ _LIBCPP_TEMPLATE_VIS
+ _LIBCPP_PREFERRED_NAME(cmatch)
+ _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcmatch))
+ _LIBCPP_PREFERRED_NAME(smatch)
+ _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wsmatch))
+ match_results
+{
+public:
+ typedef _Allocator allocator_type;
+ typedef sub_match<_BidirectionalIterator> value_type;
+private:
+ typedef vector<value_type, allocator_type> __container_type;
+
+ __container_type __matches_;
+ value_type __unmatched_;
+ value_type __prefix_;
+ value_type __suffix_;
+ bool __ready_;
+public:
+ _BidirectionalIterator __position_start_;
+ typedef const value_type& const_reference;
+ typedef value_type& reference;
+ typedef typename __container_type::const_iterator const_iterator;
+ typedef const_iterator iterator;
+ typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
+ typedef typename allocator_traits<allocator_type>::size_type size_type;
+ typedef typename iterator_traits<_BidirectionalIterator>::value_type char_type;
+ typedef basic_string<char_type> string_type;
+
+ // construct/copy/destroy:
+#ifndef _LIBCPP_CXX03_LANG
+ match_results() : match_results(allocator_type()) {}
+ explicit match_results(const allocator_type& __a);
+#else
+ explicit match_results(const allocator_type& __a = allocator_type());
+#endif
+
+// match_results(const match_results&) = default;
+// match_results& operator=(const match_results&) = default;
+// match_results(match_results&& __m) = default;
+// match_results& operator=(match_results&& __m) = default;
+// ~match_results() = default;
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool ready() const {return __ready_;}
+
+ // size:
+ _LIBCPP_INLINE_VISIBILITY
+ size_type size() const _NOEXCEPT {return __matches_.size();}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type max_size() const _NOEXCEPT {return __matches_.max_size();}
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+ bool empty() const _NOEXCEPT {return size() == 0;}
+
+ // element access:
+ _LIBCPP_INLINE_VISIBILITY
+ difference_type length(size_type __sub = 0) const
+ {
+ _LIBCPP_ASSERT(ready(), "match_results::length() called when not ready");
+ return (*this)[__sub].length();
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ difference_type position(size_type __sub = 0) const
+ {
+ _LIBCPP_ASSERT(ready(), "match_results::position() called when not ready");
+ return _VSTD::distance(__position_start_, (*this)[__sub].first);
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ string_type str(size_type __sub = 0) const
+ {
+ _LIBCPP_ASSERT(ready(), "match_results::str() called when not ready");
+ return (*this)[__sub].str();
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ const_reference operator[](size_type __n) const
+ {
+ _LIBCPP_ASSERT(ready(), "match_results::operator[]() called when not ready");
+ return __n < __matches_.size() ? __matches_[__n] : __unmatched_;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ const_reference prefix() const
+ {
+ _LIBCPP_ASSERT(ready(), "match_results::prefix() called when not ready");
+ return __prefix_;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ const_reference suffix() const
+ {
+ _LIBCPP_ASSERT(ready(), "match_results::suffix() called when not ready");
+ return __suffix_;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator begin() const {return empty() ? __matches_.end() : __matches_.begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator end() const {return __matches_.end();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator cbegin() const {return empty() ? __matches_.end() : __matches_.begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator cend() const {return __matches_.end();}
+
+ // format:
+ template <class _OutputIter>
+ _OutputIter
+ format(_OutputIter __output_iter, const char_type* __fmt_first,
+ const char_type* __fmt_last,
+ regex_constants::match_flag_type __flags = regex_constants::format_default) const;
+ template <class _OutputIter, class _ST, class _SA>
+ _LIBCPP_INLINE_VISIBILITY
+ _OutputIter
+ format(_OutputIter __output_iter, const basic_string<char_type, _ST, _SA>& __fmt,
+ regex_constants::match_flag_type __flags = regex_constants::format_default) const
+ {return format(__output_iter, __fmt.data(), __fmt.data() + __fmt.size(), __flags);}
+ template <class _ST, class _SA>
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string<char_type, _ST, _SA>
+ format(const basic_string<char_type, _ST, _SA>& __fmt,
+ regex_constants::match_flag_type __flags = regex_constants::format_default) const
+ {
+ basic_string<char_type, _ST, _SA> __r;
+ format(back_inserter(__r), __fmt.data(), __fmt.data() + __fmt.size(),
+ __flags);
+ return __r;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ string_type
+ format(const char_type* __fmt,
+ regex_constants::match_flag_type __flags = regex_constants::format_default) const
+ {
+ string_type __r;
+ format(back_inserter(__r), __fmt,
+ __fmt + char_traits<char_type>::length(__fmt), __flags);
+ return __r;
+ }
+
+ // allocator:
+ _LIBCPP_INLINE_VISIBILITY
+ allocator_type get_allocator() const {return __matches_.get_allocator();}
+
+ // swap:
+ void swap(match_results& __m);
+
+ template <class _Bp, class _Ap>
+ _LIBCPP_INLINE_VISIBILITY
+ void __assign(_BidirectionalIterator __f, _BidirectionalIterator __l,
+ const match_results<_Bp, _Ap>& __m, bool __no_update_pos)
+ {
+ _Bp __mf = __m.prefix().first;
+ __matches_.resize(__m.size());
+ for (size_type __i = 0; __i < __matches_.size(); ++__i)
+ {
+ __matches_[__i].first = _VSTD::next(__f, _VSTD::distance(__mf, __m[__i].first));
+ __matches_[__i].second = _VSTD::next(__f, _VSTD::distance(__mf, __m[__i].second));
+ __matches_[__i].matched = __m[__i].matched;
+ }
+ __unmatched_.first = __l;
+ __unmatched_.second = __l;
+ __unmatched_.matched = false;
+ __prefix_.first = _VSTD::next(__f, _VSTD::distance(__mf, __m.prefix().first));
+ __prefix_.second = _VSTD::next(__f, _VSTD::distance(__mf, __m.prefix().second));
+ __prefix_.matched = __m.prefix().matched;
+ __suffix_.first = _VSTD::next(__f, _VSTD::distance(__mf, __m.suffix().first));
+ __suffix_.second = _VSTD::next(__f, _VSTD::distance(__mf, __m.suffix().second));
+ __suffix_.matched = __m.suffix().matched;
+ if (!__no_update_pos)
+ __position_start_ = __prefix_.first;
+ __ready_ = __m.ready();
+ }
+
+private:
+ void __init(unsigned __s,
+ _BidirectionalIterator __f, _BidirectionalIterator __l,
+ bool __no_update_pos = false);
+
+ template <class, class> friend class basic_regex;
+
+ template <class _Bp, class _Ap, class _Cp, class _Tp>
+ friend
+ bool
+ regex_match(_Bp, _Bp, match_results<_Bp, _Ap>&, const basic_regex<_Cp, _Tp>&,
+ regex_constants::match_flag_type);
+
+ template <class _Bp, class _Ap>
+ friend
+ bool
+ operator==(const match_results<_Bp, _Ap>&, const match_results<_Bp, _Ap>&);
+
+ template <class, class> friend class __lookahead;
+};
+
+template <class _BidirectionalIterator, class _Allocator>
+match_results<_BidirectionalIterator, _Allocator>::match_results(
+ const allocator_type& __a)
+ : __matches_(__a),
+ __unmatched_(),
+ __prefix_(),
+ __suffix_(),
+ __ready_(false),
+ __position_start_()
+{
+}
+
+template <class _BidirectionalIterator, class _Allocator>
+void
+match_results<_BidirectionalIterator, _Allocator>::__init(unsigned __s,
+ _BidirectionalIterator __f, _BidirectionalIterator __l,
+ bool __no_update_pos)
+{
+ __unmatched_.first = __l;
+ __unmatched_.second = __l;
+ __unmatched_.matched = false;
+ __matches_.assign(__s, __unmatched_);
+ __prefix_.first = __f;
+ __prefix_.second = __f;
+ __prefix_.matched = false;
+ __suffix_ = __unmatched_;
+ if (!__no_update_pos)
+ __position_start_ = __prefix_.first;
+ __ready_ = true;
+}
+
+template <class _BidirectionalIterator, class _Allocator>
+template <class _OutputIter>
+_OutputIter
+match_results<_BidirectionalIterator, _Allocator>::format(_OutputIter __output_iter,
+ const char_type* __fmt_first, const char_type* __fmt_last,
+ regex_constants::match_flag_type __flags) const
+{
+ _LIBCPP_ASSERT(ready(), "match_results::format() called when not ready");
+ if (__flags & regex_constants::format_sed)
+ {
+ for (; __fmt_first != __fmt_last; ++__fmt_first)
+ {
+ if (*__fmt_first == '&')
+ __output_iter = _VSTD::copy(__matches_[0].first, __matches_[0].second,
+ __output_iter);
+ else if (*__fmt_first == '\\' && __fmt_first + 1 != __fmt_last)
+ {
+ ++__fmt_first;
+ if ('0' <= *__fmt_first && *__fmt_first <= '9')
+ {
+ size_t __i = *__fmt_first - '0';
+ __output_iter = _VSTD::copy((*this)[__i].first,
+ (*this)[__i].second, __output_iter);
+ }
+ else
+ {
+ *__output_iter = *__fmt_first;
+ ++__output_iter;
+ }
+ }
+ else
+ {
+ *__output_iter = *__fmt_first;
+ ++__output_iter;
+ }
+ }
+ }
+ else
+ {
+ for (; __fmt_first != __fmt_last; ++__fmt_first)
+ {
+ if (*__fmt_first == '$' && __fmt_first + 1 != __fmt_last)
+ {
+ switch (__fmt_first[1])
+ {
+ case '$':
+ *__output_iter = *++__fmt_first;
+ ++__output_iter;
+ break;
+ case '&':
+ ++__fmt_first;
+ __output_iter = _VSTD::copy(__matches_[0].first, __matches_[0].second,
+ __output_iter);
+ break;
+ case '`':
+ ++__fmt_first;
+ __output_iter = _VSTD::copy(__prefix_.first, __prefix_.second, __output_iter);
+ break;
+ case '\'':
+ ++__fmt_first;
+ __output_iter = _VSTD::copy(__suffix_.first, __suffix_.second, __output_iter);
+ break;
+ default:
+ if ('0' <= __fmt_first[1] && __fmt_first[1] <= '9')
+ {
+ ++__fmt_first;
+ size_t __idx = *__fmt_first - '0';
+ if (__fmt_first + 1 != __fmt_last &&
+ '0' <= __fmt_first[1] && __fmt_first[1] <= '9')
+ {
+ ++__fmt_first;
+ if (__idx >= numeric_limits<size_t>::max() / 10)
+ __throw_regex_error<regex_constants::error_escape>();
+ __idx = 10 * __idx + *__fmt_first - '0';
+ }
+ __output_iter = _VSTD::copy((*this)[__idx].first,
+ (*this)[__idx].second, __output_iter);
+ }
+ else
+ {
+ *__output_iter = *__fmt_first;
+ ++__output_iter;
+ }
+ break;
+ }
+ }
+ else
+ {
+ *__output_iter = *__fmt_first;
+ ++__output_iter;
+ }
+ }
+ }
+ return __output_iter;
+}
+
+template <class _BidirectionalIterator, class _Allocator>
+void
+match_results<_BidirectionalIterator, _Allocator>::swap(match_results& __m)
+{
+ using _VSTD::swap;
+ swap(__matches_, __m.__matches_);
+ swap(__unmatched_, __m.__unmatched_);
+ swap(__prefix_, __m.__prefix_);
+ swap(__suffix_, __m.__suffix_);
+ swap(__position_start_, __m.__position_start_);
+ swap(__ready_, __m.__ready_);
+}
+
+template <class _BidirectionalIterator, class _Allocator>
+bool
+operator==(const match_results<_BidirectionalIterator, _Allocator>& __x,
+ const match_results<_BidirectionalIterator, _Allocator>& __y)
+{
+ if (__x.__ready_ != __y.__ready_)
+ return false;
+ if (!__x.__ready_)
+ return true;
+ return __x.__matches_ == __y.__matches_ &&
+ __x.__prefix_ == __y.__prefix_ &&
+ __x.__suffix_ == __y.__suffix_;
+}
+
+template <class _BidirectionalIterator, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const match_results<_BidirectionalIterator, _Allocator>& __x,
+ const match_results<_BidirectionalIterator, _Allocator>& __y)
+{
+ return !(__x == __y);
+}
+
+template <class _BidirectionalIterator, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(match_results<_BidirectionalIterator, _Allocator>& __x,
+ match_results<_BidirectionalIterator, _Allocator>& __y)
+{
+ __x.swap(__y);
+}
+
+// regex_search
+
+template <class _CharT, class _Traits>
+template <class _Allocator>
+bool
+basic_regex<_CharT, _Traits>::__match_at_start_ecma(
+ const _CharT* __first, const _CharT* __last,
+ match_results<const _CharT*, _Allocator>& __m,
+ regex_constants::match_flag_type __flags, bool __at_first) const
+{
+ vector<__state> __states;
+ __node* __st = __start_.get();
+ if (__st)
+ {
+ sub_match<const _CharT*> __unmatched;
+ __unmatched.first = __last;
+ __unmatched.second = __last;
+ __unmatched.matched = false;
+
+ __states.push_back(__state());
+ __states.back().__do_ = 0;
+ __states.back().__first_ = __first;
+ __states.back().__current_ = __first;
+ __states.back().__last_ = __last;
+ __states.back().__sub_matches_.resize(mark_count(), __unmatched);
+ __states.back().__loop_data_.resize(__loop_count());
+ __states.back().__node_ = __st;
+ __states.back().__flags_ = __flags;
+ __states.back().__at_first_ = __at_first;
+ int __counter = 0;
+ int __length = __last - __first;
+ do
+ {
+ ++__counter;
+ if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 &&
+ __counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length)
+ __throw_regex_error<regex_constants::error_complexity>();
+ __state& __s = __states.back();
+ if (__s.__node_)
+ __s.__node_->__exec(__s);
+ switch (__s.__do_)
+ {
+ case __state::__end_state:
+ if ((__flags & regex_constants::match_not_null) &&
+ __s.__current_ == __first)
+ {
+ __states.pop_back();
+ break;
+ }
+ if ((__flags & regex_constants::__full_match) &&
+ __s.__current_ != __last)
+ {
+ __states.pop_back();
+ break;
+ }
+ __m.__matches_[0].first = __first;
+ __m.__matches_[0].second = _VSTD::next(__first, __s.__current_ - __first);
+ __m.__matches_[0].matched = true;
+ for (unsigned __i = 0; __i < __s.__sub_matches_.size(); ++__i)
+ __m.__matches_[__i+1] = __s.__sub_matches_[__i];
+ return true;
+ case __state::__accept_and_consume:
+ case __state::__repeat:
+ case __state::__accept_but_not_consume:
+ break;
+ case __state::__split:
+ {
+ __state __snext = __s;
+ __s.__node_->__exec_split(true, __s);
+ __snext.__node_->__exec_split(false, __snext);
+ __states.push_back(_VSTD::move(__snext));
+ }
+ break;
+ case __state::__reject:
+ __states.pop_back();
+ break;
+ default:
+ __throw_regex_error<regex_constants::__re_err_unknown>();
+ break;
+
+ }
+ } while (!__states.empty());
+ }
+ return false;
+}
+
+template <class _CharT, class _Traits>
+template <class _Allocator>
+bool
+basic_regex<_CharT, _Traits>::__match_at_start_posix_nosubs(
+ const _CharT* __first, const _CharT* __last,
+ match_results<const _CharT*, _Allocator>& __m,
+ regex_constants::match_flag_type __flags, bool __at_first) const
+{
+ deque<__state> __states;
+ ptrdiff_t __highest_j = 0;
+ ptrdiff_t _Np = _VSTD::distance(__first, __last);
+ __node* __st = __start_.get();
+ if (__st)
+ {
+ __states.push_back(__state());
+ __states.back().__do_ = 0;
+ __states.back().__first_ = __first;
+ __states.back().__current_ = __first;
+ __states.back().__last_ = __last;
+ __states.back().__loop_data_.resize(__loop_count());
+ __states.back().__node_ = __st;
+ __states.back().__flags_ = __flags;
+ __states.back().__at_first_ = __at_first;
+ bool __matched = false;
+ int __counter = 0;
+ int __length = __last - __first;
+ do
+ {
+ ++__counter;
+ if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 &&
+ __counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length)
+ __throw_regex_error<regex_constants::error_complexity>();
+ __state& __s = __states.back();
+ if (__s.__node_)
+ __s.__node_->__exec(__s);
+ switch (__s.__do_)
+ {
+ case __state::__end_state:
+ if ((__flags & regex_constants::match_not_null) &&
+ __s.__current_ == __first)
+ {
+ __states.pop_back();
+ break;
+ }
+ if ((__flags & regex_constants::__full_match) &&
+ __s.__current_ != __last)
+ {
+ __states.pop_back();
+ break;
+ }
+ if (!__matched || __highest_j < __s.__current_ - __s.__first_)
+ __highest_j = __s.__current_ - __s.__first_;
+ __matched = true;
+ if (__highest_j == _Np)
+ __states.clear();
+ else
+ __states.pop_back();
+ break;
+ case __state::__consume_input:
+ break;
+ case __state::__accept_and_consume:
+ __states.push_front(_VSTD::move(__s));
+ __states.pop_back();
+ break;
+ case __state::__repeat:
+ case __state::__accept_but_not_consume:
+ break;
+ case __state::__split:
+ {
+ __state __snext = __s;
+ __s.__node_->__exec_split(true, __s);
+ __snext.__node_->__exec_split(false, __snext);
+ __states.push_back(_VSTD::move(__snext));
+ }
+ break;
+ case __state::__reject:
+ __states.pop_back();
+ break;
+ default:
+ __throw_regex_error<regex_constants::__re_err_unknown>();
+ break;
+ }
+ } while (!__states.empty());
+ if (__matched)
+ {
+ __m.__matches_[0].first = __first;
+ __m.__matches_[0].second = _VSTD::next(__first, __highest_j);
+ __m.__matches_[0].matched = true;
+ return true;
+ }
+ }
+ return false;
+}
+
+template <class _CharT, class _Traits>
+template <class _Allocator>
+bool
+basic_regex<_CharT, _Traits>::__match_at_start_posix_subs(
+ const _CharT* __first, const _CharT* __last,
+ match_results<const _CharT*, _Allocator>& __m,
+ regex_constants::match_flag_type __flags, bool __at_first) const
+{
+ vector<__state> __states;
+ __state __best_state;
+ ptrdiff_t __highest_j = 0;
+ ptrdiff_t _Np = _VSTD::distance(__first, __last);
+ __node* __st = __start_.get();
+ if (__st)
+ {
+ sub_match<const _CharT*> __unmatched;
+ __unmatched.first = __last;
+ __unmatched.second = __last;
+ __unmatched.matched = false;
+
+ __states.push_back(__state());
+ __states.back().__do_ = 0;
+ __states.back().__first_ = __first;
+ __states.back().__current_ = __first;
+ __states.back().__last_ = __last;
+ __states.back().__sub_matches_.resize(mark_count(), __unmatched);
+ __states.back().__loop_data_.resize(__loop_count());
+ __states.back().__node_ = __st;
+ __states.back().__flags_ = __flags;
+ __states.back().__at_first_ = __at_first;
+ bool __matched = false;
+ int __counter = 0;
+ int __length = __last - __first;
+ do
+ {
+ ++__counter;
+ if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 &&
+ __counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length)
+ __throw_regex_error<regex_constants::error_complexity>();
+ __state& __s = __states.back();
+ if (__s.__node_)
+ __s.__node_->__exec(__s);
+ switch (__s.__do_)
+ {
+ case __state::__end_state:
+ if ((__flags & regex_constants::match_not_null) &&
+ __s.__current_ == __first)
+ {
+ __states.pop_back();
+ break;
+ }
+ if ((__flags & regex_constants::__full_match) &&
+ __s.__current_ != __last)
+ {
+ __states.pop_back();
+ break;
+ }
+ if (!__matched || __highest_j < __s.__current_ - __s.__first_)
+ {
+ __highest_j = __s.__current_ - __s.__first_;
+ __best_state = __s;
+ }
+ __matched = true;
+ if (__highest_j == _Np)
+ __states.clear();
+ else
+ __states.pop_back();
+ break;
+ case __state::__accept_and_consume:
+ case __state::__repeat:
+ case __state::__accept_but_not_consume:
+ break;
+ case __state::__split:
+ {
+ __state __snext = __s;
+ __s.__node_->__exec_split(true, __s);
+ __snext.__node_->__exec_split(false, __snext);
+ __states.push_back(_VSTD::move(__snext));
+ }
+ break;
+ case __state::__reject:
+ __states.pop_back();
+ break;
+ default:
+ __throw_regex_error<regex_constants::__re_err_unknown>();
+ break;
+ }
+ } while (!__states.empty());
+ if (__matched)
+ {
+ __m.__matches_[0].first = __first;
+ __m.__matches_[0].second = _VSTD::next(__first, __highest_j);
+ __m.__matches_[0].matched = true;
+ for (unsigned __i = 0; __i < __best_state.__sub_matches_.size(); ++__i)
+ __m.__matches_[__i+1] = __best_state.__sub_matches_[__i];
+ return true;
+ }
+ }
+ return false;
+}
+
+template <class _CharT, class _Traits>
+template <class _Allocator>
+bool
+basic_regex<_CharT, _Traits>::__match_at_start(
+ const _CharT* __first, const _CharT* __last,
+ match_results<const _CharT*, _Allocator>& __m,
+ regex_constants::match_flag_type __flags, bool __at_first) const
+{
+ if (__get_grammar(__flags_) == ECMAScript)
+ return __match_at_start_ecma(__first, __last, __m, __flags, __at_first);
+ if (mark_count() == 0)
+ return __match_at_start_posix_nosubs(__first, __last, __m, __flags, __at_first);
+ return __match_at_start_posix_subs(__first, __last, __m, __flags, __at_first);
+}
+
+template <class _CharT, class _Traits>
+template <class _Allocator>
+bool
+basic_regex<_CharT, _Traits>::__search(
+ const _CharT* __first, const _CharT* __last,
+ match_results<const _CharT*, _Allocator>& __m,
+ regex_constants::match_flag_type __flags) const
+{
+ if (__flags & regex_constants::match_prev_avail)
+ __flags &= ~(regex_constants::match_not_bol | regex_constants::match_not_bow);
+
+ __m.__init(1 + mark_count(), __first, __last,
+ __flags & regex_constants::__no_update_pos);
+ if (__match_at_start(__first, __last, __m, __flags,
+ !(__flags & regex_constants::__no_update_pos)))
+ {
+ __m.__prefix_.second = __m[0].first;
+ __m.__prefix_.matched = __m.__prefix_.first != __m.__prefix_.second;
+ __m.__suffix_.first = __m[0].second;
+ __m.__suffix_.matched = __m.__suffix_.first != __m.__suffix_.second;
+ return true;
+ }
+ if (__first != __last && !(__flags & regex_constants::match_continuous))
+ {
+ __flags |= regex_constants::match_prev_avail;
+ for (++__first; __first != __last; ++__first)
+ {
+ __m.__matches_.assign(__m.size(), __m.__unmatched_);
+ if (__match_at_start(__first, __last, __m, __flags, false))
+ {
+ __m.__prefix_.second = __m[0].first;
+ __m.__prefix_.matched = __m.__prefix_.first != __m.__prefix_.second;
+ __m.__suffix_.first = __m[0].second;
+ __m.__suffix_.matched = __m.__suffix_.first != __m.__suffix_.second;
+ return true;
+ }
+ __m.__matches_.assign(__m.size(), __m.__unmatched_);
+ }
+ }
+ __m.__matches_.clear();
+ return false;
+}
+
+template <class _BidirectionalIterator, class _Allocator, class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+regex_search(_BidirectionalIterator __first, _BidirectionalIterator __last,
+ match_results<_BidirectionalIterator, _Allocator>& __m,
+ const basic_regex<_CharT, _Traits>& __e,
+ regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+ int __offset = (__flags & regex_constants::match_prev_avail) ? 1 : 0;
+ basic_string<_CharT> __s(_VSTD::prev(__first, __offset), __last);
+ match_results<const _CharT*> __mc;
+ bool __r = __e.__search(__s.data() + __offset, __s.data() + __s.size(), __mc, __flags);
+ __m.__assign(__first, __last, __mc, __flags & regex_constants::__no_update_pos);
+ return __r;
+}
+
+template <class _Iter, class _Allocator, class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+regex_search(__wrap_iter<_Iter> __first,
+ __wrap_iter<_Iter> __last,
+ match_results<__wrap_iter<_Iter>, _Allocator>& __m,
+ const basic_regex<_CharT, _Traits>& __e,
+ regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+ match_results<const _CharT*> __mc;
+ bool __r = __e.__search(__first.base(), __last.base(), __mc, __flags);
+ __m.__assign(__first, __last, __mc, __flags & regex_constants::__no_update_pos);
+ return __r;
+}
+
+template <class _Allocator, class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+regex_search(const _CharT* __first, const _CharT* __last,
+ match_results<const _CharT*, _Allocator>& __m,
+ const basic_regex<_CharT, _Traits>& __e,
+ regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+ return __e.__search(__first, __last, __m, __flags);
+}
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+regex_search(_BidirectionalIterator __first, _BidirectionalIterator __last,
+ const basic_regex<_CharT, _Traits>& __e,
+ regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+ basic_string<_CharT> __s(__first, __last);
+ match_results<const _CharT*> __mc;
+ return __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+regex_search(const _CharT* __first, const _CharT* __last,
+ const basic_regex<_CharT, _Traits>& __e,
+ regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+ match_results<const _CharT*> __mc;
+ return __e.__search(__first, __last, __mc, __flags);
+}
+
+template <class _CharT, class _Allocator, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+regex_search(const _CharT* __str, match_results<const _CharT*, _Allocator>& __m,
+ const basic_regex<_CharT, _Traits>& __e,
+ regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+ return __e.__search(__str, __str + _Traits::length(__str), __m, __flags);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+regex_search(const _CharT* __str, const basic_regex<_CharT, _Traits>& __e,
+ regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+ match_results<const _CharT*> __m;
+ return _VSTD::regex_search(__str, __m, __e, __flags);
+}
+
+template <class _ST, class _SA, class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+regex_search(const basic_string<_CharT, _ST, _SA>& __s,
+ const basic_regex<_CharT, _Traits>& __e,
+ regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+ match_results<const _CharT*> __mc;
+ return __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags);
+}
+
+template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+regex_search(const basic_string<_CharT, _ST, _SA>& __s,
+ match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m,
+ const basic_regex<_CharT, _Traits>& __e,
+ regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+ match_results<const _CharT*> __mc;
+ bool __r = __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags);
+ __m.__assign(__s.begin(), __s.end(), __mc, __flags & regex_constants::__no_update_pos);
+ return __r;
+}
+
+#if _LIBCPP_STD_VER > 11
+template <class _ST, class _SA, class _Ap, class _Cp, class _Tp>
+bool
+regex_search(const basic_string<_Cp, _ST, _SA>&& __s,
+ match_results<typename basic_string<_Cp, _ST, _SA>::const_iterator, _Ap>&,
+ const basic_regex<_Cp, _Tp>& __e,
+ regex_constants::match_flag_type __flags = regex_constants::match_default) = delete;
+#endif
+
+// regex_match
+
+template <class _BidirectionalIterator, class _Allocator, class _CharT, class _Traits>
+bool
+regex_match(_BidirectionalIterator __first, _BidirectionalIterator __last,
+ match_results<_BidirectionalIterator, _Allocator>& __m,
+ const basic_regex<_CharT, _Traits>& __e,
+ regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+ bool __r = _VSTD::regex_search(
+ __first, __last, __m, __e,
+ __flags | regex_constants::match_continuous |
+ regex_constants::__full_match);
+ if (__r)
+ {
+ __r = !__m.suffix().matched;
+ if (!__r)
+ __m.__matches_.clear();
+ }
+ return __r;
+}
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+regex_match(_BidirectionalIterator __first, _BidirectionalIterator __last,
+ const basic_regex<_CharT, _Traits>& __e,
+ regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+ match_results<_BidirectionalIterator> __m;
+ return _VSTD::regex_match(__first, __last, __m, __e, __flags);
+}
+
+template <class _CharT, class _Allocator, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+regex_match(const _CharT* __str, match_results<const _CharT*, _Allocator>& __m,
+ const basic_regex<_CharT, _Traits>& __e,
+ regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+ return _VSTD::regex_match(__str, __str + _Traits::length(__str), __m, __e, __flags);
+}
+
+template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+regex_match(const basic_string<_CharT, _ST, _SA>& __s,
+ match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m,
+ const basic_regex<_CharT, _Traits>& __e,
+ regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+ return _VSTD::regex_match(__s.begin(), __s.end(), __m, __e, __flags);
+}
+
+#if _LIBCPP_STD_VER > 11
+template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+regex_match(const basic_string<_CharT, _ST, _SA>&& __s,
+ match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m,
+ const basic_regex<_CharT, _Traits>& __e,
+ regex_constants::match_flag_type __flags = regex_constants::match_default) = delete;
+#endif
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+regex_match(const _CharT* __str, const basic_regex<_CharT, _Traits>& __e,
+ regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+ return _VSTD::regex_match(__str, __str + _Traits::length(__str), __e, __flags);
+}
+
+template <class _ST, class _SA, class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+regex_match(const basic_string<_CharT, _ST, _SA>& __s,
+ const basic_regex<_CharT, _Traits>& __e,
+ regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+ return _VSTD::regex_match(__s.begin(), __s.end(), __e, __flags);
+}
+
+// regex_iterator
+
+template <class _BidirectionalIterator,
+ class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type,
+ class _Traits = regex_traits<_CharT> >
+ class _LIBCPP_TEMPLATE_VIS regex_iterator;
+
+typedef regex_iterator<const char*> cregex_iterator;
+typedef regex_iterator<string::const_iterator> sregex_iterator;
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+typedef regex_iterator<const wchar_t*> wcregex_iterator;
+typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
+#endif
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+class
+ _LIBCPP_TEMPLATE_VIS
+ _LIBCPP_PREFERRED_NAME(cregex_iterator)
+ _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcregex_iterator))
+ _LIBCPP_PREFERRED_NAME(sregex_iterator)
+ _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wsregex_iterator))
+ regex_iterator
+{
+public:
+ typedef basic_regex<_CharT, _Traits> regex_type;
+ typedef match_results<_BidirectionalIterator> value_type;
+ typedef ptrdiff_t difference_type;
+ typedef const value_type* pointer;
+ typedef const value_type& reference;
+ typedef forward_iterator_tag iterator_category;
+
+private:
+ _BidirectionalIterator __begin_;
+ _BidirectionalIterator __end_;
+ const regex_type* __pregex_;
+ regex_constants::match_flag_type __flags_;
+ value_type __match_;
+
+public:
+ regex_iterator();
+ regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+ const regex_type& __re,
+ regex_constants::match_flag_type __m
+ = regex_constants::match_default);
+#if _LIBCPP_STD_VER > 11
+ regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+ const regex_type&& __re,
+ regex_constants::match_flag_type __m
+ = regex_constants::match_default) = delete;
+#endif
+
+ bool operator==(const regex_iterator& __x) const;
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const regex_iterator& __x) const {return !(*this == __x);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ reference operator*() const {return __match_;}
+ _LIBCPP_INLINE_VISIBILITY
+ pointer operator->() const {return _VSTD::addressof(__match_);}
+
+ regex_iterator& operator++();
+ _LIBCPP_INLINE_VISIBILITY
+ regex_iterator operator++(int)
+ {
+ regex_iterator __t(*this);
+ ++(*this);
+ return __t;
+ }
+};
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+regex_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_iterator()
+ : __begin_(), __end_(), __pregex_(nullptr), __flags_(), __match_()
+{
+}
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+regex_iterator<_BidirectionalIterator, _CharT, _Traits>::
+ regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+ const regex_type& __re, regex_constants::match_flag_type __m)
+ : __begin_(__a),
+ __end_(__b),
+ __pregex_(_VSTD::addressof(__re)),
+ __flags_(__m)
+{
+ _VSTD::regex_search(__begin_, __end_, __match_, *__pregex_, __flags_);
+}
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+bool
+regex_iterator<_BidirectionalIterator, _CharT, _Traits>::
+ operator==(const regex_iterator& __x) const
+{
+ if (__match_.empty() && __x.__match_.empty())
+ return true;
+ if (__match_.empty() || __x.__match_.empty())
+ return false;
+ return __begin_ == __x.__begin_ &&
+ __end_ == __x.__end_ &&
+ __pregex_ == __x.__pregex_ &&
+ __flags_ == __x.__flags_ &&
+ __match_[0] == __x.__match_[0];
+}
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+regex_iterator<_BidirectionalIterator, _CharT, _Traits>&
+regex_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++()
+{
+ __flags_ |= regex_constants::__no_update_pos;
+ _BidirectionalIterator __start = __match_[0].second;
+ if (__match_[0].first == __match_[0].second)
+ {
+ if (__start == __end_)
+ {
+ __match_ = value_type();
+ return *this;
+ }
+ else if (_VSTD::regex_search(__start, __end_, __match_, *__pregex_,
+ __flags_ | regex_constants::match_not_null |
+ regex_constants::match_continuous))
+ return *this;
+ else
+ ++__start;
+ }
+ __flags_ |= regex_constants::match_prev_avail;
+ if (!_VSTD::regex_search(__start, __end_, __match_, *__pregex_, __flags_))
+ __match_ = value_type();
+ return *this;
+}
+
+// regex_token_iterator
+
+template <class _BidirectionalIterator,
+ class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type,
+ class _Traits = regex_traits<_CharT> >
+ class _LIBCPP_TEMPLATE_VIS regex_token_iterator;
+
+typedef regex_token_iterator<const char*> cregex_token_iterator;
+typedef regex_token_iterator<string::const_iterator> sregex_token_iterator;
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
+typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
+#endif
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+class
+ _LIBCPP_TEMPLATE_VIS
+ _LIBCPP_PREFERRED_NAME(cregex_token_iterator)
+ _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcregex_token_iterator))
+ _LIBCPP_PREFERRED_NAME(sregex_token_iterator)
+ _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wsregex_token_iterator))
+ regex_token_iterator
+{
+public:
+ typedef basic_regex<_CharT, _Traits> regex_type;
+ typedef sub_match<_BidirectionalIterator> value_type;
+ typedef ptrdiff_t difference_type;
+ typedef const value_type* pointer;
+ typedef const value_type& reference;
+ typedef forward_iterator_tag iterator_category;
+
+private:
+ typedef regex_iterator<_BidirectionalIterator, _CharT, _Traits> _Position;
+
+ _Position __position_;
+ const value_type* __result_;
+ value_type __suffix_;
+ ptrdiff_t __n_;
+ vector<int> __subs_;
+
+public:
+ regex_token_iterator();
+ regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+ const regex_type& __re, int __submatch = 0,
+ regex_constants::match_flag_type __m =
+ regex_constants::match_default);
+#if _LIBCPP_STD_VER > 11
+ regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+ const regex_type&& __re, int __submatch = 0,
+ regex_constants::match_flag_type __m =
+ regex_constants::match_default) = delete;
+#endif
+
+ regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+ const regex_type& __re, const vector<int>& __submatches,
+ regex_constants::match_flag_type __m =
+ regex_constants::match_default);
+#if _LIBCPP_STD_VER > 11
+ regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+ const regex_type&& __re, const vector<int>& __submatches,
+ regex_constants::match_flag_type __m =
+ regex_constants::match_default) = delete;
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+ regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+ const regex_type& __re,
+ initializer_list<int> __submatches,
+ regex_constants::match_flag_type __m =
+ regex_constants::match_default);
+
+#if _LIBCPP_STD_VER > 11
+ regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+ const regex_type&& __re,
+ initializer_list<int> __submatches,
+ regex_constants::match_flag_type __m =
+ regex_constants::match_default) = delete;
+#endif
+#endif // _LIBCPP_CXX03_LANG
+ template <size_t _Np>
+ regex_token_iterator(_BidirectionalIterator __a,
+ _BidirectionalIterator __b,
+ const regex_type& __re,
+ const int (&__submatches)[_Np],
+ regex_constants::match_flag_type __m =
+ regex_constants::match_default);
+#if _LIBCPP_STD_VER > 11
+ template <size_t _Np>
+ regex_token_iterator(_BidirectionalIterator __a,
+ _BidirectionalIterator __b,
+ const regex_type&& __re,
+ const int (&__submatches)[_Np],
+ regex_constants::match_flag_type __m =
+ regex_constants::match_default) = delete;
+#endif
+
+ regex_token_iterator(const regex_token_iterator&);
+ regex_token_iterator& operator=(const regex_token_iterator&);
+
+ bool operator==(const regex_token_iterator& __x) const;
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const regex_token_iterator& __x) const {return !(*this == __x);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ const value_type& operator*() const {return *__result_;}
+ _LIBCPP_INLINE_VISIBILITY
+ const value_type* operator->() const {return __result_;}
+
+ regex_token_iterator& operator++();
+ _LIBCPP_INLINE_VISIBILITY
+ regex_token_iterator operator++(int)
+ {
+ regex_token_iterator __t(*this);
+ ++(*this);
+ return __t;
+ }
+
+private:
+ void __init(_BidirectionalIterator __a, _BidirectionalIterator __b);
+ void __establish_result () {
+ if (__subs_[__n_] == -1)
+ __result_ = &__position_->prefix();
+ else
+ __result_ = &(*__position_)[__subs_[__n_]];
+ }
+};
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
+ regex_token_iterator()
+ : __result_(nullptr),
+ __suffix_(),
+ __n_(0)
+{
+}
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+void
+regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
+ __init(_BidirectionalIterator __a, _BidirectionalIterator __b)
+{
+ if (__position_ != _Position())
+ __establish_result ();
+ else if (__subs_[__n_] == -1)
+ {
+ __suffix_.matched = true;
+ __suffix_.first = __a;
+ __suffix_.second = __b;
+ __result_ = &__suffix_;
+ }
+ else
+ __result_ = nullptr;
+}
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
+ regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+ const regex_type& __re, int __submatch,
+ regex_constants::match_flag_type __m)
+ : __position_(__a, __b, __re, __m),
+ __n_(0),
+ __subs_(1, __submatch)
+{
+ __init(__a, __b);
+}
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
+ regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+ const regex_type& __re, const vector<int>& __submatches,
+ regex_constants::match_flag_type __m)
+ : __position_(__a, __b, __re, __m),
+ __n_(0),
+ __subs_(__submatches)
+{
+ __init(__a, __b);
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
+ regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+ const regex_type& __re,
+ initializer_list<int> __submatches,
+ regex_constants::match_flag_type __m)
+ : __position_(__a, __b, __re, __m),
+ __n_(0),
+ __subs_(__submatches)
+{
+ __init(__a, __b);
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+template <size_t _Np>
+regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
+ regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+ const regex_type& __re,
+ const int (&__submatches)[_Np],
+ regex_constants::match_flag_type __m)
+ : __position_(__a, __b, __re, __m),
+ __n_(0),
+ __subs_(begin(__submatches), end(__submatches))
+{
+ __init(__a, __b);
+}
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
+ regex_token_iterator(const regex_token_iterator& __x)
+ : __position_(__x.__position_),
+ __result_(__x.__result_),
+ __suffix_(__x.__suffix_),
+ __n_(__x.__n_),
+ __subs_(__x.__subs_)
+{
+ if (__x.__result_ == &__x.__suffix_)
+ __result_ = &__suffix_;
+ else if ( __result_ != nullptr )
+ __establish_result ();
+}
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>&
+regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
+ operator=(const regex_token_iterator& __x)
+{
+ if (this != &__x)
+ {
+ __position_ = __x.__position_;
+ if (__x.__result_ == &__x.__suffix_)
+ __result_ = &__suffix_;
+ else
+ __result_ = __x.__result_;
+ __suffix_ = __x.__suffix_;
+ __n_ = __x.__n_;
+ __subs_ = __x.__subs_;
+
+ if ( __result_ != nullptr && __result_ != &__suffix_ )
+ __establish_result();
+ }
+ return *this;
+}
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+bool
+regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
+ operator==(const regex_token_iterator& __x) const
+{
+ if (__result_ == nullptr && __x.__result_ == nullptr)
+ return true;
+ if (__result_ == &__suffix_ && __x.__result_ == &__x.__suffix_ &&
+ __suffix_ == __x.__suffix_)
+ return true;
+ if (__result_ == nullptr || __x.__result_ == nullptr)
+ return false;
+ if (__result_ == &__suffix_ || __x.__result_ == &__x.__suffix_)
+ return false;
+ return __position_ == __x.__position_ && __n_ == __x.__n_ &&
+ __subs_ == __x.__subs_;
+}
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>&
+regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++()
+{
+ _Position __prev = __position_;
+ if (__result_ == &__suffix_)
+ __result_ = nullptr;
+ else if (static_cast<size_t>(__n_ + 1) < __subs_.size())
+ {
+ ++__n_;
+ __establish_result();
+ }
+ else
+ {
+ __n_ = 0;
+ ++__position_;
+ if (__position_ != _Position())
+ __establish_result();
+ else
+ {
+ if (_VSTD::find(__subs_.begin(), __subs_.end(), -1) != __subs_.end()
+ && __prev->suffix().length() != 0)
+ {
+ __suffix_.matched = true;
+ __suffix_.first = __prev->suffix().first;
+ __suffix_.second = __prev->suffix().second;
+ __result_ = &__suffix_;
+ }
+ else
+ __result_ = nullptr;
+ }
+ }
+ return *this;
+}
+
+// regex_replace
+
+template <class _OutputIterator, class _BidirectionalIterator,
+ class _Traits, class _CharT>
+_OutputIterator
+regex_replace(_OutputIterator __output_iter,
+ _BidirectionalIterator __first, _BidirectionalIterator __last,
+ const basic_regex<_CharT, _Traits>& __e, const _CharT* __fmt,
+ regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+ typedef regex_iterator<_BidirectionalIterator, _CharT, _Traits> _Iter;
+ _Iter __i(__first, __last, __e, __flags);
+ _Iter __eof;
+ if (__i == __eof)
+ {
+ if (!(__flags & regex_constants::format_no_copy))
+ __output_iter = _VSTD::copy(__first, __last, __output_iter);
+ }
+ else
+ {
+ sub_match<_BidirectionalIterator> __lm;
+ for (size_t __len = char_traits<_CharT>::length(__fmt); __i != __eof; ++__i)
+ {
+ if (!(__flags & regex_constants::format_no_copy))
+ __output_iter = _VSTD::copy(__i->prefix().first, __i->prefix().second, __output_iter);
+ __output_iter = __i->format(__output_iter, __fmt, __fmt + __len, __flags);
+ __lm = __i->suffix();
+ if (__flags & regex_constants::format_first_only)
+ break;
+ }
+ if (!(__flags & regex_constants::format_no_copy))
+ __output_iter = _VSTD::copy(__lm.first, __lm.second, __output_iter);
+ }
+ return __output_iter;
+}
+
+template <class _OutputIterator, class _BidirectionalIterator,
+ class _Traits, class _CharT, class _ST, class _SA>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+regex_replace(_OutputIterator __output_iter,
+ _BidirectionalIterator __first, _BidirectionalIterator __last,
+ const basic_regex<_CharT, _Traits>& __e,
+ const basic_string<_CharT, _ST, _SA>& __fmt,
+ regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+ return _VSTD::regex_replace(__output_iter, __first, __last, __e, __fmt.c_str(), __flags);
+}
+
+template <class _Traits, class _CharT, class _ST, class _SA, class _FST,
+ class _FSA>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _ST, _SA>
+regex_replace(const basic_string<_CharT, _ST, _SA>& __s,
+ const basic_regex<_CharT, _Traits>& __e,
+ const basic_string<_CharT, _FST, _FSA>& __fmt,
+ regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+ basic_string<_CharT, _ST, _SA> __r;
+ _VSTD::regex_replace(back_inserter(__r), __s.begin(), __s.end(), __e,
+ __fmt.c_str(), __flags);
+ return __r;
+}
+
+template <class _Traits, class _CharT, class _ST, class _SA>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _ST, _SA>
+regex_replace(const basic_string<_CharT, _ST, _SA>& __s,
+ const basic_regex<_CharT, _Traits>& __e, const _CharT* __fmt,
+ regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+ basic_string<_CharT, _ST, _SA> __r;
+ _VSTD::regex_replace(back_inserter(__r), __s.begin(), __s.end(), __e,
+ __fmt, __flags);
+ return __r;
+}
+
+template <class _Traits, class _CharT, class _ST, class _SA>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT>
+regex_replace(const _CharT* __s,
+ const basic_regex<_CharT, _Traits>& __e,
+ const basic_string<_CharT, _ST, _SA>& __fmt,
+ regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+ basic_string<_CharT> __r;
+ _VSTD::regex_replace(back_inserter(__r), __s,
+ __s + char_traits<_CharT>::length(__s), __e,
+ __fmt.c_str(), __flags);
+ return __r;
+}
+
+template <class _Traits, class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT>
+regex_replace(const _CharT* __s,
+ const basic_regex<_CharT, _Traits>& __e,
+ const _CharT* __fmt,
+ regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+ basic_string<_CharT> __r;
+ _VSTD::regex_replace(back_inserter(__r), __s,
+ __s + char_traits<_CharT>::length(__s), __e,
+ __fmt, __flags);
+ return __r;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_REGEX
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/semaphore b/contrib/libs/cxxsupp/libcxxmsvc/include/semaphore
new file mode 100644
index 0000000000..753d50f512
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/semaphore
@@ -0,0 +1,188 @@
+// -*- 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_SEMAPHORE
+#define _LIBCPP_SEMAPHORE
+
+/*
+ semaphore synopsis
+
+namespace std {
+
+template<ptrdiff_t least_max_value = implementation-defined>
+class counting_semaphore
+{
+public:
+static constexpr ptrdiff_t max() noexcept;
+
+constexpr explicit counting_semaphore(ptrdiff_t desired);
+~counting_semaphore();
+
+counting_semaphore(const counting_semaphore&) = delete;
+counting_semaphore& operator=(const counting_semaphore&) = delete;
+
+void release(ptrdiff_t update = 1);
+void acquire();
+bool try_acquire() noexcept;
+template<class Rep, class Period>
+ bool try_acquire_for(const chrono::duration<Rep, Period>& rel_time);
+template<class Clock, class Duration>
+ bool try_acquire_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+private:
+ptrdiff_t counter; // exposition only
+};
+
+using binary_semaphore = counting_semaphore<1>;
+
+}
+
+*/
+
+#include <__availability>
+#include <__config>
+#include <__thread/timed_backoff_policy.h>
+#include <__threading_support>
+#include <atomic>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifdef _LIBCPP_HAS_NO_THREADS
+# error <semaphore> is not supported on this single threaded system
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+#if _LIBCPP_STD_VER >= 14
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+/*
+
+__atomic_semaphore_base is the general-case implementation.
+It is a typical Dijkstra semaphore algorithm over atomics, wait and notify
+functions. It avoids contention against users' own use of those facilities.
+
+*/
+
+class __atomic_semaphore_base
+{
+ __atomic_base<ptrdiff_t> __a;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr explicit __atomic_semaphore_base(ptrdiff_t __count) : __a(__count)
+ {
+ }
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ void release(ptrdiff_t __update = 1)
+ {
+ if(0 < __a.fetch_add(__update, memory_order_release))
+ ;
+ else if(__update > 1)
+ __a.notify_all();
+ else
+ __a.notify_one();
+ }
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ void acquire()
+ {
+ 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);
+ };
+ __cxx_atomic_wait(&__a.__a_, __test_fn);
+ }
+ template <class Rep, class Period>
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ bool try_acquire_for(chrono::duration<Rep, Period> const& __rel_time)
+ {
+ if (__rel_time == chrono::duration<Rep, Period>::zero())
+ return try_acquire();
+ auto const __test_fn = [this]() { return try_acquire(); };
+ return __libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy(), __rel_time);
+ }
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ bool try_acquire()
+ {
+ auto __old = __a.load(memory_order_acquire);
+ while (true) {
+ if (__old == 0)
+ return false;
+ if (__a.compare_exchange_strong(__old, __old - 1, memory_order_acquire, memory_order_relaxed))
+ return true;
+ }
+ }
+};
+
+#define _LIBCPP_SEMAPHORE_MAX (numeric_limits<ptrdiff_t>::max())
+
+template<ptrdiff_t __least_max_value = _LIBCPP_SEMAPHORE_MAX>
+class counting_semaphore
+{
+ __atomic_semaphore_base __semaphore;
+
+public:
+ static constexpr ptrdiff_t max() noexcept {
+ return __least_max_value;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr explicit counting_semaphore(ptrdiff_t __count) : __semaphore(__count) { }
+ ~counting_semaphore() = default;
+
+ counting_semaphore(const counting_semaphore&) = delete;
+ counting_semaphore& operator=(const counting_semaphore&) = delete;
+
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ void release(ptrdiff_t __update = 1)
+ {
+ __semaphore.release(__update);
+ }
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ void acquire()
+ {
+ __semaphore.acquire();
+ }
+ template<class Rep, class Period>
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ bool try_acquire_for(chrono::duration<Rep, Period> const& __rel_time)
+ {
+ return __semaphore.try_acquire_for(chrono::duration_cast<chrono::nanoseconds>(__rel_time));
+ }
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ bool try_acquire()
+ {
+ return __semaphore.try_acquire();
+ }
+ template <class Clock, class Duration>
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ bool try_acquire_until(chrono::time_point<Clock, Duration> const& __abs_time)
+ {
+ auto const current = Clock::now();
+ if (current >= __abs_time)
+ return try_acquire();
+ else
+ return try_acquire_for(__abs_time - current);
+ }
+};
+
+using binary_semaphore = counting_semaphore<1>;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 14
+
+_LIBCPP_POP_MACROS
+
+#endif //_LIBCPP_SEMAPHORE
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/set b/contrib/libs/cxxsupp/libcxxmsvc/include/set
new file mode 100644
index 0000000000..176369e81b
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/set
@@ -0,0 +1,1564 @@
+// -*- 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_SET
+#define _LIBCPP_SET
+
+/*
+
+ set synopsis
+
+namespace std
+{
+
+template <class Key, class Compare = less<Key>,
+ class Allocator = allocator<Key>>
+class set
+{
+public:
+ // types:
+ typedef Key key_type;
+ typedef key_type value_type;
+ typedef Compare key_compare;
+ typedef key_compare value_compare;
+ typedef Allocator allocator_type;
+ typedef typename allocator_type::reference reference;
+ typedef typename allocator_type::const_reference const_reference;
+ typedef typename allocator_type::size_type size_type;
+ typedef typename allocator_type::difference_type difference_type;
+ typedef typename allocator_type::pointer pointer;
+ typedef typename allocator_type::const_pointer const_pointer;
+
+ typedef implementation-defined iterator;
+ typedef implementation-defined const_iterator;
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+ typedef unspecified node_type; // C++17
+ typedef INSERT_RETURN_TYPE<iterator, node_type> insert_return_type; // C++17
+
+ // construct/copy/destroy:
+ set()
+ noexcept(
+ is_nothrow_default_constructible<allocator_type>::value &&
+ is_nothrow_default_constructible<key_compare>::value &&
+ is_nothrow_copy_constructible<key_compare>::value);
+ explicit set(const value_compare& comp);
+ set(const value_compare& comp, const allocator_type& a);
+ template <class InputIterator>
+ set(InputIterator first, InputIterator last,
+ const value_compare& comp = value_compare());
+ template <class InputIterator>
+ set(InputIterator first, InputIterator last, const value_compare& comp,
+ const allocator_type& a);
+ set(const set& s);
+ set(set&& s)
+ noexcept(
+ is_nothrow_move_constructible<allocator_type>::value &&
+ is_nothrow_move_constructible<key_compare>::value);
+ explicit set(const allocator_type& a);
+ set(const set& s, const allocator_type& a);
+ set(set&& s, const allocator_type& a);
+ set(initializer_list<value_type> il, const value_compare& comp = value_compare());
+ set(initializer_list<value_type> il, const value_compare& comp,
+ const allocator_type& a);
+ template <class InputIterator>
+ set(InputIterator first, InputIterator last, const allocator_type& a)
+ : set(first, last, Compare(), a) {} // C++14
+ set(initializer_list<value_type> il, const allocator_type& a)
+ : set(il, Compare(), a) {} // C++14
+ ~set();
+
+ set& operator=(const set& s);
+ set& operator=(set&& s)
+ noexcept(
+ allocator_type::propagate_on_container_move_assignment::value &&
+ is_nothrow_move_assignable<allocator_type>::value &&
+ is_nothrow_move_assignable<key_compare>::value);
+ set& operator=(initializer_list<value_type> il);
+
+ // iterators:
+ iterator begin() noexcept;
+ const_iterator begin() const noexcept;
+ iterator end() noexcept;
+ const_iterator end() const noexcept;
+
+ reverse_iterator rbegin() noexcept;
+ const_reverse_iterator rbegin() const noexcept;
+ reverse_iterator rend() noexcept;
+ const_reverse_iterator rend() const noexcept;
+
+ const_iterator cbegin() const noexcept;
+ const_iterator cend() const noexcept;
+ const_reverse_iterator crbegin() const noexcept;
+ const_reverse_iterator crend() const noexcept;
+
+ // capacity:
+ bool empty() const noexcept;
+ size_type size() const noexcept;
+ size_type max_size() const noexcept;
+
+ // modifiers:
+ template <class... Args>
+ pair<iterator, bool> emplace(Args&&... args);
+ template <class... Args>
+ iterator emplace_hint(const_iterator position, Args&&... args);
+ pair<iterator,bool> insert(const value_type& v);
+ pair<iterator,bool> insert(value_type&& v);
+ iterator insert(const_iterator position, const value_type& v);
+ iterator insert(const_iterator position, value_type&& v);
+ template <class InputIterator>
+ void insert(InputIterator first, InputIterator last);
+ void insert(initializer_list<value_type> il);
+
+ node_type extract(const_iterator position); // C++17
+ node_type extract(const key_type& x); // C++17
+ insert_return_type insert(node_type&& nh); // C++17
+ iterator insert(const_iterator hint, node_type&& nh); // C++17
+
+ iterator erase(const_iterator position);
+ iterator erase(iterator position); // C++14
+ size_type erase(const key_type& k);
+ iterator erase(const_iterator first, const_iterator last);
+ void clear() noexcept;
+
+ template<class C2>
+ void merge(set<Key, C2, Allocator>& source); // C++17
+ template<class C2>
+ void merge(set<Key, C2, Allocator>&& source); // C++17
+ template<class C2>
+ void merge(multiset<Key, C2, Allocator>& source); // C++17
+ template<class C2>
+ void merge(multiset<Key, C2, Allocator>&& source); // C++17
+
+ void swap(set& s)
+ noexcept(
+ __is_nothrow_swappable<key_compare>::value &&
+ (!allocator_type::propagate_on_container_swap::value ||
+ __is_nothrow_swappable<allocator_type>::value));
+
+ // observers:
+ allocator_type get_allocator() const noexcept;
+ key_compare key_comp() const;
+ value_compare value_comp() const;
+
+ // set operations:
+ iterator find(const key_type& k);
+ const_iterator find(const key_type& k) const;
+ template<typename K>
+ 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
+ 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>
+ iterator lower_bound(const K& x); // C++14
+ template<typename K>
+ const_iterator lower_bound(const K& x) const; // C++14
+
+ iterator upper_bound(const key_type& k);
+ const_iterator upper_bound(const key_type& k) const;
+ template<typename K>
+ iterator upper_bound(const K& x); // C++14
+ template<typename K>
+ const_iterator upper_bound(const K& x) const; // C++14
+ pair<iterator,iterator> equal_range(const key_type& k);
+ pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
+ template<typename K>
+ pair<iterator,iterator> equal_range(const K& x); // C++14
+ template<typename K>
+ pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14
+};
+
+template <class InputIterator,
+ class Compare = less<typename iterator_traits<InputIterator>::value_type>,
+ class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
+set(InputIterator, InputIterator,
+ Compare = Compare(), Allocator = Allocator())
+ -> set<typename iterator_traits<InputIterator>::value_type, Compare, Allocator>; // C++17
+
+template<class Key, class Compare = less<Key>, class Allocator = allocator<Key>>
+set(initializer_list<Key>, Compare = Compare(), Allocator = Allocator())
+ -> set<Key, Compare, Allocator>; // C++17
+
+template<class InputIterator, class Allocator>
+set(InputIterator, InputIterator, Allocator)
+ -> set<typename iterator_traits<InputIterator>::value_type,
+ less<typename iterator_traits<InputIterator>::value_type>, Allocator>; // C++17
+
+template<class Key, class Allocator>
+set(initializer_list<Key>, Allocator) -> set<Key, less<Key>, Allocator>; // C++17
+
+template <class Key, class Compare, class Allocator>
+bool
+operator==(const set<Key, Compare, Allocator>& x,
+ const set<Key, Compare, Allocator>& y);
+
+template <class Key, class Compare, class Allocator>
+bool
+operator< (const set<Key, Compare, Allocator>& x,
+ const set<Key, Compare, Allocator>& y);
+
+template <class Key, class Compare, class Allocator>
+bool
+operator!=(const set<Key, Compare, Allocator>& x,
+ const set<Key, Compare, Allocator>& y);
+
+template <class Key, class Compare, class Allocator>
+bool
+operator> (const set<Key, Compare, Allocator>& x,
+ const set<Key, Compare, Allocator>& y);
+
+template <class Key, class Compare, class Allocator>
+bool
+operator>=(const set<Key, Compare, Allocator>& x,
+ const set<Key, Compare, Allocator>& y);
+
+template <class Key, class Compare, class Allocator>
+bool
+operator<=(const set<Key, Compare, Allocator>& x,
+ const set<Key, Compare, Allocator>& y);
+
+// specialized algorithms:
+template <class Key, class Compare, class Allocator>
+void
+swap(set<Key, Compare, Allocator>& x, set<Key, Compare, Allocator>& y)
+ noexcept(noexcept(x.swap(y)));
+
+template <class Key, class Compare, class Allocator, class Predicate>
+typename set<Key, Compare, Allocator>::size_type
+erase_if(set<Key, Compare, Allocator>& c, Predicate pred); // C++20
+
+template <class Key, class Compare = less<Key>,
+ class Allocator = allocator<Key>>
+class multiset
+{
+public:
+ // types:
+ typedef Key key_type;
+ typedef key_type value_type;
+ typedef Compare key_compare;
+ typedef key_compare value_compare;
+ typedef Allocator allocator_type;
+ typedef typename allocator_type::reference reference;
+ typedef typename allocator_type::const_reference const_reference;
+ typedef typename allocator_type::size_type size_type;
+ typedef typename allocator_type::difference_type difference_type;
+ typedef typename allocator_type::pointer pointer;
+ typedef typename allocator_type::const_pointer const_pointer;
+
+ typedef implementation-defined iterator;
+ typedef implementation-defined const_iterator;
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+ typedef unspecified node_type; // C++17
+
+ // construct/copy/destroy:
+ multiset()
+ noexcept(
+ is_nothrow_default_constructible<allocator_type>::value &&
+ is_nothrow_default_constructible<key_compare>::value &&
+ is_nothrow_copy_constructible<key_compare>::value);
+ explicit multiset(const value_compare& comp);
+ multiset(const value_compare& comp, const allocator_type& a);
+ template <class InputIterator>
+ multiset(InputIterator first, InputIterator last,
+ const value_compare& comp = value_compare());
+ template <class InputIterator>
+ multiset(InputIterator first, InputIterator last,
+ const value_compare& comp, const allocator_type& a);
+ multiset(const multiset& s);
+ multiset(multiset&& s)
+ noexcept(
+ is_nothrow_move_constructible<allocator_type>::value &&
+ is_nothrow_move_constructible<key_compare>::value);
+ explicit multiset(const allocator_type& a);
+ multiset(const multiset& s, const allocator_type& a);
+ multiset(multiset&& s, const allocator_type& a);
+ multiset(initializer_list<value_type> il, const value_compare& comp = value_compare());
+ multiset(initializer_list<value_type> il, const value_compare& comp,
+ const allocator_type& a);
+ template <class InputIterator>
+ multiset(InputIterator first, InputIterator last, const allocator_type& a)
+ : set(first, last, Compare(), a) {} // C++14
+ multiset(initializer_list<value_type> il, const allocator_type& a)
+ : set(il, Compare(), a) {} // C++14
+ ~multiset();
+
+ multiset& operator=(const multiset& s);
+ multiset& operator=(multiset&& s)
+ noexcept(
+ allocator_type::propagate_on_container_move_assignment::value &&
+ is_nothrow_move_assignable<allocator_type>::value &&
+ is_nothrow_move_assignable<key_compare>::value);
+ multiset& operator=(initializer_list<value_type> il);
+
+ // iterators:
+ iterator begin() noexcept;
+ const_iterator begin() const noexcept;
+ iterator end() noexcept;
+ const_iterator end() const noexcept;
+
+ reverse_iterator rbegin() noexcept;
+ const_reverse_iterator rbegin() const noexcept;
+ reverse_iterator rend() noexcept;
+ const_reverse_iterator rend() const noexcept;
+
+ const_iterator cbegin() const noexcept;
+ const_iterator cend() const noexcept;
+ const_reverse_iterator crbegin() const noexcept;
+ const_reverse_iterator crend() const noexcept;
+
+ // capacity:
+ bool empty() const noexcept;
+ size_type size() const noexcept;
+ size_type max_size() const noexcept;
+
+ // modifiers:
+ template <class... Args>
+ iterator emplace(Args&&... args);
+ template <class... Args>
+ iterator emplace_hint(const_iterator position, Args&&... args);
+ iterator insert(const value_type& v);
+ iterator insert(value_type&& v);
+ iterator insert(const_iterator position, const value_type& v);
+ iterator insert(const_iterator position, value_type&& v);
+ template <class InputIterator>
+ void insert(InputIterator first, InputIterator last);
+ void insert(initializer_list<value_type> il);
+
+ node_type extract(const_iterator position); // C++17
+ node_type extract(const key_type& x); // C++17
+ iterator insert(node_type&& nh); // C++17
+ iterator insert(const_iterator hint, node_type&& nh); // C++17
+
+ iterator erase(const_iterator position);
+ iterator erase(iterator position); // C++14
+ size_type erase(const key_type& k);
+ iterator erase(const_iterator first, const_iterator last);
+ void clear() noexcept;
+
+ template<class C2>
+ void merge(multiset<Key, C2, Allocator>& source); // C++17
+ template<class C2>
+ void merge(multiset<Key, C2, Allocator>&& source); // C++17
+ template<class C2>
+ void merge(set<Key, C2, Allocator>& source); // C++17
+ template<class C2>
+ void merge(set<Key, C2, Allocator>&& source); // C++17
+
+ void swap(multiset& s)
+ noexcept(
+ __is_nothrow_swappable<key_compare>::value &&
+ (!allocator_type::propagate_on_container_swap::value ||
+ __is_nothrow_swappable<allocator_type>::value));
+
+ // observers:
+ allocator_type get_allocator() const noexcept;
+ key_compare key_comp() const;
+ value_compare value_comp() const;
+
+ // set operations:
+ iterator find(const key_type& k);
+ const_iterator find(const key_type& k) const;
+ template<typename K>
+ 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
+ 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>
+ iterator lower_bound(const K& x); // C++14
+ template<typename K>
+ const_iterator lower_bound(const K& x) const; // C++14
+
+ iterator upper_bound(const key_type& k);
+ const_iterator upper_bound(const key_type& k) const;
+ template<typename K>
+ iterator upper_bound(const K& x); // C++14
+ template<typename K>
+ const_iterator upper_bound(const K& x) const; // C++14
+
+ pair<iterator,iterator> equal_range(const key_type& k);
+ pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
+ template<typename K>
+ pair<iterator,iterator> equal_range(const K& x); // C++14
+ template<typename K>
+ pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14
+};
+
+template <class InputIterator,
+ class Compare = less<typename iterator_traits<InputIterator>::value_type>,
+ class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
+multiset(InputIterator, InputIterator,
+ Compare = Compare(), Allocator = Allocator())
+ -> multiset<typename iterator_traits<InputIterator>::value_type, Compare, Allocator>; // C++17
+
+template<class Key, class Compare = less<Key>, class Allocator = allocator<Key>>
+multiset(initializer_list<Key>, Compare = Compare(), Allocator = Allocator())
+ -> multiset<Key, Compare, Allocator>; // C++17
+
+template<class InputIterator, class Allocator>
+multiset(InputIterator, InputIterator, Allocator)
+ -> multiset<typename iterator_traits<InputIterator>::value_type,
+ less<typename iterator_traits<InputIterator>::value_type>, Allocator>; // C++17
+
+template<class Key, class Allocator>
+multiset(initializer_list<Key>, Allocator) -> multiset<Key, less<Key>, Allocator>; // C++17
+
+template <class Key, class Compare, class Allocator>
+bool
+operator==(const multiset<Key, Compare, Allocator>& x,
+ const multiset<Key, Compare, Allocator>& y);
+
+template <class Key, class Compare, class Allocator>
+bool
+operator< (const multiset<Key, Compare, Allocator>& x,
+ const multiset<Key, Compare, Allocator>& y);
+
+template <class Key, class Compare, class Allocator>
+bool
+operator!=(const multiset<Key, Compare, Allocator>& x,
+ const multiset<Key, Compare, Allocator>& y);
+
+template <class Key, class Compare, class Allocator>
+bool
+operator> (const multiset<Key, Compare, Allocator>& x,
+ const multiset<Key, Compare, Allocator>& y);
+
+template <class Key, class Compare, class Allocator>
+bool
+operator>=(const multiset<Key, Compare, Allocator>& x,
+ const multiset<Key, Compare, Allocator>& y);
+
+template <class Key, class Compare, class Allocator>
+bool
+operator<=(const multiset<Key, Compare, Allocator>& x,
+ const multiset<Key, Compare, Allocator>& y);
+
+// specialized algorithms:
+template <class Key, class Compare, class Allocator>
+void
+swap(multiset<Key, Compare, Allocator>& x, multiset<Key, Compare, Allocator>& y)
+ noexcept(noexcept(x.swap(y)));
+
+template <class Key, class Compare, class Allocator, class Predicate>
+typename multiset<Key, Compare, Allocator>::size_type
+erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20
+
+} // std
+
+*/
+
+#include <__algorithm/equal.h>
+#include <__algorithm/lexicographical_compare.h>
+#include <__assert>
+#include <__config>
+#include <__functional/is_transparent.h>
+#include <__iterator/iterator_traits.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)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Key, class _Compare, class _Allocator>
+class multiset;
+
+template <class _Key, class _Compare = less<_Key>,
+ class _Allocator = allocator<_Key> >
+class _LIBCPP_TEMPLATE_VIS set
+{
+public:
+ // types:
+ typedef _Key key_type;
+ typedef key_type value_type;
+ typedef __identity_t<_Compare> key_compare;
+ typedef key_compare value_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");
+
+private:
+ typedef __tree<value_type, value_compare, allocator_type> __base;
+ typedef allocator_traits<allocator_type> __alloc_traits;
+
+ __base __tree_;
+
+public:
+ typedef typename __base::pointer pointer;
+ typedef typename __base::const_pointer const_pointer;
+ typedef typename __base::size_type size_type;
+ typedef typename __base::difference_type difference_type;
+ typedef typename __base::const_iterator iterator;
+ typedef typename __base::const_iterator const_iterator;
+ typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
+ typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
+
+#if _LIBCPP_STD_VER > 14
+ typedef __set_node_handle<typename __base::__node, allocator_type> node_type;
+ typedef __insert_return_type<iterator, node_type> insert_return_type;
+#endif
+
+ template <class _Key2, class _Compare2, class _Alloc2>
+ friend class _LIBCPP_TEMPLATE_VIS set;
+ template <class _Key2, class _Compare2, class _Alloc2>
+ friend class _LIBCPP_TEMPLATE_VIS multiset;
+
+ _LIBCPP_INLINE_VISIBILITY
+ set()
+ _NOEXCEPT_(
+ is_nothrow_default_constructible<allocator_type>::value &&
+ is_nothrow_default_constructible<key_compare>::value &&
+ is_nothrow_copy_constructible<key_compare>::value)
+ : __tree_(value_compare()) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit set(const value_compare& __comp)
+ _NOEXCEPT_(
+ is_nothrow_default_constructible<allocator_type>::value &&
+ is_nothrow_copy_constructible<key_compare>::value)
+ : __tree_(__comp) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit set(const value_compare& __comp, const allocator_type& __a)
+ : __tree_(__comp, __a) {}
+ template <class _InputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ set(_InputIterator __f, _InputIterator __l,
+ const value_compare& __comp = value_compare())
+ : __tree_(__comp)
+ {
+ insert(__f, __l);
+ }
+
+ template <class _InputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ set(_InputIterator __f, _InputIterator __l, const value_compare& __comp,
+ const allocator_type& __a)
+ : __tree_(__comp, __a)
+ {
+ insert(__f, __l);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ template <class _InputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ set(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
+ : set(__f, __l, key_compare(), __a) {}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ set(const set& __s)
+ : __tree_(__s.__tree_)
+ {
+ insert(__s.begin(), __s.end());
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ set& operator=(const set& __s)
+ {
+ __tree_ = __s.__tree_;
+ return *this;
+ }
+
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ set(set&& __s)
+ _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
+ : __tree_(_VSTD::move(__s.__tree_)) {}
+#endif // _LIBCPP_CXX03_LANG
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit set(const allocator_type& __a)
+ : __tree_(__a) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ set(const set& __s, const allocator_type& __a)
+ : __tree_(__s.__tree_.value_comp(), __a)
+ {
+ insert(__s.begin(), __s.end());
+ }
+
+#ifndef _LIBCPP_CXX03_LANG
+ set(set&& __s, const allocator_type& __a);
+
+ _LIBCPP_INLINE_VISIBILITY
+ set(initializer_list<value_type> __il, const value_compare& __comp = value_compare())
+ : __tree_(__comp)
+ {
+ insert(__il.begin(), __il.end());
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ set(initializer_list<value_type> __il, const value_compare& __comp,
+ const allocator_type& __a)
+ : __tree_(__comp, __a)
+ {
+ insert(__il.begin(), __il.end());
+ }
+
+#if _LIBCPP_STD_VER > 11
+ _LIBCPP_INLINE_VISIBILITY
+ set(initializer_list<value_type> __il, const allocator_type& __a)
+ : set(__il, key_compare(), __a) {}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ set& operator=(initializer_list<value_type> __il)
+ {
+ __tree_.__assign_unique(__il.begin(), __il.end());
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ set& operator=(set&& __s)
+ _NOEXCEPT_(is_nothrow_move_assignable<__base>::value)
+ {
+ __tree_ = _VSTD::move(__s.__tree_);
+ return *this;
+ }
+#endif // _LIBCPP_CXX03_LANG
+
+ _LIBCPP_INLINE_VISIBILITY
+ ~set() {
+ static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), "");
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator begin() _NOEXCEPT {return __tree_.begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator end() _NOEXCEPT {return __tree_.end();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator end() const _NOEXCEPT {return __tree_.end();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ reverse_iterator rbegin() _NOEXCEPT
+ {return reverse_iterator(end());}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator rbegin() const _NOEXCEPT
+ {return const_reverse_iterator(end());}
+ _LIBCPP_INLINE_VISIBILITY
+ reverse_iterator rend() _NOEXCEPT
+ {return reverse_iterator(begin());}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator rend() const _NOEXCEPT
+ {return const_reverse_iterator(begin());}
+
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator cbegin() const _NOEXCEPT {return begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator cend() const _NOEXCEPT {return end();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator crend() const _NOEXCEPT {return rend();}
+
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+ bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type size() const _NOEXCEPT {return __tree_.size();}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
+
+ // modifiers:
+#ifndef _LIBCPP_CXX03_LANG
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool> emplace(_Args&&... __args)
+ {return __tree_.__emplace_unique(_VSTD::forward<_Args>(__args)...);}
+ template <class... _Args>
+ _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
+
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator,bool> insert(const value_type& __v)
+ {return __tree_.__insert_unique(__v);}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const_iterator __p, const value_type& __v)
+ {return __tree_.__insert_unique(__p, __v);}
+
+ template <class _InputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ void insert(_InputIterator __f, _InputIterator __l)
+ {
+ for (const_iterator __e = cend(); __f != __l; ++__f)
+ __tree_.__insert_unique(__e, *__f);
+ }
+
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator,bool> insert(value_type&& __v)
+ {return __tree_.__insert_unique(_VSTD::move(__v));}
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const_iterator __p, value_type&& __v)
+ {return __tree_.__insert_unique(__p, _VSTD::move(__v));}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void insert(initializer_list<value_type> __il)
+ {insert(__il.begin(), __il.end());}
+#endif // _LIBCPP_CXX03_LANG
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator erase(const_iterator __p) {return __tree_.erase(__p);}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type erase(const key_type& __k)
+ {return __tree_.__erase_unique(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator erase(const_iterator __f, const_iterator __l)
+ {return __tree_.erase(__f, __l);}
+ _LIBCPP_REINITIALIZES_OBJECT _LIBCPP_INLINE_VISIBILITY
+ void clear() _NOEXCEPT {__tree_.clear();}
+
+#if _LIBCPP_STD_VER > 14
+ _LIBCPP_INLINE_VISIBILITY
+ insert_return_type insert(node_type&& __nh)
+ {
+ _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
+ "node_type with incompatible allocator passed to set::insert()");
+ return __tree_.template __node_handle_insert_unique<
+ node_type, insert_return_type>(_VSTD::move(__nh));
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const_iterator __hint, node_type&& __nh)
+ {
+ _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
+ "node_type with incompatible allocator passed to set::insert()");
+ return __tree_.template __node_handle_insert_unique<node_type>(
+ __hint, _VSTD::move(__nh));
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ node_type extract(key_type const& __key)
+ {
+ return __tree_.template __node_handle_extract<node_type>(__key);
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ node_type extract(const_iterator __it)
+ {
+ return __tree_.template __node_handle_extract<node_type>(__it);
+ }
+ template <class _Compare2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(set<key_type, _Compare2, allocator_type>& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ __tree_.__node_handle_merge_unique(__source.__tree_);
+ }
+ template <class _Compare2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(set<key_type, _Compare2, allocator_type>&& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ __tree_.__node_handle_merge_unique(__source.__tree_);
+ }
+ template <class _Compare2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(multiset<key_type, _Compare2, allocator_type>& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ __tree_.__node_handle_merge_unique(__source.__tree_);
+ }
+ template <class _Compare2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(multiset<key_type, _Compare2, allocator_type>&& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ __tree_.__node_handle_merge_unique(__source.__tree_);
+ }
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(set& __s) _NOEXCEPT_(__is_nothrow_swappable<__base>::value)
+ {__tree_.swap(__s.__tree_);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();}
+ _LIBCPP_INLINE_VISIBILITY
+ key_compare key_comp() const {return __tree_.value_comp();}
+ _LIBCPP_INLINE_VISIBILITY
+ value_compare value_comp() const {return __tree_.value_comp();}
+
+ // set operations:
+ _LIBCPP_INLINE_VISIBILITY
+ iterator find(const key_type& __k) {return __tree_.find(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
+#if _LIBCPP_STD_VER > 11
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ 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 enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
+ find(const _K2& __k) const {return __tree_.find(__k);}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type count(const key_type& __k) const
+ {return __tree_.__count_unique(__k);}
+#if _LIBCPP_STD_VER > 11
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
+ count(const _K2& __k) const {return __tree_.__count_multi(__k);}
+#endif
+
+#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
+ iterator lower_bound(const key_type& __k)
+ {return __tree_.lower_bound(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator lower_bound(const key_type& __k) const
+ {return __tree_.lower_bound(__k);}
+#if _LIBCPP_STD_VER > 11
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ 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 enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
+ lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator upper_bound(const key_type& __k)
+ {return __tree_.upper_bound(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator upper_bound(const key_type& __k) const
+ {return __tree_.upper_bound(__k);}
+#if _LIBCPP_STD_VER > 11
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ 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 enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
+ upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator,iterator> equal_range(const key_type& __k)
+ {return __tree_.__equal_range_unique(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
+ {return __tree_.__equal_range_unique(__k);}
+#if _LIBCPP_STD_VER > 11
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ 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 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
+};
+
+#if _LIBCPP_STD_VER >= 17
+template<class _InputIterator,
+ class _Compare = less<__iter_value_type<_InputIterator>>,
+ class _Allocator = allocator<__iter_value_type<_InputIterator>>,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>,
+ class = enable_if_t<__is_allocator<_Allocator>::value, void>,
+ class = enable_if_t<!__is_allocator<_Compare>::value, void>>
+set(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())
+ -> set<__iter_value_type<_InputIterator>, _Compare, _Allocator>;
+
+template<class _Key, class _Compare = less<_Key>,
+ class _Allocator = allocator<_Key>,
+ class = enable_if_t<!__is_allocator<_Compare>::value, void>,
+ class = enable_if_t<__is_allocator<_Allocator>::value, void>>
+set(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator())
+ -> set<_Key, _Compare, _Allocator>;
+
+template<class _InputIterator, class _Allocator,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>,
+ class = enable_if_t<__is_allocator<_Allocator>::value, void>>
+set(_InputIterator, _InputIterator, _Allocator)
+ -> set<__iter_value_type<_InputIterator>,
+ less<__iter_value_type<_InputIterator>>, _Allocator>;
+
+template<class _Key, class _Allocator,
+ class = enable_if_t<__is_allocator<_Allocator>::value, void>>
+set(initializer_list<_Key>, _Allocator)
+ -> set<_Key, less<_Key>, _Allocator>;
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Key, class _Compare, class _Allocator>
+set<_Key, _Compare, _Allocator>::set(set&& __s, const allocator_type& __a)
+ : __tree_(_VSTD::move(__s.__tree_), __a)
+{
+ if (__a != __s.get_allocator())
+ {
+ const_iterator __e = cend();
+ while (!__s.empty())
+ insert(__e, _VSTD::move(__s.__tree_.remove(__s.begin())->__value_));
+ }
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _Key, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const set<_Key, _Compare, _Allocator>& __x,
+ const set<_Key, _Compare, _Allocator>& __y)
+{
+ return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
+}
+
+template <class _Key, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator< (const set<_Key, _Compare, _Allocator>& __x,
+ const set<_Key, _Compare, _Allocator>& __y)
+{
+ return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
+}
+
+template <class _Key, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const set<_Key, _Compare, _Allocator>& __x,
+ const set<_Key, _Compare, _Allocator>& __y)
+{
+ return !(__x == __y);
+}
+
+template <class _Key, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator> (const set<_Key, _Compare, _Allocator>& __x,
+ const set<_Key, _Compare, _Allocator>& __y)
+{
+ return __y < __x;
+}
+
+template <class _Key, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const set<_Key, _Compare, _Allocator>& __x,
+ const set<_Key, _Compare, _Allocator>& __y)
+{
+ return !(__x < __y);
+}
+
+template <class _Key, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const set<_Key, _Compare, _Allocator>& __x,
+ const set<_Key, _Compare, _Allocator>& __y)
+{
+ return !(__y < __x);
+}
+
+// specialized algorithms:
+template <class _Key, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(set<_Key, _Compare, _Allocator>& __x,
+ set<_Key, _Compare, _Allocator>& __y)
+ _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+ __x.swap(__y);
+}
+
+#if _LIBCPP_STD_VER > 17
+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 _VSTD::__libcpp_erase_if_container(__c, __pred);
+}
+#endif
+
+template <class _Key, class _Compare = less<_Key>,
+ class _Allocator = allocator<_Key> >
+class _LIBCPP_TEMPLATE_VIS multiset
+{
+public:
+ // types:
+ typedef _Key key_type;
+ typedef key_type value_type;
+ typedef __identity_t<_Compare> key_compare;
+ typedef key_compare value_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");
+
+private:
+ typedef __tree<value_type, value_compare, allocator_type> __base;
+ typedef allocator_traits<allocator_type> __alloc_traits;
+
+ __base __tree_;
+
+public:
+ typedef typename __base::pointer pointer;
+ typedef typename __base::const_pointer const_pointer;
+ typedef typename __base::size_type size_type;
+ typedef typename __base::difference_type difference_type;
+ typedef typename __base::const_iterator iterator;
+ typedef typename __base::const_iterator const_iterator;
+ typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
+ typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
+
+#if _LIBCPP_STD_VER > 14
+ typedef __set_node_handle<typename __base::__node, allocator_type> node_type;
+#endif
+
+ template <class _Key2, class _Compare2, class _Alloc2>
+ friend class _LIBCPP_TEMPLATE_VIS set;
+ template <class _Key2, class _Compare2, class _Alloc2>
+ friend class _LIBCPP_TEMPLATE_VIS multiset;
+
+ // construct/copy/destroy:
+ _LIBCPP_INLINE_VISIBILITY
+ multiset()
+ _NOEXCEPT_(
+ is_nothrow_default_constructible<allocator_type>::value &&
+ is_nothrow_default_constructible<key_compare>::value &&
+ is_nothrow_copy_constructible<key_compare>::value)
+ : __tree_(value_compare()) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit multiset(const value_compare& __comp)
+ _NOEXCEPT_(
+ is_nothrow_default_constructible<allocator_type>::value &&
+ is_nothrow_copy_constructible<key_compare>::value)
+ : __tree_(__comp) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit multiset(const value_compare& __comp, const allocator_type& __a)
+ : __tree_(__comp, __a) {}
+ template <class _InputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ multiset(_InputIterator __f, _InputIterator __l,
+ const value_compare& __comp = value_compare())
+ : __tree_(__comp)
+ {
+ insert(__f, __l);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ template <class _InputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ multiset(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
+ : multiset(__f, __l, key_compare(), __a) {}
+#endif
+
+ template <class _InputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ multiset(_InputIterator __f, _InputIterator __l,
+ const value_compare& __comp, const allocator_type& __a)
+ : __tree_(__comp, __a)
+ {
+ insert(__f, __l);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ multiset(const multiset& __s)
+ : __tree_(__s.__tree_.value_comp(),
+ __alloc_traits::select_on_container_copy_construction(__s.__tree_.__alloc()))
+ {
+ insert(__s.begin(), __s.end());
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ multiset& operator=(const multiset& __s)
+ {
+ __tree_ = __s.__tree_;
+ return *this;
+ }
+
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ multiset(multiset&& __s)
+ _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
+ : __tree_(_VSTD::move(__s.__tree_)) {}
+
+ multiset(multiset&& __s, const allocator_type& __a);
+#endif // _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ explicit multiset(const allocator_type& __a)
+ : __tree_(__a) {}
+ _LIBCPP_INLINE_VISIBILITY
+ multiset(const multiset& __s, const allocator_type& __a)
+ : __tree_(__s.__tree_.value_comp(), __a)
+ {
+ insert(__s.begin(), __s.end());
+ }
+
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ multiset(initializer_list<value_type> __il, const value_compare& __comp = value_compare())
+ : __tree_(__comp)
+ {
+ insert(__il.begin(), __il.end());
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ multiset(initializer_list<value_type> __il, const value_compare& __comp,
+ const allocator_type& __a)
+ : __tree_(__comp, __a)
+ {
+ insert(__il.begin(), __il.end());
+ }
+
+#if _LIBCPP_STD_VER > 11
+ _LIBCPP_INLINE_VISIBILITY
+ multiset(initializer_list<value_type> __il, const allocator_type& __a)
+ : multiset(__il, key_compare(), __a) {}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ multiset& operator=(initializer_list<value_type> __il)
+ {
+ __tree_.__assign_multi(__il.begin(), __il.end());
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ multiset& operator=(multiset&& __s)
+ _NOEXCEPT_(is_nothrow_move_assignable<__base>::value)
+ {
+ __tree_ = _VSTD::move(__s.__tree_);
+ return *this;
+ }
+#endif // _LIBCPP_CXX03_LANG
+
+ _LIBCPP_INLINE_VISIBILITY
+ ~multiset() {
+ static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), "");
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator begin() _NOEXCEPT {return __tree_.begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator end() _NOEXCEPT {return __tree_.end();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator end() const _NOEXCEPT {return __tree_.end();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ reverse_iterator rbegin() _NOEXCEPT
+ {return reverse_iterator(end());}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator rbegin() const _NOEXCEPT
+ {return const_reverse_iterator(end());}
+ _LIBCPP_INLINE_VISIBILITY
+ reverse_iterator rend() _NOEXCEPT
+ {return reverse_iterator(begin());}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator rend() const _NOEXCEPT
+ {return const_reverse_iterator(begin());}
+
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator cbegin() const _NOEXCEPT {return begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator cend() const _NOEXCEPT {return end();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator crend() const _NOEXCEPT {return rend();}
+
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+ bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type size() const _NOEXCEPT {return __tree_.size();}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
+
+ // modifiers:
+#ifndef _LIBCPP_CXX03_LANG
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator emplace(_Args&&... __args)
+ {return __tree_.__emplace_multi(_VSTD::forward<_Args>(__args)...);}
+ template <class... _Args>
+ _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
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const value_type& __v)
+ {return __tree_.__insert_multi(__v);}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const_iterator __p, const value_type& __v)
+ {return __tree_.__insert_multi(__p, __v);}
+
+ template <class _InputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ void insert(_InputIterator __f, _InputIterator __l)
+ {
+ for (const_iterator __e = cend(); __f != __l; ++__f)
+ __tree_.__insert_multi(__e, *__f);
+ }
+
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(value_type&& __v)
+ {return __tree_.__insert_multi(_VSTD::move(__v));}
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const_iterator __p, value_type&& __v)
+ {return __tree_.__insert_multi(__p, _VSTD::move(__v));}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void insert(initializer_list<value_type> __il)
+ {insert(__il.begin(), __il.end());}
+#endif // _LIBCPP_CXX03_LANG
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator erase(const_iterator __p) {return __tree_.erase(__p);}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type erase(const key_type& __k) {return __tree_.__erase_multi(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator erase(const_iterator __f, const_iterator __l)
+ {return __tree_.erase(__f, __l);}
+ _LIBCPP_REINITIALIZES_OBJECT _LIBCPP_INLINE_VISIBILITY
+ void clear() _NOEXCEPT {__tree_.clear();}
+
+#if _LIBCPP_STD_VER > 14
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(node_type&& __nh)
+ {
+ _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
+ "node_type with incompatible allocator passed to multiset::insert()");
+ return __tree_.template __node_handle_insert_multi<node_type>(
+ _VSTD::move(__nh));
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const_iterator __hint, node_type&& __nh)
+ {
+ _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
+ "node_type with incompatible allocator passed to multiset::insert()");
+ return __tree_.template __node_handle_insert_multi<node_type>(
+ __hint, _VSTD::move(__nh));
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ node_type extract(key_type const& __key)
+ {
+ return __tree_.template __node_handle_extract<node_type>(__key);
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ node_type extract(const_iterator __it)
+ {
+ return __tree_.template __node_handle_extract<node_type>(__it);
+ }
+ template <class _Compare2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(multiset<key_type, _Compare2, allocator_type>& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ __tree_.__node_handle_merge_multi(__source.__tree_);
+ }
+ template <class _Compare2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(multiset<key_type, _Compare2, allocator_type>&& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ __tree_.__node_handle_merge_multi(__source.__tree_);
+ }
+ template <class _Compare2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(set<key_type, _Compare2, allocator_type>& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ __tree_.__node_handle_merge_multi(__source.__tree_);
+ }
+ template <class _Compare2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(set<key_type, _Compare2, allocator_type>&& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ __tree_.__node_handle_merge_multi(__source.__tree_);
+ }
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(multiset& __s)
+ _NOEXCEPT_(__is_nothrow_swappable<__base>::value)
+ {__tree_.swap(__s.__tree_);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();}
+ _LIBCPP_INLINE_VISIBILITY
+ key_compare key_comp() const {return __tree_.value_comp();}
+ _LIBCPP_INLINE_VISIBILITY
+ value_compare value_comp() const {return __tree_.value_comp();}
+
+ // set operations:
+ _LIBCPP_INLINE_VISIBILITY
+ iterator find(const key_type& __k) {return __tree_.find(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
+#if _LIBCPP_STD_VER > 11
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ 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 enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
+ find(const _K2& __k) const {return __tree_.find(__k);}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type count(const key_type& __k) const
+ {return __tree_.__count_multi(__k);}
+#if _LIBCPP_STD_VER > 11
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
+ count(const _K2& __k) const {return __tree_.__count_multi(__k);}
+#endif
+
+#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
+ iterator lower_bound(const key_type& __k)
+ {return __tree_.lower_bound(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator lower_bound(const key_type& __k) const
+ {return __tree_.lower_bound(__k);}
+#if _LIBCPP_STD_VER > 11
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ 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 enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
+ lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator upper_bound(const key_type& __k)
+ {return __tree_.upper_bound(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator upper_bound(const key_type& __k) const
+ {return __tree_.upper_bound(__k);}
+#if _LIBCPP_STD_VER > 11
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ 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 enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
+ upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator,iterator> equal_range(const key_type& __k)
+ {return __tree_.__equal_range_multi(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
+ {return __tree_.__equal_range_multi(__k);}
+#if _LIBCPP_STD_VER > 11
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ 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 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
+};
+
+#if _LIBCPP_STD_VER >= 17
+template<class _InputIterator,
+ class _Compare = less<__iter_value_type<_InputIterator>>,
+ class _Allocator = allocator<__iter_value_type<_InputIterator>>,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>,
+ class = enable_if_t<__is_allocator<_Allocator>::value, void>,
+ class = enable_if_t<!__is_allocator<_Compare>::value, void>>
+multiset(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())
+ -> multiset<__iter_value_type<_InputIterator>, _Compare, _Allocator>;
+
+template<class _Key, class _Compare = less<_Key>,
+ class _Allocator = allocator<_Key>,
+ class = enable_if_t<__is_allocator<_Allocator>::value, void>,
+ class = enable_if_t<!__is_allocator<_Compare>::value, void>>
+multiset(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator())
+ -> multiset<_Key, _Compare, _Allocator>;
+
+template<class _InputIterator, class _Allocator,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>,
+ class = enable_if_t<__is_allocator<_Allocator>::value, void>>
+multiset(_InputIterator, _InputIterator, _Allocator)
+ -> multiset<__iter_value_type<_InputIterator>,
+ less<__iter_value_type<_InputIterator>>, _Allocator>;
+
+template<class _Key, class _Allocator,
+ class = enable_if_t<__is_allocator<_Allocator>::value, void>>
+multiset(initializer_list<_Key>, _Allocator)
+ -> multiset<_Key, less<_Key>, _Allocator>;
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Key, class _Compare, class _Allocator>
+multiset<_Key, _Compare, _Allocator>::multiset(multiset&& __s, const allocator_type& __a)
+ : __tree_(_VSTD::move(__s.__tree_), __a)
+{
+ if (__a != __s.get_allocator())
+ {
+ const_iterator __e = cend();
+ while (!__s.empty())
+ insert(__e, _VSTD::move(__s.__tree_.remove(__s.begin())->__value_));
+ }
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _Key, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const multiset<_Key, _Compare, _Allocator>& __x,
+ const multiset<_Key, _Compare, _Allocator>& __y)
+{
+ return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
+}
+
+template <class _Key, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator< (const multiset<_Key, _Compare, _Allocator>& __x,
+ const multiset<_Key, _Compare, _Allocator>& __y)
+{
+ return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
+}
+
+template <class _Key, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const multiset<_Key, _Compare, _Allocator>& __x,
+ const multiset<_Key, _Compare, _Allocator>& __y)
+{
+ return !(__x == __y);
+}
+
+template <class _Key, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator> (const multiset<_Key, _Compare, _Allocator>& __x,
+ const multiset<_Key, _Compare, _Allocator>& __y)
+{
+ return __y < __x;
+}
+
+template <class _Key, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const multiset<_Key, _Compare, _Allocator>& __x,
+ const multiset<_Key, _Compare, _Allocator>& __y)
+{
+ return !(__x < __y);
+}
+
+template <class _Key, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const multiset<_Key, _Compare, _Allocator>& __x,
+ const multiset<_Key, _Compare, _Allocator>& __y)
+{
+ return !(__y < __x);
+}
+
+template <class _Key, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(multiset<_Key, _Compare, _Allocator>& __x,
+ multiset<_Key, _Compare, _Allocator>& __y)
+ _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+ __x.swap(__y);
+}
+
+#if _LIBCPP_STD_VER > 17
+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 _VSTD::__libcpp_erase_if_container(__c, __pred);
+}
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_SET
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/setjmp.h b/contrib/libs/cxxsupp/libcxxmsvc/include/setjmp.h
new file mode 100644
index 0000000000..fca41aa31b
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/setjmp.h
@@ -0,0 +1,48 @@
+// -*- 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_SETJMP_H
+#define _LIBCPP_SETJMP_H
+
+/*
+ setjmp.h synopsis
+
+Macros:
+
+ setjmp
+
+Types:
+
+ jmp_buf
+
+void longjmp(jmp_buf env, int val);
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#include Y_MSVC_INCLUDE_NEXT(setjmp.h)
+#else
+#include_next <setjmp.h>
+#endif
+
+#ifdef __cplusplus
+
+#ifndef setjmp
+#define setjmp(env) setjmp(env)
+#endif
+
+#endif // __cplusplus
+
+#endif // _LIBCPP_SETJMP_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/shared_mutex b/contrib/libs/cxxsupp/libcxxmsvc/include/shared_mutex
new file mode 100644
index 0000000000..95aa378066
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/shared_mutex
@@ -0,0 +1,509 @@
+// -*- 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_SHARED_MUTEX
+#define _LIBCPP_SHARED_MUTEX
+
+/*
+ shared_mutex synopsis
+
+// C++1y
+
+namespace std
+{
+
+class shared_mutex // C++17
+{
+public:
+ shared_mutex();
+ ~shared_mutex();
+
+ shared_mutex(const shared_mutex&) = delete;
+ shared_mutex& operator=(const shared_mutex&) = delete;
+
+ // Exclusive ownership
+ void lock(); // blocking
+ bool try_lock();
+ void unlock();
+
+ // Shared ownership
+ void lock_shared(); // blocking
+ bool try_lock_shared();
+ void unlock_shared();
+
+ typedef implementation-defined native_handle_type; // See 30.2.3
+ native_handle_type native_handle(); // See 30.2.3
+};
+
+class shared_timed_mutex
+{
+public:
+ shared_timed_mutex();
+ ~shared_timed_mutex();
+
+ shared_timed_mutex(const shared_timed_mutex&) = delete;
+ shared_timed_mutex& operator=(const shared_timed_mutex&) = delete;
+
+ // Exclusive ownership
+ void lock(); // blocking
+ bool try_lock();
+ template <class Rep, class Period>
+ bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+ template <class Clock, class Duration>
+ bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+ void unlock();
+
+ // Shared ownership
+ void lock_shared(); // blocking
+ bool try_lock_shared();
+ template <class Rep, class Period>
+ bool
+ try_lock_shared_for(const chrono::duration<Rep, Period>& rel_time);
+ template <class Clock, class Duration>
+ bool
+ try_lock_shared_until(const chrono::time_point<Clock, Duration>& abs_time);
+ void unlock_shared();
+};
+
+template <class Mutex>
+class shared_lock
+{
+public:
+ typedef Mutex mutex_type;
+
+ // Shared locking
+ shared_lock() noexcept;
+ explicit shared_lock(mutex_type& m); // blocking
+ shared_lock(mutex_type& m, defer_lock_t) noexcept;
+ shared_lock(mutex_type& m, try_to_lock_t);
+ shared_lock(mutex_type& m, adopt_lock_t);
+ template <class Clock, class Duration>
+ shared_lock(mutex_type& m,
+ const chrono::time_point<Clock, Duration>& abs_time);
+ template <class Rep, class Period>
+ shared_lock(mutex_type& m,
+ const chrono::duration<Rep, Period>& rel_time);
+ ~shared_lock();
+
+ shared_lock(shared_lock const&) = delete;
+ shared_lock& operator=(shared_lock const&) = delete;
+
+ shared_lock(shared_lock&& u) noexcept;
+ shared_lock& operator=(shared_lock&& u) noexcept;
+
+ void lock(); // blocking
+ bool try_lock();
+ template <class Rep, class Period>
+ bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+ template <class Clock, class Duration>
+ bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+ void unlock();
+
+ // Setters
+ void swap(shared_lock& u) noexcept;
+ mutex_type* release() noexcept;
+
+ // Getters
+ bool owns_lock() const noexcept;
+ explicit operator bool () const noexcept;
+ mutex_type* mutex() const noexcept;
+};
+
+template <class Mutex>
+ void swap(shared_lock<Mutex>& x, shared_lock<Mutex>& y) noexcept;
+
+} // std
+
+*/
+
+#include <__availability>
+#include <__config>
+#include <version>
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+
+#if _LIBCPP_STD_VER > 11 || defined(_LIBCPP_BUILDING_LIBRARY)
+
+#include <__mutex_base>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifdef _LIBCPP_HAS_NO_THREADS
+#error <shared_mutex> is not supported on this single threaded system
+#else // !_LIBCPP_HAS_NO_THREADS
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+struct _LIBCPP_TYPE_VIS _LIBCPP_AVAILABILITY_SHARED_MUTEX _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("shared_mutex"))
+__shared_mutex_base
+{
+ mutex __mut_;
+ condition_variable __gate1_;
+ condition_variable __gate2_;
+ unsigned __state_;
+
+ static const unsigned __write_entered_ = 1U << (sizeof(unsigned)*__CHAR_BIT__ - 1);
+ static const unsigned __n_readers_ = ~__write_entered_;
+
+ __shared_mutex_base();
+ _LIBCPP_INLINE_VISIBILITY ~__shared_mutex_base() = default;
+
+ __shared_mutex_base(const __shared_mutex_base&) = delete;
+ __shared_mutex_base& operator=(const __shared_mutex_base&) = delete;
+
+ // Exclusive ownership
+ void lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability()); // blocking
+ bool try_lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(try_acquire_capability(true));
+ void unlock() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability());
+
+ // Shared ownership
+ void lock_shared() _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_shared_capability()); // blocking
+ bool try_lock_shared() _LIBCPP_THREAD_SAFETY_ANNOTATION(try_acquire_shared_capability(true));
+ void unlock_shared() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_shared_capability());
+
+// typedef implementation-defined native_handle_type; // See 30.2.3
+// native_handle_type native_handle(); // See 30.2.3
+};
+
+
+#if _LIBCPP_STD_VER > 14
+class _LIBCPP_TYPE_VIS _LIBCPP_AVAILABILITY_SHARED_MUTEX shared_mutex
+{
+ __shared_mutex_base __base;
+public:
+ _LIBCPP_INLINE_VISIBILITY shared_mutex() : __base() {}
+ _LIBCPP_INLINE_VISIBILITY ~shared_mutex() = default;
+
+ shared_mutex(const shared_mutex&) = delete;
+ shared_mutex& operator=(const shared_mutex&) = delete;
+
+ // Exclusive ownership
+ _LIBCPP_INLINE_VISIBILITY void lock() { return __base.lock(); }
+ _LIBCPP_INLINE_VISIBILITY bool try_lock() { return __base.try_lock(); }
+ _LIBCPP_INLINE_VISIBILITY void unlock() { return __base.unlock(); }
+
+ // Shared ownership
+ _LIBCPP_INLINE_VISIBILITY void lock_shared() { return __base.lock_shared(); }
+ _LIBCPP_INLINE_VISIBILITY bool try_lock_shared() { return __base.try_lock_shared(); }
+ _LIBCPP_INLINE_VISIBILITY void unlock_shared() { return __base.unlock_shared(); }
+
+// typedef __shared_mutex_base::native_handle_type native_handle_type;
+// _LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() { return __base::unlock_shared(); }
+};
+#endif
+
+
+class _LIBCPP_TYPE_VIS _LIBCPP_AVAILABILITY_SHARED_MUTEX shared_timed_mutex
+{
+ __shared_mutex_base __base;
+public:
+ shared_timed_mutex();
+ _LIBCPP_INLINE_VISIBILITY ~shared_timed_mutex() = default;
+
+ shared_timed_mutex(const shared_timed_mutex&) = delete;
+ shared_timed_mutex& operator=(const shared_timed_mutex&) = delete;
+
+ // Exclusive ownership
+ void lock();
+ bool try_lock();
+ template <class _Rep, class _Period>
+ _LIBCPP_INLINE_VISIBILITY
+ bool
+ try_lock_for(const chrono::duration<_Rep, _Period>& __rel_time)
+ {
+ return try_lock_until(chrono::steady_clock::now() + __rel_time);
+ }
+ template <class _Clock, class _Duration>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ bool
+ try_lock_until(const chrono::time_point<_Clock, _Duration>& __abs_time);
+ void unlock();
+
+ // Shared ownership
+ void lock_shared();
+ bool try_lock_shared();
+ template <class _Rep, class _Period>
+ _LIBCPP_INLINE_VISIBILITY
+ bool
+ try_lock_shared_for(const chrono::duration<_Rep, _Period>& __rel_time)
+ {
+ return try_lock_shared_until(chrono::steady_clock::now() + __rel_time);
+ }
+ template <class _Clock, class _Duration>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ bool
+ try_lock_shared_until(const chrono::time_point<_Clock, _Duration>& __abs_time);
+ void unlock_shared();
+};
+
+template <class _Clock, class _Duration>
+bool
+shared_timed_mutex::try_lock_until(
+ const chrono::time_point<_Clock, _Duration>& __abs_time)
+{
+ unique_lock<mutex> __lk(__base.__mut_);
+ if (__base.__state_ & __base.__write_entered_)
+ {
+ while (true)
+ {
+ cv_status __status = __base.__gate1_.wait_until(__lk, __abs_time);
+ if ((__base.__state_ & __base.__write_entered_) == 0)
+ break;
+ if (__status == cv_status::timeout)
+ return false;
+ }
+ }
+ __base.__state_ |= __base.__write_entered_;
+ if (__base.__state_ & __base.__n_readers_)
+ {
+ while (true)
+ {
+ cv_status __status = __base.__gate2_.wait_until(__lk, __abs_time);
+ if ((__base.__state_ & __base.__n_readers_) == 0)
+ break;
+ if (__status == cv_status::timeout)
+ {
+ __base.__state_ &= ~__base.__write_entered_;
+ __base.__gate1_.notify_all();
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
+template <class _Clock, class _Duration>
+bool
+shared_timed_mutex::try_lock_shared_until(
+ const chrono::time_point<_Clock, _Duration>& __abs_time)
+{
+ unique_lock<mutex> __lk(__base.__mut_);
+ if ((__base.__state_ & __base.__write_entered_) || (__base.__state_ & __base.__n_readers_) == __base.__n_readers_)
+ {
+ while (true)
+ {
+ cv_status status = __base.__gate1_.wait_until(__lk, __abs_time);
+ if ((__base.__state_ & __base.__write_entered_) == 0 &&
+ (__base.__state_ & __base.__n_readers_) < __base.__n_readers_)
+ break;
+ if (status == cv_status::timeout)
+ return false;
+ }
+ }
+ unsigned __num_readers = (__base.__state_ & __base.__n_readers_) + 1;
+ __base.__state_ &= ~__base.__n_readers_;
+ __base.__state_ |= __num_readers;
+ return true;
+}
+
+template <class _Mutex>
+class shared_lock
+{
+public:
+ typedef _Mutex mutex_type;
+
+private:
+ mutex_type* __m_;
+ bool __owns_;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ shared_lock() _NOEXCEPT
+ : __m_(nullptr),
+ __owns_(false)
+ {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit shared_lock(mutex_type& __m)
+ : __m_(_VSTD::addressof(__m)),
+ __owns_(true)
+ {__m_->lock_shared();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ shared_lock(mutex_type& __m, defer_lock_t) _NOEXCEPT
+ : __m_(_VSTD::addressof(__m)),
+ __owns_(false)
+ {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ shared_lock(mutex_type& __m, try_to_lock_t)
+ : __m_(_VSTD::addressof(__m)),
+ __owns_(__m.try_lock_shared())
+ {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ shared_lock(mutex_type& __m, adopt_lock_t)
+ : __m_(_VSTD::addressof(__m)),
+ __owns_(true)
+ {}
+
+ template <class _Clock, class _Duration>
+ _LIBCPP_INLINE_VISIBILITY
+ shared_lock(mutex_type& __m,
+ const chrono::time_point<_Clock, _Duration>& __abs_time)
+ : __m_(_VSTD::addressof(__m)),
+ __owns_(__m.try_lock_shared_until(__abs_time))
+ {}
+
+ template <class _Rep, class _Period>
+ _LIBCPP_INLINE_VISIBILITY
+ shared_lock(mutex_type& __m,
+ const chrono::duration<_Rep, _Period>& __rel_time)
+ : __m_(_VSTD::addressof(__m)),
+ __owns_(__m.try_lock_shared_for(__rel_time))
+ {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ ~shared_lock()
+ {
+ if (__owns_)
+ __m_->unlock_shared();
+ }
+
+ shared_lock(shared_lock const&) = delete;
+ shared_lock& operator=(shared_lock const&) = delete;
+
+ _LIBCPP_INLINE_VISIBILITY
+ shared_lock(shared_lock&& __u) _NOEXCEPT
+ : __m_(__u.__m_),
+ __owns_(__u.__owns_)
+ {
+ __u.__m_ = nullptr;
+ __u.__owns_ = false;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ shared_lock& operator=(shared_lock&& __u) _NOEXCEPT
+ {
+ if (__owns_)
+ __m_->unlock_shared();
+ __m_ = nullptr;
+ __owns_ = false;
+ __m_ = __u.__m_;
+ __owns_ = __u.__owns_;
+ __u.__m_ = nullptr;
+ __u.__owns_ = false;
+ return *this;
+ }
+
+ void lock();
+ bool try_lock();
+ template <class Rep, class Period>
+ bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+ template <class Clock, class Duration>
+ bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+ void unlock();
+
+ // Setters
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(shared_lock& __u) _NOEXCEPT
+ {
+ _VSTD::swap(__m_, __u.__m_);
+ _VSTD::swap(__owns_, __u.__owns_);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ mutex_type* release() _NOEXCEPT
+ {
+ mutex_type* __m = __m_;
+ __m_ = nullptr;
+ __owns_ = false;
+ return __m;
+ }
+
+ // Getters
+ _LIBCPP_INLINE_VISIBILITY
+ bool owns_lock() const _NOEXCEPT {return __owns_;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit operator bool () const _NOEXCEPT {return __owns_;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ mutex_type* mutex() const _NOEXCEPT {return __m_;}
+};
+
+template <class _Mutex>
+void
+shared_lock<_Mutex>::lock()
+{
+ if (__m_ == nullptr)
+ __throw_system_error(EPERM, "shared_lock::lock: references null mutex");
+ if (__owns_)
+ __throw_system_error(EDEADLK, "shared_lock::lock: already locked");
+ __m_->lock_shared();
+ __owns_ = true;
+}
+
+template <class _Mutex>
+bool
+shared_lock<_Mutex>::try_lock()
+{
+ if (__m_ == nullptr)
+ __throw_system_error(EPERM, "shared_lock::try_lock: references null mutex");
+ if (__owns_)
+ __throw_system_error(EDEADLK, "shared_lock::try_lock: already locked");
+ __owns_ = __m_->try_lock_shared();
+ return __owns_;
+}
+
+template <class _Mutex>
+template <class _Rep, class _Period>
+bool
+shared_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __d)
+{
+ if (__m_ == nullptr)
+ __throw_system_error(EPERM, "shared_lock::try_lock_for: references null mutex");
+ if (__owns_)
+ __throw_system_error(EDEADLK, "shared_lock::try_lock_for: already locked");
+ __owns_ = __m_->try_lock_shared_for(__d);
+ return __owns_;
+}
+
+template <class _Mutex>
+template <class _Clock, class _Duration>
+bool
+shared_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t)
+{
+ if (__m_ == nullptr)
+ __throw_system_error(EPERM, "shared_lock::try_lock_until: references null mutex");
+ if (__owns_)
+ __throw_system_error(EDEADLK, "shared_lock::try_lock_until: already locked");
+ __owns_ = __m_->try_lock_shared_until(__t);
+ return __owns_;
+}
+
+template <class _Mutex>
+void
+shared_lock<_Mutex>::unlock()
+{
+ if (!__owns_)
+ __throw_system_error(EPERM, "shared_lock::unlock: not locked");
+ __m_->unlock_shared();
+ __owns_ = false;
+}
+
+template <class _Mutex>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(shared_lock<_Mutex>& __x, shared_lock<_Mutex>& __y) _NOEXCEPT
+ {__x.swap(__y);}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // !_LIBCPP_HAS_NO_THREADS
+
+#endif // _LIBCPP_STD_VER > 11
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_SHARED_MUTEX
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/span b/contrib/libs/cxxsupp/libcxxmsvc/include/span
new file mode 100644
index 0000000000..0101dcb822
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/span
@@ -0,0 +1,658 @@
+// -*- 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_SPAN
+#define _LIBCPP_SPAN
+
+/*
+ span synopsis
+
+namespace std {
+
+// constants
+inline constexpr size_t dynamic_extent = numeric_limits<size_t>::max();
+
+// [views.span], class template span
+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 :
+ (sizeof(ElementType) * Extent))> as_bytes(span<ElementType, Extent> s) noexcept;
+
+template <class ElementType, size_t Extent>
+ span< byte, ((Extent == dynamic_extent) ? dynamic_extent :
+ (sizeof(ElementType) * Extent))> as_writable_bytes(span<ElementType, Extent> s) noexcept;
+
+
+template <class ElementType, size_t Extent = dynamic_extent>
+class span {
+public:
+ // constants and types
+ using element_type = ElementType;
+ using value_type = remove_cv_t<ElementType>;
+ using size_type = size_t;
+ using difference_type = ptrdiff_t;
+ using pointer = element_type*;
+ using const_pointer = const element_type*;
+ using reference = element_type&;
+ using const_reference = const element_type&;
+ using iterator = implementation-defined;
+ using reverse_iterator = std::reverse_iterator<iterator>;
+ static constexpr size_type extent = Extent;
+
+ // [span.cons], span constructors, copy, assignment, and destructor
+ constexpr span() noexcept;
+ template <class It>
+ constexpr explicit(Extent != dynamic_extent) span(It first, size_type count);
+ template <class It, class End>
+ constexpr explicit(Extent != dynamic_extent) span(It first, End last);
+ template <size_t N>
+ constexpr span(type_identity_t<element_type> (&arr)[N]) noexcept;
+ template <size_t N>
+ constexpr span(array<value_type, N>& arr) noexcept;
+ template <size_t N>
+ constexpr span(const array<value_type, N>& arr) noexcept;
+ template<class R>
+ constexpr explicit(Extent != dynamic_extent) span(R&& r);
+ constexpr span(const span& other) noexcept = default;
+ template <class OtherElementType, size_t OtherExtent>
+ constexpr explicit(Extent != dynamic_extent) span(const span<OtherElementType, OtherExtent>& s) noexcept;
+ ~span() noexcept = default;
+ constexpr span& operator=(const span& other) noexcept = default;
+
+ // [span.sub], span subviews
+ template <size_t Count>
+ constexpr span<element_type, Count> first() const;
+ template <size_t Count>
+ constexpr span<element_type, Count> last() const;
+ template <size_t Offset, size_t Count = dynamic_extent>
+ constexpr span<element_type, see below> subspan() const;
+
+ constexpr span<element_type, dynamic_extent> first(size_type count) const;
+ constexpr span<element_type, dynamic_extent> last(size_type count) const;
+ constexpr span<element_type, dynamic_extent> subspan(size_type offset, size_type count = dynamic_extent) const;
+
+ // [span.obs], span observers
+ constexpr size_type size() const noexcept;
+ constexpr size_type size_bytes() const noexcept;
+ [[nodiscard]] constexpr bool empty() const noexcept;
+
+ // [span.elem], span element access
+ constexpr reference operator[](size_type idx) const;
+ constexpr reference front() const;
+ constexpr reference back() const;
+ constexpr pointer data() const noexcept;
+
+ // [span.iterators], span iterator support
+ constexpr iterator begin() const noexcept;
+ constexpr iterator end() const noexcept;
+ constexpr reverse_iterator rbegin() const noexcept;
+ constexpr reverse_iterator rend() const noexcept;
+
+private:
+ pointer data_; // exposition only
+ size_type size_; // exposition only
+};
+
+template<class It, class EndOrSize>
+ span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<_It>>>;
+
+template<class T, size_t N>
+ span(T (&)[N]) -> span<T, N>;
+
+template<class T, size_t N>
+ span(array<T, N>&) -> span<T, N>;
+
+template<class T, size_t N>
+ span(const array<T, N>&) -> span<const T, N>;
+
+template<class R>
+ span(R&&) -> span<remove_reference_t<ranges::range_reference_t<R>>>;
+
+} // namespace std
+
+*/
+
+#include <__assert>
+#include <__config>
+#include <__debug>
+#include <__iterator/concepts.h>
+#include <__iterator/wrap_iter.h>
+#include <__ranges/concepts.h>
+#include <__ranges/data.h>
+#include <__ranges/enable_borrowed_range.h>
+#include <__ranges/enable_view.h>
+#include <__ranges/size.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
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+inline constexpr size_t dynamic_extent = numeric_limits<size_t>::max();
+template <typename _Tp, size_t _Extent = dynamic_extent> class span;
+
+
+template <class _Tp>
+struct __is_std_array : false_type {};
+
+template <class _Tp, size_t _Sz>
+struct __is_std_array<array<_Tp, _Sz>> : true_type {};
+
+template <class _Tp>
+struct __is_std_span : false_type {};
+
+template <class _Tp, size_t _Sz>
+struct __is_std_span<span<_Tp, _Sz>> : true_type {};
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+template <class _Range, class _ElementType>
+concept __span_compatible_range =
+ ranges::contiguous_range<_Range> &&
+ ranges::sized_range<_Range> &&
+ (ranges::borrowed_range<_Range> || is_const_v<_ElementType>) &&
+ !__is_std_span<remove_cvref_t<_Range>>::value &&
+ !__is_std_array<remove_cvref_t<_Range>>::value &&
+ !is_array_v<remove_cvref_t<_Range>> &&
+ is_convertible_v<remove_reference_t<ranges::range_reference_t<_Range>>(*)[], _ElementType(*)[]>;
+#else
+template <class _Tp, class _ElementType, class = void>
+struct __is_span_compatible_container : public false_type {};
+
+template <class _Tp, class _ElementType>
+struct __is_span_compatible_container<_Tp, _ElementType,
+ void_t<
+ // is not a specialization of span
+ enable_if_t<!__is_std_span<_Tp>::value, nullptr_t>,
+ // is not a specialization of array
+ enable_if_t<!__is_std_array<_Tp>::value, nullptr_t>,
+ // is_array_v<Container> is false,
+ enable_if_t<!is_array_v<_Tp>, nullptr_t>,
+ // data(cont) and size(cont) are well formed
+ decltype(data(declval<_Tp>())),
+ decltype(size(declval<_Tp>())),
+ // remove_pointer_t<decltype(data(cont))>(*)[] is convertible to ElementType(*)[]
+ enable_if_t<
+ is_convertible_v<remove_pointer_t<decltype(data(declval<_Tp &>()))>(*)[],
+ _ElementType(*)[]>,
+ nullptr_t>
+ >>
+ : public true_type {};
+#endif
+
+template <typename _Tp, size_t _Extent>
+class _LIBCPP_TEMPLATE_VIS span {
+public:
+// constants and types
+ using element_type = _Tp;
+ using value_type = remove_cv_t<_Tp>;
+ using size_type = size_t;
+ using difference_type = ptrdiff_t;
+ using pointer = _Tp *;
+ using const_pointer = const _Tp *;
+ using reference = _Tp &;
+ using const_reference = const _Tp &;
+#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;
+
+// [span.cons], span constructors, copy, assignment, and destructor
+ template <size_t _Sz = _Extent, enable_if_t<_Sz == 0, nullptr_t> = nullptr>
+ _LIBCPP_INLINE_VISIBILITY constexpr span() noexcept : __data{nullptr} {}
+
+ constexpr span (const span&) noexcept = default;
+ constexpr span& operator=(const span&) noexcept = default;
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+ template <class _It,
+ enable_if_t<contiguous_iterator<_It> &&
+ is_convertible_v<remove_reference_t<iter_reference_t<_It>>(*)[], element_type (*)[]>,
+ nullptr_t> = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr explicit span(_It __first, size_type __count)
+ : __data{_VSTD::to_address(__first)} {
+ (void)__count;
+ _LIBCPP_ASSERT(_Extent == __count, "size mismatch in span's constructor (iterator, len)");
+ }
+
+ template <
+ class _It, class _End,
+ enable_if_t<is_convertible_v<remove_reference_t<iter_reference_t<_It> > (*)[], element_type (*)[]> &&
+ contiguous_iterator<_It> && sized_sentinel_for<_End, _It> && !is_convertible_v<_End, size_t>,
+ nullptr_t> = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr explicit span(_It __first, _End __last) : __data{_VSTD::to_address(__first)} {
+ (void)__last;
+ _LIBCPP_ASSERT((__last - __first >= 0), "invalid range in span's constructor (iterator, sentinel)");
+ _LIBCPP_ASSERT(__last - __first == _Extent,
+ "invalid range in span's constructor (iterator, sentinel): last - first != extent");
+ }
+#else
+ _LIBCPP_INLINE_VISIBILITY constexpr explicit span(pointer __ptr, size_type __count) : __data{__ptr}
+ { (void)__count; _LIBCPP_ASSERT(_Extent == __count, "size mismatch in span's constructor (ptr, len)"); }
+ _LIBCPP_INLINE_VISIBILITY constexpr explicit span(pointer __f, pointer __l) : __data{__f}
+ { (void)__l; _LIBCPP_ASSERT(_Extent == distance(__f, __l), "size mismatch in span's constructor (ptr, ptr)"); }
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+ _LIBCPP_INLINE_VISIBILITY constexpr span(type_identity_t<element_type> (&__arr)[_Extent]) noexcept : __data{__arr} {}
+
+ template <class _OtherElementType,
+ enable_if_t<is_convertible_v<_OtherElementType(*)[], element_type (*)[]>, nullptr_t> = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr span(array<_OtherElementType, _Extent>& __arr) noexcept : __data{__arr.data()} {}
+
+ template <class _OtherElementType,
+ enable_if_t<is_convertible_v<const _OtherElementType(*)[], element_type (*)[]>, nullptr_t> = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr span(const array<_OtherElementType, _Extent>& __arr) noexcept : __data{__arr.data()} {}
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+ template <__span_compatible_range<element_type> _Range>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr explicit span(_Range&& __r) : __data{ranges::data(__r)} {
+ _LIBCPP_ASSERT(ranges::size(__r) == _Extent, "size mismatch in span's constructor (range)");
+ }
+#else
+ template <class _Container>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr explicit span( _Container& __c,
+ enable_if_t<__is_span_compatible_container<_Container, _Tp>::value, nullptr_t> = nullptr)
+ : __data{_VSTD::data(__c)} {
+ _LIBCPP_ASSERT(_Extent == _VSTD::size(__c), "size mismatch in span's constructor (range)");
+ }
+
+ template <class _Container>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr explicit span(const _Container& __c,
+ enable_if_t<__is_span_compatible_container<const _Container, _Tp>::value, nullptr_t> = nullptr)
+ : __data{_VSTD::data(__c)} {
+ _LIBCPP_ASSERT(_Extent == _VSTD::size(__c), "size mismatch in span's constructor (range)");
+ }
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+ template <class _OtherElementType>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr span(const span<_OtherElementType, _Extent>& __other,
+ enable_if_t<
+ is_convertible_v<_OtherElementType(*)[], element_type (*)[]>,
+ nullptr_t> = nullptr)
+ : __data{__other.data()} {}
+
+ template <class _OtherElementType>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr explicit span(const span<_OtherElementType, dynamic_extent>& __other,
+ enable_if_t<
+ is_convertible_v<_OtherElementType(*)[], element_type (*)[]>,
+ nullptr_t> = nullptr) noexcept
+ : __data{__other.data()} { _LIBCPP_ASSERT(_Extent == __other.size(), "size mismatch in span's constructor (other span)"); }
+
+
+// ~span() noexcept = default;
+
+ template <size_t _Count>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr span<element_type, _Count> first() const noexcept
+ {
+ static_assert(_Count <= _Extent, "Count out of range in span::first()");
+ return span<element_type, _Count>{data(), _Count};
+ }
+
+ template <size_t _Count>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr span<element_type, _Count> last() const noexcept
+ {
+ static_assert(_Count <= _Extent, "Count out of range in span::last()");
+ return span<element_type, _Count>{data() + size() - _Count, _Count};
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr span<element_type, dynamic_extent> first(size_type __count) const noexcept
+ {
+ _LIBCPP_ASSERT(__count <= size(), "Count out of range in span::first(count)");
+ return {data(), __count};
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr span<element_type, dynamic_extent> last(size_type __count) const noexcept
+ {
+ _LIBCPP_ASSERT(__count <= size(), "Count out of range in span::last(count)");
+ return {data() + size() - __count, __count};
+ }
+
+ template <size_t _Offset, size_t _Count = dynamic_extent>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr auto subspan() const noexcept
+ -> span<element_type, _Count != dynamic_extent ? _Count : _Extent - _Offset>
+ {
+ static_assert(_Offset <= _Extent, "Offset out of range in span::subspan()");
+ static_assert(_Count == dynamic_extent || _Count <= _Extent - _Offset, "Offset + count out of range in span::subspan()");
+
+ using _ReturnType = span<element_type, _Count != dynamic_extent ? _Count : _Extent - _Offset>;
+ return _ReturnType{data() + _Offset, _Count == dynamic_extent ? size() - _Offset : _Count};
+ }
+
+
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr span<element_type, dynamic_extent>
+ subspan(size_type __offset, size_type __count = dynamic_extent) const noexcept
+ {
+ _LIBCPP_ASSERT(__offset <= size(), "Offset out of range in span::subspan(offset, count)");
+ _LIBCPP_ASSERT(__count <= size() || __count == dynamic_extent, "Count out of range in span::subspan(offset, count)");
+ if (__count == dynamic_extent)
+ return {data() + __offset, size() - __offset};
+ _LIBCPP_ASSERT(__count <= size() - __offset, "Offset + count out of range in span::subspan(offset, count)");
+ return {data() + __offset, __count};
+ }
+
+ _LIBCPP_INLINE_VISIBILITY constexpr size_type size() const noexcept { return _Extent; }
+ _LIBCPP_INLINE_VISIBILITY constexpr size_type size_bytes() const noexcept { return _Extent * sizeof(element_type); }
+ [[nodiscard]] _LIBCPP_INLINE_VISIBILITY constexpr bool empty() const noexcept { return _Extent == 0; }
+
+ _LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept
+ {
+ _LIBCPP_ASSERT(__idx < size(), "span<T,N>[] index out of bounds");
+ return __data[__idx];
+ }
+
+ _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
+ {
+ _LIBCPP_ASSERT(!empty(), "span<T, N>::front() on empty span");
+ return __data[0];
+ }
+
+ _LIBCPP_INLINE_VISIBILITY constexpr reference back() const noexcept
+ {
+ _LIBCPP_ASSERT(!empty(), "span<T, N>::back() on empty span");
+ return __data[size()-1];
+ }
+
+ _LIBCPP_INLINE_VISIBILITY constexpr pointer data() const noexcept { return __data; }
+
+// [span.iter], span iterator support
+ _LIBCPP_INLINE_VISIBILITY constexpr iterator begin() const noexcept { return iterator(data()); }
+ _LIBCPP_INLINE_VISIBILITY constexpr iterator end() const noexcept { return iterator(data() + size()); }
+ _LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); }
+ _LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rend() const noexcept { return reverse_iterator(begin()); }
+
+ _LIBCPP_INLINE_VISIBILITY span<const byte, _Extent * sizeof(element_type)> __as_bytes() const noexcept
+ { return span<const byte, _Extent * sizeof(element_type)>{reinterpret_cast<const byte *>(data()), size_bytes()}; }
+
+ _LIBCPP_INLINE_VISIBILITY span<byte, _Extent * sizeof(element_type)> __as_writable_bytes() const noexcept
+ { return span<byte, _Extent * sizeof(element_type)>{reinterpret_cast<byte *>(data()), size_bytes()}; }
+
+private:
+ pointer __data;
+
+};
+
+
+template <typename _Tp>
+class _LIBCPP_TEMPLATE_VIS span<_Tp, dynamic_extent> {
+private:
+
+public:
+// constants and types
+ using element_type = _Tp;
+ using value_type = remove_cv_t<_Tp>;
+ using size_type = size_t;
+ using difference_type = ptrdiff_t;
+ using pointer = _Tp *;
+ using const_pointer = const _Tp *;
+ using reference = _Tp &;
+ using const_reference = const _Tp &;
+#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;
+
+// [span.cons], span constructors, copy, assignment, and destructor
+ _LIBCPP_INLINE_VISIBILITY constexpr span() noexcept : __data{nullptr}, __size{0} {}
+
+ constexpr span (const span&) noexcept = default;
+ constexpr span& operator=(const span&) noexcept = default;
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+ template <class _It,
+ enable_if_t<contiguous_iterator<_It> &&
+ is_convertible_v<remove_reference_t<iter_reference_t<_It> > (*)[], element_type (*)[]>,
+ nullptr_t> = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr span(_It __first, size_type __count)
+ : __data{_VSTD::to_address(__first)}, __size{__count} {}
+
+ template <
+ class _It, class _End,
+ enable_if_t<is_convertible_v<remove_reference_t<iter_reference_t<_It> > (*)[], element_type (*)[]> &&
+ contiguous_iterator<_It> && sized_sentinel_for<_End, _It> && !is_convertible_v<_End, size_t>,
+ nullptr_t> = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr span(_It __first, _End __last)
+ : __data(_VSTD::to_address(__first)), __size(__last - __first) {}
+#else
+ _LIBCPP_INLINE_VISIBILITY constexpr span(pointer __ptr, size_type __count) : __data{__ptr}, __size{__count} {}
+ _LIBCPP_INLINE_VISIBILITY constexpr span(pointer __f, pointer __l) : __data{__f}, __size{static_cast<size_t>(distance(__f, __l))} {}
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+ template <size_t _Sz>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr span(type_identity_t<element_type> (&__arr)[_Sz]) noexcept : __data{__arr}, __size{_Sz} {}
+
+ template <class _OtherElementType, size_t _Sz,
+ enable_if_t<is_convertible_v<_OtherElementType(*)[], element_type (*)[]>, nullptr_t> = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr span(array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {}
+
+ template <class _OtherElementType, size_t _Sz,
+ enable_if_t<is_convertible_v<const _OtherElementType(*)[], element_type (*)[]>, nullptr_t> = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr span(const array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {}
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+ template <__span_compatible_range<element_type> _Range>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr span(_Range&& __r) : __data(ranges::data(__r)), __size{ranges::size(__r)} {}
+#else
+ template <class _Container>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr span( _Container& __c,
+ enable_if_t<__is_span_compatible_container<_Container, _Tp>::value, nullptr_t> = nullptr)
+ : __data{_VSTD::data(__c)}, __size{(size_type) _VSTD::size(__c)} {}
+
+ template <class _Container>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr span(const _Container& __c,
+ enable_if_t<__is_span_compatible_container<const _Container, _Tp>::value, nullptr_t> = nullptr)
+ : __data{_VSTD::data(__c)}, __size{(size_type) _VSTD::size(__c)} {}
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+ template <class _OtherElementType, size_t _OtherExtent>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr span(const span<_OtherElementType, _OtherExtent>& __other,
+ enable_if_t<
+ is_convertible_v<_OtherElementType(*)[], element_type (*)[]>,
+ nullptr_t> = nullptr) noexcept
+ : __data{__other.data()}, __size{__other.size()} {}
+
+// ~span() noexcept = default;
+
+ template <size_t _Count>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr span<element_type, _Count> first() const noexcept
+ {
+ _LIBCPP_ASSERT(_Count <= size(), "Count out of range in span::first()");
+ return span<element_type, _Count>{data(), _Count};
+ }
+
+ template <size_t _Count>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr span<element_type, _Count> last() const noexcept
+ {
+ _LIBCPP_ASSERT(_Count <= size(), "Count out of range in span::last()");
+ return span<element_type, _Count>{data() + size() - _Count, _Count};
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr span<element_type, dynamic_extent> first(size_type __count) const noexcept
+ {
+ _LIBCPP_ASSERT(__count <= size(), "Count out of range in span::first(count)");
+ return {data(), __count};
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr span<element_type, dynamic_extent> last (size_type __count) const noexcept
+ {
+ _LIBCPP_ASSERT(__count <= size(), "Count out of range in span::last(count)");
+ return {data() + size() - __count, __count};
+ }
+
+ template <size_t _Offset, size_t _Count = dynamic_extent>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr span<element_type, _Count> subspan() const noexcept
+ {
+ _LIBCPP_ASSERT(_Offset <= size(), "Offset out of range in span::subspan()");
+ _LIBCPP_ASSERT(_Count == dynamic_extent || _Count <= size() - _Offset, "Offset + count out of range in span::subspan()");
+ return span<element_type, _Count>{data() + _Offset, _Count == dynamic_extent ? size() - _Offset : _Count};
+ }
+
+ constexpr span<element_type, dynamic_extent>
+ _LIBCPP_INLINE_VISIBILITY
+ subspan(size_type __offset, size_type __count = dynamic_extent) const noexcept
+ {
+ _LIBCPP_ASSERT(__offset <= size(), "Offset out of range in span::subspan(offset, count)");
+ _LIBCPP_ASSERT(__count <= size() || __count == dynamic_extent, "count out of range in span::subspan(offset, count)");
+ if (__count == dynamic_extent)
+ return {data() + __offset, size() - __offset};
+ _LIBCPP_ASSERT(__count <= size() - __offset, "Offset + count out of range in span::subspan(offset, count)");
+ return {data() + __offset, __count};
+ }
+
+ _LIBCPP_INLINE_VISIBILITY constexpr size_type size() const noexcept { return __size; }
+ _LIBCPP_INLINE_VISIBILITY constexpr size_type size_bytes() const noexcept { return __size * sizeof(element_type); }
+ [[nodiscard]] _LIBCPP_INLINE_VISIBILITY constexpr bool empty() const noexcept { return __size == 0; }
+
+ _LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept
+ {
+ _LIBCPP_ASSERT(__idx < size(), "span<T>[] index out of bounds");
+ return __data[__idx];
+ }
+
+ _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
+ {
+ _LIBCPP_ASSERT(!empty(), "span<T>[].front() on empty span");
+ return __data[0];
+ }
+
+ _LIBCPP_INLINE_VISIBILITY constexpr reference back() const noexcept
+ {
+ _LIBCPP_ASSERT(!empty(), "span<T>[].back() on empty span");
+ return __data[size()-1];
+ }
+
+
+ _LIBCPP_INLINE_VISIBILITY constexpr pointer data() const noexcept { return __data; }
+
+// [span.iter], span iterator support
+ _LIBCPP_INLINE_VISIBILITY constexpr iterator begin() const noexcept { return iterator(data()); }
+ _LIBCPP_INLINE_VISIBILITY constexpr iterator end() const noexcept { return iterator(data() + size()); }
+ _LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); }
+ _LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rend() const noexcept { return reverse_iterator(begin()); }
+
+ inline _LIBCPP_INLINE_VISIBILITY span<const byte, dynamic_extent> __as_bytes() const noexcept;
+
+ inline _LIBCPP_INLINE_VISIBILITY span<byte, dynamic_extent> __as_writable_bytes() const noexcept;
+
+private:
+ pointer __data;
+ size_type __size;
+};
+
+template<typename _Tp>
+inline _LIBCPP_INLINE_VISIBILITY span<const byte, dynamic_extent> span<_Tp, dynamic_extent>::__as_bytes() const noexcept
+{ return {reinterpret_cast<const byte *>(data()), size_bytes()}; }
+
+template<typename _Tp>
+inline _LIBCPP_INLINE_VISIBILITY span<byte, dynamic_extent> span<_Tp, dynamic_extent>::__as_writable_bytes() const noexcept
+{ return {reinterpret_cast<byte *>(data()), size_bytes()}; }
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+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_CONCEPTS)
+
+// as_bytes & as_writable_bytes
+template <class _Tp, size_t _Extent>
+_LIBCPP_INLINE_VISIBILITY
+auto as_bytes(span<_Tp, _Extent> __s) noexcept
+-> decltype(__s.__as_bytes())
+{ return __s.__as_bytes(); }
+
+template <class _Tp, size_t _Extent>
+_LIBCPP_INLINE_VISIBILITY
+auto as_writable_bytes(span<_Tp, _Extent> __s) noexcept
+-> enable_if_t<!is_const_v<_Tp>, decltype(__s.__as_writable_bytes())>
+{ return __s.__as_writable_bytes(); }
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+template<contiguous_iterator _It, class _EndOrSize>
+ span(_It, _EndOrSize) -> span<remove_reference_t<iter_reference_t<_It>>>;
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+template<class _Tp, size_t _Sz>
+ span(_Tp (&)[_Sz]) -> span<_Tp, _Sz>;
+
+template<class _Tp, size_t _Sz>
+ span(array<_Tp, _Sz>&) -> span<_Tp, _Sz>;
+
+template<class _Tp, size_t _Sz>
+ span(const array<_Tp, _Sz>&) -> span<const _Tp, _Sz>;
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+template<ranges::contiguous_range _Range>
+ span(_Range&&) -> span<remove_reference_t<ranges::range_reference_t<_Range>>>;
+#endif
+
+#endif // _LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_SPAN
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/sstream b/contrib/libs/cxxsupp/libcxxmsvc/include/sstream
new file mode 100644
index 0000000000..dd1d9c3d0c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/sstream
@@ -0,0 +1,872 @@
+// -*- 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_SSTREAM
+#define _LIBCPP_SSTREAM
+
+/*
+ sstream synopsis
+
+template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+class basic_stringbuf
+ : public basic_streambuf<charT, traits>
+{
+public:
+ typedef charT char_type;
+ typedef traits traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+ typedef Allocator allocator_type;
+
+ // 27.8.1.1 [stringbuf.cons], constructors:
+ explicit basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out); // before C++20
+ basic_stringbuf() : basic_stringbuf(ios_base::in | ios_base::out) {} // C++20
+ explicit basic_stringbuf(ios_base::openmode which); // C++20
+ explicit basic_stringbuf(const basic_string<char_type, traits_type, allocator_type>& str,
+ ios_base::openmode which = ios_base::in | ios_base::out);
+ basic_stringbuf(basic_stringbuf&& rhs);
+
+ // 27.8.1.2 Assign and swap:
+ basic_stringbuf& operator=(basic_stringbuf&& rhs);
+ void swap(basic_stringbuf& rhs);
+
+ // 27.8.1.3 Get and set:
+ basic_string<char_type, traits_type, allocator_type> str() const;
+ void str(const basic_string<char_type, traits_type, allocator_type>& s);
+
+protected:
+ // 27.8.1.4 Overridden virtual functions:
+ virtual int_type underflow();
+ virtual int_type pbackfail(int_type c = traits_type::eof());
+ virtual int_type overflow (int_type c = traits_type::eof());
+ virtual basic_streambuf<char_type, traits_type>* setbuf(char_type*, streamsize);
+ virtual pos_type seekoff(off_type off, ios_base::seekdir way,
+ ios_base::openmode which = ios_base::in | ios_base::out);
+ virtual pos_type seekpos(pos_type sp,
+ ios_base::openmode which = ios_base::in | ios_base::out);
+};
+
+template <class charT, class traits, class Allocator>
+ void swap(basic_stringbuf<charT, traits, Allocator>& x,
+ basic_stringbuf<charT, traits, Allocator>& y);
+
+typedef basic_stringbuf<char> stringbuf;
+typedef basic_stringbuf<wchar_t> wstringbuf;
+
+template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+class basic_istringstream
+ : public basic_istream<charT, traits>
+{
+public:
+ typedef charT char_type;
+ typedef traits traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+ typedef Allocator allocator_type;
+
+ // 27.8.2.1 Constructors:
+ explicit basic_istringstream(ios_base::openmode which = ios_base::in); // before C++20
+ basic_istringstream() : basic_istringstream(ios_base::in) {} // C++20
+ explicit basic_istringstream(ios_base::openmode which); // C++20
+
+ explicit basic_istringstream(const basic_string<char_type, traits_type,allocator_type>& str,
+ ios_base::openmode which = ios_base::in);
+ basic_istringstream(basic_istringstream&& rhs);
+
+ // 27.8.2.2 Assign and swap:
+ basic_istringstream& operator=(basic_istringstream&& rhs);
+ void swap(basic_istringstream& rhs);
+
+ // 27.8.2.3 Members:
+ basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
+ basic_string<char_type, traits_type, allocator_type> str() const;
+ void str(const basic_string<char_type, traits_type, allocator_type>& s);
+};
+
+template <class charT, class traits, class Allocator>
+ void swap(basic_istringstream<charT, traits, Allocator>& x,
+ basic_istringstream<charT, traits, Allocator>& y);
+
+typedef basic_istringstream<char> istringstream;
+typedef basic_istringstream<wchar_t> wistringstream;
+
+template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+class basic_ostringstream
+ : public basic_ostream<charT, traits>
+{
+public:
+ // types:
+ typedef charT char_type;
+ typedef traits traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+ typedef Allocator allocator_type;
+
+ // 27.8.3.1 Constructors/destructor:
+ explicit basic_ostringstream(ios_base::openmode which = ios_base::out); // before C++20
+ basic_ostringstream() : basic_ostringstream(ios_base::out) {} // C++20
+ explicit basic_ostringstream(ios_base::openmode which); // C++20
+
+ explicit basic_ostringstream(const basic_string<char_type, traits_type, allocator_type>& str,
+ ios_base::openmode which = ios_base::out);
+ basic_ostringstream(basic_ostringstream&& rhs);
+
+ // 27.8.3.2 Assign/swap:
+ basic_ostringstream& operator=(basic_ostringstream&& rhs);
+ void swap(basic_ostringstream& rhs);
+
+ // 27.8.3.3 Members:
+ basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
+ basic_string<char_type, traits_type, allocator_type> str() const;
+ void str(const basic_string<char_type, traits_type, allocator_type>& s);
+};
+
+template <class charT, class traits, class Allocator>
+ void swap(basic_ostringstream<charT, traits, Allocator>& x,
+ basic_ostringstream<charT, traits, Allocator>& y);
+
+typedef basic_ostringstream<char> ostringstream;
+typedef basic_ostringstream<wchar_t> wostringstream;
+
+template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+class basic_stringstream
+ : public basic_iostream<charT, traits>
+{
+public:
+ // types:
+ typedef charT char_type;
+ typedef traits traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+ typedef Allocator allocator_type;
+
+ // constructors/destructor
+ explicit basic_stringstream(ios_base::openmode which = ios_base::out | ios_base::in); // before C++20
+ basic_stringstream() : basic_stringstream(ios_base::out | ios_base::in) {} // C++20
+ explicit basic_stringstream(ios_base::openmode which); // C++20
+
+ explicit basic_stringstream(const basic_string<char_type, traits_type, allocator_type>& str,
+ ios_base::openmode which = ios_base::out|ios_base::in);
+ basic_stringstream(basic_stringstream&& rhs);
+
+ // 27.8.5.1 Assign/swap:
+ basic_stringstream& operator=(basic_stringstream&& rhs);
+ void swap(basic_stringstream& rhs);
+
+ // Members:
+ basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
+ basic_string<char_type, traits_type, allocator_type> str() const;
+ void str(const basic_string<char_type, traits_type, allocator_type>& str);
+};
+
+template <class charT, class traits, class Allocator>
+ void swap(basic_stringstream<charT, traits, Allocator>& x,
+ basic_stringstream<charT, traits, Allocator>& y);
+
+typedef basic_stringstream<char> stringstream;
+typedef basic_stringstream<wchar_t> wstringstream;
+
+} // std
+
+*/
+
+#include <__config>
+#include <istream>
+#include <ostream>
+#include <string>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// basic_stringbuf
+
+template <class _CharT, class _Traits, class _Allocator>
+class _LIBCPP_TEMPLATE_VIS basic_stringbuf
+ : public basic_streambuf<_CharT, _Traits>
+{
+public:
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+ typedef _Allocator allocator_type;
+
+ typedef basic_string<char_type, traits_type, allocator_type> string_type;
+
+private:
+
+ string_type __str_;
+ mutable char_type* __hm_;
+ ios_base::openmode __mode_;
+
+public:
+ // 30.8.2.1 [stringbuf.cons], constructors
+ _LIBCPP_INLINE_VISIBILITY
+ 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) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit basic_stringbuf(const string_type& __s,
+ ios_base::openmode __wch = ios_base::in | ios_base::out)
+ : __str_(__s.get_allocator()), __hm_(nullptr), __mode_(__wch)
+ {
+ str(__s);
+ }
+
+ basic_stringbuf(basic_stringbuf&& __rhs);
+
+ // 27.8.1.2 Assign and swap:
+ basic_stringbuf& operator=(basic_stringbuf&& __rhs);
+ void swap(basic_stringbuf& __rhs);
+
+ // 27.8.1.3 Get and set:
+ string_type str() const;
+ void str(const string_type& __s);
+
+protected:
+ // 27.8.1.4 Overridden virtual functions:
+ virtual int_type underflow();
+ virtual int_type pbackfail(int_type __c = traits_type::eof());
+ virtual int_type overflow (int_type __c = traits_type::eof());
+ virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,
+ ios_base::openmode __wch = ios_base::in | ios_base::out);
+ _LIBCPP_INLINE_VISIBILITY
+ virtual pos_type seekpos(pos_type __sp,
+ ios_base::openmode __wch = ios_base::in | ios_base::out) {
+ return seekoff(__sp, ios_base::beg, __wch);
+ }
+};
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(basic_stringbuf&& __rhs)
+ : __mode_(__rhs.__mode_)
+{
+ char_type* __p = const_cast<char_type*>(__rhs.__str_.data());
+ ptrdiff_t __binp = -1;
+ ptrdiff_t __ninp = -1;
+ ptrdiff_t __einp = -1;
+ if (__rhs.eback() != nullptr)
+ {
+ __binp = __rhs.eback() - __p;
+ __ninp = __rhs.gptr() - __p;
+ __einp = __rhs.egptr() - __p;
+ }
+ ptrdiff_t __bout = -1;
+ ptrdiff_t __nout = -1;
+ ptrdiff_t __eout = -1;
+ if (__rhs.pbase() != nullptr)
+ {
+ __bout = __rhs.pbase() - __p;
+ __nout = __rhs.pptr() - __p;
+ __eout = __rhs.epptr() - __p;
+ }
+ ptrdiff_t __hm = __rhs.__hm_ == nullptr ? -1 : __rhs.__hm_ - __p;
+ __str_ = _VSTD::move(__rhs.__str_);
+ __p = const_cast<char_type*>(__str_.data());
+ if (__binp != -1)
+ this->setg(__p + __binp, __p + __ninp, __p + __einp);
+ if (__bout != -1)
+ {
+ this->setp(__p + __bout, __p + __eout);
+ this->__pbump(__nout);
+ }
+ __hm_ = __hm == -1 ? nullptr : __p + __hm;
+ __p = const_cast<char_type*>(__rhs.__str_.data());
+ __rhs.setg(__p, __p, __p);
+ __rhs.setp(__p, __p);
+ __rhs.__hm_ = __p;
+ this->pubimbue(__rhs.getloc());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_stringbuf<_CharT, _Traits, _Allocator>&
+basic_stringbuf<_CharT, _Traits, _Allocator>::operator=(basic_stringbuf&& __rhs)
+{
+ char_type* __p = const_cast<char_type*>(__rhs.__str_.data());
+ ptrdiff_t __binp = -1;
+ ptrdiff_t __ninp = -1;
+ ptrdiff_t __einp = -1;
+ if (__rhs.eback() != nullptr)
+ {
+ __binp = __rhs.eback() - __p;
+ __ninp = __rhs.gptr() - __p;
+ __einp = __rhs.egptr() - __p;
+ }
+ ptrdiff_t __bout = -1;
+ ptrdiff_t __nout = -1;
+ ptrdiff_t __eout = -1;
+ if (__rhs.pbase() != nullptr)
+ {
+ __bout = __rhs.pbase() - __p;
+ __nout = __rhs.pptr() - __p;
+ __eout = __rhs.epptr() - __p;
+ }
+ ptrdiff_t __hm = __rhs.__hm_ == nullptr ? -1 : __rhs.__hm_ - __p;
+ __str_ = _VSTD::move(__rhs.__str_);
+ __p = const_cast<char_type*>(__str_.data());
+ if (__binp != -1)
+ this->setg(__p + __binp, __p + __ninp, __p + __einp);
+ else
+ this->setg(nullptr, nullptr, nullptr);
+ if (__bout != -1)
+ {
+ this->setp(__p + __bout, __p + __eout);
+ this->__pbump(__nout);
+ }
+ else
+ this->setp(nullptr, nullptr);
+
+ __hm_ = __hm == -1 ? nullptr : __p + __hm;
+ __mode_ = __rhs.__mode_;
+ __p = const_cast<char_type*>(__rhs.__str_.data());
+ __rhs.setg(__p, __p, __p);
+ __rhs.setp(__p, __p);
+ __rhs.__hm_ = __p;
+ this->pubimbue(__rhs.getloc());
+ return *this;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+void
+basic_stringbuf<_CharT, _Traits, _Allocator>::swap(basic_stringbuf& __rhs)
+{
+ char_type* __p = const_cast<char_type*>(__rhs.__str_.data());
+ ptrdiff_t __rbinp = -1;
+ ptrdiff_t __rninp = -1;
+ ptrdiff_t __reinp = -1;
+ if (__rhs.eback() != nullptr)
+ {
+ __rbinp = __rhs.eback() - __p;
+ __rninp = __rhs.gptr() - __p;
+ __reinp = __rhs.egptr() - __p;
+ }
+ ptrdiff_t __rbout = -1;
+ ptrdiff_t __rnout = -1;
+ ptrdiff_t __reout = -1;
+ if (__rhs.pbase() != nullptr)
+ {
+ __rbout = __rhs.pbase() - __p;
+ __rnout = __rhs.pptr() - __p;
+ __reout = __rhs.epptr() - __p;
+ }
+ ptrdiff_t __rhm = __rhs.__hm_ == nullptr ? -1 : __rhs.__hm_ - __p;
+ __p = const_cast<char_type*>(__str_.data());
+ ptrdiff_t __lbinp = -1;
+ ptrdiff_t __lninp = -1;
+ ptrdiff_t __leinp = -1;
+ if (this->eback() != nullptr)
+ {
+ __lbinp = this->eback() - __p;
+ __lninp = this->gptr() - __p;
+ __leinp = this->egptr() - __p;
+ }
+ ptrdiff_t __lbout = -1;
+ ptrdiff_t __lnout = -1;
+ ptrdiff_t __leout = -1;
+ if (this->pbase() != nullptr)
+ {
+ __lbout = this->pbase() - __p;
+ __lnout = this->pptr() - __p;
+ __leout = this->epptr() - __p;
+ }
+ ptrdiff_t __lhm = __hm_ == nullptr ? -1 : __hm_ - __p;
+ _VSTD::swap(__mode_, __rhs.__mode_);
+ __str_.swap(__rhs.__str_);
+ __p = const_cast<char_type*>(__str_.data());
+ if (__rbinp != -1)
+ this->setg(__p + __rbinp, __p + __rninp, __p + __reinp);
+ else
+ this->setg(nullptr, nullptr, nullptr);
+ if (__rbout != -1)
+ {
+ this->setp(__p + __rbout, __p + __reout);
+ this->__pbump(__rnout);
+ }
+ else
+ this->setp(nullptr, nullptr);
+ __hm_ = __rhm == -1 ? nullptr : __p + __rhm;
+ __p = const_cast<char_type*>(__rhs.__str_.data());
+ if (__lbinp != -1)
+ __rhs.setg(__p + __lbinp, __p + __lninp, __p + __leinp);
+ else
+ __rhs.setg(nullptr, nullptr, nullptr);
+ if (__lbout != -1)
+ {
+ __rhs.setp(__p + __lbout, __p + __leout);
+ __rhs.__pbump(__lnout);
+ }
+ else
+ __rhs.setp(nullptr, nullptr);
+ __rhs.__hm_ = __lhm == -1 ? nullptr : __p + __lhm;
+ locale __tl = __rhs.getloc();
+ __rhs.pubimbue(this->getloc());
+ this->pubimbue(__tl);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x,
+ basic_stringbuf<_CharT, _Traits, _Allocator>& __y)
+{
+ __x.swap(__y);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>
+basic_stringbuf<_CharT, _Traits, _Allocator>::str() const
+{
+ if (__mode_ & ios_base::out)
+ {
+ if (__hm_ < this->pptr())
+ __hm_ = this->pptr();
+ return string_type(this->pbase(), __hm_, __str_.get_allocator());
+ }
+ else if (__mode_ & ios_base::in)
+ return string_type(this->eback(), this->egptr(), __str_.get_allocator());
+ return string_type(__str_.get_allocator());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+void
+basic_stringbuf<_CharT, _Traits, _Allocator>::str(const string_type& __s)
+{
+ __str_ = __s;
+ __hm_ = nullptr;
+ if (__mode_ & ios_base::in)
+ {
+ __hm_ = const_cast<char_type*>(__str_.data()) + __str_.size();
+ this->setg(const_cast<char_type*>(__str_.data()),
+ const_cast<char_type*>(__str_.data()),
+ __hm_);
+ }
+ if (__mode_ & ios_base::out)
+ {
+ typename string_type::size_type __sz = __str_.size();
+ __hm_ = const_cast<char_type*>(__str_.data()) + __sz;
+ __str_.resize(__str_.capacity());
+ this->setp(const_cast<char_type*>(__str_.data()),
+ const_cast<char_type*>(__str_.data()) + __str_.size());
+ if (__mode_ & (ios_base::app | ios_base::ate))
+ {
+ while (__sz > INT_MAX)
+ {
+ this->pbump(INT_MAX);
+ __sz -= INT_MAX;
+ }
+ if (__sz > 0)
+ this->pbump(__sz);
+ }
+ }
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type
+basic_stringbuf<_CharT, _Traits, _Allocator>::underflow()
+{
+ if (__hm_ < this->pptr())
+ __hm_ = this->pptr();
+ if (__mode_ & ios_base::in)
+ {
+ if (this->egptr() < __hm_)
+ this->setg(this->eback(), this->gptr(), __hm_);
+ if (this->gptr() < this->egptr())
+ return traits_type::to_int_type(*this->gptr());
+ }
+ return traits_type::eof();
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type
+basic_stringbuf<_CharT, _Traits, _Allocator>::pbackfail(int_type __c)
+{
+ if (__hm_ < this->pptr())
+ __hm_ = this->pptr();
+ if (this->eback() < this->gptr())
+ {
+ if (traits_type::eq_int_type(__c, traits_type::eof()))
+ {
+ this->setg(this->eback(), this->gptr()-1, __hm_);
+ return traits_type::not_eof(__c);
+ }
+ if ((__mode_ & ios_base::out) ||
+ traits_type::eq(traits_type::to_char_type(__c), this->gptr()[-1]))
+ {
+ this->setg(this->eback(), this->gptr()-1, __hm_);
+ *this->gptr() = traits_type::to_char_type(__c);
+ return __c;
+ }
+ }
+ return traits_type::eof();
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type
+basic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c)
+{
+ if (!traits_type::eq_int_type(__c, traits_type::eof()))
+ {
+ ptrdiff_t __ninp = this->gptr() - this->eback();
+ if (this->pptr() == this->epptr())
+ {
+ if (!(__mode_ & ios_base::out))
+ return traits_type::eof();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ ptrdiff_t __nout = this->pptr() - this->pbase();
+ ptrdiff_t __hm = __hm_ - this->pbase();
+ __str_.push_back(char_type());
+ __str_.resize(__str_.capacity());
+ char_type* __p = const_cast<char_type*>(__str_.data());
+ this->setp(__p, __p + __str_.size());
+ this->__pbump(__nout);
+ __hm_ = this->pbase() + __hm;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ return traits_type::eof();
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ }
+ __hm_ = _VSTD::max(this->pptr() + 1, __hm_);
+ if (__mode_ & ios_base::in)
+ {
+ char_type* __p = const_cast<char_type*>(__str_.data());
+ this->setg(__p, __p + __ninp, __hm_);
+ }
+ return this->sputc(traits_type::to_char_type(__c));
+ }
+ return traits_type::not_eof(__c);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+typename basic_stringbuf<_CharT, _Traits, _Allocator>::pos_type
+basic_stringbuf<_CharT, _Traits, _Allocator>::seekoff(off_type __off,
+ ios_base::seekdir __way,
+ ios_base::openmode __wch)
+{
+ if (__hm_ < this->pptr())
+ __hm_ = this->pptr();
+ if ((__wch & (ios_base::in | ios_base::out)) == 0)
+ return pos_type(-1);
+ if ((__wch & (ios_base::in | ios_base::out)) == (ios_base::in | ios_base::out)
+ && __way == ios_base::cur)
+ return pos_type(-1);
+ const ptrdiff_t __hm = __hm_ == nullptr ? 0 : __hm_ - __str_.data();
+ off_type __noff;
+ switch (__way)
+ {
+ case ios_base::beg:
+ __noff = 0;
+ break;
+ case ios_base::cur:
+ if (__wch & ios_base::in)
+ __noff = this->gptr() - this->eback();
+ else
+ __noff = this->pptr() - this->pbase();
+ break;
+ case ios_base::end:
+ __noff = __hm;
+ break;
+ default:
+ return pos_type(-1);
+ }
+ __noff += __off;
+ if (__noff < 0 || __hm < __noff)
+ return pos_type(-1);
+ if (__noff != 0)
+ {
+ if ((__wch & ios_base::in) && this->gptr() == nullptr)
+ return pos_type(-1);
+ if ((__wch & ios_base::out) && this->pptr() == nullptr)
+ return pos_type(-1);
+ }
+ if (__wch & ios_base::in)
+ this->setg(this->eback(), this->eback() + __noff, __hm_);
+ if (__wch & ios_base::out)
+ {
+ this->setp(this->pbase(), this->epptr());
+ this->pbump(__noff);
+ }
+ return pos_type(__noff);
+}
+
+// basic_istringstream
+
+template <class _CharT, class _Traits, class _Allocator>
+class _LIBCPP_TEMPLATE_VIS basic_istringstream
+ : public basic_istream<_CharT, _Traits>
+{
+public:
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+ typedef _Allocator allocator_type;
+
+ typedef basic_string<char_type, traits_type, allocator_type> string_type;
+
+private:
+ basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
+
+public:
+ // 30.8.3.1 [istringstream.cons], constructors
+ _LIBCPP_INLINE_VISIBILITY
+ 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) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit basic_istringstream(const string_type& __s,
+ ios_base::openmode __wch = ios_base::in)
+ : basic_istream<_CharT, _Traits>(&__sb_)
+ , __sb_(__s, __wch | ios_base::in)
+ { }
+
+ _LIBCPP_INLINE_VISIBILITY
+ basic_istringstream(basic_istringstream&& __rhs)
+ : basic_istream<_CharT, _Traits>(_VSTD::move(__rhs))
+ , __sb_(_VSTD::move(__rhs.__sb_))
+ {
+ basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
+ }
+
+ // 27.8.2.2 Assign and swap:
+ basic_istringstream& operator=(basic_istringstream&& __rhs) {
+ basic_istream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
+ __sb_ = _VSTD::move(__rhs.__sb_);
+ return *this;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(basic_istringstream& __rhs) {
+ basic_istream<char_type, traits_type>::swap(__rhs);
+ __sb_.swap(__rhs.__sb_);
+ }
+
+ // 27.8.2.3 Members:
+ _LIBCPP_INLINE_VISIBILITY
+ basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {
+ return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ string_type str() const {
+ return __sb_.str();
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ void str(const string_type& __s) {
+ __sb_.str(__s);
+ }
+};
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x,
+ basic_istringstream<_CharT, _Traits, _Allocator>& __y)
+{
+ __x.swap(__y);
+}
+
+// basic_ostringstream
+
+template <class _CharT, class _Traits, class _Allocator>
+class _LIBCPP_TEMPLATE_VIS basic_ostringstream
+ : public basic_ostream<_CharT, _Traits>
+{
+public:
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+ typedef _Allocator allocator_type;
+
+ typedef basic_string<char_type, traits_type, allocator_type> string_type;
+
+private:
+ basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
+
+public:
+ // 30.8.4.1 [ostringstream.cons], constructors
+ _LIBCPP_INLINE_VISIBILITY
+ 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) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit basic_ostringstream(const string_type& __s,
+ ios_base::openmode __wch = ios_base::out)
+ : basic_ostream<_CharT, _Traits>(&__sb_)
+ , __sb_(__s, __wch | ios_base::out)
+ { }
+
+ _LIBCPP_INLINE_VISIBILITY
+ basic_ostringstream(basic_ostringstream&& __rhs)
+ : basic_ostream<_CharT, _Traits>(_VSTD::move(__rhs))
+ , __sb_(_VSTD::move(__rhs.__sb_))
+ {
+ basic_ostream<_CharT, _Traits>::set_rdbuf(&__sb_);
+ }
+
+ // 27.8.2.2 Assign and swap:
+ basic_ostringstream& operator=(basic_ostringstream&& __rhs) {
+ basic_ostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
+ __sb_ = _VSTD::move(__rhs.__sb_);
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(basic_ostringstream& __rhs) {
+ basic_ostream<char_type, traits_type>::swap(__rhs);
+ __sb_.swap(__rhs.__sb_);
+ }
+
+ // 27.8.2.3 Members:
+ _LIBCPP_INLINE_VISIBILITY
+ basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {
+ return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ string_type str() const {
+ return __sb_.str();
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ void str(const string_type& __s) {
+ __sb_.str(__s);
+ }
+};
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x,
+ basic_ostringstream<_CharT, _Traits, _Allocator>& __y)
+{
+ __x.swap(__y);
+}
+
+// basic_stringstream
+
+template <class _CharT, class _Traits, class _Allocator>
+class _LIBCPP_TEMPLATE_VIS basic_stringstream
+ : public basic_iostream<_CharT, _Traits>
+{
+public:
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+ typedef _Allocator allocator_type;
+
+ typedef basic_string<char_type, traits_type, allocator_type> string_type;
+
+private:
+ basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
+
+public:
+ // 30.8.5.1 [stringstream.cons], constructors
+ _LIBCPP_INLINE_VISIBILITY
+ 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) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit basic_stringstream(const string_type& __s,
+ ios_base::openmode __wch = ios_base::in | ios_base::out)
+ : basic_iostream<_CharT, _Traits>(&__sb_)
+ , __sb_(__s, __wch)
+ { }
+
+ _LIBCPP_INLINE_VISIBILITY
+ basic_stringstream(basic_stringstream&& __rhs)
+ : basic_iostream<_CharT, _Traits>(_VSTD::move(__rhs))
+ , __sb_(_VSTD::move(__rhs.__sb_))
+ {
+ basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
+ }
+
+ // 27.8.2.2 Assign and swap:
+ basic_stringstream& operator=(basic_stringstream&& __rhs) {
+ basic_iostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
+ __sb_ = _VSTD::move(__rhs.__sb_);
+ return *this;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(basic_stringstream& __rhs) {
+ basic_iostream<char_type, traits_type>::swap(__rhs);
+ __sb_.swap(__rhs.__sb_);
+ }
+
+ // 27.8.2.3 Members:
+ _LIBCPP_INLINE_VISIBILITY
+ basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {
+ return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ string_type str() const {
+ return __sb_.str();
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ void str(const string_type& __s) {
+ __sb_.str(__s);
+ }
+};
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x,
+ basic_stringstream<_CharT, _Traits, _Allocator>& __y)
+{
+ __x.swap(__y);
+}
+
+#if defined(_LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1)
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringbuf<char>)
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringstream<char>)
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostringstream<char>)
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istringstream<char>)
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_SSTREAM
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/stack b/contrib/libs/cxxsupp/libcxxmsvc/include/stack
new file mode 100644
index 0000000000..87d85c440a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/stack
@@ -0,0 +1,357 @@
+// -*- 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_STACK
+#define _LIBCPP_STACK
+
+/*
+ stack synopsis
+
+namespace std
+{
+
+template <class T, class Container = deque<T>>
+class stack
+{
+public:
+ typedef Container container_type;
+ typedef typename container_type::value_type value_type;
+ typedef typename container_type::reference reference;
+ typedef typename container_type::const_reference const_reference;
+ typedef typename container_type::size_type size_type;
+
+protected:
+ container_type c;
+
+public:
+ stack() = default;
+ ~stack() = default;
+
+ stack(const stack& q) = default;
+ stack(stack&& q) = default;
+
+ stack& operator=(const stack& q) = default;
+ stack& operator=(stack&& q) = default;
+
+ explicit stack(const container_type& c);
+ explicit stack(container_type&& c);
+ template <class InputIterator> stack(InputIterator first, InputIterator last); // since C++23
+ template <class Alloc> explicit stack(const Alloc& a);
+ template <class Alloc> stack(const container_type& c, const Alloc& a);
+ template <class Alloc> stack(container_type&& c, const Alloc& a);
+ template <class Alloc> stack(const stack& c, const Alloc& a);
+ template <class Alloc> stack(stack&& c, const Alloc& a);
+ template<class InputIterator, class Alloc>
+ stack(InputIterator first, InputIterator last, const Alloc&); // since C++23
+
+ bool empty() const;
+ size_type size() const;
+ reference top();
+ const_reference top() const;
+
+ void push(const value_type& x);
+ void push(value_type&& x);
+ template <class... Args> reference emplace(Args&&... args); // reference in C++17
+ void pop();
+
+ void swap(stack& c) noexcept(is_nothrow_swappable_v<Container>)
+};
+
+template<class Container>
+ stack(Container) -> stack<typename Container::value_type, Container>; // C++17
+
+template<class InputIterator>
+ stack(InputIterator, InputIterator) -> stack<iter-value-type<InputIterator>>; // since C++23
+
+template<class Container, class Allocator>
+ stack(Container, Allocator) -> stack<typename Container::value_type, Container>; // C++17
+
+template<class InputIterator, class Allocator>
+ stack(InputIterator, InputIterator, Allocator)
+ -> stack<iter-value-type<InputIterator>,
+ deque<iter-value-type<InputIterator>, Allocator>>; // since C++23
+
+template <class T, class Container>
+ bool operator==(const stack<T, Container>& x, const stack<T, Container>& y);
+template <class T, class Container>
+ bool operator< (const stack<T, Container>& x, const stack<T, Container>& y);
+template <class T, class Container>
+ bool operator!=(const stack<T, Container>& x, const stack<T, Container>& y);
+template <class T, class Container>
+ bool operator> (const stack<T, Container>& x, const stack<T, Container>& y);
+template <class T, class Container>
+ bool operator>=(const stack<T, Container>& x, const stack<T, Container>& y);
+template <class T, class Container>
+ bool operator<=(const stack<T, Container>& x, const stack<T, Container>& y);
+
+template <class T, class Container>
+ void swap(stack<T, Container>& x, stack<T, Container>& y)
+ noexcept(noexcept(x.swap(y)));
+
+} // std
+
+*/
+
+#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <__memory/uses_allocator.h>
+#include <__utility/forward.h>
+#include <deque>
+#include <type_traits>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TEMPLATE_VIS stack;
+
+template <class _Tp, class _Container>
+_LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y);
+
+template <class _Tp, class _Container>
+_LIBCPP_INLINE_VISIBILITY
+bool
+operator< (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y);
+
+template <class _Tp, class _Container /*= deque<_Tp>*/>
+class _LIBCPP_TEMPLATE_VIS stack
+{
+public:
+ typedef _Container container_type;
+ typedef typename container_type::value_type value_type;
+ typedef typename container_type::reference reference;
+ typedef typename container_type::const_reference const_reference;
+ typedef typename container_type::size_type size_type;
+ static_assert((is_same<_Tp, value_type>::value), "" );
+
+protected:
+ container_type c;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ stack()
+ _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value)
+ : c() {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ stack(const stack& __q) : c(__q.c) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ stack& operator=(const stack& __q) {c = __q.c; return *this;}
+
+
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ stack(stack&& __q)
+ _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value)
+ : c(_VSTD::move(__q.c)) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ stack& operator=(stack&& __q)
+ _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value)
+ {c = _VSTD::move(__q.c); return *this;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit stack(container_type&& __c) : c(_VSTD::move(__c)) {}
+#endif // _LIBCPP_CXX03_LANG
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit stack(const container_type& __c) : c(__c) {}
+
+ template <class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY
+ explicit stack(const _Alloc& __a,
+ __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
+ : c(__a) {}
+ template <class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY
+ stack(const container_type& __c, const _Alloc& __a,
+ __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
+ : c(__c, __a) {}
+ template <class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY
+ stack(const stack& __s, const _Alloc& __a,
+ __enable_if_t<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,
+ __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
+ : c(_VSTD::move(__c), __a) {}
+ template <class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY
+ stack(stack&& __s, const _Alloc& __a,
+ __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
+ : c(_VSTD::move(__s.c), __a) {}
+#endif // _LIBCPP_CXX03_LANG
+
+#if _LIBCPP_STD_VER > 20
+ template <class _InputIterator,
+ class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>>
+ _LIBCPP_HIDE_FROM_ABI
+ stack(_InputIterator __first, _InputIterator __last) : c(__first, __last) {}
+
+ template <class _InputIterator,
+ class _Alloc,
+ class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>>
+ _LIBCPP_HIDE_FROM_ABI
+ stack(_InputIterator __first, _InputIterator __last, const _Alloc& __alloc) : c(__first, __last, __alloc) {}
+#endif
+
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+ bool empty() const {return c.empty();}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type size() const {return c.size();}
+ _LIBCPP_INLINE_VISIBILITY
+ reference top() {return c.back();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reference top() const {return c.back();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void push(const value_type& __v) {c.push_back(__v);}
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ void push(value_type&& __v) {c.push_back(_VSTD::move(__v));}
+
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+#if _LIBCPP_STD_VER > 14
+ decltype(auto) emplace(_Args&&... __args)
+ { return c.emplace_back(_VSTD::forward<_Args>(__args)...);}
+#else
+ void emplace(_Args&&... __args)
+ { c.emplace_back(_VSTD::forward<_Args>(__args)...);}
+#endif
+#endif // _LIBCPP_CXX03_LANG
+
+ _LIBCPP_INLINE_VISIBILITY
+ void pop() {c.pop_back();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(stack& __s)
+ _NOEXCEPT_(__is_nothrow_swappable<container_type>::value)
+ {
+ using _VSTD::swap;
+ swap(c, __s.c);
+ }
+
+ template <class T1, class _C1>
+ friend
+ bool
+ operator==(const stack<T1, _C1>& __x, const stack<T1, _C1>& __y);
+
+ template <class T1, class _C1>
+ friend
+ bool
+ operator< (const stack<T1, _C1>& __x, const stack<T1, _C1>& __y);
+};
+
+#if _LIBCPP_STD_VER > 14
+template<class _Container,
+ class = enable_if_t<!__is_allocator<_Container>::value>
+>
+stack(_Container)
+ -> stack<typename _Container::value_type, _Container>;
+
+template<class _Container,
+ class _Alloc,
+ class = enable_if_t<!__is_allocator<_Container>::value>,
+ class = enable_if_t<uses_allocator<_Container, _Alloc>::value>
+ >
+stack(_Container, _Alloc)
+ -> stack<typename _Container::value_type, _Container>;
+#endif
+
+#if _LIBCPP_STD_VER > 20
+template<class _InputIterator,
+ class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>>
+stack(_InputIterator, _InputIterator)
+ -> stack<__iter_value_type<_InputIterator>>;
+
+template<class _InputIterator,
+ class _Alloc,
+ class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = __enable_if_t<__is_allocator<_Alloc>::value>>
+stack(_InputIterator, _InputIterator, _Alloc)
+ -> stack<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>;
+#endif
+
+template <class _Tp, class _Container>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
+{
+ return __x.c == __y.c;
+}
+
+template <class _Tp, class _Container>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator< (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
+{
+ return __x.c < __y.c;
+}
+
+template <class _Tp, class _Container>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
+{
+ return !(__x == __y);
+}
+
+template <class _Tp, class _Container>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator> (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
+{
+ return __y < __x;
+}
+
+template <class _Tp, class _Container>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
+{
+ return !(__x < __y);
+}
+
+template <class _Tp, class _Container>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
+{
+ return !(__y < __x);
+}
+
+template <class _Tp, class _Container>
+inline _LIBCPP_INLINE_VISIBILITY
+__enable_if_t<__is_swappable<_Container>::value, void>
+swap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y)
+ _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+ __x.swap(__y);
+}
+
+template <class _Tp, class _Container, class _Alloc>
+struct _LIBCPP_TEMPLATE_VIS uses_allocator<stack<_Tp, _Container>, _Alloc>
+ : public uses_allocator<_Container, _Alloc>
+{
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STACK
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/stdatomic.h b/contrib/libs/cxxsupp/libcxxmsvc/include/stdatomic.h
new file mode 100644
index 0000000000..d9550c4406
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/stdatomic.h
@@ -0,0 +1,235 @@
+// -*- 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_STDATOMIC_H
+#define _LIBCPP_STDATOMIC_H
+
+/*
+ stdatomic.h synopsis
+
+template<class T>
+ using std-atomic = std::atomic<T>; // exposition only
+
+#define _Atomic(T) std-atomic<T>
+
+#define ATOMIC_BOOL_LOCK_FREE see below
+#define ATOMIC_CHAR_LOCK_FREE see below
+#define ATOMIC_CHAR16_T_LOCK_FREE see below
+#define ATOMIC_CHAR32_T_LOCK_FREE see below
+#define ATOMIC_WCHAR_T_LOCK_FREE see below
+#define ATOMIC_SHORT_LOCK_FREE see below
+#define ATOMIC_INT_LOCK_FREE see below
+#define ATOMIC_LONG_LOCK_FREE see below
+#define ATOMIC_LLONG_LOCK_FREE see below
+#define ATOMIC_POINTER_LOCK_FREE see below
+
+using std::memory_order // see below
+using std::memory_order_relaxed // see below
+using std::memory_order_consume // see below
+using std::memory_order_acquire // see below
+using std::memory_order_release // see below
+using std::memory_order_acq_rel // see below
+using std::memory_order_seq_cst // see below
+
+using std::atomic_flag // see below
+
+using std::atomic_bool // see below
+using std::atomic_char // see below
+using std::atomic_schar // see below
+using std::atomic_uchar // see below
+using std::atomic_short // see below
+using std::atomic_ushort // see below
+using std::atomic_int // see below
+using std::atomic_uint // see below
+using std::atomic_long // see below
+using std::atomic_ulong // see below
+using std::atomic_llong // see below
+using std::atomic_ullong // see below
+using std::atomic_char8_t // see below
+using std::atomic_char16_t // see below
+using std::atomic_char32_t // see below
+using std::atomic_wchar_t // see below
+using std::atomic_int8_t // see below
+using std::atomic_uint8_t // see below
+using std::atomic_int16_t // see below
+using std::atomic_uint16_t // see below
+using std::atomic_int32_t // see below
+using std::atomic_uint32_t // see below
+using std::atomic_int64_t // see below
+using std::atomic_uint64_t // see below
+using std::atomic_int_least8_t // see below
+using std::atomic_uint_least8_t // see below
+using std::atomic_int_least16_t // see below
+using std::atomic_uint_least16_t // see below
+using std::atomic_int_least32_t // see below
+using std::atomic_uint_least32_t // see below
+using std::atomic_int_least64_t // see below
+using std::atomic_uint_least64_t // see below
+using std::atomic_int_fast8_t // see below
+using std::atomic_uint_fast8_t // see below
+using std::atomic_int_fast16_t // see below
+using std::atomic_uint_fast16_t // see below
+using std::atomic_int_fast32_t // see below
+using std::atomic_uint_fast32_t // see below
+using std::atomic_int_fast64_t // see below
+using std::atomic_uint_fast64_t // see below
+using std::atomic_intptr_t // see below
+using std::atomic_uintptr_t // see below
+using std::atomic_size_t // see below
+using std::atomic_ptrdiff_t // see below
+using std::atomic_intmax_t // see below
+using std::atomic_uintmax_t // see below
+
+using std::atomic_is_lock_free // see below
+using std::atomic_load // see below
+using std::atomic_load_explicit // see below
+using std::atomic_store // see below
+using std::atomic_store_explicit // see below
+using std::atomic_exchange // see below
+using std::atomic_exchange_explicit // see below
+using std::atomic_compare_exchange_strong // see below
+using std::atomic_compare_exchange_strong_explicit // see below
+using std::atomic_compare_exchange_weak // see below
+using std::atomic_compare_exchange_weak_explicit // see below
+using std::atomic_fetch_add // see below
+using std::atomic_fetch_add_explicit // see below
+using std::atomic_fetch_sub // see below
+using std::atomic_fetch_sub_explicit // see below
+using std::atomic_fetch_or // see below
+using std::atomic_fetch_or_explicit // see below
+using std::atomic_fetch_and // see below
+using std::atomic_fetch_and_explicit // see below
+using std::atomic_flag_test_and_set // see below
+using std::atomic_flag_test_and_set_explicit // see below
+using std::atomic_flag_clear // see below
+using std::atomic_flag_clear_explicit // see below
+
+using std::atomic_thread_fence // see below
+using std::atomic_signal_fence // see below
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 20
+
+#include <atomic>
+#include <version>
+
+#ifdef _Atomic
+# undef _Atomic
+#endif
+
+#define _Atomic(_Tp) ::std::atomic<_Tp>
+
+using std::memory_order _LIBCPP_USING_IF_EXISTS;
+using std::memory_order_relaxed _LIBCPP_USING_IF_EXISTS;
+using std::memory_order_consume _LIBCPP_USING_IF_EXISTS;
+using std::memory_order_acquire _LIBCPP_USING_IF_EXISTS;
+using std::memory_order_release _LIBCPP_USING_IF_EXISTS;
+using std::memory_order_acq_rel _LIBCPP_USING_IF_EXISTS;
+using std::memory_order_seq_cst _LIBCPP_USING_IF_EXISTS;
+
+using std::atomic_flag _LIBCPP_USING_IF_EXISTS;
+
+using std::atomic_bool _LIBCPP_USING_IF_EXISTS;
+using std::atomic_char _LIBCPP_USING_IF_EXISTS;
+using std::atomic_schar _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uchar _LIBCPP_USING_IF_EXISTS;
+using std::atomic_short _LIBCPP_USING_IF_EXISTS;
+using std::atomic_ushort _LIBCPP_USING_IF_EXISTS;
+using std::atomic_int _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uint _LIBCPP_USING_IF_EXISTS;
+using std::atomic_long _LIBCPP_USING_IF_EXISTS;
+using std::atomic_ulong _LIBCPP_USING_IF_EXISTS;
+using std::atomic_llong _LIBCPP_USING_IF_EXISTS;
+using std::atomic_ullong _LIBCPP_USING_IF_EXISTS;
+using std::atomic_char8_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_char16_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_char32_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_wchar_t _LIBCPP_USING_IF_EXISTS;
+
+using std::atomic_int8_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uint8_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_int16_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uint16_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_int32_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uint32_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_int64_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uint64_t _LIBCPP_USING_IF_EXISTS;
+
+using std::atomic_int_least8_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uint_least8_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_int_least16_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uint_least16_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_int_least32_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uint_least32_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_int_least64_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uint_least64_t _LIBCPP_USING_IF_EXISTS;
+
+using std::atomic_int_fast8_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uint_fast8_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_int_fast16_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uint_fast16_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_int_fast32_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uint_fast32_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_int_fast64_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uint_fast64_t _LIBCPP_USING_IF_EXISTS;
+
+using std::atomic_intptr_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uintptr_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_size_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_ptrdiff_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_intmax_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uintmax_t _LIBCPP_USING_IF_EXISTS;
+
+using std::atomic_compare_exchange_strong _LIBCPP_USING_IF_EXISTS;
+using std::atomic_compare_exchange_strong_explicit _LIBCPP_USING_IF_EXISTS;
+using std::atomic_compare_exchange_weak _LIBCPP_USING_IF_EXISTS;
+using std::atomic_compare_exchange_weak_explicit _LIBCPP_USING_IF_EXISTS;
+using std::atomic_exchange _LIBCPP_USING_IF_EXISTS;
+using std::atomic_exchange_explicit _LIBCPP_USING_IF_EXISTS;
+using std::atomic_fetch_add _LIBCPP_USING_IF_EXISTS;
+using std::atomic_fetch_add_explicit _LIBCPP_USING_IF_EXISTS;
+using std::atomic_fetch_and _LIBCPP_USING_IF_EXISTS;
+using std::atomic_fetch_and_explicit _LIBCPP_USING_IF_EXISTS;
+using std::atomic_fetch_or _LIBCPP_USING_IF_EXISTS;
+using std::atomic_fetch_or_explicit _LIBCPP_USING_IF_EXISTS;
+using std::atomic_fetch_sub _LIBCPP_USING_IF_EXISTS;
+using std::atomic_fetch_sub_explicit _LIBCPP_USING_IF_EXISTS;
+using std::atomic_flag_clear _LIBCPP_USING_IF_EXISTS;
+using std::atomic_flag_clear_explicit _LIBCPP_USING_IF_EXISTS;
+using std::atomic_flag_test_and_set _LIBCPP_USING_IF_EXISTS;
+using std::atomic_flag_test_and_set_explicit _LIBCPP_USING_IF_EXISTS;
+using std::atomic_is_lock_free _LIBCPP_USING_IF_EXISTS;
+using std::atomic_load _LIBCPP_USING_IF_EXISTS;
+using std::atomic_load_explicit _LIBCPP_USING_IF_EXISTS;
+using std::atomic_store _LIBCPP_USING_IF_EXISTS;
+using std::atomic_store_explicit _LIBCPP_USING_IF_EXISTS;
+
+using std::atomic_signal_fence _LIBCPP_USING_IF_EXISTS;
+using std::atomic_thread_fence _LIBCPP_USING_IF_EXISTS;
+
+#elif defined(_LIBCPP_COMPILER_CLANG_BASED)
+
+// Before C++23, we include the next <stdatomic.h> on the path to avoid hijacking
+// the header. We do this because Clang has historically shipped a <stdatomic.h>
+// header that would be available in all Standard modes, and we don't want to
+// break that use case.
+# if __has_include_next(<stdatomic.h>)
+# include_next <stdatomic.h>
+# endif
+
+#endif // _LIBCPP_STD_VER > 20
+
+#endif // _LIBCPP_STDATOMIC_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/stdbool.h b/contrib/libs/cxxsupp/libcxxmsvc/include/stdbool.h
new file mode 100644
index 0000000000..c596f2441c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/stdbool.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_STDBOOL_H
+#define _LIBCPP_STDBOOL_H
+
+
+/*
+ stdbool.h synopsis
+
+Macros:
+
+ __bool_true_false_are_defined
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#include Y_MSVC_INCLUDE_NEXT(stdbool.h)
+#else
+#include_next <stdbool.h>
+#endif
+
+#ifdef __cplusplus
+#undef bool
+#undef true
+#undef false
+#undef __bool_true_false_are_defined
+#define __bool_true_false_are_defined 1
+#endif
+
+#endif // _LIBCPP_STDBOOL_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/stddef.h b/contrib/libs/cxxsupp/libcxxmsvc/include/stddef.h
new file mode 100644
index 0000000000..7b2c6464e5
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/stddef.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
+//
+//===----------------------------------------------------------------------===//
+
+#if defined(__need_ptrdiff_t) || defined(__need_size_t) || \
+ defined(__need_wchar_t) || defined(__need_NULL) || defined(__need_wint_t)
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#include Y_UCRT_INCLUDE_NEXT(stddef.h)
+#else
+#include_next <stddef.h>
+#endif
+
+#elif !defined(_LIBCPP_STDDEF_H)
+#define _LIBCPP_STDDEF_H
+
+/*
+ stddef.h synopsis
+
+Macros:
+
+ offsetof(type,member-designator)
+ NULL
+
+Types:
+
+ ptrdiff_t
+ size_t
+ max_align_t // C++11
+ nullptr_t
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#include Y_UCRT_INCLUDE_NEXT(stddef.h)
+typedef double max_align_t;
+#else
+#include_next <stddef.h>
+#endif
+
+#ifdef __cplusplus
+ typedef decltype(nullptr) nullptr_t;
+#endif
+
+#endif // _LIBCPP_STDDEF_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/stdexcept b/contrib/libs/cxxsupp/libcxxmsvc/include/stdexcept
new file mode 100644
index 0000000000..f6dcf5ffea
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/stdexcept
@@ -0,0 +1,309 @@
+// -*- 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_STDEXCEPT
+#define _LIBCPP_STDEXCEPT
+
+/*
+ stdexcept synopsis
+
+namespace std
+{
+
+class logic_error;
+ class domain_error;
+ class invalid_argument;
+ class length_error;
+ class out_of_range;
+class runtime_error;
+ class range_error;
+ class overflow_error;
+ class underflow_error;
+
+for each class xxx_error:
+
+class xxx_error : public exception // at least indirectly
+{
+public:
+ explicit xxx_error(const string& what_arg);
+ explicit xxx_error(const char* what_arg);
+
+ virtual const char* what() const noexcept // returns what_arg
+};
+
+} // std
+
+*/
+
+#include <__config>
+#include <cstdlib>
+#include <exception>
+#include <iosfwd> // for string forward decl
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifndef _LIBCPP_ABI_VCRUNTIME
+class _LIBCPP_HIDDEN __libcpp_refstring
+{
+ const char* __imp_;
+
+ bool __uses_refcount() const;
+public:
+ explicit __libcpp_refstring(const char* __msg);
+ __libcpp_refstring(const __libcpp_refstring& __s) _NOEXCEPT;
+ __libcpp_refstring& operator=(const __libcpp_refstring& __s) _NOEXCEPT;
+ ~__libcpp_refstring();
+
+ const char* c_str() const _NOEXCEPT {return __imp_;}
+};
+#endif // !_LIBCPP_ABI_VCRUNTIME
+
+_LIBCPP_END_NAMESPACE_STD
+
+namespace std // purposefully not using versioning namespace
+{
+
+class _LIBCPP_EXCEPTION_ABI logic_error
+ : public exception
+{
+#ifndef _LIBCPP_ABI_VCRUNTIME
+private:
+ _VSTD::__libcpp_refstring __imp_;
+public:
+ explicit logic_error(const string&);
+ explicit logic_error(const char*);
+
+ logic_error(const logic_error&) _NOEXCEPT;
+ logic_error& operator=(const logic_error&) _NOEXCEPT;
+
+ virtual ~logic_error() _NOEXCEPT;
+
+ virtual const char* what() const _NOEXCEPT;
+#else
+public:
+ explicit logic_error(const _VSTD::string&); // Symbol uses versioned std::string
+ _LIBCPP_INLINE_VISIBILITY explicit logic_error(const char* __s) : exception(__s) {}
+#endif
+};
+
+class _LIBCPP_EXCEPTION_ABI runtime_error
+ : public exception
+{
+#ifndef _LIBCPP_ABI_VCRUNTIME
+private:
+ _VSTD::__libcpp_refstring __imp_;
+public:
+ explicit runtime_error(const string&);
+ explicit runtime_error(const char*);
+
+ runtime_error(const runtime_error&) _NOEXCEPT;
+ runtime_error& operator=(const runtime_error&) _NOEXCEPT;
+
+ virtual ~runtime_error() _NOEXCEPT;
+
+ virtual const char* what() const _NOEXCEPT;
+#else
+public:
+ explicit runtime_error(const _VSTD::string&); // Symbol uses versioned std::string
+ _LIBCPP_INLINE_VISIBILITY explicit runtime_error(const char* __s) : exception(__s) {}
+#endif // _LIBCPP_ABI_VCRUNTIME
+};
+
+class _LIBCPP_EXCEPTION_ABI domain_error
+ : public logic_error
+{
+public:
+ _LIBCPP_INLINE_VISIBILITY explicit domain_error(const string& __s) : logic_error(__s) {}
+ _LIBCPP_INLINE_VISIBILITY explicit domain_error(const char* __s) : logic_error(__s) {}
+
+#ifndef _LIBCPP_ABI_VCRUNTIME
+ domain_error(const domain_error&) _NOEXCEPT = default;
+ virtual ~domain_error() _NOEXCEPT;
+#endif
+};
+
+class _LIBCPP_EXCEPTION_ABI invalid_argument
+ : public logic_error
+{
+public:
+ _LIBCPP_INLINE_VISIBILITY explicit invalid_argument(const string& __s) : logic_error(__s) {}
+ _LIBCPP_INLINE_VISIBILITY explicit invalid_argument(const char* __s) : logic_error(__s) {}
+
+#ifndef _LIBCPP_ABI_VCRUNTIME
+ invalid_argument(const invalid_argument&) _NOEXCEPT = default;
+ virtual ~invalid_argument() _NOEXCEPT;
+#endif
+};
+
+class _LIBCPP_EXCEPTION_ABI length_error
+ : public logic_error
+{
+public:
+ _LIBCPP_INLINE_VISIBILITY explicit length_error(const string& __s) : logic_error(__s) {}
+ _LIBCPP_INLINE_VISIBILITY explicit length_error(const char* __s) : logic_error(__s) {}
+#ifndef _LIBCPP_ABI_VCRUNTIME
+ length_error(const length_error&) _NOEXCEPT = default;
+ virtual ~length_error() _NOEXCEPT;
+#endif
+};
+
+class _LIBCPP_EXCEPTION_ABI out_of_range
+ : public logic_error
+{
+public:
+ _LIBCPP_INLINE_VISIBILITY explicit out_of_range(const string& __s) : logic_error(__s) {}
+ _LIBCPP_INLINE_VISIBILITY explicit out_of_range(const char* __s) : logic_error(__s) {}
+
+#ifndef _LIBCPP_ABI_VCRUNTIME
+ out_of_range(const out_of_range&) _NOEXCEPT = default;
+ virtual ~out_of_range() _NOEXCEPT;
+#endif
+};
+
+class _LIBCPP_EXCEPTION_ABI range_error
+ : public runtime_error
+{
+public:
+ _LIBCPP_INLINE_VISIBILITY explicit range_error(const string& __s) : runtime_error(__s) {}
+ _LIBCPP_INLINE_VISIBILITY explicit range_error(const char* __s) : runtime_error(__s) {}
+
+#ifndef _LIBCPP_ABI_VCRUNTIME
+ range_error(const range_error&) _NOEXCEPT = default;
+ virtual ~range_error() _NOEXCEPT;
+#endif
+};
+
+class _LIBCPP_EXCEPTION_ABI overflow_error
+ : public runtime_error
+{
+public:
+ _LIBCPP_INLINE_VISIBILITY explicit overflow_error(const string& __s) : runtime_error(__s) {}
+ _LIBCPP_INLINE_VISIBILITY explicit overflow_error(const char* __s) : runtime_error(__s) {}
+
+#ifndef _LIBCPP_ABI_VCRUNTIME
+ overflow_error(const overflow_error&) _NOEXCEPT = default;
+ virtual ~overflow_error() _NOEXCEPT;
+#endif
+};
+
+class _LIBCPP_EXCEPTION_ABI underflow_error
+ : public runtime_error
+{
+public:
+ _LIBCPP_INLINE_VISIBILITY explicit underflow_error(const string& __s) : runtime_error(__s) {}
+ _LIBCPP_INLINE_VISIBILITY explicit underflow_error(const char* __s) : runtime_error(__s) {}
+
+#ifndef _LIBCPP_ABI_VCRUNTIME
+ underflow_error(const underflow_error&) _NOEXCEPT = default;
+ virtual ~underflow_error() _NOEXCEPT;
+#endif
+};
+
+} // namespace std
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// in the dylib
+_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __throw_runtime_error(const char*);
+
+_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
+void __throw_logic_error(const char*__msg)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw logic_error(__msg);
+#else
+ ((void)__msg);
+ _VSTD::abort();
+#endif
+}
+
+_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
+void __throw_domain_error(const char*__msg)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw domain_error(__msg);
+#else
+ ((void)__msg);
+ _VSTD::abort();
+#endif
+}
+
+_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
+void __throw_invalid_argument(const char*__msg)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw invalid_argument(__msg);
+#else
+ ((void)__msg);
+ _VSTD::abort();
+#endif
+}
+
+_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
+void __throw_length_error(const char*__msg)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw length_error(__msg);
+#else
+ ((void)__msg);
+ _VSTD::abort();
+#endif
+}
+
+_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
+void __throw_out_of_range(const char*__msg)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw out_of_range(__msg);
+#else
+ ((void)__msg);
+ _VSTD::abort();
+#endif
+}
+
+_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
+void __throw_range_error(const char*__msg)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw range_error(__msg);
+#else
+ ((void)__msg);
+ _VSTD::abort();
+#endif
+}
+
+_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
+void __throw_overflow_error(const char*__msg)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw overflow_error(__msg);
+#else
+ ((void)__msg);
+ _VSTD::abort();
+#endif
+}
+
+_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
+void __throw_underflow_error(const char*__msg)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw underflow_error(__msg);
+#else
+ ((void)__msg);
+ _VSTD::abort();
+#endif
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STDEXCEPT
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/stdint.h b/contrib/libs/cxxsupp/libcxxmsvc/include/stdint.h
new file mode 100644
index 0000000000..c9342a388e
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/stdint.h
@@ -0,0 +1,129 @@
+// -*- 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_STDINT_H
+// AIX system headers need stdint.h to be re-enterable while _STD_TYPES_T
+// is defined until an inclusion of it without _STD_TYPES_T occurs, in which
+// case the header guard macro is defined.
+#if !defined(_AIX) || !defined(_STD_TYPES_T)
+#define _LIBCPP_STDINT_H
+#endif // _STD_TYPES_T
+
+/*
+ stdint.h synopsis
+
+Macros:
+
+ INT8_MIN
+ INT16_MIN
+ INT32_MIN
+ INT64_MIN
+
+ INT8_MAX
+ INT16_MAX
+ INT32_MAX
+ INT64_MAX
+
+ UINT8_MAX
+ UINT16_MAX
+ UINT32_MAX
+ UINT64_MAX
+
+ INT_LEAST8_MIN
+ INT_LEAST16_MIN
+ INT_LEAST32_MIN
+ INT_LEAST64_MIN
+
+ INT_LEAST8_MAX
+ INT_LEAST16_MAX
+ INT_LEAST32_MAX
+ INT_LEAST64_MAX
+
+ UINT_LEAST8_MAX
+ UINT_LEAST16_MAX
+ UINT_LEAST32_MAX
+ UINT_LEAST64_MAX
+
+ INT_FAST8_MIN
+ INT_FAST16_MIN
+ INT_FAST32_MIN
+ INT_FAST64_MIN
+
+ INT_FAST8_MAX
+ INT_FAST16_MAX
+ INT_FAST32_MAX
+ INT_FAST64_MAX
+
+ UINT_FAST8_MAX
+ UINT_FAST16_MAX
+ UINT_FAST32_MAX
+ UINT_FAST64_MAX
+
+ INTPTR_MIN
+ INTPTR_MAX
+ UINTPTR_MAX
+
+ INTMAX_MIN
+ INTMAX_MAX
+
+ UINTMAX_MAX
+
+ PTRDIFF_MIN
+ PTRDIFF_MAX
+
+ SIG_ATOMIC_MIN
+ SIG_ATOMIC_MAX
+
+ SIZE_MAX
+
+ WCHAR_MIN
+ WCHAR_MAX
+
+ WINT_MIN
+ WINT_MAX
+
+ INT8_C(value)
+ INT16_C(value)
+ INT32_C(value)
+ INT64_C(value)
+
+ UINT8_C(value)
+ UINT16_C(value)
+ UINT32_C(value)
+ UINT64_C(value)
+
+ INTMAX_C(value)
+ UINTMAX_C(value)
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+/* C99 stdlib (e.g. glibc < 2.18) does not provide macros needed
+ for C++11 unless __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS
+ are defined
+*/
+#if defined(__cplusplus) && !defined(__STDC_LIMIT_MACROS)
+# define __STDC_LIMIT_MACROS
+#endif
+#if defined(__cplusplus) && !defined(__STDC_CONSTANT_MACROS)
+# define __STDC_CONSTANT_MACROS
+#endif
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#include Y_MSVC_INCLUDE_NEXT(stdint.h)
+#else
+#include_next <stdint.h>
+#endif
+
+#endif // _LIBCPP_STDINT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/stdio.h b/contrib/libs/cxxsupp/libcxxmsvc/include/stdio.h
new file mode 100644
index 0000000000..d0ffec5fb0
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/stdio.h
@@ -0,0 +1,127 @@
+// -*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#if defined(__need_FILE) || defined(__need___FILE)
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#include Y_UCRT_INCLUDE_NEXT(stdio.h)
+#else
+#include_next <stdio.h>
+#endif
+
+#elif !defined(_LIBCPP_STDIO_H)
+#define _LIBCPP_STDIO_H
+
+/*
+ stdio.h synopsis
+
+Macros:
+
+ BUFSIZ
+ EOF
+ FILENAME_MAX
+ FOPEN_MAX
+ L_tmpnam
+ NULL
+ SEEK_CUR
+ SEEK_END
+ SEEK_SET
+ TMP_MAX
+ _IOFBF
+ _IOLBF
+ _IONBF
+ stderr
+ stdin
+ stdout
+
+Types:
+
+FILE
+fpos_t
+size_t
+
+int remove(const char* filename);
+int rename(const char* old, const char* new);
+FILE* tmpfile(void);
+char* tmpnam(char* s);
+int fclose(FILE* stream);
+int fflush(FILE* stream);
+FILE* fopen(const char* restrict filename, const char* restrict mode);
+FILE* freopen(const char* restrict filename, const char * restrict mode,
+ FILE * restrict stream);
+void setbuf(FILE* restrict stream, char* restrict buf);
+int setvbuf(FILE* restrict stream, char* restrict buf, int mode, size_t size);
+int fprintf(FILE* restrict stream, const char* restrict format, ...);
+int fscanf(FILE* restrict stream, const char * restrict format, ...);
+int printf(const char* restrict format, ...);
+int scanf(const char* restrict format, ...);
+int snprintf(char* restrict s, size_t n, const char* restrict format, ...); // C99
+int sprintf(char* restrict s, const char* restrict format, ...);
+int sscanf(const char* restrict s, const char* restrict format, ...);
+int vfprintf(FILE* restrict stream, const char* restrict format, va_list arg);
+int vfscanf(FILE* restrict stream, const char* restrict format, va_list arg); // C99
+int vprintf(const char* restrict format, va_list arg);
+int vscanf(const char* restrict format, va_list arg); // C99
+int vsnprintf(char* restrict s, size_t n, const char* restrict format, // C99
+ va_list arg);
+int vsprintf(char* restrict s, const char* restrict format, va_list arg);
+int vsscanf(const char* restrict s, const char* restrict format, va_list arg); // C99
+int fgetc(FILE* stream);
+char* fgets(char* restrict s, int n, FILE* restrict stream);
+int fputc(int c, FILE* stream);
+int fputs(const char* restrict s, FILE* restrict stream);
+int getc(FILE* stream);
+int getchar(void);
+char* gets(char* s); // removed in C++14
+int putc(int c, FILE* stream);
+int putchar(int c);
+int puts(const char* s);
+int ungetc(int c, FILE* stream);
+size_t fread(void* restrict ptr, size_t size, size_t nmemb,
+ FILE* restrict stream);
+size_t fwrite(const void* restrict ptr, size_t size, size_t nmemb,
+ FILE* restrict stream);
+int fgetpos(FILE* restrict stream, fpos_t* restrict pos);
+int fseek(FILE* stream, long offset, int whence);
+int fsetpos(FILE*stream, const fpos_t* pos);
+long ftell(FILE* stream);
+void rewind(FILE* stream);
+void clearerr(FILE* stream);
+int feof(FILE* stream);
+int ferror(FILE* stream);
+void perror(const char* s);
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#include Y_UCRT_INCLUDE_NEXT(stdio.h)
+#else
+#include_next <stdio.h>
+#endif
+
+#ifdef __cplusplus
+
+#undef getc
+#undef putc
+#undef clearerr
+#undef feof
+#undef ferror
+
+#endif
+
+#endif // _LIBCPP_STDIO_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/stdlib.h b/contrib/libs/cxxsupp/libcxxmsvc/include/stdlib.h
new file mode 100644
index 0000000000..a5c4986a6a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/stdlib.h
@@ -0,0 +1,190 @@
+// -*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#if defined(__need_malloc_and_calloc)
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#include Y_UCRT_INCLUDE_NEXT(stdlib.h)
+#else
+#include_next <stdlib.h>
+#endif
+
+#elif !defined(_LIBCPP_STDLIB_H)
+#define _LIBCPP_STDLIB_H
+
+/*
+ stdlib.h synopsis
+
+Macros:
+
+ EXIT_FAILURE
+ EXIT_SUCCESS
+ MB_CUR_MAX
+ NULL
+ RAND_MAX
+
+Types:
+
+ size_t
+ div_t
+ ldiv_t
+ lldiv_t // C99
+
+double atof (const char* nptr);
+int atoi (const char* nptr);
+long atol (const char* nptr);
+long long atoll(const char* nptr); // C99
+double strtod (const char* restrict nptr, char** restrict endptr);
+float strtof (const char* restrict nptr, char** restrict endptr); // C99
+long double strtold (const char* restrict nptr, char** restrict endptr); // C99
+long strtol (const char* restrict nptr, char** restrict endptr, int base);
+long long strtoll (const char* restrict nptr, char** restrict endptr, int base); // C99
+unsigned long strtoul (const char* restrict nptr, char** restrict endptr, int base);
+unsigned long long strtoull(const char* restrict nptr, char** restrict endptr, int base); // C99
+int rand(void);
+void srand(unsigned int seed);
+void* calloc(size_t nmemb, size_t size);
+void free(void* ptr);
+void* malloc(size_t size);
+void* realloc(void* ptr, size_t size);
+void abort(void);
+int atexit(void (*func)(void));
+void exit(int status);
+void _Exit(int status);
+char* getenv(const char* name);
+int system(const char* string);
+void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
+ int (*compar)(const void *, const void *));
+void qsort(void* base, size_t nmemb, size_t size,
+ int (*compar)(const void *, const void *));
+int abs( int j);
+long abs( long j);
+long long abs(long long j); // C++0X
+long labs( long j);
+long long llabs(long long j); // C99
+div_t div( int numer, int denom);
+ldiv_t div( long numer, long denom);
+lldiv_t div(long long numer, long long denom); // C++0X
+ldiv_t ldiv( long numer, long denom);
+lldiv_t lldiv(long long numer, long long denom); // C99
+int mblen(const char* s, size_t n);
+int mbtowc(wchar_t* restrict pwc, const char* restrict s, size_t n);
+int wctomb(char* s, wchar_t wchar);
+size_t mbstowcs(wchar_t* restrict pwcs, const char* restrict s, size_t n);
+size_t wcstombs(char* restrict s, const wchar_t* restrict pwcs, size_t n);
+int at_quick_exit(void (*func)(void)) // C++11
+void quick_exit(int status); // C++11
+void *aligned_alloc(size_t alignment, size_t size); // C11
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#include Y_UCRT_INCLUDE_NEXT(stdlib.h)
+#ifdef __cplusplus
+extern "C" {
+#endif
+float fabsf(float);
+double fabs(double);
+long double fabsl(long double);
+#ifdef __cplusplus
+}
+#endif
+#else
+#include_next <stdlib.h>
+#endif
+
+#ifdef __cplusplus
+extern "C++" {
+// abs
+
+#ifdef abs
+# undef abs
+#endif
+#ifdef labs
+# undef labs
+#endif
+#ifdef llabs
+# undef llabs
+#endif
+
+// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined
+#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__)
+inline _LIBCPP_INLINE_VISIBILITY long abs(long __x) _NOEXCEPT {
+ return __builtin_labs(__x);
+}
+inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {
+ return __builtin_llabs(__x);
+}
+#endif // !defined(_LIBCPP_MSVCRT) && !defined(__sun__)
+
+#if !defined(__sun__)
+inline _LIBCPP_INLINE_VISIBILITY float abs(float __lcpp_x) _NOEXCEPT {
+#ifdef _LIBCPP_COMPILER_MSVC
+ return fabsf(__lcpp_x);
+#else
+ return __builtin_fabsf(__lcpp_x); // Use builtins to prevent needing math.h
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY double abs(double __lcpp_x) _NOEXCEPT {
+#ifdef _LIBCPP_COMPILER_MSVC
+ return fabs(__lcpp_x);
+#else
+ return __builtin_fabs(__lcpp_x);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY long double
+abs(long double __lcpp_x) _NOEXCEPT {
+#ifdef _LIBCPP_COMPILER_MSVC
+ return fabsl(__lcpp_x);
+#else
+ return __builtin_fabsl(__lcpp_x);
+#endif
+}
+#endif // !defined(__sun__)
+
+// div
+
+#ifdef div
+# undef div
+#endif
+#ifdef ldiv
+# undef ldiv
+#endif
+#ifdef lldiv
+# undef lldiv
+#endif
+
+// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined
+#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__)
+inline _LIBCPP_INLINE_VISIBILITY ldiv_t div(long __x, long __y) _NOEXCEPT {
+ return ::ldiv(__x, __y);
+}
+#if !(defined(__FreeBSD__) && !defined(__LONG_LONG_SUPPORTED))
+inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x,
+ long long __y) _NOEXCEPT {
+ return ::lldiv(__x, __y);
+}
+#endif
+#endif // _LIBCPP_MSVCRT / __sun__
+} // extern "C++"
+#endif // __cplusplus
+
+#endif // _LIBCPP_STDLIB_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/stlfwd b/contrib/libs/cxxsupp/libcxxmsvc/include/stlfwd
new file mode 100644
index 0000000000..adad6790dc
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/stlfwd
@@ -0,0 +1,63 @@
+#pragma once
+
+#include <__config>
+#include <cstddef>
+#include <iosfwd>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+ template <class F, class S>
+ struct pair;
+
+ template <class T, size_t N>
+ struct array;
+
+ template <class T, class A>
+ class vector;
+
+ template <class T, class A>
+ class list;
+
+ template <class T, class A>
+ class deque;
+
+ template <class T, class C, class A>
+ class set;
+
+ template <class T, class C, class A>
+ class multiset;
+
+ template <class K, class V, class C, class A>
+ class map;
+
+ template <class K, class V, class C, class A>
+ class multimap;
+
+ template <typename... TArgs>
+ class tuple;
+
+ constexpr void get(...) = delete;
+
+ template <class>
+ class _LIBCPP_TEMPLATE_VIS function;
+
+ template <class _Tp>
+ struct _LIBCPP_TEMPLATE_VIS default_delete;
+
+ template <class _Tp, class Deleter = default_delete<_Tp>>
+ class _LIBCPP_TEMPLATE_VIS unique_ptr;
+
+ template <class T>
+ class _LIBCPP_TEMPLATE_VIS shared_ptr;
+
+ /* basic_string is already forward-declared in <iosfwd> */
+
+ template<class T, class Traits>
+ class basic_string_view;
+
+_LIBCPP_END_NAMESPACE_STD
+
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/streambuf b/contrib/libs/cxxsupp/libcxxmsvc/include/streambuf
new file mode 100644
index 0000000000..abcdfe2e2f
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/streambuf
@@ -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_STREAMBUF
+#define _LIBCPP_STREAMBUF
+
+/*
+ streambuf synopsis
+
+namespace std
+{
+
+template <class charT, class traits = char_traits<charT> >
+class basic_streambuf
+{
+public:
+ // types:
+ typedef charT char_type;
+ typedef traits traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+
+ virtual ~basic_streambuf();
+
+ // 27.6.2.2.1 locales:
+ locale pubimbue(const locale& loc);
+ locale getloc() const;
+
+ // 27.6.2.2.2 buffer and positioning:
+ basic_streambuf* pubsetbuf(char_type* s, streamsize n);
+ pos_type pubseekoff(off_type off, ios_base::seekdir way,
+ ios_base::openmode which = ios_base::in | ios_base::out);
+ pos_type pubseekpos(pos_type sp,
+ ios_base::openmode which = ios_base::in | ios_base::out);
+ int pubsync();
+
+ // Get and put areas:
+ // 27.6.2.2.3 Get area:
+ streamsize in_avail();
+ int_type snextc();
+ int_type sbumpc();
+ int_type sgetc();
+ streamsize sgetn(char_type* s, streamsize n);
+
+ // 27.6.2.2.4 Putback:
+ int_type sputbackc(char_type c);
+ int_type sungetc();
+
+ // 27.6.2.2.5 Put area:
+ int_type sputc(char_type c);
+ streamsize sputn(const char_type* s, streamsize n);
+
+protected:
+ basic_streambuf();
+ basic_streambuf(const basic_streambuf& rhs);
+ basic_streambuf& operator=(const basic_streambuf& rhs);
+ void swap(basic_streambuf& rhs);
+
+ // 27.6.2.3.2 Get area:
+ char_type* eback() const;
+ char_type* gptr() const;
+ char_type* egptr() const;
+ void gbump(int n);
+ void setg(char_type* gbeg, char_type* gnext, char_type* gend);
+
+ // 27.6.2.3.3 Put area:
+ char_type* pbase() const;
+ char_type* pptr() const;
+ char_type* epptr() const;
+ void pbump(int n);
+ void setp(char_type* pbeg, char_type* pend);
+
+ // 27.6.2.4 virtual functions:
+ // 27.6.2.4.1 Locales:
+ virtual void imbue(const locale& loc);
+
+ // 27.6.2.4.2 Buffer management and positioning:
+ virtual basic_streambuf* setbuf(char_type* s, streamsize n);
+ virtual pos_type seekoff(off_type off, ios_base::seekdir way,
+ ios_base::openmode which = ios_base::in | ios_base::out);
+ virtual pos_type seekpos(pos_type sp,
+ ios_base::openmode which = ios_base::in | ios_base::out);
+ virtual int sync();
+
+ // 27.6.2.4.3 Get area:
+ virtual streamsize showmanyc();
+ virtual streamsize xsgetn(char_type* s, streamsize n);
+ virtual int_type underflow();
+ virtual int_type uflow();
+
+ // 27.6.2.4.4 Putback:
+ virtual int_type pbackfail(int_type c = traits_type::eof());
+
+ // 27.6.2.4.5 Put area:
+ virtual streamsize xsputn(const char_type* s, streamsize n);
+ virtual int_type overflow (int_type c = traits_type::eof());
+};
+
+} // std
+
+*/
+
+#include <__config>
+#include <cstdint>
+#include <ios>
+#include <iosfwd>
+#include <version>
+
+#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 _CharT, class _Traits>
+class _LIBCPP_TEMPLATE_VIS basic_streambuf
+{
+public:
+ // types:
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+
+ static_assert((is_same<_CharT, typename traits_type::char_type>::value),
+ "traits_type::char_type must be the same type as CharT");
+
+ virtual ~basic_streambuf();
+
+ // 27.6.2.2.1 locales:
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ locale pubimbue(const locale& __loc) {
+ imbue(__loc);
+ locale __r = __loc_;
+ __loc_ = __loc;
+ return __r;
+ }
+
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ locale getloc() const { return __loc_; }
+
+ // 27.6.2.2.2 buffer and positioning:
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ basic_streambuf* pubsetbuf(char_type* __s, streamsize __n)
+ { return setbuf(__s, __n); }
+
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ pos_type pubseekoff(off_type __off, ios_base::seekdir __way,
+ ios_base::openmode __which = ios_base::in | ios_base::out)
+ { return seekoff(__off, __way, __which); }
+
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ pos_type pubseekpos(pos_type __sp,
+ ios_base::openmode __which = ios_base::in | ios_base::out)
+ { return seekpos(__sp, __which); }
+
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ int pubsync() { return sync(); }
+
+ // Get and put areas:
+ // 27.6.2.2.3 Get area:
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ streamsize in_avail() {
+ if (__ninp_ < __einp_)
+ return static_cast<streamsize>(__einp_ - __ninp_);
+ return showmanyc();
+ }
+
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ int_type snextc() {
+ if (sbumpc() == traits_type::eof())
+ return traits_type::eof();
+ return sgetc();
+ }
+
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ int_type sbumpc() {
+ if (__ninp_ == __einp_)
+ return uflow();
+ return traits_type::to_int_type(*__ninp_++);
+ }
+
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ int_type sgetc() {
+ if (__ninp_ == __einp_)
+ return underflow();
+ return traits_type::to_int_type(*__ninp_);
+ }
+
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ streamsize sgetn(char_type* __s, streamsize __n)
+ { return xsgetn(__s, __n); }
+
+ // 27.6.2.2.4 Putback:
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ int_type sputbackc(char_type __c) {
+ if (__binp_ == __ninp_ || !traits_type::eq(__c, __ninp_[-1]))
+ return pbackfail(traits_type::to_int_type(__c));
+ return traits_type::to_int_type(*--__ninp_);
+ }
+
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ int_type sungetc() {
+ if (__binp_ == __ninp_)
+ return pbackfail();
+ return traits_type::to_int_type(*--__ninp_);
+ }
+
+ // 27.6.2.2.5 Put area:
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ int_type sputc(char_type __c) {
+ if (__nout_ == __eout_)
+ return overflow(traits_type::to_int_type(__c));
+ *__nout_++ = __c;
+ return traits_type::to_int_type(__c);
+ }
+
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ streamsize sputn(const char_type* __s, streamsize __n)
+ { return xsputn(__s, __n); }
+
+protected:
+ basic_streambuf();
+ basic_streambuf(const basic_streambuf& __rhs);
+ basic_streambuf& operator=(const basic_streambuf& __rhs);
+ void swap(basic_streambuf& __rhs);
+
+ // 27.6.2.3.2 Get area:
+ _LIBCPP_INLINE_VISIBILITY char_type* eback() const {return __binp_;}
+ _LIBCPP_INLINE_VISIBILITY char_type* gptr() const {return __ninp_;}
+ _LIBCPP_INLINE_VISIBILITY char_type* egptr() const {return __einp_;}
+
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ void gbump(int __n) { __ninp_ += __n; }
+
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ void setg(char_type* __gbeg, char_type* __gnext, char_type* __gend) {
+ __binp_ = __gbeg;
+ __ninp_ = __gnext;
+ __einp_ = __gend;
+ }
+
+ // 27.6.2.3.3 Put area:
+ _LIBCPP_INLINE_VISIBILITY char_type* pbase() const {return __bout_;}
+ _LIBCPP_INLINE_VISIBILITY char_type* pptr() const {return __nout_;}
+ _LIBCPP_INLINE_VISIBILITY char_type* epptr() const {return __eout_;}
+
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ void pbump(int __n) { __nout_ += __n; }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __pbump(streamsize __n) { __nout_ += __n; }
+
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ void setp(char_type* __pbeg, char_type* __pend) {
+ __bout_ = __nout_ = __pbeg;
+ __eout_ = __pend;
+ }
+
+ // 27.6.2.4 virtual functions:
+ // 27.6.2.4.1 Locales:
+ virtual void imbue(const locale& __loc);
+
+ // 27.6.2.4.2 Buffer management and positioning:
+ virtual basic_streambuf* setbuf(char_type* __s, streamsize __n);
+ virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,
+ ios_base::openmode __which = ios_base::in | ios_base::out);
+ virtual pos_type seekpos(pos_type __sp,
+ ios_base::openmode __which = ios_base::in | ios_base::out);
+ virtual int sync();
+
+ // 27.6.2.4.3 Get area:
+ virtual streamsize showmanyc();
+ virtual streamsize xsgetn(char_type* __s, streamsize __n);
+ virtual int_type underflow();
+ virtual int_type uflow();
+
+ // 27.6.2.4.4 Putback:
+ virtual int_type pbackfail(int_type __c = traits_type::eof());
+
+ // 27.6.2.4.5 Put area:
+ virtual streamsize xsputn(const char_type* __s, streamsize __n);
+ virtual int_type overflow(int_type __c = traits_type::eof());
+
+private:
+ locale __loc_;
+ char_type* __binp_;
+ char_type* __ninp_;
+ char_type* __einp_;
+ char_type* __bout_;
+ char_type* __nout_;
+ char_type* __eout_;
+};
+
+template <class _CharT, class _Traits>
+basic_streambuf<_CharT, _Traits>::~basic_streambuf()
+{
+}
+
+template <class _CharT, class _Traits>
+basic_streambuf<_CharT, _Traits>::basic_streambuf()
+ : __binp_(nullptr),
+ __ninp_(nullptr),
+ __einp_(nullptr),
+ __bout_(nullptr),
+ __nout_(nullptr),
+ __eout_(nullptr)
+{
+}
+
+template <class _CharT, class _Traits>
+basic_streambuf<_CharT, _Traits>::basic_streambuf(const basic_streambuf& __sb)
+ : __loc_(__sb.__loc_),
+ __binp_(__sb.__binp_),
+ __ninp_(__sb.__ninp_),
+ __einp_(__sb.__einp_),
+ __bout_(__sb.__bout_),
+ __nout_(__sb.__nout_),
+ __eout_(__sb.__eout_)
+{
+}
+
+template <class _CharT, class _Traits>
+basic_streambuf<_CharT, _Traits>&
+basic_streambuf<_CharT, _Traits>::operator=(const basic_streambuf& __sb)
+{
+ __loc_ = __sb.__loc_;
+ __binp_ = __sb.__binp_;
+ __ninp_ = __sb.__ninp_;
+ __einp_ = __sb.__einp_;
+ __bout_ = __sb.__bout_;
+ __nout_ = __sb.__nout_;
+ __eout_ = __sb.__eout_;
+ return *this;
+}
+
+template <class _CharT, class _Traits>
+void
+basic_streambuf<_CharT, _Traits>::swap(basic_streambuf& __sb)
+{
+ _VSTD::swap(__loc_, __sb.__loc_);
+ _VSTD::swap(__binp_, __sb.__binp_);
+ _VSTD::swap(__ninp_, __sb.__ninp_);
+ _VSTD::swap(__einp_, __sb.__einp_);
+ _VSTD::swap(__bout_, __sb.__bout_);
+ _VSTD::swap(__nout_, __sb.__nout_);
+ _VSTD::swap(__eout_, __sb.__eout_);
+}
+
+template <class _CharT, class _Traits>
+void
+basic_streambuf<_CharT, _Traits>::imbue(const locale&)
+{
+}
+
+template <class _CharT, class _Traits>
+basic_streambuf<_CharT, _Traits>*
+basic_streambuf<_CharT, _Traits>::setbuf(char_type*, streamsize)
+{
+ return this;
+}
+
+template <class _CharT, class _Traits>
+typename basic_streambuf<_CharT, _Traits>::pos_type
+basic_streambuf<_CharT, _Traits>::seekoff(off_type, ios_base::seekdir,
+ ios_base::openmode)
+{
+ return pos_type(off_type(-1));
+}
+
+template <class _CharT, class _Traits>
+typename basic_streambuf<_CharT, _Traits>::pos_type
+basic_streambuf<_CharT, _Traits>::seekpos(pos_type, ios_base::openmode)
+{
+ return pos_type(off_type(-1));
+}
+
+template <class _CharT, class _Traits>
+int
+basic_streambuf<_CharT, _Traits>::sync()
+{
+ return 0;
+}
+
+template <class _CharT, class _Traits>
+streamsize
+basic_streambuf<_CharT, _Traits>::showmanyc()
+{
+ return 0;
+}
+
+template <class _CharT, class _Traits>
+streamsize
+basic_streambuf<_CharT, _Traits>::xsgetn(char_type* __s, streamsize __n)
+{
+ const int_type __eof = traits_type::eof();
+ int_type __c;
+ streamsize __i = 0;
+ while(__i < __n)
+ {
+ if (__ninp_ < __einp_)
+ {
+ const streamsize __len = _VSTD::min(static_cast<streamsize>(INT_MAX),
+ _VSTD::min(__einp_ - __ninp_, __n - __i));
+ traits_type::copy(__s, __ninp_, __len);
+ __s += __len;
+ __i += __len;
+ this->gbump(__len);
+ }
+ else if ((__c = uflow()) != __eof)
+ {
+ *__s = traits_type::to_char_type(__c);
+ ++__s;
+ ++__i;
+ }
+ else
+ break;
+ }
+ return __i;
+}
+
+template <class _CharT, class _Traits>
+typename basic_streambuf<_CharT, _Traits>::int_type
+basic_streambuf<_CharT, _Traits>::underflow()
+{
+ return traits_type::eof();
+}
+
+template <class _CharT, class _Traits>
+typename basic_streambuf<_CharT, _Traits>::int_type
+basic_streambuf<_CharT, _Traits>::uflow()
+{
+ if (underflow() == traits_type::eof())
+ return traits_type::eof();
+ return traits_type::to_int_type(*__ninp_++);
+}
+
+template <class _CharT, class _Traits>
+typename basic_streambuf<_CharT, _Traits>::int_type
+basic_streambuf<_CharT, _Traits>::pbackfail(int_type)
+{
+ return traits_type::eof();
+}
+
+template <class _CharT, class _Traits>
+streamsize
+basic_streambuf<_CharT, _Traits>::xsputn(const char_type* __s, streamsize __n)
+{
+ streamsize __i = 0;
+ int_type __eof = traits_type::eof();
+ while( __i < __n)
+ {
+ if (__nout_ >= __eout_)
+ {
+ if (overflow(traits_type::to_int_type(*__s)) == __eof)
+ break;
+ ++__s;
+ ++__i;
+ }
+ else
+ {
+ streamsize __chunk_size = _VSTD::min(__eout_ - __nout_, __n - __i);
+ traits_type::copy(__nout_, __s, __chunk_size);
+ __nout_ += __chunk_size;
+ __s += __chunk_size;
+ __i += __chunk_size;
+ }
+ }
+ return __i;
+}
+
+template <class _CharT, class _Traits>
+typename basic_streambuf<_CharT, _Traits>::int_type
+basic_streambuf<_CharT, _Traits>::overflow(int_type)
+{
+ return traits_type::eof();
+}
+
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<char>)
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<wchar_t>)
+
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<char>)
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<wchar_t>)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_STREAMBUF
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/string b/contrib/libs/cxxsupp/libcxxmsvc/include/string
new file mode 100644
index 0000000000..a1bfff1f6a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/string
@@ -0,0 +1,4528 @@
+// -*- 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_STRING
+#define _LIBCPP_STRING
+
+/*
+ string synopsis
+
+namespace std
+{
+
+template <class stateT>
+class fpos
+{
+private:
+ stateT st;
+public:
+ fpos(streamoff = streamoff());
+
+ operator streamoff() const;
+
+ stateT state() const;
+ void state(stateT);
+
+ fpos& operator+=(streamoff);
+ fpos operator+ (streamoff) const;
+ fpos& operator-=(streamoff);
+ fpos operator- (streamoff) const;
+};
+
+template <class stateT> streamoff operator-(const fpos<stateT>& x, const fpos<stateT>& y);
+
+template <class stateT> bool operator==(const fpos<stateT>& x, const fpos<stateT>& y);
+template <class stateT> bool operator!=(const fpos<stateT>& x, const fpos<stateT>& y);
+
+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 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 int compare(const char_type* s1, const char_type* s2, size_t n);
+ static size_t length(const char_type* s);
+ static const char_type* find(const char_type* s, size_t n, const char_type& a);
+ static char_type* move(char_type* s1, const char_type* s2, size_t n);
+ static char_type* copy(char_type* s1, const char_type* s2, size_t n);
+ static char_type* assign(char_type* s, size_t n, char_type a);
+
+ 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
+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
+{
+public:
+// types:
+ typedef traits traits_type;
+ typedef typename traits_type::char_type value_type;
+ typedef Allocator allocator_type;
+ typedef typename allocator_type::size_type size_type;
+ typedef typename allocator_type::difference_type difference_type;
+ typedef typename allocator_type::reference reference;
+ typedef typename allocator_type::const_reference const_reference;
+ typedef typename allocator_type::pointer pointer;
+ typedef typename allocator_type::const_pointer const_pointer;
+ typedef implementation-defined iterator;
+ typedef implementation-defined const_iterator;
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+
+ static const size_type npos = -1;
+
+ basic_string()
+ noexcept(is_nothrow_default_constructible<allocator_type>::value);
+ explicit basic_string(const allocator_type& a);
+ basic_string(const basic_string& str);
+ basic_string(basic_string&& str)
+ noexcept(is_nothrow_move_constructible<allocator_type>::value);
+ basic_string(const basic_string& str, size_type pos,
+ const allocator_type& a = allocator_type());
+ basic_string(const basic_string& str, size_type pos, size_type n,
+ const Allocator& a = Allocator());
+ template<class T>
+ basic_string(const T& t, size_type pos, size_type n, const Allocator& a = Allocator()); // C++17
+ template <class T>
+ 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,
+ const allocator_type& a = allocator_type());
+ basic_string(initializer_list<value_type>, const Allocator& = Allocator());
+ basic_string(const basic_string&, const Allocator&);
+ basic_string(basic_string&&, const Allocator&);
+
+ ~basic_string();
+
+ operator basic_string_view<charT, traits>() const noexcept;
+
+ basic_string& operator=(const basic_string& str);
+ template <class T>
+ basic_string& operator=(const T& t); // C++17
+ basic_string& operator=(basic_string&& str)
+ noexcept(
+ 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>);
+
+ iterator begin() noexcept;
+ const_iterator begin() const noexcept;
+ iterator end() noexcept;
+ const_iterator end() const noexcept;
+
+ reverse_iterator rbegin() noexcept;
+ const_reverse_iterator rbegin() const noexcept;
+ reverse_iterator rend() noexcept;
+ const_reverse_iterator rend() const noexcept;
+
+ const_iterator cbegin() const noexcept;
+ const_iterator cend() const noexcept;
+ const_reverse_iterator crbegin() const noexcept;
+ const_reverse_iterator crend() const noexcept;
+
+ size_type size() const noexcept;
+ size_type length() const noexcept;
+ size_type max_size() const noexcept;
+ size_type capacity() const noexcept;
+
+ void resize(size_type n, value_type c);
+ void resize(size_type n);
+
+ template<class Operation>
+ constexpr void resize_and_overwrite(size_type n, Operation op); // since C++23
+
+ void reserve(size_type res_arg);
+ void reserve(); // deprecated in C++20
+ void shrink_to_fit();
+ void clear() noexcept;
+ bool empty() const noexcept;
+
+ const_reference operator[](size_type pos) const;
+ reference operator[](size_type pos);
+
+ const_reference at(size_type n) const;
+ reference at(size_type n);
+
+ basic_string& operator+=(const basic_string& str);
+ template <class T>
+ basic_string& operator+=(const T& t); // C++17
+ basic_string& operator+=(const value_type* s);
+ basic_string& operator+=(value_type c);
+ basic_string& operator+=(initializer_list<value_type>);
+
+ basic_string& append(const basic_string& str);
+ template <class T>
+ basic_string& append(const T& t); // C++17
+ basic_string& append(const basic_string& str, size_type pos, size_type n=npos); //C++14
+ template <class T>
+ basic_string& append(const T& t, size_type pos, size_type n=npos); // C++17
+ basic_string& append(const value_type* s, size_type n);
+ basic_string& append(const value_type* s);
+ basic_string& append(size_type n, value_type c);
+ template<class InputIterator>
+ basic_string& append(InputIterator first, InputIterator last);
+ basic_string& append(initializer_list<value_type>);
+
+ void push_back(value_type c);
+ void pop_back();
+ reference front();
+ const_reference front() const;
+ reference back();
+ const_reference back() const;
+
+ basic_string& assign(const basic_string& str);
+ template <class T>
+ basic_string& assign(const T& t); // C++17
+ basic_string& assign(basic_string&& str);
+ basic_string& assign(const basic_string& str, size_type pos, size_type n=npos); // C++14
+ template <class T>
+ basic_string& assign(const T& t, size_type pos, size_type n=npos); // C++17
+ basic_string& assign(const value_type* s, size_type n);
+ basic_string& assign(const value_type* s);
+ basic_string& assign(size_type n, value_type c);
+ template<class InputIterator>
+ basic_string& assign(InputIterator first, InputIterator last);
+ basic_string& assign(initializer_list<value_type>);
+
+ basic_string& insert(size_type pos1, const basic_string& str);
+ template <class T>
+ basic_string& insert(size_type pos1, const T& t);
+ basic_string& insert(size_type pos1, const basic_string& str,
+ size_type pos2, size_type n);
+ template <class T>
+ basic_string& insert(size_type pos1, const T& t, size_type pos2, size_type n); // C++17
+ basic_string& insert(size_type pos, const value_type* s, size_type n=npos); //C++14
+ basic_string& insert(size_type pos, const value_type* s);
+ basic_string& insert(size_type pos, size_type n, value_type c);
+ iterator insert(const_iterator p, value_type c);
+ iterator insert(const_iterator p, size_type n, value_type c);
+ template<class InputIterator>
+ iterator insert(const_iterator p, InputIterator first, InputIterator last);
+ iterator insert(const_iterator p, initializer_list<value_type>);
+
+ basic_string& erase(size_type pos = 0, size_type n = npos);
+ iterator erase(const_iterator position);
+ iterator erase(const_iterator first, const_iterator last);
+
+ basic_string& replace(size_type pos1, size_type n1, const basic_string& str);
+ template <class T>
+ basic_string& replace(size_type pos1, size_type n1, const T& t); // C++17
+ basic_string& replace(size_type pos1, size_type n1, const basic_string& str,
+ size_type pos2, size_type n2=npos); // C++14
+ template <class T>
+ basic_string& replace(size_type pos1, size_type n1, const T& t,
+ size_type pos2, size_type n); // C++17
+ basic_string& replace(size_type pos, size_type n1, const value_type* s, size_type n2);
+ basic_string& replace(size_type pos, size_type n1, const value_type* s);
+ basic_string& replace(size_type pos, size_type n1, size_type n2, value_type c);
+ basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str);
+ template <class T>
+ basic_string& replace(const_iterator i1, const_iterator i2, const T& t); // C++17
+ basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s, size_type n);
+ basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s);
+ basic_string& replace(const_iterator i1, const_iterator i2, size_type n, value_type c);
+ template<class InputIterator>
+ basic_string& replace(const_iterator i1, const_iterator i2, InputIterator j1, InputIterator j2);
+ basic_string& replace(const_iterator i1, const_iterator i2, initializer_list<value_type>);
+
+ size_type copy(value_type* s, size_type n, size_type pos = 0) const;
+ basic_string substr(size_type pos = 0, size_type n = npos) const;
+
+ void swap(basic_string& str)
+ noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value ||
+ allocator_traits<allocator_type>::is_always_equal::value); // C++17
+
+ const value_type* c_str() const noexcept;
+ const value_type* data() const noexcept;
+ value_type* data() noexcept; // C++17
+
+ allocator_type get_allocator() const noexcept;
+
+ 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 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 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 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 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 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 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, 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
+ int compare(size_type pos1, size_type n1, const basic_string& str,
+ size_type pos2, size_type n2=npos) const; // C++14
+ template <class T>
+ int compare(size_type pos1, size_type n1, const T& t,
+ size_type pos2, size_type n2=npos) const; // C++17
+ int compare(const value_type* s) const noexcept;
+ int compare(size_type pos1, size_type n1, const value_type* s) const;
+ int compare(size_type pos1, size_type n1, const value_type* s, size_type n2) const;
+
+ bool starts_with(basic_string_view<charT, traits> sv) const noexcept; // C++20
+ bool starts_with(charT c) const noexcept; // C++20
+ bool starts_with(const charT* s) const; // C++20
+ bool ends_with(basic_string_view<charT, traits> sv) const noexcept; // C++20
+ bool ends_with(charT c) const noexcept; // C++20
+ bool ends_with(const charT* s) const; // C++20
+
+ constexpr bool contains(basic_string_view<charT, traits> sv) const noexcept; // C++2b
+ constexpr bool contains(charT c) const noexcept; // C++2b
+ constexpr bool contains(const charT* s) const; // C++2b
+
+ bool __invariants() const;
+};
+
+template<class InputIterator,
+ class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
+basic_string(InputIterator, InputIterator, Allocator = Allocator())
+ -> basic_string<typename iterator_traits<InputIterator>::value_type,
+ char_traits<typename iterator_traits<InputIterator>::value_type>,
+ Allocator>; // C++17
+
+template<class charT, class traits, class Allocator>
+basic_string<charT, traits, Allocator>
+operator+(const basic_string<charT, traits, Allocator>& lhs,
+ const basic_string<charT, traits, Allocator>& rhs);
+
+template<class charT, class traits, class Allocator>
+basic_string<charT, traits, Allocator>
+operator+(const charT* lhs , const basic_string<charT,traits,Allocator>&rhs);
+
+template<class charT, class traits, class Allocator>
+basic_string<charT, traits, Allocator>
+operator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs);
+
+template<class charT, class traits, class Allocator>
+basic_string<charT, traits, Allocator>
+operator+(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs);
+
+template<class charT, class traits, class Allocator>
+basic_string<charT, traits, Allocator>
+operator+(const basic_string<charT, traits, Allocator>& lhs, charT rhs);
+
+template<class charT, class traits, class Allocator>
+bool operator==(const basic_string<charT, traits, Allocator>& lhs,
+ const basic_string<charT, traits, Allocator>& rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator==(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator==(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator!=(const basic_string<charT,traits,Allocator>& lhs,
+ const basic_string<charT, traits, Allocator>& rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator!=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator!=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator< (const basic_string<charT, traits, Allocator>& lhs,
+ const basic_string<charT, traits, Allocator>& rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator< (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator< (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator> (const basic_string<charT, traits, Allocator>& lhs,
+ const basic_string<charT, traits, Allocator>& rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator> (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator> (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator<=(const basic_string<charT, traits, Allocator>& lhs,
+ const basic_string<charT, traits, Allocator>& rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator<=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator<=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator>=(const basic_string<charT, traits, Allocator>& lhs,
+ const basic_string<charT, traits, Allocator>& rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator>=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator>=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+void swap(basic_string<charT, traits, Allocator>& lhs,
+ basic_string<charT, traits, Allocator>& rhs)
+ noexcept(noexcept(lhs.swap(rhs)));
+
+template<class charT, class traits, class Allocator>
+basic_istream<charT, traits>&
+operator>>(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str);
+
+template<class charT, class traits, class Allocator>
+basic_ostream<charT, traits>&
+operator<<(basic_ostream<charT, traits>& os, const basic_string<charT, traits, Allocator>& str);
+
+template<class charT, class traits, class Allocator>
+basic_istream<charT, traits>&
+getline(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str,
+ charT delim);
+
+template<class charT, class traits, class Allocator>
+basic_istream<charT, traits>&
+getline(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str);
+
+template<class charT, class traits, class Allocator, class U>
+typename basic_string<charT, traits, Allocator>::size_type
+erase(basic_string<charT, traits, Allocator>& c, const U& value); // C++20
+template<class charT, class traits, class Allocator, class Predicate>
+typename basic_string<charT, traits, Allocator>::size_type
+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;
+
+int stoi (const string& str, size_t* idx = nullptr, int base = 10);
+long stol (const string& str, size_t* idx = nullptr, int base = 10);
+unsigned long stoul (const string& str, size_t* idx = nullptr, int base = 10);
+long long stoll (const string& str, size_t* idx = nullptr, int base = 10);
+unsigned long long stoull(const string& str, size_t* idx = nullptr, int base = 10);
+
+float stof (const string& str, size_t* idx = nullptr);
+double stod (const string& str, size_t* idx = nullptr);
+long double stold(const string& str, size_t* idx = nullptr);
+
+string to_string(int val);
+string to_string(unsigned val);
+string to_string(long val);
+string to_string(unsigned long val);
+string to_string(long long val);
+string to_string(unsigned long long val);
+string to_string(float val);
+string to_string(double val);
+string to_string(long double val);
+
+int stoi (const wstring& str, size_t* idx = nullptr, int base = 10);
+long stol (const wstring& str, size_t* idx = nullptr, int base = 10);
+unsigned long stoul (const wstring& str, size_t* idx = nullptr, int base = 10);
+long long stoll (const wstring& str, size_t* idx = nullptr, int base = 10);
+unsigned long long stoull(const wstring& str, size_t* idx = nullptr, int base = 10);
+
+float stof (const wstring& str, size_t* idx = nullptr);
+double stod (const wstring& str, size_t* idx = nullptr);
+long double stold(const wstring& str, size_t* idx = nullptr);
+
+wstring to_wstring(int val);
+wstring to_wstring(unsigned val);
+wstring to_wstring(long val);
+wstring to_wstring(unsigned long val);
+wstring to_wstring(long long val);
+wstring to_wstring(unsigned long long val);
+wstring to_wstring(float val);
+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
+
+} // std
+
+*/
+
+#include <__algorithm/max.h>
+#include <__algorithm/min.h>
+#include <__algorithm/remove.h>
+#include <__algorithm/remove_if.h>
+#include <__assert>
+#include <__config>
+#include <__debug>
+#include <__ios/fpos.h>
+#include <__iterator/wrap_iter.h>
+#include <compare>
+#include <cstdio> // EOF
+#include <cstdlib>
+#include <cstring>
+#include <initializer_list>
+#include <iosfwd>
+#include <iterator>
+#include <memory>
+#include <stdexcept>
+#include <string_view>
+#include <type_traits>
+#include <utility>
+#include <version>
+
+// TODO: remove these headers
+#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 <new>
+#include <typeinfo>
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# include <cwchar>
+#endif
+
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+# include <cstdint>
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( push )
+#pragma warning ( disable : 4455 )
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// basic_string
+
+template<class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>
+operator+(const basic_string<_CharT, _Traits, _Allocator>& __x,
+ const basic_string<_CharT, _Traits, _Allocator>& __y);
+
+template<class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>
+operator+(const _CharT* __x, const basic_string<_CharT,_Traits,_Allocator>& __y);
+
+template<class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>
+operator+(_CharT __x, const basic_string<_CharT,_Traits,_Allocator>& __y);
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>
+operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, const _CharT* __y);
+
+template<class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>
+operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y);
+
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS string operator+<char, char_traits<char>, allocator<char> >(char const*, string const&))
+
+template <class _Iter>
+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 __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<
+ is_convertible<const _Tp&, basic_string_view<_CharT, _Traits> >::value &&
+ !is_convertible<const _Tp&, const _CharT*>::value
+ > {};
+
+#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
+
+template <class _CharT, size_t = sizeof(_CharT)>
+struct __padding
+{
+ unsigned char __xx[sizeof(_CharT)-1];
+};
+
+template <class _CharT>
+struct __padding<_CharT, 1>
+{
+};
+
+#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
+
+#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
+
+template<class _CharT, class _Traits, class _Allocator>
+class
+ _LIBCPP_TEMPLATE_VIS
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
+ _LIBCPP_PREFERRED_NAME(u8string)
+#endif
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ _LIBCPP_PREFERRED_NAME(u16string)
+ _LIBCPP_PREFERRED_NAME(u32string)
+#endif
+ basic_string
+{
+ static_assert(sizeof(_CharT) <= 4, "libc++ implementation of std::basic_string does not support extra-wide character types");
+public:
+ typedef basic_string __self;
+ typedef basic_string_view<_CharT, _Traits> __self_view;
+ typedef _Traits traits_type;
+ typedef _CharT value_type;
+ typedef _Allocator allocator_type;
+ typedef allocator_traits<allocator_type> __alloc_traits;
+ typedef typename __alloc_traits::size_type size_type;
+ typedef typename __alloc_traits::difference_type difference_type;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef typename __alloc_traits::pointer pointer;
+ typedef typename __alloc_traits::const_pointer const_pointer;
+
+ static_assert((!is_array<value_type>::value), "Character type of basic_string must not be an array");
+ static_assert(( is_standard_layout<value_type>::value), "Character type of basic_string must be standard-layout");
+ static_assert(( is_trivial<value_type>::value), "Character type of basic_string must be trivial");
+ static_assert(( is_same<_CharT, typename traits_type::char_type>::value),
+ "traits_type::char_type must be the same type as CharT");
+ static_assert(( is_same<typename allocator_type::value_type, value_type>::value),
+ "Allocator::value_type must be same type as value_type");
+
+#if _YNDX_LIBCPP_MAKE_STRING_ITERATOR_POINTERS == 1
+ typedef pointer iterator;
+ typedef const_pointer const_iterator;
+#else
+ typedef __wrap_iter<pointer> iterator;
+ typedef __wrap_iter<const_pointer> const_iterator;
+#endif
+ typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
+ typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
+
+private:
+
+#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
+
+ struct __long
+ {
+ pointer __data_;
+ size_type __size_;
+ size_type __cap_;
+ };
+
+#ifdef _LIBCPP_BIG_ENDIAN
+ static const size_type __short_mask = 0x01;
+ static const size_type __long_mask = 0x1ul;
+#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
+
+ enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ?
+ (sizeof(__long) - 1)/sizeof(value_type) : 2};
+
+ struct __short
+ {
+ value_type __data_[__min_cap];
+ struct
+ : __padding<value_type>
+ {
+ unsigned char __size_;
+ };
+ };
+
+#else
+
+ struct __long
+ {
+ size_type __cap_;
+ size_type __size_;
+ pointer __data_;
+ };
+
+#ifdef _LIBCPP_BIG_ENDIAN
+ static const size_type __short_mask = 0x80;
+ static const size_type __long_mask = ~(size_type(~0) >> 1);
+#else // _LIBCPP_BIG_ENDIAN
+ static const size_type __short_mask = 0x01;
+ static const size_type __long_mask = 0x1ul;
+#endif // _LIBCPP_BIG_ENDIAN
+
+ enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ?
+ (sizeof(__long) - 1)/sizeof(value_type) : 2};
+
+ struct __short
+ {
+ union
+ {
+ unsigned char __size_;
+ value_type __lx;
+ };
+ value_type __data_[__min_cap];
+ };
+
+#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
+
+ union __ulx{__long __lx; __short __lxx;};
+
+ enum {__n_words = sizeof(__ulx) / sizeof(size_type)};
+
+ struct __raw
+ {
+ size_type __words[__n_words];
+ };
+
+ struct __rep
+ {
+ union
+ {
+ __long __l;
+ __short __s;
+ __raw __r;
+ };
+ };
+
+ __compressed_pair<__rep, allocator_type> __r_;
+
+public:
+ _LIBCPP_TEMPLATE_DATA_VIS
+ static const size_type npos = -1;
+
+ _LIBCPP_INLINE_VISIBILITY basic_string()
+ _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
+
+ _LIBCPP_INLINE_VISIBILITY explicit basic_string(const allocator_type& __a)
+#if _LIBCPP_STD_VER <= 14
+ _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value);
+#else
+ _NOEXCEPT;
+#endif
+
+ basic_string(const basic_string& __str);
+ basic_string(const basic_string& __str, const allocator_type& __a);
+
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string(basic_string&& __str)
+#if _LIBCPP_STD_VER <= 14
+ _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
+#else
+ _NOEXCEPT;
+#endif
+
+#if _LIBCPP_STD_VER > 17
+ basic_string(nullptr_t) = delete;
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string(basic_string&& __str, const allocator_type& __a);
+#endif // _LIBCPP_CXX03_LANG
+
+ template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> >
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string(const _CharT* __s) : __r_(__default_init_tag(), __default_init_tag()) {
+ _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr");
+ __init(__s, traits_type::length(__s));
+ _VSTD::__debug_db_insert_c(this);
+ }
+
+ template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> >
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string(const _CharT* __s, const _Allocator& __a);
+
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ basic_string(nullptr_t, size_t) = delete;
+
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string(const _CharT* __s, size_type __n);
+
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ basic_string(nullptr_t, size_t, const _Allocator&) = delete;
+
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string(const _CharT* __s, size_type __n, const _Allocator& __a);
+
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string(size_type __n, _CharT __c);
+
+ template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> >
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string(size_type __n, _CharT __c, const _Allocator& __a);
+
+ basic_string(const basic_string& __str, size_type __pos, size_type __n,
+ const _Allocator& __a = _Allocator());
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string(const basic_string& __str, size_type __pos,
+ const _Allocator& __a = _Allocator());
+
+ template<class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value> >
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ basic_string(const _Tp& __t, size_type __pos, size_type __n,
+ const allocator_type& __a = allocator_type());
+
+ template<class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
+ !__is_same_uncvref<_Tp, basic_string>::value> >
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ explicit basic_string(const _Tp& __t);
+
+ template<class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value> >
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ explicit basic_string(const _Tp& __t, const allocator_type& __a);
+
+ template<class _InputIterator, class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value> >
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string(_InputIterator __first, _InputIterator __last);
+ template<class _InputIterator, class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value> >
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a);
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string(initializer_list<_CharT> __il);
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string(initializer_list<_CharT> __il, const _Allocator& __a);
+#endif // _LIBCPP_CXX03_LANG
+
+ inline ~basic_string();
+
+ _LIBCPP_INLINE_VISIBILITY
+ operator __self_view() const _NOEXCEPT { return __self_view(data(), size()); }
+
+ basic_string& operator=(const basic_string& __str);
+
+ basic_string& operator=(nullptr_t) = delete;
+
+ template <class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value> >
+ basic_string& operator=(const _Tp& __t)
+ {__self_view __sv = __t; return assign(__sv);}
+
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string& operator=(basic_string&& __str)
+ _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
+ _LIBCPP_INLINE_VISIBILITY
+ 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
+ _LIBCPP_INLINE_VISIBILITY
+ iterator begin() _NOEXCEPT
+ {return iterator(this, __get_pointer());}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator begin() const _NOEXCEPT
+ {return const_iterator(this, __get_pointer());}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator end() _NOEXCEPT
+ {return iterator(this, __get_pointer() + size());}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator end() const _NOEXCEPT
+ {return const_iterator(this, __get_pointer() + size());}
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ iterator begin() _NOEXCEPT
+ {return iterator(__get_pointer());}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator begin() const _NOEXCEPT
+ {return const_iterator(__get_pointer());}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator end() _NOEXCEPT
+ {return iterator(__get_pointer() + size());}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator end() const _NOEXCEPT
+ {return const_iterator(__get_pointer() + size());}
+#endif // _LIBCPP_DEBUG_LEVEL == 2
+ _LIBCPP_INLINE_VISIBILITY
+ reverse_iterator rbegin() _NOEXCEPT
+ {return reverse_iterator(end());}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator rbegin() const _NOEXCEPT
+ {return const_reverse_iterator(end());}
+ _LIBCPP_INLINE_VISIBILITY
+ reverse_iterator rend() _NOEXCEPT
+ {return reverse_iterator(begin());}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator rend() const _NOEXCEPT
+ {return const_reverse_iterator(begin());}
+
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator cbegin() const _NOEXCEPT
+ {return begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator cend() const _NOEXCEPT
+ {return end();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator crbegin() const _NOEXCEPT
+ {return rbegin();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator crend() const _NOEXCEPT
+ {return rend();}
+
+ _LIBCPP_INLINE_VISIBILITY size_type size() const _NOEXCEPT
+ {return __is_long() ? __get_long_size() : __get_short_size();}
+ _LIBCPP_INLINE_VISIBILITY size_type length() const _NOEXCEPT {return size();}
+ _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY size_type capacity() const _NOEXCEPT
+ {return (__is_long() ? __get_long_cap()
+ : static_cast<size_type>(__min_cap)) - 1;}
+
+
+#if _YNDX_LIBCXX_ENABLE_STRING_RESIZE_UNINITIALIZED == 1
+ inline void resize_uninitialized(size_type __n)
+ {
+ __resize_default_init(__n);
+ }
+#endif
+
+ void resize(size_type __n, value_type __c);
+ _LIBCPP_INLINE_VISIBILITY void resize(size_type __n) {resize(__n, value_type());}
+
+ void reserve(size_type __requested_capacity);
+
+#if _LIBCPP_STD_VER > 20
+ template <class _Op>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ void resize_and_overwrite(size_type __n, _Op __op) {
+ __resize_default_init(__n);
+ __erase_to_end(_VSTD::move(__op)(data(), _LIBCPP_AUTO_CAST(__n)));
+ }
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY void __resize_default_init(size_type __n);
+
+ _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_INLINE_VISIBILITY
+ void reserve() _NOEXCEPT {shrink_to_fit();}
+ _LIBCPP_INLINE_VISIBILITY
+ void shrink_to_fit() _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ void clear() _NOEXCEPT;
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+ bool empty() const _NOEXCEPT {return size() == 0;}
+
+ _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __pos) const _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __pos) _NOEXCEPT;
+
+ const_reference at(size_type __n) const;
+ reference at(size_type __n);
+
+ _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(const basic_string& __str) {return append(__str);}
+
+ template <class _Tp>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ __enable_if_t
+ <
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
+ && !__is_same_uncvref<_Tp, basic_string >::value,
+ basic_string&
+ >
+ operator+=(const _Tp& __t) {__self_view __sv = __t; return append(__sv);}
+ _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(const value_type* __s) {return append(__s);}
+ _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
+
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string& append(const basic_string& __str);
+
+ template <class _Tp>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ __enable_if_t<
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
+ && !__is_same_uncvref<_Tp, basic_string>::value,
+ basic_string&
+ >
+ append(const _Tp& __t) { __self_view __sv = __t; return append(__sv.data(), __sv.size()); }
+ basic_string& append(const basic_string& __str, size_type __pos, size_type __n=npos);
+
+ template <class _Tp>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ __enable_if_t
+ <
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
+ && !__is_same_uncvref<_Tp, basic_string>::value,
+ basic_string&
+ >
+ append(const _Tp& __t, size_type __pos, size_type __n=npos);
+ basic_string& append(const value_type* __s, size_type __n);
+ basic_string& append(const value_type* __s);
+ basic_string& append(size_type __n, value_type __c);
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __append_default_init(size_type __n);
+
+ template<class _InputIterator>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ __enable_if_t
+ <
+ __is_exactly_cpp17_input_iterator<_InputIterator>::value,
+ basic_string&
+ >
+ _LIBCPP_INLINE_VISIBILITY
+ append(_InputIterator __first, _InputIterator __last) {
+ const basic_string __temp(__first, __last, __alloc());
+ append(__temp.data(), __temp.size());
+ return *this;
+ }
+ template<class _ForwardIterator>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ __enable_if_t
+ <
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
+ basic_string&
+ >
+ _LIBCPP_INLINE_VISIBILITY
+ 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
+
+ void push_back(value_type __c);
+ _LIBCPP_INLINE_VISIBILITY
+ void pop_back();
+ _LIBCPP_INLINE_VISIBILITY reference front() _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY const_reference front() const _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY reference back() _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY const_reference back() const _NOEXCEPT;
+
+ template <class _Tp>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ __enable_if_t
+ <
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
+ basic_string&
+ >
+ assign(const _Tp & __t) { __self_view __sv = __t; return assign(__sv.data(), __sv.size()); }
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string& assign(const basic_string& __str) { return *this = __str; }
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string& assign(basic_string&& __str)
+ _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))
+ {*this = _VSTD::move(__str); return *this;}
+#endif
+ basic_string& assign(const basic_string& __str, size_type __pos, size_type __n=npos);
+ template <class _Tp>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ __enable_if_t
+ <
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
+ && !__is_same_uncvref<_Tp, basic_string>::value,
+ basic_string&
+ >
+ assign(const _Tp & __t, size_type __pos, size_type __n=npos);
+ basic_string& assign(const value_type* __s, size_type __n);
+ basic_string& assign(const value_type* __s);
+ basic_string& assign(size_type __n, value_type __c);
+ template<class _InputIterator>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ __enable_if_t
+ <
+ __is_exactly_cpp17_input_iterator<_InputIterator>::value,
+ basic_string&
+ >
+ assign(_InputIterator __first, _InputIterator __last);
+ template<class _ForwardIterator>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ __enable_if_t
+ <
+ __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
+
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string& insert(size_type __pos1, const basic_string& __str);
+
+ template <class _Tp>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ __enable_if_t
+ <
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
+ basic_string&
+ >
+ insert(size_type __pos1, const _Tp& __t)
+ { __self_view __sv = __t; return insert(__pos1, __sv.data(), __sv.size()); }
+
+ template <class _Tp>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ __enable_if_t
+ <
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value,
+ basic_string&
+ >
+ insert(size_type __pos1, const _Tp& __t, size_type __pos2, size_type __n=npos);
+ basic_string& insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n=npos);
+ basic_string& insert(size_type __pos, const value_type* __s, size_type __n);
+ basic_string& insert(size_type __pos, const value_type* __s);
+ basic_string& insert(size_type __pos, size_type __n, value_type __c);
+ iterator insert(const_iterator __pos, value_type __c);
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const_iterator __pos, size_type __n, value_type __c);
+ template<class _InputIterator>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ __enable_if_t
+ <
+ __is_exactly_cpp17_input_iterator<_InputIterator>::value,
+ iterator
+ >
+ insert(const_iterator __pos, _InputIterator __first, _InputIterator __last);
+ template<class _ForwardIterator>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ __enable_if_t
+ <
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
+ iterator
+ >
+ insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last);
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const_iterator __pos, initializer_list<value_type> __il)
+ {return insert(__pos, __il.begin(), __il.end());}
+#endif // _LIBCPP_CXX03_LANG
+
+ basic_string& erase(size_type __pos = 0, size_type __n = npos);
+ _LIBCPP_INLINE_VISIBILITY
+ iterator erase(const_iterator __pos);
+ _LIBCPP_INLINE_VISIBILITY
+ iterator erase(const_iterator __first, const_iterator __last);
+
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str);
+
+ template <class _Tp>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ __enable_if_t
+ <
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
+ basic_string&
+ >
+ replace(size_type __pos1, size_type __n1, const _Tp& __t) { __self_view __sv = __t; return replace(__pos1, __n1, __sv.data(), __sv.size()); }
+ basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos);
+ template <class _Tp>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ __enable_if_t
+ <
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value,
+ basic_string&
+ >
+ replace(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos);
+ basic_string& replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2);
+ basic_string& replace(size_type __pos, size_type __n1, const value_type* __s);
+ basic_string& replace(size_type __pos, size_type __n1, size_type __n2, value_type __c);
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string& replace(const_iterator __i1, const_iterator __i2, const basic_string& __str);
+
+ template <class _Tp>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ __enable_if_t
+ <
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
+ basic_string&
+ >
+ replace(const_iterator __i1, const_iterator __i2, const _Tp& __t) { __self_view __sv = __t; return replace(__i1 - begin(), __i2 - __i1, __sv); }
+
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n);
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s);
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string& replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c);
+ template<class _InputIterator>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ __enable_if_t
+ <
+ __is_cpp17_input_iterator<_InputIterator>::value,
+ basic_string&
+ >
+ replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2);
+#ifndef _LIBCPP_CXX03_LANG
+ _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
+
+ size_type copy(value_type* __s, size_type __n, size_type __pos = 0) const;
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string substr(size_type __pos = 0, size_type __n = npos) const;
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(basic_string& __str)
+#if _LIBCPP_STD_VER >= 14
+ _NOEXCEPT;
+#else
+ _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
+ __is_nothrow_swappable<allocator_type>::value);
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ const value_type* c_str() const _NOEXCEPT {return data();}
+ _LIBCPP_INLINE_VISIBILITY
+ const value_type* data() const _NOEXCEPT {return _VSTD::__to_address(__get_pointer());}
+#if _LIBCPP_STD_VER > 14 || defined(_LIBCPP_BUILDING_LIBRARY)
+ _LIBCPP_INLINE_VISIBILITY
+ value_type* data() _NOEXCEPT {return _VSTD::__to_address(__get_pointer());}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ allocator_type get_allocator() const _NOEXCEPT {return __alloc();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type find(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;
+
+ template <class _Tp>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ __enable_if_t
+ <
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
+ size_type
+ >
+ 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;
+ size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
+
+ template <class _Tp>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ __enable_if_t
+ <
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
+ size_type
+ >
+ 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;
+ size_type rfind(value_type __c, size_type __pos = npos) const _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type find_first_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;
+
+ template <class _Tp>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ __enable_if_t
+ <
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
+ size_type
+ >
+ 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;
+ _LIBCPP_INLINE_VISIBILITY
+ size_type find_first_of(value_type __c, size_type __pos = 0) const _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
+
+ template <class _Tp>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ __enable_if_t
+ <
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
+ size_type
+ >
+ 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;
+ _LIBCPP_INLINE_VISIBILITY
+ size_type find_last_of(value_type __c, size_type __pos = npos) const _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type find_first_not_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;
+
+ template <class _Tp>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ __enable_if_t
+ <
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
+ size_type
+ >
+ 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;
+ _LIBCPP_INLINE_VISIBILITY
+ size_type find_first_not_of(value_type __c, size_type __pos = 0) const _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
+
+ template <class _Tp>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ __enable_if_t
+ <
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
+ size_type
+ >
+ 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;
+ _LIBCPP_INLINE_VISIBILITY
+ size_type find_last_not_of(value_type __c, size_type __pos = npos) const _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY
+ int compare(const basic_string& __str) const _NOEXCEPT;
+
+ template <class _Tp>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ __enable_if_t
+ <
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
+ int
+ >
+ compare(const _Tp &__t) const _NOEXCEPT;
+
+ template <class _Tp>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ __enable_if_t
+ <
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
+ int
+ >
+ compare(size_type __pos1, size_type __n1, const _Tp& __t) const;
+
+ _LIBCPP_INLINE_VISIBILITY
+ int compare(size_type __pos1, size_type __n1, const basic_string& __str) const;
+ int compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos) const;
+
+ template <class _Tp>
+ inline _LIBCPP_INLINE_VISIBILITY
+ __enable_if_t
+ <
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value,
+ int
+ >
+ compare(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos) const;
+ int compare(const value_type* __s) const _NOEXCEPT;
+ int compare(size_type __pos1, size_type __n1, const value_type* __s) const;
+ int compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const;
+
+//WARN: disabled std guards in order to allow using these options without switching to new std
+//#if _LIBCPP_STD_VER > 17
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool starts_with(__self_view __sv) const noexcept
+ { return __self_view(data(), size()).starts_with(__sv); }
+
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool starts_with(value_type __c) const noexcept
+ { return !empty() && _Traits::eq(front(), __c); }
+
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool starts_with(const value_type* __s) const noexcept
+ { return starts_with(__self_view(__s)); }
+
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool ends_with(__self_view __sv) const noexcept
+ { return __self_view(data(), size()).ends_with( __sv); }
+
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool ends_with(value_type __c) const noexcept
+ { return !empty() && _Traits::eq(back(), __c); }
+
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool ends_with(const value_type* __s) const noexcept
+ { return ends_with(__self_view(__s)); }
+//#endif
+
+#if _LIBCPP_STD_VER >= 20
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool contains(__self_view __sv) const noexcept
+ { return __self_view(data(), size()).contains(__sv); }
+
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool contains(value_type __c) const noexcept
+ { return __self_view(data(), size()).contains(__c); }
+
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool contains(const value_type* __s) const
+ { return __self_view(data(), size()).contains(__s); }
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY bool __invariants() const;
+
+ _LIBCPP_INLINE_VISIBILITY void __clear_and_shrink() _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY void __shrink_or_extend(size_type __target_capacity);
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool __is_long() const _NOEXCEPT
+ {return bool(__r_.first().__s.__size_ & __short_mask);}
+
+#if _LIBCPP_DEBUG_LEVEL == 2
+
+ bool __dereferenceable(const const_iterator* __i) const;
+ bool __decrementable(const const_iterator* __i) const;
+ 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
+
+private:
+ _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI static bool __fits_in_sso(size_type __sz) {
+ // SSO is disabled during constant evaluation because `__is_long` isn't constexpr friendly
+ return !__libcpp_is_constant_evaluated() && (__sz < __min_cap);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ allocator_type& __alloc() _NOEXCEPT
+ {return __r_.second();}
+ _LIBCPP_INLINE_VISIBILITY
+ const allocator_type& __alloc() const _NOEXCEPT
+ {return __r_.second();}
+
+#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __set_short_size(size_type __s) _NOEXCEPT
+# ifdef _LIBCPP_BIG_ENDIAN
+ {__r_.first().__s.__size_ = (unsigned char)(__s << 1);}
+# else
+ {__r_.first().__s.__size_ = (unsigned char)(__s);}
+# endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type __get_short_size() const _NOEXCEPT
+# ifdef _LIBCPP_BIG_ENDIAN
+ {return __r_.first().__s.__size_ >> 1;}
+# else
+ {return __r_.first().__s.__size_;}
+# endif
+
+#else // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __set_short_size(size_type __s) _NOEXCEPT
+# ifdef _LIBCPP_BIG_ENDIAN
+ {__r_.first().__s.__size_ = (unsigned char)(__s);}
+# else
+ {__r_.first().__s.__size_ = (unsigned char)(__s << 1);}
+# endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type __get_short_size() const _NOEXCEPT
+# ifdef _LIBCPP_BIG_ENDIAN
+ {return __r_.first().__s.__size_;}
+# else
+ {return __r_.first().__s.__size_ >> 1;}
+# endif
+
+#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __set_long_size(size_type __s) _NOEXCEPT
+ {__r_.first().__l.__size_ = __s;}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type __get_long_size() const _NOEXCEPT
+ {return __r_.first().__l.__size_;}
+ _LIBCPP_INLINE_VISIBILITY
+ void __set_size(size_type __s) _NOEXCEPT
+ {if (__is_long()) __set_long_size(__s); else __set_short_size(__s);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __set_long_cap(size_type __s) _NOEXCEPT
+ {__r_.first().__l.__cap_ = __long_mask | __s;}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type __get_long_cap() const _NOEXCEPT
+ {return __r_.first().__l.__cap_ & size_type(~__long_mask);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __set_long_pointer(pointer __p) _NOEXCEPT
+ {__r_.first().__l.__data_ = __p;}
+ _LIBCPP_INLINE_VISIBILITY
+ pointer __get_long_pointer() _NOEXCEPT
+ {return __r_.first().__l.__data_;}
+ _LIBCPP_INLINE_VISIBILITY
+ const_pointer __get_long_pointer() const _NOEXCEPT
+ {return __r_.first().__l.__data_;}
+ _LIBCPP_INLINE_VISIBILITY
+ pointer __get_short_pointer() _NOEXCEPT
+ {return pointer_traits<pointer>::pointer_to(__r_.first().__s.__data_[0]);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_pointer __get_short_pointer() const _NOEXCEPT
+ {return pointer_traits<const_pointer>::pointer_to(__r_.first().__s.__data_[0]);}
+ _LIBCPP_INLINE_VISIBILITY
+ pointer __get_pointer() _NOEXCEPT
+ {return __is_long() ? __get_long_pointer() : __get_short_pointer();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_pointer __get_pointer() const _NOEXCEPT
+ {return __is_long() ? __get_long_pointer() : __get_short_pointer();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __zero() _NOEXCEPT
+ {
+ size_type (&__a)[__n_words] = __r_.first().__r.__words;
+ for (unsigned __i = 0; __i < __n_words; ++__i)
+ __a[__i] = 0;
+ }
+
+ template <size_type __a> static
+ _LIBCPP_INLINE_VISIBILITY
+ size_type __align_it(size_type __s) _NOEXCEPT
+ {return (__s + (__a-1)) & ~(__a-1);}
+ enum {__alignment = 16};
+ static _LIBCPP_INLINE_VISIBILITY
+ size_type __recommend(size_type __s) _NOEXCEPT
+ {
+ if (__s < __min_cap) return static_cast<size_type>(__min_cap) - 1;
+ size_type __guess = __align_it<sizeof(value_type) < __alignment ?
+ __alignment/sizeof(value_type) : 1 > (__s+1) - 1;
+ if (__guess == __min_cap) ++__guess;
+ return __guess;
+ }
+
+ inline
+ void __init(const value_type* __s, size_type __sz, size_type __reserve);
+ inline
+ void __init(const value_type* __s, size_type __sz);
+ inline
+ void __init(size_type __n, value_type __c);
+
+ // Slow path for the (inlined) copy constructor for 'long' strings.
+ // Always externally instantiated and not inlined.
+ // Requires that __s is zero terminated.
+ // The main reason for this function to exist is because for unstable, we
+ // want to allow inlining of the copy constructor. However, we don't want
+ // to call the __init() functions as those are marked as inline which may
+ // result in over-aggressive inlining by the compiler, where our aim is
+ // to only inline the fast path code directly in the ctor.
+ void __init_copy_ctor_external(const value_type* __s, size_type __sz);
+
+ template <class _InputIterator>
+ inline
+ __enable_if_t
+ <
+ __is_exactly_cpp17_input_iterator<_InputIterator>::value
+ >
+ __init(_InputIterator __first, _InputIterator __last);
+
+ template <class _ForwardIterator>
+ inline
+ __enable_if_t
+ <
+ __is_cpp17_forward_iterator<_ForwardIterator>::value
+ >
+ __init(_ForwardIterator __first, _ForwardIterator __last);
+
+ void __grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz,
+ size_type __n_copy, size_type __n_del, size_type __n_add = 0);
+ void __grow_by_and_replace(size_type __old_cap, size_type __delta_cap, size_type __old_sz,
+ size_type __n_copy, size_type __n_del,
+ size_type __n_add, const value_type* __p_new_stuff);
+
+ // __assign_no_alias is invoked for assignment operations where we
+ // have proof that the input does not alias the current instance.
+ // For example, operator=(basic_string) performs a 'self' check.
+ template <bool __is_short>
+ basic_string& __assign_no_alias(const value_type* __s, size_type __n);
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __erase_to_end(size_type __pos);
+
+ // __erase_external_with_move is invoked for erase() invocations where
+ // `n ~= npos`, likely requiring memory moves on the string data.
+ void __erase_external_with_move(size_type __pos, size_type __n);
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __copy_assign_alloc(const basic_string& __str)
+ {__copy_assign_alloc(__str, integral_constant<bool,
+ __alloc_traits::propagate_on_container_copy_assignment::value>());}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __copy_assign_alloc(const basic_string& __str, true_type)
+ {
+ if (__alloc() == __str.__alloc())
+ __alloc() = __str.__alloc();
+ else
+ {
+ if (!__str.__is_long())
+ {
+ __clear_and_shrink();
+ __alloc() = __str.__alloc();
+ }
+ else
+ {
+ allocator_type __a = __str.__alloc();
+ pointer __p = __alloc_traits::allocate(__a, __str.__get_long_cap());
+ __clear_and_shrink();
+ __alloc() = _VSTD::move(__a);
+ __set_long_pointer(__p);
+ __set_long_cap(__str.__get_long_cap());
+ __set_long_size(__str.size());
+ }
+ }
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __copy_assign_alloc(const basic_string&, false_type) _NOEXCEPT
+ {}
+
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ void __move_assign(basic_string& __str, false_type)
+ _NOEXCEPT_(__alloc_traits::is_always_equal::value);
+ _LIBCPP_INLINE_VISIBILITY
+ void __move_assign(basic_string& __str, true_type)
+#if _LIBCPP_STD_VER > 14
+ _NOEXCEPT;
+#else
+ _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
+#endif
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ void
+ __move_assign_alloc(basic_string& __str)
+ _NOEXCEPT_(
+ !__alloc_traits::propagate_on_container_move_assignment::value ||
+ is_nothrow_move_assignable<allocator_type>::value)
+ {__move_assign_alloc(__str, integral_constant<bool,
+ __alloc_traits::propagate_on_container_move_assignment::value>());}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __move_assign_alloc(basic_string& __c, true_type)
+ _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
+ {
+ __alloc() = _VSTD::move(__c.__alloc());
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __move_assign_alloc(basic_string&, false_type)
+ _NOEXCEPT
+ {}
+
+ basic_string& __assign_external(const value_type* __s);
+ basic_string& __assign_external(const value_type* __s, size_type __n);
+
+ // Assigns the value in __s, guaranteed to be __n < __min_cap in length.
+ inline basic_string& __assign_short(const value_type* __s, size_type __n) {
+ pointer __p = __is_long()
+ ? (__set_long_size(__n), __get_long_pointer())
+ : (__set_short_size(__n), __get_short_pointer());
+ traits_type::move(_VSTD::__to_address(__p), __s, __n);
+ traits_type::assign(__p[__n], value_type());
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI basic_string& __null_terminate_at(value_type* __p, size_type __newsz) {
+ __set_size(__newsz);
+ __invalidate_iterators_past(__newsz);
+ traits_type::assign(__p[__newsz], value_type());
+ return *this;
+ }
+
+ _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();
+ }
+
+ _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
+ void __throw_length_error() const {
+ _VSTD::__throw_length_error("basic_string");
+ }
+
+ _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
+ void __throw_out_of_range() const {
+ _VSTD::__throw_out_of_range("basic_string");
+ }
+
+ 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&);
+ friend basic_string operator+<>(const basic_string&, const value_type*);
+ friend basic_string operator+<>(const basic_string&, value_type);
+};
+
+// These declarations must appear before any functions are implicitly used
+// so that they have the correct visibility specifier.
+#ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
+ _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, char)
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, wchar_t)
+# endif
+#else
+ _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, char)
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, wchar_t)
+# endif
+#endif
+
+
+#if _LIBCPP_STD_VER >= 17
+template<class _InputIterator,
+ class _CharT = __iter_value_type<_InputIterator>,
+ class _Allocator = allocator<_CharT>,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = enable_if_t<__is_allocator<_Allocator>::value>
+ >
+basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
+ -> basic_string<_CharT, char_traits<_CharT>, _Allocator>;
+
+template<class _CharT,
+ class _Traits,
+ class _Allocator = allocator<_CharT>,
+ class = enable_if_t<__is_allocator<_Allocator>::value>
+ >
+explicit basic_string(basic_string_view<_CharT, _Traits>, const _Allocator& = _Allocator())
+ -> basic_string<_CharT, _Traits, _Allocator>;
+
+template<class _CharT,
+ class _Traits,
+ class _Allocator = allocator<_CharT>,
+ class = enable_if_t<__is_allocator<_Allocator>::value>,
+ class _Sz = typename allocator_traits<_Allocator>::size_type
+ >
+basic_string(basic_string_view<_CharT, _Traits>, _Sz, _Sz, const _Allocator& = _Allocator())
+ -> basic_string<_CharT, _Traits, _Allocator>;
+#endif
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+void
+basic_string<_CharT, _Traits, _Allocator>::__invalidate_all_iterators()
+{
+#if _LIBCPP_DEBUG_LEVEL == 2
+ if (!__libcpp_is_constant_evaluated())
+ __get_db()->__invalidate_all(this);
+#endif
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+void
+basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type __pos)
+{
+#if _LIBCPP_DEBUG_LEVEL == 2
+ if (!__libcpp_is_constant_evaluated()) {
+ __c_node* __c = __get_db()->__find_c_and_lock(this);
+ if (__c)
+ {
+ const_pointer __new_last = __get_pointer() + __pos;
+ for (__i_node** __p = __c->end_; __p != __c->beg_; )
+ {
+ --__p;
+ const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_);
+ if (__i->base() > __new_last)
+ {
+ (*__p)->__c_ = nullptr;
+ if (--__c->end_ != __p)
+ _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
+ }
+ }
+ __get_db()->unlock();
+ }
+ }
+#else
+ (void)__pos;
+#endif // _LIBCPP_DEBUG_LEVEL == 2
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+basic_string<_CharT, _Traits, _Allocator>::basic_string()
+ _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
+ : __r_(__default_init_tag(), __default_init_tag())
+{
+ _VSTD::__debug_db_insert_c(this);
+ __zero();
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __a)
+#if _LIBCPP_STD_VER <= 14
+ _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
+#else
+ _NOEXCEPT
+#endif
+: __r_(__default_init_tag(), __a)
+{
+ _VSTD::__debug_db_insert_c(this);
+ __zero();
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s,
+ size_type __sz,
+ size_type __reserve)
+{
+ if (__reserve > max_size())
+ __throw_length_error();
+ pointer __p;
+ if (__fits_in_sso(__reserve))
+ {
+ __set_short_size(__sz);
+ __p = __get_short_pointer();
+ }
+ else
+ {
+ size_type __cap = __recommend(__reserve);
+ __p = __alloc_traits::allocate(__alloc(), __cap+1);
+ __set_long_pointer(__p);
+ __set_long_cap(__cap+1);
+ __set_long_size(__sz);
+ }
+ traits_type::copy(_VSTD::__to_address(__p), __s, __sz);
+ traits_type::assign(__p[__sz], value_type());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+void
+basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz)
+{
+ if (__sz > max_size())
+ __throw_length_error();
+ pointer __p;
+ if (__fits_in_sso(__sz))
+ {
+ __set_short_size(__sz);
+ __p = __get_short_pointer();
+ }
+ else
+ {
+ size_type __cap = __recommend(__sz);
+ __p = __alloc_traits::allocate(__alloc(), __cap+1);
+ __set_long_pointer(__p);
+ __set_long_cap(__cap+1);
+ __set_long_size(__sz);
+ }
+ traits_type::copy(_VSTD::__to_address(__p), __s, __sz);
+ traits_type::assign(__p[__sz], value_type());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+template <class>
+basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a)
+ : __r_(__default_init_tag(), __a)
+{
+ _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr");
+ __init(__s, traits_type::length(__s));
+ _VSTD::__debug_db_insert_c(this);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n)
+ : __r_(__default_init_tag(), __default_init_tag())
+{
+ _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr");
+ __init(__s, __n);
+ _VSTD::__debug_db_insert_c(this);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n, const _Allocator& __a)
+ : __r_(__default_init_tag(), __a)
+{
+ _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr");
+ __init(__s, __n);
+ _VSTD::__debug_db_insert_c(this);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str)
+ : __r_(__default_init_tag(), __alloc_traits::select_on_container_copy_construction(__str.__alloc()))
+{
+ if (!__str.__is_long())
+ __r_.first().__r = __str.__r_.first().__r;
+ else
+ __init_copy_ctor_external(_VSTD::__to_address(__str.__get_long_pointer()),
+ __str.__get_long_size());
+ _VSTD::__debug_db_insert_c(this);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>::basic_string(
+ const basic_string& __str, const allocator_type& __a)
+ : __r_(__default_init_tag(), __a)
+{
+ if (!__str.__is_long())
+ __r_.first().__r = __str.__r_.first().__r;
+ else
+ __init_copy_ctor_external(_VSTD::__to_address(__str.__get_long_pointer()),
+ __str.__get_long_size());
+ _VSTD::__debug_db_insert_c(this);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+void basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(
+ const value_type* __s, size_type __sz) {
+ pointer __p;
+ if (__fits_in_sso(__sz)) {
+ __p = __get_short_pointer();
+ __set_short_size(__sz);
+ } else {
+ if (__sz > max_size())
+ __throw_length_error();
+ size_t __cap = __recommend(__sz);
+ __p = __alloc_traits::allocate(__alloc(), __cap + 1);
+ __set_long_pointer(__p);
+ __set_long_cap(__cap + 1);
+ __set_long_size(__sz);
+ }
+ traits_type::copy(_VSTD::__to_address(__p), __s, __sz + 1);
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str)
+#if _LIBCPP_STD_VER <= 14
+ _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
+#else
+ _NOEXCEPT
+#endif
+ : __r_(_VSTD::move(__str.__r_))
+{
+ __str.__zero();
+ _VSTD::__debug_db_insert_c(this);
+#if _LIBCPP_DEBUG_LEVEL == 2
+ if (!__libcpp_is_constant_evaluated() && __is_long())
+ __get_db()->swap(this, &__str);
+#endif
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, const allocator_type& __a)
+ : __r_(__default_init_tag(), __a)
+{
+ if (__str.__is_long() && __a != __str.__alloc()) // copy, not move
+ __init(_VSTD::__to_address(__str.__get_long_pointer()), __str.__get_long_size());
+ else
+ {
+ __r_.first().__r = __str.__r_.first().__r;
+ __str.__zero();
+ }
+ _VSTD::__debug_db_insert_c(this);
+#if _LIBCPP_DEBUG_LEVEL == 2
+ if (!__libcpp_is_constant_evaluated() && __is_long())
+ __get_db()->swap(this, &__str);
+#endif
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _CharT, class _Traits, class _Allocator>
+void
+basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c)
+{
+ if (__n > max_size())
+ __throw_length_error();
+ pointer __p;
+ if (__fits_in_sso(__n))
+ {
+ __set_short_size(__n);
+ __p = __get_short_pointer();
+ }
+ else
+ {
+ size_type __cap = __recommend(__n);
+ __p = __alloc_traits::allocate(__alloc(), __cap+1);
+ __set_long_pointer(__p);
+ __set_long_cap(__cap+1);
+ __set_long_size(__n);
+ }
+ traits_type::assign(_VSTD::__to_address(__p), __n, __c);
+ traits_type::assign(__p[__n], value_type());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c)
+ : __r_(__default_init_tag(), __default_init_tag())
+{
+ __init(__n, __c);
+ _VSTD::__debug_db_insert_c(this);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+template <class>
+basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c, const _Allocator& __a)
+ : __r_(__default_init_tag(), __a)
+{
+ __init(__n, __c);
+ _VSTD::__debug_db_insert_c(this);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str,
+ size_type __pos, size_type __n,
+ const _Allocator& __a)
+ : __r_(__default_init_tag(), __a)
+{
+ size_type __str_sz = __str.size();
+ if (__pos > __str_sz)
+ __throw_out_of_range();
+ __init(__str.data() + __pos, _VSTD::min(__n, __str_sz - __pos));
+ _VSTD::__debug_db_insert_c(this);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, size_type __pos,
+ const _Allocator& __a)
+ : __r_(__default_init_tag(), __a)
+{
+ size_type __str_sz = __str.size();
+ if (__pos > __str_sz)
+ __throw_out_of_range();
+ __init(__str.data() + __pos, __str_sz - __pos);
+ _VSTD::__debug_db_insert_c(this);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+template <class _Tp, class>
+basic_string<_CharT, _Traits, _Allocator>::basic_string(
+ const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a)
+ : __r_(__default_init_tag(), __a)
+{
+ __self_view __sv0 = __t;
+ __self_view __sv = __sv0.substr(__pos, __n);
+ __init(__sv.data(), __sv.size());
+ _VSTD::__debug_db_insert_c(this);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+template <class _Tp, class>
+basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t)
+ : __r_(__default_init_tag(), __default_init_tag())
+{
+ __self_view __sv = __t;
+ __init(__sv.data(), __sv.size());
+ _VSTD::__debug_db_insert_c(this);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+template <class _Tp, class>
+basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t, const _Allocator& __a)
+ : __r_(__default_init_tag(), __a)
+{
+ __self_view __sv = __t;
+ __init(__sv.data(), __sv.size());
+ _VSTD::__debug_db_insert_c(this);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+template <class _InputIterator>
+__enable_if_t
+<
+ __is_exactly_cpp17_input_iterator<_InputIterator>::value
+>
+basic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _InputIterator __last)
+{
+ __zero();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ for (; __first != __last; ++__first)
+ push_back(*__first);
+#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>
+template <class _ForwardIterator>
+__enable_if_t
+<
+ __is_cpp17_forward_iterator<_ForwardIterator>::value
+>
+basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _ForwardIterator __last)
+{
+ size_type __sz = static_cast<size_type>(_VSTD::distance(__first, __last));
+ if (__sz > max_size())
+ __throw_length_error();
+ pointer __p;
+ if (__fits_in_sso(__sz))
+ {
+ __set_short_size(__sz);
+ __p = __get_short_pointer();
+ }
+ else
+ {
+ size_type __cap = __recommend(__sz);
+ __p = __alloc_traits::allocate(__alloc(), __cap+1);
+ __set_long_pointer(__p);
+ __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>
+template<class _InputIterator, class>
+inline
+basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last)
+ : __r_(__default_init_tag(), __default_init_tag())
+{
+ __init(__first, __last);
+ _VSTD::__debug_db_insert_c(this);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+template<class _InputIterator, class>
+inline
+basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last,
+ const allocator_type& __a)
+ : __r_(__default_init_tag(), __a)
+{
+ __init(__first, __last);
+ _VSTD::__debug_db_insert_c(this);
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+basic_string<_CharT, _Traits, _Allocator>::basic_string(
+ initializer_list<_CharT> __il)
+ : __r_(__default_init_tag(), __default_init_tag())
+{
+ __init(__il.begin(), __il.end());
+ _VSTD::__debug_db_insert_c(this);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+
+basic_string<_CharT, _Traits, _Allocator>::basic_string(
+ initializer_list<_CharT> __il, const _Allocator& __a)
+ : __r_(__default_init_tag(), __a)
+{
+ __init(__il.begin(), __il.end());
+ _VSTD::__debug_db_insert_c(this);
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>::~basic_string()
+{
+#if _LIBCPP_DEBUG_LEVEL == 2
+ if (!__libcpp_is_constant_evaluated())
+ __get_db()->__erase_c(this);
+#endif
+ if (__is_long())
+ __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+void
+basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace
+ (size_type __old_cap, size_type __delta_cap, size_type __old_sz,
+ size_type __n_copy, size_type __n_del, size_type __n_add, const value_type* __p_new_stuff)
+{
+ size_type __ms = max_size();
+ if (__delta_cap > __ms - __old_cap - 1)
+ __throw_length_error();
+ pointer __old_p = __get_pointer();
+ size_type __cap = __old_cap < __ms / 2 - __alignment ?
+ __recommend(_VSTD::max(__old_cap + __delta_cap, 2 * __old_cap)) :
+ __ms - 1;
+ pointer __p = __alloc_traits::allocate(__alloc(), __cap+1);
+ __invalidate_all_iterators();
+ if (__n_copy != 0)
+ traits_type::copy(_VSTD::__to_address(__p),
+ _VSTD::__to_address(__old_p), __n_copy);
+ if (__n_add != 0)
+ traits_type::copy(_VSTD::__to_address(__p) + __n_copy, __p_new_stuff, __n_add);
+ size_type __sec_cp_sz = __old_sz - __n_del - __n_copy;
+ if (__sec_cp_sz != 0)
+ traits_type::copy(_VSTD::__to_address(__p) + __n_copy + __n_add,
+ _VSTD::__to_address(__old_p) + __n_copy + __n_del, __sec_cp_sz);
+ if (__old_cap+1 != __min_cap)
+ __alloc_traits::deallocate(__alloc(), __old_p, __old_cap+1);
+ __set_long_pointer(__p);
+ __set_long_cap(__cap+1);
+ __old_sz = __n_copy + __n_add + __sec_cp_sz;
+ __set_long_size(__old_sz);
+ traits_type::assign(__p[__old_sz], value_type());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+void
+basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz,
+ size_type __n_copy, size_type __n_del, size_type __n_add)
+{
+ size_type __ms = max_size();
+ if (__delta_cap > __ms - __old_cap)
+ __throw_length_error();
+ pointer __old_p = __get_pointer();
+ size_type __cap = __old_cap < __ms / 2 - __alignment ?
+ __recommend(_VSTD::max(__old_cap + __delta_cap, 2 * __old_cap)) :
+ __ms - 1;
+ pointer __p = __alloc_traits::allocate(__alloc(), __cap+1);
+ __invalidate_all_iterators();
+ if (__n_copy != 0)
+ traits_type::copy(_VSTD::__to_address(__p),
+ _VSTD::__to_address(__old_p), __n_copy);
+ size_type __sec_cp_sz = __old_sz - __n_del - __n_copy;
+ if (__sec_cp_sz != 0)
+ traits_type::copy(_VSTD::__to_address(__p) + __n_copy + __n_add,
+ _VSTD::__to_address(__old_p) + __n_copy + __n_del,
+ __sec_cp_sz);
+ if (__old_cap+1 != __min_cap)
+ __alloc_traits::deallocate(__alloc(), __old_p, __old_cap+1);
+ __set_long_pointer(__p);
+ __set_long_cap(__cap+1);
+}
+
+// assign
+
+template <class _CharT, class _Traits, class _Allocator>
+template <bool __is_short>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias(
+ const value_type* __s, size_type __n) {
+ size_type __cap = __is_short ? __min_cap : __get_long_cap();
+ if (__n < __cap) {
+ pointer __p = __is_short ? __get_short_pointer() : __get_long_pointer();
+ __is_short ? __set_short_size(__n) : __set_long_size(__n);
+ traits_type::copy(_VSTD::__to_address(__p), __s, __n);
+ traits_type::assign(__p[__n], value_type());
+ __invalidate_iterators_past(__n);
+ } else {
+ size_type __sz = __is_short ? __get_short_size() : __get_long_size();
+ __grow_by_and_replace(__cap - 1, __n - __cap + 1, __sz, 0, __sz, __n, __s);
+ }
+ return *this;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::__assign_external(
+ const value_type* __s, size_type __n) {
+ size_type __cap = capacity();
+ if (__cap >= __n) {
+ value_type* __p = _VSTD::__to_address(__get_pointer());
+ traits_type::move(__p, __s, __n);
+ return __null_terminate_at(__p, __n);
+ } else {
+ size_type __sz = size();
+ __grow_by_and_replace(__cap, __n - __cap, __sz, 0, __sz, __n, __s);
+ return *this;
+ }
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __n)
+{
+ _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::assign received nullptr");
+ return (_LIBCPP_BUILTIN_CONSTANT_P(__n) && __fits_in_sso(__n))
+ ? __assign_short(__s, __n)
+ : __assign_external(__s, __n);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c)
+{
+ size_type __cap = capacity();
+ if (__cap < __n)
+ {
+ size_type __sz = size();
+ __grow_by(__cap, __n - __cap, __sz, 0, __sz);
+ }
+ value_type* __p = _VSTD::__to_address(__get_pointer());
+ traits_type::assign(__p, __n, __c);
+ return __null_terminate_at(__p, __n);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c)
+{
+ pointer __p;
+ if (__is_long())
+ {
+ __p = __get_long_pointer();
+ __set_long_size(1);
+ }
+ else
+ {
+ __p = __get_short_pointer();
+ __set_short_size(1);
+ }
+ traits_type::assign(*__p, __c);
+ traits_type::assign(*++__p, value_type());
+ __invalidate_iterators_past(1);
+ return *this;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str)
+{
+ if (this != &__str) {
+ __copy_assign_alloc(__str);
+ if (!__is_long()) {
+ if (!__str.__is_long()) {
+ __r_.first().__r = __str.__r_.first().__r;
+ } else {
+ return __assign_no_alias<true>(__str.data(), __str.size());
+ }
+ } else {
+ return __assign_no_alias<false>(__str.data(), __str.size());
+ }
+ }
+ return *this;
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+void
+basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, false_type)
+ _NOEXCEPT_(__alloc_traits::is_always_equal::value)
+{
+ if (__alloc() != __str.__alloc())
+ assign(__str);
+ else
+ __move_assign(__str, true_type());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+void
+basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type)
+#if _LIBCPP_STD_VER > 14
+ _NOEXCEPT
+#else
+ _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
+#endif
+{
+ if (__is_long()) {
+ __alloc_traits::deallocate(__alloc(), __get_long_pointer(),
+ __get_long_cap());
+#if _LIBCPP_STD_VER <= 14
+ if (!is_nothrow_move_assignable<allocator_type>::value) {
+ __set_short_size(0);
+ traits_type::assign(__get_short_pointer()[0], value_type());
+ }
+#endif
+ }
+ __move_assign_alloc(__str);
+ __r_.first() = __str.__r_.first();
+ __str.__set_short_size(0);
+ traits_type::assign(__str.__get_short_pointer()[0], value_type());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::operator=(basic_string&& __str)
+ _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))
+{
+ __move_assign(__str, integral_constant<bool,
+ __alloc_traits::propagate_on_container_move_assignment::value>());
+ return *this;
+}
+
+#endif
+
+template <class _CharT, class _Traits, class _Allocator>
+template<class _InputIterator>
+__enable_if_t
+<
+ __is_exactly_cpp17_input_iterator<_InputIterator>::value,
+ basic_string<_CharT, _Traits, _Allocator>&
+>
+basic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
+{
+ const basic_string __temp(__first, __last, __alloc());
+ assign(__temp.data(), __temp.size());
+ return *this;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+template<class _ForwardIterator>
+__enable_if_t
+<
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
+ basic_string<_CharT, _Traits, _Allocator>&
+>
+basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last)
+{
+ size_type __cap = capacity();
+ 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)))
+ {
+ if (__cap < __n)
+ {
+ size_type __sz = size();
+ __grow_by(__cap, __n - __cap, __sz, 0, __sz);
+ }
+ pointer __p = __get_pointer();
+ for (; __first != __last; ++__p, (void) ++__first)
+ traits_type::assign(*__p, *__first);
+ traits_type::assign(*__p, value_type());
+ __set_size(__n);
+ __invalidate_iterators_past(__n);
+ }
+ else
+ {
+ const basic_string __temp(__first, __last, __alloc());
+ assign(__temp.data(), __temp.size());
+ }
+ return *this;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, size_type __pos, size_type __n)
+{
+ size_type __sz = __str.size();
+ if (__pos > __sz)
+ __throw_out_of_range();
+ return assign(__str.data() + __pos, _VSTD::min(__n, __sz - __pos));
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+template <class _Tp>
+__enable_if_t
+<
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
+ && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,
+ basic_string<_CharT, _Traits, _Allocator>&
+>
+basic_string<_CharT, _Traits, _Allocator>::assign(const _Tp & __t, size_type __pos, size_type __n)
+{
+ __self_view __sv = __t;
+ size_type __sz = __sv.size();
+ if (__pos > __sz)
+ __throw_out_of_range();
+ return assign(__sv.data() + __pos, _VSTD::min(__n, __sz - __pos));
+}
+
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::__assign_external(const value_type* __s) {
+ return __assign_external(__s, traits_type::length(__s));
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s)
+{
+ _LIBCPP_ASSERT(__s != nullptr, "string::assign received nullptr");
+ return _LIBCPP_BUILTIN_CONSTANT_P(*__s)
+ ? (__fits_in_sso(traits_type::length(__s))
+ ? __assign_short(__s, traits_type::length(__s))
+ : __assign_external(__s, traits_type::length(__s)))
+ : __assign_external(__s);
+}
+// append
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_type __n)
+{
+ _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::append received nullptr");
+ size_type __cap = capacity();
+ size_type __sz = size();
+ if (__cap - __sz >= __n)
+ {
+ if (__n)
+ {
+ value_type* __p = _VSTD::__to_address(__get_pointer());
+ traits_type::copy(__p + __sz, __s, __n);
+ __sz += __n;
+ __set_size(__sz);
+ traits_type::assign(__p[__sz], value_type());
+ }
+ }
+ else
+ __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __sz, 0, __n, __s);
+ return *this;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c)
+{
+ if (__n)
+ {
+ size_type __cap = capacity();
+ size_type __sz = size();
+ if (__cap - __sz < __n)
+ __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0);
+ pointer __p = __get_pointer();
+ traits_type::assign(_VSTD::__to_address(__p) + __sz, __n, __c);
+ __sz += __n;
+ __set_size(__sz);
+ traits_type::assign(__p[__sz], value_type());
+ }
+ return *this;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline void
+basic_string<_CharT, _Traits, _Allocator>::__append_default_init(size_type __n)
+{
+ if (__n)
+ {
+ size_type __cap = capacity();
+ size_type __sz = size();
+ if (__cap - __sz < __n)
+ __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0);
+ pointer __p = __get_pointer();
+ __sz += __n;
+ __set_size(__sz);
+ traits_type::assign(__p[__sz], value_type());
+ }
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+void
+basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c)
+{
+ bool __is_short = !__is_long();
+ size_type __cap;
+ size_type __sz;
+ if (__is_short)
+ {
+ __cap = __min_cap - 1;
+ __sz = __get_short_size();
+ }
+ else
+ {
+ __cap = __get_long_cap() - 1;
+ __sz = __get_long_size();
+ }
+ if (__sz == __cap)
+ {
+ __grow_by(__cap, 1, __sz, __sz, 0);
+ __is_short = false; // the string is always long after __grow_by
+ }
+ pointer __p;
+ if (__is_short)
+ {
+ __p = __get_short_pointer() + __sz;
+ __set_short_size(__sz+1);
+ }
+ else
+ {
+ __p = __get_long_pointer() + __sz;
+ __set_long_size(__sz+1);
+ }
+ traits_type::assign(*__p, __c);
+ traits_type::assign(*++__p, value_type());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+template<class _ForwardIterator>
+__enable_if_t
+<
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
+ basic_string<_CharT, _Traits, _Allocator>&
+>
+basic_string<_CharT, _Traits, _Allocator>::append(
+ _ForwardIterator __first, _ForwardIterator __last)
+{
+ size_type __sz = size();
+ size_type __cap = capacity();
+ size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
+ if (__n)
+ {
+ if (__string_is_trivial_iterator<_ForwardIterator>::value &&
+ !__addr_in_range(*__first))
+ {
+ if (__cap - __sz < __n)
+ __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0);
+ pointer __p = __get_pointer() + __sz;
+ for (; __first != __last; ++__p, (void) ++__first)
+ traits_type::assign(*__p, *__first);
+ 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;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str)
+{
+ return append(__str.data(), __str.size());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str, size_type __pos, size_type __n)
+{
+ size_type __sz = __str.size();
+ if (__pos > __sz)
+ __throw_out_of_range();
+ return append(__str.data() + __pos, _VSTD::min(__n, __sz - __pos));
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+template <class _Tp>
+ __enable_if_t
+ <
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,
+ basic_string<_CharT, _Traits, _Allocator>&
+ >
+basic_string<_CharT, _Traits, _Allocator>::append(const _Tp & __t, size_type __pos, size_type __n)
+{
+ __self_view __sv = __t;
+ size_type __sz = __sv.size();
+ if (__pos > __sz)
+ __throw_out_of_range();
+ return append(__sv.data() + __pos, _VSTD::min(__n, __sz - __pos));
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s)
+{
+ _LIBCPP_ASSERT(__s != nullptr, "string::append received nullptr");
+ return append(__s, traits_type::length(__s));
+}
+
+// insert
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s, size_type __n)
+{
+ _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::insert received nullptr");
+ size_type __sz = size();
+ if (__pos > __sz)
+ __throw_out_of_range();
+ size_type __cap = capacity();
+ if (__cap - __sz >= __n)
+ {
+ if (__n)
+ {
+ value_type* __p = _VSTD::__to_address(__get_pointer());
+ size_type __n_move = __sz - __pos;
+ if (__n_move != 0)
+ {
+ if (__p + __pos <= __s && __s < __p + __sz)
+ __s += __n;
+ traits_type::move(__p + __pos + __n, __p + __pos, __n_move);
+ }
+ traits_type::move(__p + __pos, __s, __n);
+ __sz += __n;
+ __set_size(__sz);
+ traits_type::assign(__p[__sz], value_type());
+ }
+ }
+ else
+ __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __pos, 0, __n, __s);
+ return *this;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n, value_type __c)
+{
+ size_type __sz = size();
+ if (__pos > __sz)
+ __throw_out_of_range();
+ if (__n)
+ {
+ size_type __cap = capacity();
+ value_type* __p;
+ if (__cap - __sz >= __n)
+ {
+ __p = _VSTD::__to_address(__get_pointer());
+ size_type __n_move = __sz - __pos;
+ if (__n_move != 0)
+ traits_type::move(__p + __pos + __n, __p + __pos, __n_move);
+ }
+ else
+ {
+ __grow_by(__cap, __sz + __n - __cap, __sz, __pos, 0, __n);
+ __p = _VSTD::__to_address(__get_long_pointer());
+ }
+ traits_type::assign(__p + __pos, __n, __c);
+ __sz += __n;
+ __set_size(__sz);
+ traits_type::assign(__p[__sz], value_type());
+ }
+ return *this;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+template<class _InputIterator>
+__enable_if_t
+<
+ __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)
+{
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,
+ "string::insert(iterator, range) called with an iterator not"
+ " referring to this string");
+ const basic_string __temp(__first, __last, __alloc());
+ return insert(__pos, __temp.data(), __temp.data() + __temp.size());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+template<class _ForwardIterator>
+__enable_if_t
+<
+ __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)
+{
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,
+ "string::insert(iterator, range) called with an iterator not"
+ " referring to this string");
+
+ size_type __ip = static_cast<size_type>(__pos - begin());
+ size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
+ if (__n)
+ {
+ if (__string_is_trivial_iterator<_ForwardIterator>::value &&
+ !__addr_in_range(*__first))
+ {
+ 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, (void) ++__first)
+ traits_type::assign(*__p, *__first);
+ }
+ else
+ {
+ const basic_string __temp(__first, __last, __alloc());
+ return insert(__pos, __temp.data(), __temp.data() + __temp.size());
+ }
+ }
+ return begin() + __ip;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str)
+{
+ return insert(__pos1, __str.data(), __str.size());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str,
+ size_type __pos2, size_type __n)
+{
+ size_type __str_sz = __str.size();
+ if (__pos2 > __str_sz)
+ __throw_out_of_range();
+ return insert(__pos1, __str.data() + __pos2, _VSTD::min(__n, __str_sz - __pos2));
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+template <class _Tp>
+__enable_if_t
+<
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,
+ basic_string<_CharT, _Traits, _Allocator>&
+>
+basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const _Tp& __t,
+ size_type __pos2, size_type __n)
+{
+ __self_view __sv = __t;
+ size_type __str_sz = __sv.size();
+ if (__pos2 > __str_sz)
+ __throw_out_of_range();
+ return insert(__pos1, __sv.data() + __pos2, _VSTD::min(__n, __str_sz - __pos2));
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s)
+{
+ _LIBCPP_ASSERT(__s != nullptr, "string::insert received nullptr");
+ return insert(__pos, __s, traits_type::length(__s));
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+typename basic_string<_CharT, _Traits, _Allocator>::iterator
+basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_type __c)
+{
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,
+ "string::insert(iterator, character) called with an iterator not"
+ " referring to this string");
+
+ size_type __ip = static_cast<size_type>(__pos - begin());
+ size_type __sz = size();
+ size_type __cap = capacity();
+ value_type* __p;
+ if (__cap == __sz)
+ {
+ __grow_by(__cap, 1, __sz, __ip, 0, 1);
+ __p = _VSTD::__to_address(__get_long_pointer());
+ }
+ else
+ {
+ __p = _VSTD::__to_address(__get_pointer());
+ size_type __n_move = __sz - __ip;
+ if (__n_move != 0)
+ traits_type::move(__p + __ip + 1, __p + __ip, __n_move);
+ }
+ traits_type::assign(__p[__ip], __c);
+ traits_type::assign(__p[++__sz], value_type());
+ __set_size(__sz);
+ return begin() + static_cast<difference_type>(__ip);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+typename basic_string<_CharT, _Traits, _Allocator>::iterator
+basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, size_type __n, value_type __c)
+{
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,
+ "string::insert(iterator, n, value) called with an iterator not"
+ " referring to this string");
+ difference_type __p = __pos - begin();
+ insert(static_cast<size_type>(__p), __n, __c);
+ return begin() + __p;
+}
+
+// replace
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2)
+ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
+{
+ _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::replace received nullptr");
+ size_type __sz = size();
+ if (__pos > __sz)
+ __throw_out_of_range();
+ __n1 = _VSTD::min(__n1, __sz - __pos);
+ size_type __cap = capacity();
+ if (__cap - __sz + __n1 >= __n2)
+ {
+ value_type* __p = _VSTD::__to_address(__get_pointer());
+ if (__n1 != __n2)
+ {
+ size_type __n_move = __sz - __pos - __n1;
+ if (__n_move != 0)
+ {
+ if (__n1 > __n2)
+ {
+ traits_type::move(__p + __pos, __s, __n2);
+ traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move);
+ return __null_terminate_at(__p, __sz + (__n2 - __n1));
+ }
+ if (__p + __pos < __s && __s < __p + __sz)
+ {
+ if (__p + __pos + __n1 <= __s)
+ __s += __n2 - __n1;
+ else // __p + __pos < __s < __p + __pos + __n1
+ {
+ traits_type::move(__p + __pos, __s, __n1);
+ __pos += __n1;
+ __s += __n2;
+ __n2 -= __n1;
+ __n1 = 0;
+ }
+ }
+ traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move);
+ }
+ }
+ traits_type::move(__p + __pos, __s, __n2);
+ return __null_terminate_at(__p, __sz + (__n2 - __n1));
+ }
+ else
+ __grow_by_and_replace(__cap, __sz - __n1 + __n2 - __cap, __sz, __pos, __n1, __n2, __s);
+ return *this;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, size_type __n2, value_type __c)
+{
+ size_type __sz = size();
+ if (__pos > __sz)
+ __throw_out_of_range();
+ __n1 = _VSTD::min(__n1, __sz - __pos);
+ size_type __cap = capacity();
+ value_type* __p;
+ if (__cap - __sz + __n1 >= __n2)
+ {
+ __p = _VSTD::__to_address(__get_pointer());
+ if (__n1 != __n2)
+ {
+ size_type __n_move = __sz - __pos - __n1;
+ if (__n_move != 0)
+ traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move);
+ }
+ }
+ else
+ {
+ __grow_by(__cap, __sz - __n1 + __n2 - __cap, __sz, __pos, __n1, __n2);
+ __p = _VSTD::__to_address(__get_long_pointer());
+ }
+ traits_type::assign(__p + __pos, __n2, __c);
+ return __null_terminate_at(__p, __sz - (__n1 - __n2));
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+template<class _InputIterator>
+__enable_if_t
+<
+ __is_cpp17_input_iterator<_InputIterator>::value,
+ basic_string<_CharT, _Traits, _Allocator>&
+>
+basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2,
+ _InputIterator __j1, _InputIterator __j2)
+{
+ const basic_string __temp(__j1, __j2, __alloc());
+ return replace(__i1, __i2, __temp);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str)
+{
+ return replace(__pos1, __n1, __str.data(), __str.size());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str,
+ size_type __pos2, size_type __n2)
+{
+ size_type __str_sz = __str.size();
+ if (__pos2 > __str_sz)
+ __throw_out_of_range();
+ return replace(__pos1, __n1, __str.data() + __pos2, _VSTD::min(__n2, __str_sz - __pos2));
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+template <class _Tp>
+__enable_if_t
+<
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,
+ basic_string<_CharT, _Traits, _Allocator>&
+>
+basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const _Tp& __t,
+ size_type __pos2, size_type __n2)
+{
+ __self_view __sv = __t;
+ size_type __str_sz = __sv.size();
+ if (__pos2 > __str_sz)
+ __throw_out_of_range();
+ return replace(__pos1, __n1, __sv.data() + __pos2, _VSTD::min(__n2, __str_sz - __pos2));
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s)
+{
+ _LIBCPP_ASSERT(__s != nullptr, "string::replace received nullptr");
+ return replace(__pos, __n1, __s, traits_type::length(__s));
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const basic_string& __str)
+{
+ return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1),
+ __str.data(), __str.size());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n)
+{
+ return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __s, __n);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s)
+{
+ return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __s);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c)
+{
+ return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __n, __c);
+}
+
+// erase
+
+// 'externally instantiated' erase() implementation, called when __n != npos.
+// Does not check __pos against size()
+template <class _CharT, class _Traits, class _Allocator>
+void
+basic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move(
+ size_type __pos, size_type __n)
+{
+ if (__n)
+ {
+ size_type __sz = size();
+ value_type* __p = _VSTD::__to_address(__get_pointer());
+ __n = _VSTD::min(__n, __sz - __pos);
+ size_type __n_move = __sz - __pos - __n;
+ if (__n_move != 0)
+ traits_type::move(__p + __pos, __p + __pos + __n, __n_move);
+ __null_terminate_at(__p, __sz - __n);
+ }
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos,
+ size_type __n) {
+ if (__pos > size())
+ __throw_out_of_range();
+ if (__n == npos) {
+ __erase_to_end(__pos);
+ } else {
+ __erase_external_with_move(__pos, __n);
+ }
+ return *this;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+typename basic_string<_CharT, _Traits, _Allocator>::iterator
+basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos)
+{
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,
+ "string::erase(iterator) called with an iterator not"
+ " referring to this string");
+
+ _LIBCPP_ASSERT(__pos != end(), "string::erase(iterator) called with a non-dereferenceable iterator");
+ iterator __b = begin();
+ size_type __r = static_cast<size_type>(__pos - __b);
+ erase(__r, 1);
+ return __b + static_cast<difference_type>(__r);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+typename basic_string<_CharT, _Traits, _Allocator>::iterator
+basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_iterator __last)
+{
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this,
+ "string::erase(iterator, iterator) called with an iterator not"
+ " referring to this string");
+
+ _LIBCPP_ASSERT(__first <= __last, "string::erase(first, last) called with invalid range");
+ iterator __b = begin();
+ size_type __r = static_cast<size_type>(__first - __b);
+ erase(__r, static_cast<size_type>(__last - __first));
+ return __b + static_cast<difference_type>(__r);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+void
+basic_string<_CharT, _Traits, _Allocator>::pop_back()
+{
+ _LIBCPP_ASSERT(!empty(), "string::pop_back(): string is already empty");
+ __erase_to_end(size() - 1);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+void
+basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT
+{
+ __invalidate_all_iterators();
+ if (__is_long())
+ {
+ traits_type::assign(*__get_long_pointer(), value_type());
+ __set_long_size(0);
+ }
+ else
+ {
+ traits_type::assign(*__get_short_pointer(), value_type());
+ __set_short_size(0);
+ }
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+void
+basic_string<_CharT, _Traits, _Allocator>::__erase_to_end(size_type __pos)
+{
+ __null_terminate_at(_VSTD::__to_address(__get_pointer()), __pos);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+void
+basic_string<_CharT, _Traits, _Allocator>::resize(size_type __n, value_type __c)
+{
+ size_type __sz = size();
+ if (__n > __sz)
+ append(__n - __sz, __c);
+ else
+ __erase_to_end(__n);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline void
+basic_string<_CharT, _Traits, _Allocator>::__resize_default_init(size_type __n)
+{
+ size_type __sz = size();
+ if (__n > __sz) {
+ __append_default_init(__n - __sz);
+ } else
+ __erase_to_end(__n);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::max_size() const _NOEXCEPT
+{
+ size_type __m = __alloc_traits::max_size(__alloc());
+#ifdef _LIBCPP_BIG_ENDIAN
+ return (__m <= ~__long_mask ? __m : __m/2) - __alignment;
+#else
+ return __m - __alignment;
+#endif
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+void
+basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacity)
+{
+ if (__requested_capacity > max_size())
+ __throw_length_error();
+
+ // Make sure reserve(n) never shrinks. This is technically only required in C++20
+ // and later (since P0966R1), however we provide consistent behavior in all Standard
+ // modes because this function is instantiated in the shared library.
+ if (__requested_capacity <= capacity())
+ return;
+
+ size_type __target_capacity = _VSTD::max(__requested_capacity, size());
+ __target_capacity = __recommend(__target_capacity);
+ if (__target_capacity == capacity()) return;
+
+ __shrink_or_extend(__target_capacity);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+void
+basic_string<_CharT, _Traits, _Allocator>::shrink_to_fit() _NOEXCEPT
+{
+ size_type __target_capacity = __recommend(size());
+ if (__target_capacity == capacity()) return;
+
+ __shrink_or_extend(__target_capacity);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+void
+basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target_capacity)
+{
+ size_type __cap = capacity();
+ size_type __sz = size();
+
+ pointer __new_data, __p;
+ bool __was_long, __now_long;
+ if (__target_capacity == __min_cap - 1)
+ {
+ __was_long = true;
+ __now_long = false;
+ __new_data = __get_short_pointer();
+ __p = __get_long_pointer();
+ }
+ else
+ {
+ if (__target_capacity > __cap)
+ __new_data = __alloc_traits::allocate(__alloc(), __target_capacity+1);
+ else
+ {
+ #ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+ #endif // _LIBCPP_NO_EXCEPTIONS
+ __new_data = __alloc_traits::allocate(__alloc(), __target_capacity+1);
+ #ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ return;
+ }
+ #else // _LIBCPP_NO_EXCEPTIONS
+ if (__new_data == nullptr)
+ return;
+ #endif // _LIBCPP_NO_EXCEPTIONS
+ }
+ __now_long = true;
+ __was_long = __is_long();
+ __p = __get_pointer();
+ }
+ traits_type::copy(_VSTD::__to_address(__new_data),
+ _VSTD::__to_address(__p), size()+1);
+ if (__was_long)
+ __alloc_traits::deallocate(__alloc(), __p, __cap+1);
+ if (__now_long)
+ {
+ __set_long_cap(__target_capacity+1);
+ __set_long_size(__sz);
+ __set_long_pointer(__new_data);
+ }
+ else
+ __set_short_size(__sz);
+ __invalidate_all_iterators();
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+typename basic_string<_CharT, _Traits, _Allocator>::const_reference
+basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) const _NOEXCEPT
+{
+ _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds");
+ return *(data() + __pos);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+typename basic_string<_CharT, _Traits, _Allocator>::reference
+basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) _NOEXCEPT
+{
+ _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds");
+ return *(__get_pointer() + __pos);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+typename basic_string<_CharT, _Traits, _Allocator>::const_reference
+basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const
+{
+ if (__n >= size())
+ __throw_out_of_range();
+ return (*this)[__n];
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+typename basic_string<_CharT, _Traits, _Allocator>::reference
+basic_string<_CharT, _Traits, _Allocator>::at(size_type __n)
+{
+ if (__n >= size())
+ __throw_out_of_range();
+ return (*this)[__n];
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+typename basic_string<_CharT, _Traits, _Allocator>::reference
+basic_string<_CharT, _Traits, _Allocator>::front() _NOEXCEPT
+{
+ _LIBCPP_ASSERT(!empty(), "string::front(): string is empty");
+ return *__get_pointer();
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+typename basic_string<_CharT, _Traits, _Allocator>::const_reference
+basic_string<_CharT, _Traits, _Allocator>::front() const _NOEXCEPT
+{
+ _LIBCPP_ASSERT(!empty(), "string::front(): string is empty");
+ return *data();
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+typename basic_string<_CharT, _Traits, _Allocator>::reference
+basic_string<_CharT, _Traits, _Allocator>::back() _NOEXCEPT
+{
+ _LIBCPP_ASSERT(!empty(), "string::back(): string is empty");
+ return *(__get_pointer() + size() - 1);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+typename basic_string<_CharT, _Traits, _Allocator>::const_reference
+basic_string<_CharT, _Traits, _Allocator>::back() const _NOEXCEPT
+{
+ _LIBCPP_ASSERT(!empty(), "string::back(): string is empty");
+ return *(data() + size() - 1);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n, size_type __pos) const
+{
+ size_type __sz = size();
+ if (__pos > __sz)
+ __throw_out_of_range();
+ size_type __rlen = _VSTD::min(__n, __sz - __pos);
+ traits_type::copy(__s, data() + __pos, __rlen);
+ return __rlen;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+basic_string<_CharT, _Traits, _Allocator>
+basic_string<_CharT, _Traits, _Allocator>::substr(size_type __pos, size_type __n) const
+{
+ return basic_string(*this, __pos, __n, __alloc());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+void
+basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str)
+#if _LIBCPP_STD_VER >= 14
+ _NOEXCEPT
+#else
+ _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
+ __is_nothrow_swappable<allocator_type>::value)
+#endif
+{
+#if _LIBCPP_DEBUG_LEVEL == 2
+ if (!__libcpp_is_constant_evaluated()) {
+ if (!__is_long())
+ __get_db()->__invalidate_all(this);
+ if (!__str.__is_long())
+ __get_db()->__invalidate_all(&__str);
+ __get_db()->swap(this, &__str);
+ }
+#endif
+ _LIBCPP_ASSERT(
+ __alloc_traits::propagate_on_container_swap::value ||
+ __alloc_traits::is_always_equal::value ||
+ __alloc() == __str.__alloc(), "swapping non-equal allocators");
+ _VSTD::swap(__r_.first(), __str.__r_.first());
+ _VSTD::__swap_allocator(__alloc(), __str.__alloc());
+}
+
+// find
+
+template <class _Traits>
+struct _LIBCPP_HIDDEN __traits_eq
+{
+ typedef typename _Traits::char_type char_type;
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const char_type& __x, const char_type& __y) _NOEXCEPT
+ {return _Traits::eq(__x, __y);}
+};
+
+template<class _CharT, class _Traits, class _Allocator>
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s,
+ size_type __pos,
+ size_type __n) const _NOEXCEPT
+{
+ _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find(): received nullptr");
+ return __str_find<value_type, size_type, traits_type, npos>
+ (data(), size(), __s, __pos, __n);
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str,
+ size_type __pos) const _NOEXCEPT
+{
+ return __str_find<value_type, size_type, traits_type, npos>
+ (data(), size(), __str.data(), __pos, __str.size());
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+template <class _Tp>
+__enable_if_t
+<
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
+ typename basic_string<_CharT, _Traits, _Allocator>::size_type
+>
+basic_string<_CharT, _Traits, _Allocator>::find(const _Tp &__t,
+ size_type __pos) const _NOEXCEPT
+{
+ __self_view __sv = __t;
+ return __str_find<value_type, size_type, traits_type, npos>
+ (data(), size(), __sv.data(), __pos, __sv.size());
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s,
+ size_type __pos) const _NOEXCEPT
+{
+ _LIBCPP_ASSERT(__s != nullptr, "string::find(): received nullptr");
+ return __str_find<value_type, size_type, traits_type, npos>
+ (data(), size(), __s, __pos, traits_type::length(__s));
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find(value_type __c,
+ size_type __pos) const _NOEXCEPT
+{
+ return __str_find<value_type, size_type, traits_type, npos>
+ (data(), size(), __c, __pos);
+}
+
+// rfind
+
+template<class _CharT, class _Traits, class _Allocator>
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s,
+ size_type __pos,
+ size_type __n) const _NOEXCEPT
+{
+ _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::rfind(): received nullptr");
+ return __str_rfind<value_type, size_type, traits_type, npos>
+ (data(), size(), __s, __pos, __n);
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str,
+ size_type __pos) const _NOEXCEPT
+{
+ return __str_rfind<value_type, size_type, traits_type, npos>
+ (data(), size(), __str.data(), __pos, __str.size());
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+template <class _Tp>
+__enable_if_t
+<
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
+ typename basic_string<_CharT, _Traits, _Allocator>::size_type
+>
+basic_string<_CharT, _Traits, _Allocator>::rfind(const _Tp& __t,
+ size_type __pos) const _NOEXCEPT
+{
+ __self_view __sv = __t;
+ return __str_rfind<value_type, size_type, traits_type, npos>
+ (data(), size(), __sv.data(), __pos, __sv.size());
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s,
+ size_type __pos) const _NOEXCEPT
+{
+ _LIBCPP_ASSERT(__s != nullptr, "string::rfind(): received nullptr");
+ return __str_rfind<value_type, size_type, traits_type, npos>
+ (data(), size(), __s, __pos, traits_type::length(__s));
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::rfind(value_type __c,
+ size_type __pos) const _NOEXCEPT
+{
+ return __str_rfind<value_type, size_type, traits_type, npos>
+ (data(), size(), __c, __pos);
+}
+
+// find_first_of
+
+template<class _CharT, class _Traits, class _Allocator>
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s,
+ size_type __pos,
+ size_type __n) const _NOEXCEPT
+{
+ _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_of(): received nullptr");
+ return __str_find_first_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __s, __pos, __n);
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __str,
+ size_type __pos) const _NOEXCEPT
+{
+ return __str_find_first_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __str.data(), __pos, __str.size());
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+template <class _Tp>
+__enable_if_t
+<
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
+ typename basic_string<_CharT, _Traits, _Allocator>::size_type
+>
+basic_string<_CharT, _Traits, _Allocator>::find_first_of(const _Tp& __t,
+ size_type __pos) const _NOEXCEPT
+{
+ __self_view __sv = __t;
+ return __str_find_first_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __sv.data(), __pos, __sv.size());
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s,
+ size_type __pos) const _NOEXCEPT
+{
+ _LIBCPP_ASSERT(__s != nullptr, "string::find_first_of(): received nullptr");
+ return __str_find_first_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __s, __pos, traits_type::length(__s));
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c,
+ size_type __pos) const _NOEXCEPT
+{
+ return find(__c, __pos);
+}
+
+// find_last_of
+
+template<class _CharT, class _Traits, class _Allocator>
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s,
+ size_type __pos,
+ size_type __n) const _NOEXCEPT
+{
+ _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_of(): received nullptr");
+ return __str_find_last_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __s, __pos, __n);
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __str,
+ size_type __pos) const _NOEXCEPT
+{
+ return __str_find_last_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __str.data(), __pos, __str.size());
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+template <class _Tp>
+__enable_if_t
+<
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
+ typename basic_string<_CharT, _Traits, _Allocator>::size_type
+>
+basic_string<_CharT, _Traits, _Allocator>::find_last_of(const _Tp& __t,
+ size_type __pos) const _NOEXCEPT
+{
+ __self_view __sv = __t;
+ return __str_find_last_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __sv.data(), __pos, __sv.size());
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s,
+ size_type __pos) const _NOEXCEPT
+{
+ _LIBCPP_ASSERT(__s != nullptr, "string::find_last_of(): received nullptr");
+ return __str_find_last_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __s, __pos, traits_type::length(__s));
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c,
+ size_type __pos) const _NOEXCEPT
+{
+ return rfind(__c, __pos);
+}
+
+// find_first_not_of
+
+template<class _CharT, class _Traits, class _Allocator>
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s,
+ size_type __pos,
+ size_type __n) const _NOEXCEPT
+{
+ _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_not_of(): received nullptr");
+ return __str_find_first_not_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __s, __pos, __n);
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string& __str,
+ size_type __pos) const _NOEXCEPT
+{
+ return __str_find_first_not_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __str.data(), __pos, __str.size());
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+template <class _Tp>
+__enable_if_t
+<
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
+ typename basic_string<_CharT, _Traits, _Allocator>::size_type
+>
+basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const _Tp& __t,
+ size_type __pos) const _NOEXCEPT
+{
+ __self_view __sv = __t;
+ return __str_find_first_not_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __sv.data(), __pos, __sv.size());
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s,
+ size_type __pos) const _NOEXCEPT
+{
+ _LIBCPP_ASSERT(__s != nullptr, "string::find_first_not_of(): received nullptr");
+ return __str_find_first_not_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __s, __pos, traits_type::length(__s));
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(value_type __c,
+ size_type __pos) const _NOEXCEPT
+{
+ return __str_find_first_not_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __c, __pos);
+}
+
+// find_last_not_of
+
+template<class _CharT, class _Traits, class _Allocator>
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s,
+ size_type __pos,
+ size_type __n) const _NOEXCEPT
+{
+ _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_not_of(): received nullptr");
+ return __str_find_last_not_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __s, __pos, __n);
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string& __str,
+ size_type __pos) const _NOEXCEPT
+{
+ return __str_find_last_not_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __str.data(), __pos, __str.size());
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+template <class _Tp>
+__enable_if_t
+<
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
+ typename basic_string<_CharT, _Traits, _Allocator>::size_type
+>
+basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const _Tp& __t,
+ size_type __pos) const _NOEXCEPT
+{
+ __self_view __sv = __t;
+ return __str_find_last_not_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __sv.data(), __pos, __sv.size());
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s,
+ size_type __pos) const _NOEXCEPT
+{
+ _LIBCPP_ASSERT(__s != nullptr, "string::find_last_not_of(): received nullptr");
+ return __str_find_last_not_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __s, __pos, traits_type::length(__s));
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c,
+ size_type __pos) const _NOEXCEPT
+{
+ return __str_find_last_not_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __c, __pos);
+}
+
+// compare
+
+template <class _CharT, class _Traits, class _Allocator>
+template <class _Tp>
+__enable_if_t
+<
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
+ int
+>
+basic_string<_CharT, _Traits, _Allocator>::compare(const _Tp& __t) const _NOEXCEPT
+{
+ __self_view __sv = __t;
+ size_t __lhs_sz = size();
+ size_t __rhs_sz = __sv.size();
+ int __result = traits_type::compare(data(), __sv.data(),
+ _VSTD::min(__lhs_sz, __rhs_sz));
+ if (__result != 0)
+ return __result;
+ if (__lhs_sz < __rhs_sz)
+ return -1;
+ if (__lhs_sz > __rhs_sz)
+ return 1;
+ return 0;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+int
+basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) const _NOEXCEPT
+{
+ return compare(__self_view(__str));
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+int
+basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
+ size_type __n1,
+ const value_type* __s,
+ size_type __n2) const
+{
+ _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::compare(): received nullptr");
+ size_type __sz = size();
+ if (__pos1 > __sz || __n2 == npos)
+ __throw_out_of_range();
+ size_type __rlen = _VSTD::min(__n1, __sz - __pos1);
+ int __r = traits_type::compare(data() + __pos1, __s, _VSTD::min(__rlen, __n2));
+ if (__r == 0)
+ {
+ if (__rlen < __n2)
+ __r = -1;
+ else if (__rlen > __n2)
+ __r = 1;
+ }
+ return __r;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+template <class _Tp>
+__enable_if_t
+<
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
+ int
+>
+basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
+ size_type __n1,
+ const _Tp& __t) const
+{
+ __self_view __sv = __t;
+ return compare(__pos1, __n1, __sv.data(), __sv.size());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline
+int
+basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
+ size_type __n1,
+ const basic_string& __str) const
+{
+ return compare(__pos1, __n1, __str.data(), __str.size());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+template <class _Tp>
+__enable_if_t
+<
+ __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
+ && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,
+ int
+>
+basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
+ size_type __n1,
+ const _Tp& __t,
+ size_type __pos2,
+ size_type __n2) const
+{
+ __self_view __sv = __t;
+ return __self_view(*this).substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+int
+basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
+ size_type __n1,
+ const basic_string& __str,
+ size_type __pos2,
+ size_type __n2) const
+{
+ return compare(__pos1, __n1, __self_view(__str), __pos2, __n2);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+int
+basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const _NOEXCEPT
+{
+ _LIBCPP_ASSERT(__s != nullptr, "string::compare(): received nullptr");
+ return compare(0, npos, __s, traits_type::length(__s));
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+int
+basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
+ size_type __n1,
+ const value_type* __s) const
+{
+ _LIBCPP_ASSERT(__s != nullptr, "string::compare(): received nullptr");
+ return compare(__pos1, __n1, __s, traits_type::length(__s));
+}
+
+// __invariants
+
+template<class _CharT, class _Traits, class _Allocator>
+inline
+bool
+basic_string<_CharT, _Traits, _Allocator>::__invariants() const
+{
+ if (size() > capacity())
+ return false;
+ if (capacity() < __min_cap - 1)
+ return false;
+ if (data() == nullptr)
+ return false;
+ if (data()[size()] != value_type())
+ return false;
+ return true;
+}
+
+// __clear_and_shrink
+
+template<class _CharT, class _Traits, class _Allocator>
+inline
+void
+basic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT
+{
+ clear();
+ if(__is_long())
+ {
+ __alloc_traits::deallocate(__alloc(), __get_long_pointer(), capacity() + 1);
+ __set_long_cap(0);
+ __set_short_size(0);
+ traits_type::assign(*__get_short_pointer(), value_type());
+ }
+}
+
+// operator==
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
+ const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
+{
+ size_t __lhs_sz = __lhs.size();
+ return __lhs_sz == __rhs.size() && _Traits::compare(__lhs.data(),
+ __rhs.data(),
+ __lhs_sz) == 0;
+}
+
+template<class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs,
+ const basic_string<char, char_traits<char>, _Allocator>& __rhs) _NOEXCEPT
+{
+ size_t __lhs_sz = __lhs.size();
+ if (__lhs_sz != __rhs.size())
+ return false;
+ const char* __lp = __lhs.data();
+ const char* __rp = __rhs.data();
+ if (__lhs.__is_long())
+ return char_traits<char>::compare(__lp, __rp, __lhs_sz) == 0;
+ for (; __lhs_sz != 0; --__lhs_sz, ++__lp, ++__rp)
+ if (*__lp != *__rp)
+ return false;
+ return true;
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const _CharT* __lhs,
+ const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
+{
+ typedef basic_string<_CharT, _Traits, _Allocator> _String;
+ _LIBCPP_ASSERT(__lhs != nullptr, "operator==(char*, basic_string): received nullptr");
+ size_t __lhs_len = _Traits::length(__lhs);
+ if (__lhs_len != __rhs.size()) return false;
+ return __rhs.compare(0, _String::npos, __lhs, __lhs_len) == 0;
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
+ const _CharT* __rhs) _NOEXCEPT
+{
+ typedef basic_string<_CharT, _Traits, _Allocator> _String;
+ _LIBCPP_ASSERT(__rhs != nullptr, "operator==(basic_string, char*): received nullptr");
+ size_t __rhs_len = _Traits::length(__rhs);
+ if (__rhs_len != __lhs.size()) return false;
+ return __lhs.compare(0, _String::npos, __rhs, __rhs_len) == 0;
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
+ const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
+{
+ return !(__lhs == __rhs);
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const _CharT* __lhs,
+ const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
+{
+ return !(__lhs == __rhs);
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
+ const _CharT* __rhs) _NOEXCEPT
+{
+ return !(__lhs == __rhs);
+}
+
+// operator<
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
+ const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
+{
+ return __lhs.compare(__rhs) < 0;
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
+ const _CharT* __rhs) _NOEXCEPT
+{
+ return __lhs.compare(__rhs) < 0;
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator< (const _CharT* __lhs,
+ const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
+{
+ return __rhs.compare(__lhs) > 0;
+}
+
+// operator>
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
+ const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
+{
+ return __rhs < __lhs;
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
+ const _CharT* __rhs) _NOEXCEPT
+{
+ return __rhs < __lhs;
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator> (const _CharT* __lhs,
+ const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
+{
+ return __rhs < __lhs;
+}
+
+// operator<=
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
+ const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
+{
+ return !(__rhs < __lhs);
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
+ const _CharT* __rhs) _NOEXCEPT
+{
+ return !(__rhs < __lhs);
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const _CharT* __lhs,
+ const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
+{
+ return !(__rhs < __lhs);
+}
+
+// operator>=
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
+ const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
+{
+ return !(__lhs < __rhs);
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
+ const _CharT* __rhs) _NOEXCEPT
+{
+ return !(__lhs < __rhs);
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const _CharT* __lhs,
+ const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
+{
+ return !(__lhs < __rhs);
+}
+
+// operator +
+
+template<class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>
+operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
+ const basic_string<_CharT, _Traits, _Allocator>& __rhs)
+{
+ using _String = basic_string<_CharT, _Traits, _Allocator>;
+ _String __r(_String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator()));
+ typename _String::size_type __lhs_sz = __lhs.size();
+ typename _String::size_type __rhs_sz = __rhs.size();
+ __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + __rhs_sz);
+ __r.append(__rhs.data(), __rhs_sz);
+ return __r;
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>
+operator+(const _CharT* __lhs , const basic_string<_CharT,_Traits,_Allocator>& __rhs)
+{
+ using _String = basic_string<_CharT, _Traits, _Allocator>;
+ _String __r(_String::__alloc_traits::select_on_container_copy_construction(__rhs.get_allocator()));
+ typename _String::size_type __lhs_sz = _Traits::length(__lhs);
+ typename _String::size_type __rhs_sz = __rhs.size();
+ __r.__init(__lhs, __lhs_sz, __lhs_sz + __rhs_sz);
+ __r.append(__rhs.data(), __rhs_sz);
+ return __r;
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>
+operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Allocator>& __rhs)
+{
+ using _String = basic_string<_CharT, _Traits, _Allocator>;
+ _String __r(_String::__alloc_traits::select_on_container_copy_construction(__rhs.get_allocator()));
+ typename _String::size_type __rhs_sz = __rhs.size();
+ __r.__init(&__lhs, 1, 1 + __rhs_sz);
+ __r.append(__rhs.data(), __rhs_sz);
+ return __r;
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline
+basic_string<_CharT, _Traits, _Allocator>
+operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs)
+{
+ using _String = basic_string<_CharT, _Traits, _Allocator>;
+ _String __r(_String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator()));
+ typename _String::size_type __lhs_sz = __lhs.size();
+ typename _String::size_type __rhs_sz = _Traits::length(__rhs);
+ __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + __rhs_sz);
+ __r.append(__rhs, __rhs_sz);
+ return __r;
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>
+operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs)
+{
+ using _String = basic_string<_CharT, _Traits, _Allocator>;
+ _String __r(_String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator()));
+ typename _String::size_type __lhs_sz = __lhs.size();
+ __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + 1);
+ __r.push_back(__rhs);
+ return __r;
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>
+operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs)
+{
+ return _VSTD::move(__lhs.append(__rhs));
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>
+operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs)
+{
+ return _VSTD::move(__rhs.insert(0, __lhs));
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>
+operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs)
+{
+ return _VSTD::move(__lhs.append(__rhs));
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>
+operator+(const _CharT* __lhs , basic_string<_CharT,_Traits,_Allocator>&& __rhs)
+{
+ return _VSTD::move(__rhs.insert(0, __lhs));
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>
+operator+(_CharT __lhs, basic_string<_CharT,_Traits,_Allocator>&& __rhs)
+{
+ __rhs.insert(__rhs.begin(), __lhs);
+ return _VSTD::move(__rhs);
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>
+operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs)
+{
+ return _VSTD::move(__lhs.append(__rhs));
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>
+operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs)
+{
+ __lhs.push_back(__rhs);
+ return _VSTD::move(__lhs);
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+// swap
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(basic_string<_CharT, _Traits, _Allocator>& __lhs,
+ basic_string<_CharT, _Traits, _Allocator>& __rhs)
+ _NOEXCEPT_(_NOEXCEPT_(__lhs.swap(__rhs)))
+{
+ __lhs.swap(__rhs);
+}
+
+_LIBCPP_FUNC_VIS int stoi (const string& __str, size_t* __idx = nullptr, int __base = 10);
+_LIBCPP_FUNC_VIS long stol (const string& __str, size_t* __idx = nullptr, int __base = 10);
+_LIBCPP_FUNC_VIS unsigned long stoul (const string& __str, size_t* __idx = nullptr, int __base = 10);
+_LIBCPP_FUNC_VIS long long stoll (const string& __str, size_t* __idx = nullptr, int __base = 10);
+_LIBCPP_FUNC_VIS unsigned long long stoull(const string& __str, size_t* __idx = nullptr, int __base = 10);
+
+_LIBCPP_FUNC_VIS float stof (const string& __str, size_t* __idx = nullptr);
+_LIBCPP_FUNC_VIS double stod (const string& __str, size_t* __idx = nullptr);
+_LIBCPP_FUNC_VIS long double stold(const string& __str, size_t* __idx = nullptr);
+
+_LIBCPP_FUNC_VIS string to_string(int __val);
+_LIBCPP_FUNC_VIS string to_string(unsigned __val);
+_LIBCPP_FUNC_VIS string to_string(long __val);
+_LIBCPP_FUNC_VIS string to_string(unsigned long __val);
+_LIBCPP_FUNC_VIS string to_string(long long __val);
+_LIBCPP_FUNC_VIS string to_string(unsigned long long __val);
+_LIBCPP_FUNC_VIS string to_string(float __val);
+_LIBCPP_FUNC_VIS string to_string(double __val);
+_LIBCPP_FUNC_VIS string to_string(long double __val);
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+_LIBCPP_FUNC_VIS int stoi (const wstring& __str, size_t* __idx = nullptr, int __base = 10);
+_LIBCPP_FUNC_VIS long stol (const wstring& __str, size_t* __idx = nullptr, int __base = 10);
+_LIBCPP_FUNC_VIS unsigned long stoul (const wstring& __str, size_t* __idx = nullptr, int __base = 10);
+_LIBCPP_FUNC_VIS long long stoll (const wstring& __str, size_t* __idx = nullptr, int __base = 10);
+_LIBCPP_FUNC_VIS unsigned long long stoull(const wstring& __str, size_t* __idx = nullptr, int __base = 10);
+
+_LIBCPP_FUNC_VIS float stof (const wstring& __str, size_t* __idx = nullptr);
+_LIBCPP_FUNC_VIS double stod (const wstring& __str, size_t* __idx = nullptr);
+_LIBCPP_FUNC_VIS long double stold(const wstring& __str, size_t* __idx = nullptr);
+
+_LIBCPP_FUNC_VIS wstring to_wstring(int __val);
+_LIBCPP_FUNC_VIS wstring to_wstring(unsigned __val);
+_LIBCPP_FUNC_VIS wstring to_wstring(long __val);
+_LIBCPP_FUNC_VIS wstring to_wstring(unsigned long __val);
+_LIBCPP_FUNC_VIS wstring to_wstring(long long __val);
+_LIBCPP_FUNC_VIS wstring to_wstring(unsigned long long __val);
+_LIBCPP_FUNC_VIS wstring to_wstring(float __val);
+_LIBCPP_FUNC_VIS wstring to_wstring(double __val);
+_LIBCPP_FUNC_VIS wstring to_wstring(long double __val);
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+template<class _CharT, class _Traits, class _Allocator>
+_LIBCPP_TEMPLATE_DATA_VIS
+const typename basic_string<_CharT, _Traits, _Allocator>::size_type
+ basic_string<_CharT, _Traits, _Allocator>::npos;
+
+template <class _CharT, class _Allocator>
+struct _LIBCPP_TEMPLATE_VIS
+ hash<basic_string<_CharT, char_traits<_CharT>, _Allocator> >
+ : public unary_function<
+ basic_string<_CharT, char_traits<_CharT>, _Allocator>, size_t>
+{
+ size_t
+ operator()(const basic_string<_CharT, char_traits<_CharT>, _Allocator>& __val) const _NOEXCEPT
+ { return __do_string_hash(__val.data(), __val.data() + __val.size()); }
+};
+
+
+template<class _CharT, class _Traits, class _Allocator>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const basic_string<_CharT, _Traits, _Allocator>& __str);
+
+template<class _CharT, class _Traits, class _Allocator>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ basic_string<_CharT, _Traits, _Allocator>& __str);
+
+template<class _CharT, class _Traits, class _Allocator>
+basic_istream<_CharT, _Traits>&
+getline(basic_istream<_CharT, _Traits>& __is,
+ basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm);
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>&
+getline(basic_istream<_CharT, _Traits>& __is,
+ basic_string<_CharT, _Traits, _Allocator>& __str);
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>&
+getline(basic_istream<_CharT, _Traits>&& __is,
+ basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm);
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>&
+getline(basic_istream<_CharT, _Traits>&& __is,
+ basic_string<_CharT, _Traits, _Allocator>& __str);
+
+#if _LIBCPP_STD_VER > 17
+template <class _CharT, class _Traits, class _Allocator, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+ typename basic_string<_CharT, _Traits, _Allocator>::size_type
+ erase(basic_string<_CharT, _Traits, _Allocator>& __str, const _Up& __v) {
+ auto __old_size = __str.size();
+ __str.erase(_VSTD::remove(__str.begin(), __str.end(), __v), __str.end());
+ return __old_size - __str.size();
+}
+
+template <class _CharT, class _Traits, class _Allocator, class _Predicate>
+inline _LIBCPP_INLINE_VISIBILITY
+ typename basic_string<_CharT, _Traits, _Allocator>::size_type
+ erase_if(basic_string<_CharT, _Traits, _Allocator>& __str,
+ _Predicate __pred) {
+ auto __old_size = __str.size();
+ __str.erase(_VSTD::remove_if(__str.begin(), __str.end(), __pred),
+ __str.end());
+ return __old_size - __str.size();
+}
+#endif
+
+#if _LIBCPP_DEBUG_LEVEL == 2
+
+template<class _CharT, class _Traits, class _Allocator>
+bool
+basic_string<_CharT, _Traits, _Allocator>::__dereferenceable(const const_iterator* __i) const
+{
+ return data() <= _VSTD::__to_address(__i->base()) &&
+ _VSTD::__to_address(__i->base()) < data() + size();
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+bool
+basic_string<_CharT, _Traits, _Allocator>::__decrementable(const const_iterator* __i) const
+{
+ return data() < _VSTD::__to_address(__i->base()) &&
+ _VSTD::__to_address(__i->base()) <= data() + size();
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+bool
+basic_string<_CharT, _Traits, _Allocator>::__addable(const const_iterator* __i, ptrdiff_t __n) const
+{
+ const value_type* __p = _VSTD::__to_address(__i->base()) + __n;
+ return data() <= __p && __p <= data() + size();
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+bool
+basic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __n) const
+{
+ const value_type* __p = _VSTD::__to_address(__i->base()) + __n;
+ return data() <= __p && __p < data() + size();
+}
+
+#endif // _LIBCPP_DEBUG_LEVEL == 2
+
+#if _LIBCPP_STD_VER > 11
+// Literal suffixes for basic_string [basic.string.literals]
+inline namespace literals
+{
+ inline namespace string_literals
+ {
+ inline _LIBCPP_INLINE_VISIBILITY
+ basic_string<char> operator "" s( const char *__str, size_t __len )
+ {
+ return basic_string<char> (__str, __len);
+ }
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ inline _LIBCPP_INLINE_VISIBILITY
+ basic_string<wchar_t> operator "" s( const wchar_t *__str, size_t __len )
+ {
+ return basic_string<wchar_t> (__str, __len);
+ }
+#endif
+
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
+ inline _LIBCPP_INLINE_VISIBILITY
+ basic_string<char8_t> operator "" s(const char8_t *__str, size_t __len) _NOEXCEPT
+ {
+ return basic_string<char8_t> (__str, __len);
+ }
+#endif
+
+ inline _LIBCPP_INLINE_VISIBILITY
+ basic_string<char16_t> operator "" s( const char16_t *__str, size_t __len )
+ {
+ return basic_string<char16_t> (__str, __len);
+ }
+
+ inline _LIBCPP_INLINE_VISIBILITY
+ basic_string<char32_t> operator "" s( const char32_t *__str, size_t __len )
+ {
+ return basic_string<char32_t> (__str, __len);
+ }
+ } // namespace string_literals
+} // namespace literals
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( pop )
+#endif
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_STRING
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/string.h b/contrib/libs/cxxsupp/libcxxmsvc/include/string.h
new file mode 100644
index 0000000000..099b6616ab
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/string.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_STRING_H
+#define _LIBCPP_STRING_H
+
+/*
+ string.h synopsis
+
+Macros:
+
+ NULL
+
+Types:
+
+ size_t
+
+void* memcpy(void* restrict s1, const void* restrict s2, size_t n);
+void* memmove(void* s1, const void* s2, size_t n);
+char* strcpy (char* restrict s1, const char* restrict s2);
+char* strncpy(char* restrict s1, const char* restrict s2, size_t n);
+char* strcat (char* restrict s1, const char* restrict s2);
+char* strncat(char* restrict s1, const char* restrict s2, size_t n);
+int memcmp(const void* s1, const void* s2, size_t n);
+int strcmp (const char* s1, const char* s2);
+int strncmp(const char* s1, const char* s2, size_t n);
+int strcoll(const char* s1, const char* s2);
+size_t strxfrm(char* restrict s1, const char* restrict s2, size_t n);
+const void* memchr(const void* s, int c, size_t n);
+ void* memchr( void* s, int c, size_t n);
+const char* strchr(const char* s, int c);
+ char* strchr( char* s, int c);
+size_t strcspn(const char* s1, const char* s2);
+const char* strpbrk(const char* s1, const char* s2);
+ char* strpbrk( char* s1, const char* s2);
+const char* strrchr(const char* s, int c);
+ char* strrchr( char* s, int c);
+size_t strspn(const char* s1, const char* s2);
+const char* strstr(const char* s1, const char* s2);
+ char* strstr( char* s1, const char* s2);
+char* strtok(char* restrict s1, const char* restrict s2);
+void* memset(void* s, int c, size_t n);
+char* strerror(int errnum);
+size_t strlen(const char* s);
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#include Y_UCRT_INCLUDE_NEXT(string.h)
+#else
+#include_next <string.h>
+#endif
+
+// MSVCRT, GNU libc and its derivates may already have the correct prototype in
+// <string.h>. This macro can be defined by users if their C library provides
+// the right signature.
+#if defined(__CORRECT_ISO_CPP_STRING_H_PROTO) || defined(_LIBCPP_MSVCRT) || \
+ defined(__sun__) || defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_)
+#define _LIBCPP_STRING_H_HAS_CONST_OVERLOADS
+#endif
+
+#if defined(__cplusplus) && !defined(_LIBCPP_STRING_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD)
+extern "C++" {
+inline _LIBCPP_INLINE_VISIBILITY
+char* __libcpp_strchr(const char* __s, int __c) {return (char*)strchr(__s, __c);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+const char* strchr(const char* __s, int __c) {return __libcpp_strchr(__s, __c);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+ char* strchr( char* __s, int __c) {return __libcpp_strchr(__s, __c);}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char* __libcpp_strpbrk(const char* __s1, const char* __s2) {return (char*)strpbrk(__s1, __s2);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+const char* strpbrk(const char* __s1, const char* __s2) {return __libcpp_strpbrk(__s1, __s2);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+ char* strpbrk( char* __s1, const char* __s2) {return __libcpp_strpbrk(__s1, __s2);}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char* __libcpp_strrchr(const char* __s, int __c) {return (char*)strrchr(__s, __c);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+const char* strrchr(const char* __s, int __c) {return __libcpp_strrchr(__s, __c);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+ char* strrchr( char* __s, int __c) {return __libcpp_strrchr(__s, __c);}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void* __libcpp_memchr(const void* __s, int __c, size_t __n) {return (void*)memchr(__s, __c, __n);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+const void* memchr(const void* __s, int __c, size_t __n) {return __libcpp_memchr(__s, __c, __n);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+ void* memchr( void* __s, int __c, size_t __n) {return __libcpp_memchr(__s, __c, __n);}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char* __libcpp_strstr(const char* __s1, const char* __s2) {return (char*)strstr(__s1, __s2);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+const char* strstr(const char* __s1, const char* __s2) {return __libcpp_strstr(__s1, __s2);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+ char* strstr( char* __s1, const char* __s2) {return __libcpp_strstr(__s1, __s2);}
+}
+#endif
+
+#endif // _LIBCPP_STRING_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/string_view b/contrib/libs/cxxsupp/libcxxmsvc/include/string_view
new file mode 100644
index 0000000000..81d8c8a2b7
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/string_view
@@ -0,0 +1,970 @@
+// -*- 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_STRING_VIEW
+#define _LIBCPP_STRING_VIEW
+
+/*
+string_view synopsis
+
+namespace std {
+
+ // 7.2, Class template basic_string_view
+ 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,
+ basic_string_view<charT, traits> y) noexcept;
+ template<class charT, class traits>
+ constexpr bool operator!=(basic_string_view<charT, traits> x,
+ basic_string_view<charT, traits> y) noexcept;
+ template<class charT, class traits>
+ constexpr bool operator< (basic_string_view<charT, traits> x,
+ basic_string_view<charT, traits> y) noexcept;
+ template<class charT, class traits>
+ constexpr bool operator> (basic_string_view<charT, traits> x,
+ basic_string_view<charT, traits> y) noexcept;
+ template<class charT, class traits>
+ constexpr bool operator<=(basic_string_view<charT, traits> x,
+ basic_string_view<charT, traits> y) noexcept;
+ template<class charT, class traits>
+ constexpr bool operator>=(basic_string_view<charT, traits> x,
+ basic_string_view<charT, traits> y) noexcept;
+ // see below, sufficient additional overloads of comparison functions
+
+ // 7.10, Inserters and extractors
+ template<class charT, class traits>
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os,
+ basic_string_view<charT, traits> str);
+
+ // 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;
+
+ template<class charT, class traits = char_traits<charT>>
+ class basic_string_view {
+ public:
+ // types
+ typedef traits traits_type;
+ typedef charT value_type;
+ typedef charT* pointer;
+ typedef const charT* const_pointer;
+ typedef charT& reference;
+ typedef const charT& const_reference;
+ typedef implementation-defined const_iterator;
+ typedef const_iterator iterator;
+ typedef reverse_iterator<const_iterator> const_reverse_iterator;
+ typedef const_reverse_iterator reverse_iterator;
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ static constexpr size_type npos = size_type(-1);
+
+ // 7.3, basic_string_view constructors and assignment operators
+ constexpr basic_string_view() noexcept;
+ constexpr basic_string_view(const basic_string_view&) noexcept = default;
+ 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);
+ template <class It, class End>
+ constexpr basic_string_view(It begin, End end); // C++20
+ template <class Range>
+ constexpr basic_string_view(Range&& r); // C++23
+
+ // 7.4, basic_string_view iterator support
+ constexpr const_iterator begin() const noexcept;
+ constexpr const_iterator end() const noexcept;
+ constexpr const_iterator cbegin() const noexcept;
+ constexpr const_iterator cend() const noexcept;
+ const_reverse_iterator rbegin() const noexcept;
+ const_reverse_iterator rend() const noexcept;
+ const_reverse_iterator crbegin() const noexcept;
+ const_reverse_iterator crend() const noexcept;
+
+ // 7.5, basic_string_view capacity
+ constexpr size_type size() const noexcept;
+ constexpr size_type length() const noexcept;
+ constexpr size_type max_size() const noexcept;
+ constexpr bool empty() const noexcept;
+
+ // 7.6, basic_string_view element access
+ constexpr const_reference operator[](size_type pos) const;
+ constexpr const_reference at(size_type pos) const;
+ constexpr const_reference front() const;
+ constexpr const_reference back() const;
+ constexpr const_pointer data() const noexcept;
+
+ // 7.7, basic_string_view modifiers
+ constexpr void remove_prefix(size_type n);
+ 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; // 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;
+ constexpr int compare(size_type pos1, size_type n1, basic_string_view s) const;
+ constexpr int compare(size_type pos1, size_type n1,
+ basic_string_view s, size_type pos2, size_type n2) const;
+ constexpr int compare(const charT* s) const;
+ constexpr int compare(size_type pos1, size_type n1, const charT* s) const;
+ constexpr int compare(size_type pos1, size_type n1,
+ 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 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 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 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 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 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 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
+ constexpr bool starts_with(const charT* s) const; // C++20
+ constexpr bool ends_with(basic_string_view s) const noexcept; // C++20
+ constexpr bool ends_with(charT c) const noexcept; // C++20
+ constexpr bool ends_with(const charT* s) const; // C++20
+
+ constexpr bool contains(basic_string_view s) const noexcept; // C++2b
+ constexpr bool contains(charT c) const noexcept; // C++2b
+ constexpr bool contains(const charT* s) const; // C++2b
+
+ private:
+ const_pointer data_; // exposition only
+ size_type size_; // exposition only
+ };
+
+ // basic_string_view deduction guides
+ template<class It, class End>
+ basic_string_view(It, End) -> basic_string_view<iter_value_t<It>>; // C++20
+ template<class Range>
+ basic_string_view(Range&&) -> basic_string_view<ranges::range_value_t<Range>>; // C++23
+
+ // 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;
+
+} // namespace std
+
+
+*/
+
+#include <__algorithm/min.h>
+#include <__assert>
+#include <__config>
+#include <__ranges/concepts.h>
+#include <__ranges/data.h>
+#include <__ranges/enable_borrowed_range.h>
+#include <__ranges/enable_view.h>
+#include <__ranges/size.h>
+#include <__string>
+#include <compare>
+#include <iosfwd>
+#include <iterator>
+#include <limits>
+#include <stdexcept>
+#include <type_traits>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( push )
+#pragma warning ( disable : 4455 )
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template<class _CharT, class _Traits = char_traits<_CharT> >
+ class _LIBCPP_TEMPLATE_VIS basic_string_view;
+
+typedef basic_string_view<char> string_view;
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
+typedef basic_string_view<char8_t> u8string_view;
+#endif
+typedef basic_string_view<char16_t> u16string_view;
+typedef basic_string_view<char32_t> u32string_view;
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+typedef basic_string_view<wchar_t> wstring_view;
+#endif
+
+template<class _CharT, class _Traits>
+class
+ _LIBCPP_PREFERRED_NAME(string_view)
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
+ _LIBCPP_PREFERRED_NAME(u8string_view)
+#endif
+ _LIBCPP_PREFERRED_NAME(u16string_view)
+ _LIBCPP_PREFERRED_NAME(u32string_view)
+ _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstring_view))
+ basic_string_view {
+public:
+ // types
+ typedef _Traits traits_type;
+ typedef _CharT value_type;
+ typedef _CharT* pointer;
+ typedef const _CharT* const_pointer;
+ typedef _CharT& reference;
+ typedef const _CharT& const_reference;
+ typedef const_pointer const_iterator; // See [string.view.iterators]
+ typedef const_iterator iterator;
+ typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
+ typedef const_reverse_iterator reverse_iterator;
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ static _LIBCPP_CONSTEXPR const size_type npos = -1; // size_type(-1);
+
+ static_assert((!is_array<value_type>::value), "Character type of basic_string_view must not be an array");
+ static_assert(( is_standard_layout<value_type>::value), "Character type of basic_string_view must be standard-layout");
+ static_assert(( is_trivial<value_type>::value), "Character type of basic_string_view must be trivial");
+ static_assert((is_same<_CharT, typename traits_type::char_type>::value),
+ "traits_type::char_type must be the same type as CharT");
+
+ // [string.view.cons], construct/copy
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ basic_string_view() _NOEXCEPT : __data (nullptr), __size(0) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string_view(const basic_string_view&) _NOEXCEPT = default;
+
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string_view& operator=(const basic_string_view&) _NOEXCEPT = default;
+
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ basic_string_view(nullptr_t, size_t) = delete;
+
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ basic_string_view(const _CharT* __s, size_type __len) _NOEXCEPT
+ : __data(__s), __size(__len)
+ {
+#if _LIBCPP_STD_VER > 11
+ _LIBCPP_ASSERT(__len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): received nullptr");
+#endif
+ }
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+ template <contiguous_iterator _It, sized_sentinel_for<_It> _End>
+ requires (is_same_v<iter_value_t<_It>, _CharT> && !is_convertible_v<_End, size_type>)
+ constexpr _LIBCPP_HIDE_FROM_ABI basic_string_view(_It __begin, _End __end)
+ : __data(_VSTD::to_address(__begin)), __size(__end - __begin)
+ {
+ _LIBCPP_ASSERT((__end - __begin) >= 0, "std::string_view::string_view(iterator, sentinel) received invalid range");
+ }
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+#if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+ template <class _Range>
+ requires (
+ !is_same_v<remove_cvref_t<_Range>, basic_string_view> &&
+ ranges::contiguous_range<_Range> &&
+ ranges::sized_range<_Range> &&
+ is_same_v<ranges::range_value_t<_Range>, _CharT> &&
+ !is_convertible_v<_Range, const _CharT*> &&
+ (!requires(remove_cvref_t<_Range>& d) {
+ d.operator _VSTD::basic_string_view<_CharT, _Traits>();
+ }) &&
+ (!requires {
+ typename remove_reference_t<_Range>::traits_type;
+ } || is_same_v<typename remove_reference_t<_Range>::traits_type, _Traits>)
+ )
+ constexpr _LIBCPP_HIDE_FROM_ABI
+ basic_string_view(_Range&& __r) : __data(ranges::data(__r)), __size(ranges::size(__r)) {}
+#endif
+
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ basic_string_view(const _CharT* __s)
+ : __data(__s), __size(_VSTD::__char_traits_length_checked<_Traits>(__s)) {}
+
+#if _LIBCPP_STD_VER > 17
+ basic_string_view(nullptr_t) = delete;
+#endif
+
+ // [string.view.iterators], iterators
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ const_iterator begin() const _NOEXCEPT { return cbegin(); }
+
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ const_iterator end() const _NOEXCEPT { return cend(); }
+
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ const_iterator cbegin() const _NOEXCEPT { return __data; }
+
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ const_iterator cend() const _NOEXCEPT { return __data + __size; }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator crbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator crend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); }
+
+ // [string.view.capacity], capacity
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ size_type size() const _NOEXCEPT { return __size; }
+
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ size_type length() const _NOEXCEPT { return __size; }
+
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ size_type max_size() const _NOEXCEPT { return numeric_limits<size_type>::max() / sizeof(value_type); }
+
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ bool empty() const _NOEXCEPT { return __size == 0; }
+
+ // [string.view.access], element access
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ const_reference operator[](size_type __pos) const _NOEXCEPT {
+ return _LIBCPP_ASSERT(__pos < size(), "string_view[] index out of bounds"), __data[__pos];
+ }
+
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ const_reference at(size_type __pos) const
+ {
+ return __pos >= size()
+ ? (__throw_out_of_range("string_view::at"), __data[0])
+ : __data[__pos];
+ }
+
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ const_reference front() const _NOEXCEPT
+ {
+ return _LIBCPP_ASSERT(!empty(), "string_view::front(): string is empty"), __data[0];
+ }
+
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ const_reference back() const _NOEXCEPT
+ {
+ return _LIBCPP_ASSERT(!empty(), "string_view::back(): string is empty"), __data[__size-1];
+ }
+
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ const_pointer data() const _NOEXCEPT { return __data; }
+
+ // [string.view.modifiers], modifiers:
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ void remove_prefix(size_type __n) _NOEXCEPT
+ {
+ _LIBCPP_ASSERT(__n <= size(), "remove_prefix() can't remove more than size()");
+ __data += __n;
+ __size -= __n;
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ void remove_suffix(size_type __n) _NOEXCEPT
+ {
+ _LIBCPP_ASSERT(__n <= size(), "remove_suffix() can't remove more than size()");
+ __size -= __n;
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ void swap(basic_string_view& __other) _NOEXCEPT
+ {
+ const value_type *__p = __data;
+ __data = __other.__data;
+ __other.__data = __p;
+
+ size_type __sz = __size;
+ __size = __other.__size;
+ __other.__size = __sz;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const
+ {
+ if (__pos > size())
+ __throw_out_of_range("string_view::copy");
+ size_type __rlen = _VSTD::min(__n, size() - __pos);
+ _Traits::copy(__s, data() + __pos, __rlen);
+ return __rlen;
+ }
+
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ basic_string_view substr(size_type __pos = 0, size_type __n = npos) const
+ {
+ return __pos > size()
+ ? (__throw_out_of_range("string_view::substr"), basic_string_view())
+ : basic_string_view(data() + __pos, _VSTD::min(__n, size() - __pos));
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 int compare(basic_string_view __sv) const _NOEXCEPT
+ {
+ size_type __rlen = _VSTD::min( size(), __sv.size());
+ int __retval = _Traits::compare(data(), __sv.data(), __rlen);
+ if ( __retval == 0 ) // first __rlen chars matched
+ __retval = size() == __sv.size() ? 0 : ( size() < __sv.size() ? -1 : 1 );
+ return __retval;
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ int compare(size_type __pos1, size_type __n1, basic_string_view __sv) const
+ {
+ return substr(__pos1, __n1).compare(__sv);
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ int compare( size_type __pos1, size_type __n1,
+ basic_string_view __sv, size_type __pos2, size_type __n2) const
+ {
+ return substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ int compare(const _CharT* __s) const _NOEXCEPT
+ {
+ return compare(basic_string_view(__s));
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ int compare(size_type __pos1, size_type __n1, const _CharT* __s) const
+ {
+ return substr(__pos1, __n1).compare(basic_string_view(__s));
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ int compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const
+ {
+ return substr(__pos1, __n1).compare(basic_string_view(__s, __n2));
+ }
+
+ // find
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ size_type find(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT
+ {
+ _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr");
+ return __str_find<value_type, size_type, traits_type, npos>
+ (data(), size(), __s.data(), __pos, __s.size());
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ size_type find(_CharT __c, size_type __pos = 0) const _NOEXCEPT
+ {
+ return __str_find<value_type, size_type, traits_type, npos>
+ (data(), size(), __c, __pos);
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ 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>
+ (data(), size(), __s, __pos, __n);
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ 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>
+ (data(), size(), __s, __pos, traits_type::length(__s));
+ }
+
+ // rfind
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ size_type rfind(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT
+ {
+ _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr");
+ return __str_rfind<value_type, size_type, traits_type, npos>
+ (data(), size(), __s.data(), __pos, __s.size());
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ size_type rfind(_CharT __c, size_type __pos = npos) const _NOEXCEPT
+ {
+ return __str_rfind<value_type, size_type, traits_type, npos>
+ (data(), size(), __c, __pos);
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ 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>
+ (data(), size(), __s, __pos, __n);
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ 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>
+ (data(), size(), __s, __pos, traits_type::length(__s));
+ }
+
+ // find_first_of
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ size_type find_first_of(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT
+ {
+ _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_of(): received nullptr");
+ return __str_find_first_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __s.data(), __pos, __s.size());
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ size_type find_first_of(_CharT __c, size_type __pos = 0) const _NOEXCEPT
+ { 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 _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>
+ (data(), size(), __s, __pos, __n);
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ 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>
+ (data(), size(), __s, __pos, traits_type::length(__s));
+ }
+
+ // find_last_of
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ size_type find_last_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
+ {
+ _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_of(): received nullptr");
+ return __str_find_last_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __s.data(), __pos, __s.size());
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ size_type find_last_of(_CharT __c, size_type __pos = npos) const _NOEXCEPT
+ { 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 _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>
+ (data(), size(), __s, __pos, __n);
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ 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>
+ (data(), size(), __s, __pos, traits_type::length(__s));
+ }
+
+ // find_first_not_of
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ size_type find_first_not_of(basic_string_view __s, size_type __pos=0) const _NOEXCEPT
+ {
+ _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_not_of(): received nullptr");
+ return __str_find_first_not_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __s.data(), __pos, __s.size());
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ size_type find_first_not_of(_CharT __c, size_type __pos=0) const _NOEXCEPT
+ {
+ return __str_find_first_not_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __c, __pos);
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ 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>
+ (data(), size(), __s, __pos, __n);
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ 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>
+ (data(), size(), __s, __pos, traits_type::length(__s));
+ }
+
+ // find_last_not_of
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ size_type find_last_not_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
+ {
+ _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_not_of(): received nullptr");
+ return __str_find_last_not_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __s.data(), __pos, __s.size());
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ size_type find_last_not_of(_CharT __c, size_type __pos=npos) const _NOEXCEPT
+ {
+ return __str_find_last_not_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __c, __pos);
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ 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>
+ (data(), size(), __s, __pos, __n);
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ 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>
+ (data(), size(), __s, __pos, traits_type::length(__s));
+ }
+
+//WARN: disabled std guards in order to allow using these options without switching to new std
+//#if _LIBCPP_STD_VER > 17
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool starts_with(basic_string_view __s) const noexcept
+ { return size() >= __s.size() && compare(0, __s.size(), __s) == 0; }
+
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool starts_with(value_type __c) const noexcept
+ { return !empty() && _Traits::eq(front(), __c); }
+
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool starts_with(const value_type* __s) const noexcept
+ { return starts_with(basic_string_view(__s)); }
+
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool ends_with(basic_string_view __s) const noexcept
+ { return size() >= __s.size() && compare(size() - __s.size(), npos, __s) == 0; }
+
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool ends_with(value_type __c) const noexcept
+ { return !empty() && _Traits::eq(back(), __c); }
+
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool ends_with(const value_type* __s) const noexcept
+ { return ends_with(basic_string_view(__s)); }
+//#endif
+
+#if _LIBCPP_STD_VER >= 20
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool contains(basic_string_view __sv) const noexcept
+ { return find(__sv) != npos; }
+
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool contains(value_type __c) const noexcept
+ { return find(__c) != npos; }
+
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool contains(const value_type* __s) const
+ { return find(__s) != npos; }
+#endif
+
+private:
+ const value_type* __data;
+ size_type __size;
+};
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+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 // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [string.view.deduct]
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+template <contiguous_iterator _It, sized_sentinel_for<_It> _End>
+ basic_string_view(_It, _End) -> basic_string_view<iter_value_t<_It>>;
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+
+#if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+template <ranges::contiguous_range _Range>
+ basic_string_view(_Range) -> basic_string_view<ranges::range_value_t<_Range>>;
+#endif
+
+// [string.view.comparison]
+// operator ==
+template<class _CharT, class _Traits>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+bool operator==(basic_string_view<_CharT, _Traits> __lhs,
+ basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+{
+ if ( __lhs.size() != __rhs.size()) return false;
+ return __lhs.compare(__rhs) == 0;
+}
+
+// The dummy default template parameters are used to work around a MSVC issue with mangling, see VSO-409326 for details.
+// This applies to the other sufficient overloads below for the other comparison operators.
+template<class _CharT, class _Traits, int = 1>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+bool operator==(basic_string_view<_CharT, _Traits> __lhs,
+ typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
+{
+ if ( __lhs.size() != __rhs.size()) return false;
+ return __lhs.compare(__rhs) == 0;
+}
+
+template<class _CharT, class _Traits, int = 2>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+bool operator==(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
+ basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+{
+ if ( __lhs.size() != __rhs.size()) return false;
+ return __lhs.compare(__rhs) == 0;
+}
+
+
+// operator !=
+template<class _CharT, class _Traits>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+bool operator!=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+{
+ if ( __lhs.size() != __rhs.size())
+ return true;
+ return __lhs.compare(__rhs) != 0;
+}
+
+template<class _CharT, class _Traits, int = 1>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+bool operator!=(basic_string_view<_CharT, _Traits> __lhs,
+ typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
+{
+ if ( __lhs.size() != __rhs.size())
+ return true;
+ return __lhs.compare(__rhs) != 0;
+}
+
+template<class _CharT, class _Traits, int = 2>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+bool operator!=(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
+ basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+{
+ if ( __lhs.size() != __rhs.size())
+ return true;
+ return __lhs.compare(__rhs) != 0;
+}
+
+
+// operator <
+template<class _CharT, class _Traits>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+bool operator<(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+{
+ return __lhs.compare(__rhs) < 0;
+}
+
+template<class _CharT, class _Traits, int = 1>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+bool operator<(basic_string_view<_CharT, _Traits> __lhs,
+ typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
+{
+ return __lhs.compare(__rhs) < 0;
+}
+
+template<class _CharT, class _Traits, int = 2>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+bool operator<(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
+ basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+{
+ return __lhs.compare(__rhs) < 0;
+}
+
+
+// operator >
+template<class _CharT, class _Traits>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+bool operator> (basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+{
+ return __lhs.compare(__rhs) > 0;
+}
+
+template<class _CharT, class _Traits, int = 1>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+bool operator>(basic_string_view<_CharT, _Traits> __lhs,
+ typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
+{
+ return __lhs.compare(__rhs) > 0;
+}
+
+template<class _CharT, class _Traits, int = 2>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+bool operator>(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
+ basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+{
+ return __lhs.compare(__rhs) > 0;
+}
+
+
+// operator <=
+template<class _CharT, class _Traits>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+bool operator<=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+{
+ return __lhs.compare(__rhs) <= 0;
+}
+
+template<class _CharT, class _Traits, int = 1>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+bool operator<=(basic_string_view<_CharT, _Traits> __lhs,
+ typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
+{
+ return __lhs.compare(__rhs) <= 0;
+}
+
+template<class _CharT, class _Traits, int = 2>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+bool operator<=(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
+ basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+{
+ return __lhs.compare(__rhs) <= 0;
+}
+
+
+// operator >=
+template<class _CharT, class _Traits>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+bool operator>=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+{
+ return __lhs.compare(__rhs) >= 0;
+}
+
+
+template<class _CharT, class _Traits, int = 1>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+bool operator>=(basic_string_view<_CharT, _Traits> __lhs,
+ typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
+{
+ return __lhs.compare(__rhs) >= 0;
+}
+
+template<class _CharT, class _Traits, int = 2>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+bool operator>=(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
+ basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+{
+ return __lhs.compare(__rhs) >= 0;
+}
+
+
+template<class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ basic_string_view<_CharT, _Traits> __str);
+
+// [string.view.hash]
+template<class _CharT>
+struct _LIBCPP_TEMPLATE_VIS hash<basic_string_view<_CharT, char_traits<_CharT> > >
+ : public unary_function<basic_string_view<_CharT, char_traits<_CharT> >, size_t>
+{
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(const basic_string_view<_CharT, char_traits<_CharT> > __val) const _NOEXCEPT {
+ return __do_string_hash(__val.data(), __val.data() + __val.size());
+ }
+};
+
+
+#if _LIBCPP_STD_VER > 11
+inline namespace literals
+{
+ inline namespace string_view_literals
+ {
+ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ basic_string_view<char> operator "" sv(const char *__str, size_t __len) _NOEXCEPT
+ {
+ return basic_string_view<char> (__str, __len);
+ }
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ basic_string_view<wchar_t> operator "" sv(const wchar_t *__str, size_t __len) _NOEXCEPT
+ {
+ return basic_string_view<wchar_t> (__str, __len);
+ }
+#endif
+
+#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
+ {
+ return basic_string_view<char8_t> (__str, __len);
+ }
+#endif
+
+ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ basic_string_view<char16_t> operator "" sv(const char16_t *__str, size_t __len) _NOEXCEPT
+ {
+ return basic_string_view<char16_t> (__str, __len);
+ }
+
+ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ basic_string_view<char32_t> operator "" sv(const char32_t *__str, size_t __len) _NOEXCEPT
+ {
+ return basic_string_view<char32_t> (__str, __len);
+ }
+ } // namespace string_view_literals
+} // namespace literals
+#endif
+_LIBCPP_END_NAMESPACE_STD
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( pop )
+#endif
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_STRING_VIEW
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/strstream b/contrib/libs/cxxsupp/libcxxmsvc/include/strstream
new file mode 100644
index 0000000000..1904bb773f
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/strstream
@@ -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_STRSTREAM
+#define _LIBCPP_STRSTREAM
+
+/*
+ strstream synopsis
+
+class strstreambuf
+ : public basic_streambuf<char>
+{
+public:
+ explicit strstreambuf(streamsize alsize_arg = 0); // before C++20
+ strstreambuf() : strstreambuf(0) {} // C++20
+ explicit strstreambuf(streamsize alsize_arg); // C++20
+
+ strstreambuf(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*));
+ strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = nullptr);
+ strstreambuf(const char* gnext_arg, streamsize n);
+
+ strstreambuf(signed char* gnext_arg, streamsize n, signed char* pbeg_arg = nullptr);
+ strstreambuf(const signed char* gnext_arg, streamsize n);
+ strstreambuf(unsigned char* gnext_arg, streamsize n, unsigned char* pbeg_arg = nullptr);
+ strstreambuf(const unsigned char* gnext_arg, streamsize n);
+
+ strstreambuf(strstreambuf&& rhs);
+ strstreambuf& operator=(strstreambuf&& rhs);
+
+ virtual ~strstreambuf();
+
+ void swap(strstreambuf& rhs);
+
+ void freeze(bool freezefl = true);
+ char* str();
+ int pcount() const;
+
+protected:
+ virtual int_type overflow (int_type c = EOF);
+ virtual int_type pbackfail(int_type c = EOF);
+ virtual int_type underflow();
+ virtual pos_type seekoff(off_type off, ios_base::seekdir way,
+ ios_base::openmode which = ios_base::in | ios_base::out);
+ virtual pos_type seekpos(pos_type sp,
+ ios_base::openmode which = ios_base::in | ios_base::out);
+ virtual streambuf* setbuf(char* s, streamsize n);
+
+private:
+ typedef T1 strstate; // exposition only
+ static const strstate allocated; // exposition only
+ static const strstate constant; // exposition only
+ static const strstate dynamic; // exposition only
+ static const strstate frozen; // exposition only
+ strstate strmode; // exposition only
+ streamsize alsize; // exposition only
+ void* (*palloc)(size_t); // exposition only
+ void (*pfree)(void*); // exposition only
+};
+
+class istrstream
+ : public basic_istream<char>
+{
+public:
+ explicit istrstream(const char* s);
+ explicit istrstream(char* s);
+ istrstream(const char* s, streamsize n);
+ istrstream(char* s, streamsize n);
+
+ virtual ~istrstream();
+
+ strstreambuf* rdbuf() const;
+ char *str();
+
+private:
+ strstreambuf sb; // exposition only
+};
+
+class ostrstream
+ : public basic_ostream<char>
+{
+public:
+ ostrstream();
+ ostrstream(char* s, int n, ios_base::openmode mode = ios_base::out);
+
+ virtual ~ostrstream();
+
+ strstreambuf* rdbuf() const;
+ void freeze(bool freezefl = true);
+ char* str();
+ int pcount() const;
+
+private:
+ strstreambuf sb; // exposition only
+};
+
+class strstream
+ : public basic_iostream<char>
+{
+public:
+ // Types
+ typedef char char_type;
+ typedef char_traits<char>::int_type int_type;
+ typedef char_traits<char>::pos_type pos_type;
+ typedef char_traits<char>::off_type off_type;
+
+ // constructors/destructor
+ strstream();
+ strstream(char* s, int n, ios_base::openmode mode = ios_base::in | ios_base::out);
+
+ virtual ~strstream();
+
+ // Members:
+ strstreambuf* rdbuf() const;
+ void freeze(bool freezefl = true);
+ int pcount() const;
+ char* str();
+
+private:
+ strstreambuf sb; // exposition only
+};
+
+} // std
+
+*/
+
+#include <__config>
+#include <istream>
+#include <ostream>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+class _LIBCPP_TYPE_VIS strstreambuf
+ : public streambuf
+{
+public:
+#ifndef _LIBCPP_CXX03_LANG
+ strstreambuf() : strstreambuf(0) {}
+ explicit strstreambuf(streamsize __alsize);
+#else
+ explicit strstreambuf(streamsize __alsize = 0);
+#endif
+ strstreambuf(void* (*__palloc)(size_t), void (*__pfree)(void*));
+ strstreambuf(char* __gnext, streamsize __n, char* __pbeg = nullptr);
+ strstreambuf(const char* __gnext, streamsize __n);
+
+ strstreambuf(signed char* __gnext, streamsize __n, signed char* __pbeg = nullptr);
+ strstreambuf(const signed char* __gnext, streamsize __n);
+ strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg = nullptr);
+ strstreambuf(const unsigned char* __gnext, streamsize __n);
+
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ strstreambuf(strstreambuf&& __rhs);
+ _LIBCPP_INLINE_VISIBILITY
+ strstreambuf& operator=(strstreambuf&& __rhs);
+#endif // _LIBCPP_CXX03_LANG
+
+ virtual ~strstreambuf();
+
+ void swap(strstreambuf& __rhs);
+
+ void freeze(bool __freezefl = true);
+ char* str();
+ int pcount() const;
+
+protected:
+ virtual int_type overflow (int_type __c = EOF);
+ virtual int_type pbackfail(int_type __c = EOF);
+ virtual int_type underflow();
+ virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,
+ ios_base::openmode __which = ios_base::in | ios_base::out);
+ virtual pos_type seekpos(pos_type __sp,
+ ios_base::openmode __which = ios_base::in | ios_base::out);
+
+private:
+ typedef unsigned __mode_type;
+ static const __mode_type __allocated = 0x01;
+ static const __mode_type __constant = 0x02;
+ static const __mode_type __dynamic = 0x04;
+ static const __mode_type __frozen = 0x08;
+ static const streamsize __default_alsize = 4096;
+
+ __mode_type __strmode_;
+ streamsize __alsize_;
+ void* (*__palloc_)(size_t);
+ void (*__pfree_)(void*);
+
+ void __init(char* __gnext, streamsize __n, char* __pbeg);
+};
+
+#ifndef _LIBCPP_CXX03_LANG
+
+inline _LIBCPP_INLINE_VISIBILITY
+strstreambuf::strstreambuf(strstreambuf&& __rhs)
+ : streambuf(__rhs),
+ __strmode_(__rhs.__strmode_),
+ __alsize_(__rhs.__alsize_),
+ __palloc_(__rhs.__palloc_),
+ __pfree_(__rhs.__pfree_)
+{
+ __rhs.setg(nullptr, nullptr, nullptr);
+ __rhs.setp(nullptr, nullptr);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+strstreambuf&
+strstreambuf::operator=(strstreambuf&& __rhs)
+{
+ if (eback() && (__strmode_ & __allocated) != 0 && (__strmode_ & __frozen) == 0)
+ {
+ if (__pfree_)
+ __pfree_(eback());
+ else
+ delete [] eback();
+ }
+ streambuf::operator=(__rhs);
+ __strmode_ = __rhs.__strmode_;
+ __alsize_ = __rhs.__alsize_;
+ __palloc_ = __rhs.__palloc_;
+ __pfree_ = __rhs.__pfree_;
+ __rhs.setg(nullptr, nullptr, nullptr);
+ __rhs.setp(nullptr, nullptr);
+ return *this;
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+class _LIBCPP_TYPE_VIS istrstream
+ : public istream
+{
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit istrstream(const char* __s)
+ : istream(&__sb_), __sb_(__s, 0) {}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit istrstream(char* __s)
+ : istream(&__sb_), __sb_(__s, 0) {}
+ _LIBCPP_INLINE_VISIBILITY
+ istrstream(const char* __s, streamsize __n)
+ : istream(&__sb_), __sb_(__s, __n) {}
+ _LIBCPP_INLINE_VISIBILITY
+ istrstream(char* __s, streamsize __n)
+ : istream(&__sb_), __sb_(__s, __n) {}
+
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ istrstream(istrstream&& __rhs)
+ : istream(_VSTD::move(__rhs)),
+ __sb_(_VSTD::move(__rhs.__sb_))
+ {
+ istream::set_rdbuf(&__sb_);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ istrstream& operator=(istrstream&& __rhs)
+ {
+ istream::operator=(_VSTD::move(__rhs));
+ __sb_ = _VSTD::move(__rhs.__sb_);
+ return *this;
+ }
+#endif // _LIBCPP_CXX03_LANG
+
+ virtual ~istrstream();
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(istrstream& __rhs)
+ {
+ istream::swap(__rhs);
+ __sb_.swap(__rhs.__sb_);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ strstreambuf* rdbuf() const {return const_cast<strstreambuf*>(&__sb_);}
+ _LIBCPP_INLINE_VISIBILITY
+ char *str() {return __sb_.str();}
+
+private:
+ strstreambuf __sb_;
+};
+
+class _LIBCPP_TYPE_VIS ostrstream
+ : public ostream
+{
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ ostrstream()
+ : ostream(&__sb_) {}
+ _LIBCPP_INLINE_VISIBILITY
+ ostrstream(char* __s, int __n, ios_base::openmode __mode = ios_base::out)
+ : ostream(&__sb_),
+ __sb_(__s, __n, __s + (__mode & ios::app ? _VSTD::strlen(__s) : 0))
+ {}
+
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ ostrstream(ostrstream&& __rhs)
+ : ostream(_VSTD::move(__rhs)),
+ __sb_(_VSTD::move(__rhs.__sb_))
+ {
+ ostream::set_rdbuf(&__sb_);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ ostrstream& operator=(ostrstream&& __rhs)
+ {
+ ostream::operator=(_VSTD::move(__rhs));
+ __sb_ = _VSTD::move(__rhs.__sb_);
+ return *this;
+ }
+#endif // _LIBCPP_CXX03_LANG
+
+ virtual ~ostrstream();
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(ostrstream& __rhs)
+ {
+ ostream::swap(__rhs);
+ __sb_.swap(__rhs.__sb_);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ strstreambuf* rdbuf() const {return const_cast<strstreambuf*>(&__sb_);}
+ _LIBCPP_INLINE_VISIBILITY
+ void freeze(bool __freezefl = true) {__sb_.freeze(__freezefl);}
+ _LIBCPP_INLINE_VISIBILITY
+ char* str() {return __sb_.str();}
+ _LIBCPP_INLINE_VISIBILITY
+ int pcount() const {return __sb_.pcount();}
+
+private:
+ strstreambuf __sb_; // exposition only
+};
+
+class _LIBCPP_TYPE_VIS strstream
+ : public iostream
+{
+public:
+ // Types
+ typedef char char_type;
+ typedef char_traits<char>::int_type int_type;
+ typedef char_traits<char>::pos_type pos_type;
+ typedef char_traits<char>::off_type off_type;
+
+ // constructors/destructor
+ _LIBCPP_INLINE_VISIBILITY
+ strstream()
+ : iostream(&__sb_) {}
+ _LIBCPP_INLINE_VISIBILITY
+ strstream(char* __s, int __n, ios_base::openmode __mode = ios_base::in | ios_base::out)
+ : iostream(&__sb_),
+ __sb_(__s, __n, __s + (__mode & ios::app ? _VSTD::strlen(__s) : 0))
+ {}
+
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ strstream(strstream&& __rhs)
+ : iostream(_VSTD::move(__rhs)),
+ __sb_(_VSTD::move(__rhs.__sb_))
+ {
+ iostream::set_rdbuf(&__sb_);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ strstream& operator=(strstream&& __rhs)
+ {
+ iostream::operator=(_VSTD::move(__rhs));
+ __sb_ = _VSTD::move(__rhs.__sb_);
+ return *this;
+ }
+#endif // _LIBCPP_CXX03_LANG
+
+ virtual ~strstream();
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(strstream& __rhs)
+ {
+ iostream::swap(__rhs);
+ __sb_.swap(__rhs.__sb_);
+ }
+
+ // Members:
+ _LIBCPP_INLINE_VISIBILITY
+ strstreambuf* rdbuf() const {return const_cast<strstreambuf*>(&__sb_);}
+ _LIBCPP_INLINE_VISIBILITY
+ void freeze(bool __freezefl = true) {__sb_.freeze(__freezefl);}
+ _LIBCPP_INLINE_VISIBILITY
+ int pcount() const {return __sb_.pcount();}
+ _LIBCPP_INLINE_VISIBILITY
+ char* str() {return __sb_.str();}
+
+private:
+ strstreambuf __sb_; // exposition only
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STRSTREAM
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/system_error b/contrib/libs/cxxsupp/libcxxmsvc/include/system_error
new file mode 100644
index 0000000000..66a3f3c1e0
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/system_error
@@ -0,0 +1,486 @@
+// -*- 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_SYSTEM_ERROR
+#define _LIBCPP_SYSTEM_ERROR
+
+/*
+ system_error synopsis
+
+namespace std
+{
+
+class error_category
+{
+public:
+ virtual ~error_category() noexcept;
+
+ constexpr error_category();
+ error_category(const error_category&) = delete;
+ error_category& operator=(const error_category&) = delete;
+
+ virtual const char* name() const noexcept = 0;
+ virtual error_condition default_error_condition(int ev) const noexcept;
+ virtual bool equivalent(int code, const error_condition& condition) const noexcept;
+ virtual bool equivalent(const error_code& code, int condition) const noexcept;
+ virtual string message(int ev) const = 0;
+
+ bool operator==(const error_category& rhs) const noexcept;
+ bool operator!=(const error_category& rhs) const noexcept;
+ bool operator<(const error_category& rhs) const noexcept;
+};
+
+const error_category& generic_category() noexcept;
+const error_category& system_category() noexcept;
+
+template <class T> struct is_error_code_enum
+ : public false_type {};
+
+template <class T> struct is_error_condition_enum
+ : public false_type {};
+
+template <class _Tp>
+inline constexpr bool is_error_condition_enum_v = is_error_condition_enum<_Tp>::value; // C++17
+
+template <class _Tp>
+inline constexpr bool is_error_code_enum_v = is_error_code_enum<_Tp>::value; // C++17
+
+class error_code
+{
+public:
+ // constructors:
+ error_code() noexcept;
+ error_code(int val, const error_category& cat) noexcept;
+ template <class ErrorCodeEnum>
+ error_code(ErrorCodeEnum e) noexcept;
+
+ // modifiers:
+ void assign(int val, const error_category& cat) noexcept;
+ template <class ErrorCodeEnum>
+ error_code& operator=(ErrorCodeEnum e) noexcept;
+ void clear() noexcept;
+
+ // observers:
+ int value() const noexcept;
+ const error_category& category() const noexcept;
+ error_condition default_error_condition() const noexcept;
+ string message() const;
+ explicit operator bool() const noexcept;
+};
+
+// non-member functions:
+bool operator<(const error_code& lhs, const error_code& rhs) noexcept;
+template <class charT, class traits>
+ basic_ostream<charT,traits>&
+ operator<<(basic_ostream<charT,traits>& os, const error_code& ec);
+
+class error_condition
+{
+public:
+ // constructors:
+ error_condition() noexcept;
+ error_condition(int val, const error_category& cat) noexcept;
+ template <class ErrorConditionEnum>
+ error_condition(ErrorConditionEnum e) noexcept;
+
+ // modifiers:
+ void assign(int val, const error_category& cat) noexcept;
+ template <class ErrorConditionEnum>
+ error_condition& operator=(ErrorConditionEnum e) noexcept;
+ void clear() noexcept;
+
+ // observers:
+ int value() const noexcept;
+ const error_category& category() const noexcept;
+ string message() const noexcept;
+ explicit operator bool() const noexcept;
+};
+
+bool operator<(const error_condition& lhs, const error_condition& rhs) noexcept;
+
+class system_error
+ : public runtime_error
+{
+public:
+ system_error(error_code ec, const string& what_arg);
+ system_error(error_code ec, const char* what_arg);
+ system_error(error_code ec);
+ system_error(int ev, const error_category& ecat, const string& what_arg);
+ system_error(int ev, const error_category& ecat, const char* what_arg);
+ system_error(int ev, const error_category& ecat);
+
+ const error_code& code() const noexcept;
+ const char* what() const noexcept;
+};
+
+template <> struct is_error_condition_enum<errc>
+ : true_type { }
+
+error_code make_error_code(errc e) noexcept;
+error_condition make_error_condition(errc e) noexcept;
+
+// Comparison operators:
+bool operator==(const error_code& lhs, const error_code& rhs) noexcept;
+bool operator==(const error_code& lhs, const error_condition& rhs) noexcept;
+bool operator==(const error_condition& lhs, const error_code& rhs) noexcept;
+bool operator==(const error_condition& lhs, const error_condition& rhs) noexcept;
+bool operator!=(const error_code& lhs, const error_code& rhs) noexcept;
+bool operator!=(const error_code& lhs, const error_condition& rhs) noexcept;
+bool operator!=(const error_condition& lhs, const error_code& rhs) noexcept;
+bool operator!=(const error_condition& lhs, const error_condition& rhs) noexcept;
+
+template <> struct hash<std::error_code>;
+template <> struct hash<std::error_condition>;
+
+} // std
+
+*/
+
+#include <__config>
+#include <__errc>
+#include <__functional/unary_function.h>
+#include <compare>
+#include <stdexcept>
+#include <string>
+#include <type_traits>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// is_error_code_enum
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_error_code_enum
+ : public false_type {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_error_code_enum_v = is_error_code_enum<_Tp>::value;
+#endif
+
+// is_error_condition_enum
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_error_condition_enum
+ : public false_type {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_error_condition_enum_v = is_error_condition_enum<_Tp>::value;
+#endif
+
+template <>
+struct _LIBCPP_TEMPLATE_VIS is_error_condition_enum<errc>
+ : true_type { };
+
+#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
+template <>
+struct _LIBCPP_TEMPLATE_VIS is_error_condition_enum<errc::__lx>
+ : true_type { };
+#endif
+
+class _LIBCPP_TYPE_VIS error_condition;
+class _LIBCPP_TYPE_VIS error_code;
+
+// class error_category
+
+class _LIBCPP_HIDDEN __do_message;
+
+class _LIBCPP_TYPE_VIS error_category
+{
+public:
+ virtual ~error_category() _NOEXCEPT;
+
+#if defined(_LIBCPP_BUILDING_LIBRARY) && \
+ defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS)
+ error_category() _NOEXCEPT;
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 error_category() _NOEXCEPT = default;
+#endif
+ error_category(const error_category&) = delete;
+ error_category& operator=(const error_category&) = delete;
+
+ virtual const char* name() const _NOEXCEPT = 0;
+ virtual error_condition default_error_condition(int __ev) const _NOEXCEPT;
+ virtual bool equivalent(int __code, const error_condition& __condition) const _NOEXCEPT;
+ virtual bool equivalent(const error_code& __code, int __condition) const _NOEXCEPT;
+ virtual string message(int __ev) const = 0;
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const error_category& __rhs) const _NOEXCEPT {return this == &__rhs;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const error_category& __rhs) const _NOEXCEPT {return !(*this == __rhs);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator< (const error_category& __rhs) const _NOEXCEPT {return this < &__rhs;}
+
+ friend class _LIBCPP_HIDDEN __do_message;
+};
+
+class _LIBCPP_HIDDEN __do_message
+ : public error_category
+{
+public:
+ virtual string message(int ev) const;
+};
+
+_LIBCPP_FUNC_VIS const error_category& generic_category() _NOEXCEPT;
+_LIBCPP_FUNC_VIS const error_category& system_category() _NOEXCEPT;
+
+class _LIBCPP_TYPE_VIS error_condition
+{
+ int __val_;
+ const error_category* __cat_;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ error_condition() _NOEXCEPT : __val_(0), __cat_(&generic_category()) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ error_condition(int __val, const error_category& __cat) _NOEXCEPT
+ : __val_(__val), __cat_(&__cat) {}
+
+ template <class _Ep>
+ _LIBCPP_INLINE_VISIBILITY
+ error_condition(_Ep __e,
+ typename enable_if<is_error_condition_enum<_Ep>::value>::type* = nullptr
+ ) _NOEXCEPT
+ {*this = make_error_condition(__e);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void assign(int __val, const error_category& __cat) _NOEXCEPT
+ {
+ __val_ = __val;
+ __cat_ = &__cat;
+ }
+
+ template <class _Ep>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if
+ <
+ is_error_condition_enum<_Ep>::value,
+ error_condition&
+ >::type
+ operator=(_Ep __e) _NOEXCEPT
+ {*this = make_error_condition(__e); return *this;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void clear() _NOEXCEPT
+ {
+ __val_ = 0;
+ __cat_ = &generic_category();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ int value() const _NOEXCEPT {return __val_;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ const error_category& category() const _NOEXCEPT {return *__cat_;}
+ string message() const;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit operator bool() const _NOEXCEPT {return __val_ != 0;}
+};
+
+inline _LIBCPP_INLINE_VISIBILITY
+error_condition
+make_error_condition(errc __e) _NOEXCEPT
+{
+ return error_condition(static_cast<int>(__e), generic_category());
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<(const error_condition& __x, const error_condition& __y) _NOEXCEPT
+{
+ return __x.category() < __y.category()
+ || (__x.category() == __y.category() && __x.value() < __y.value());
+}
+
+// error_code
+
+class _LIBCPP_TYPE_VIS error_code
+{
+ int __val_;
+ const error_category* __cat_;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ error_code() _NOEXCEPT : __val_(0), __cat_(&system_category()) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ error_code(int __val, const error_category& __cat) _NOEXCEPT
+ : __val_(__val), __cat_(&__cat) {}
+
+ template <class _Ep>
+ _LIBCPP_INLINE_VISIBILITY
+ error_code(_Ep __e,
+ typename enable_if<is_error_code_enum<_Ep>::value>::type* = nullptr
+ ) _NOEXCEPT
+ {*this = make_error_code(__e);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void assign(int __val, const error_category& __cat) _NOEXCEPT
+ {
+ __val_ = __val;
+ __cat_ = &__cat;
+ }
+
+ template <class _Ep>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if
+ <
+ is_error_code_enum<_Ep>::value,
+ error_code&
+ >::type
+ operator=(_Ep __e) _NOEXCEPT
+ {*this = make_error_code(__e); return *this;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void clear() _NOEXCEPT
+ {
+ __val_ = 0;
+ __cat_ = &system_category();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ int value() const _NOEXCEPT {return __val_;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ const error_category& category() const _NOEXCEPT {return *__cat_;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ error_condition default_error_condition() const _NOEXCEPT
+ {return __cat_->default_error_condition(__val_);}
+
+ string message() const;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit operator bool() const _NOEXCEPT {return __val_ != 0;}
+};
+
+inline _LIBCPP_INLINE_VISIBILITY
+error_code
+make_error_code(errc __e) _NOEXCEPT
+{
+ return error_code(static_cast<int>(__e), generic_category());
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<(const error_code& __x, const error_code& __y) _NOEXCEPT
+{
+ return __x.category() < __y.category()
+ || (__x.category() == __y.category() && __x.value() < __y.value());
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const error_code& __x, const error_code& __y) _NOEXCEPT
+{
+ return __x.category() == __y.category() && __x.value() == __y.value();
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const error_code& __x, const error_condition& __y) _NOEXCEPT
+{
+ return __x.category().equivalent(__x.value(), __y)
+ || __y.category().equivalent(__x, __y.value());
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const error_condition& __x, const error_code& __y) _NOEXCEPT
+{
+ return __y == __x;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const error_condition& __x, const error_condition& __y) _NOEXCEPT
+{
+ return __x.category() == __y.category() && __x.value() == __y.value();
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const error_code& __x, const error_code& __y) _NOEXCEPT
+{return !(__x == __y);}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const error_code& __x, const error_condition& __y) _NOEXCEPT
+{return !(__x == __y);}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const error_condition& __x, const error_code& __y) _NOEXCEPT
+{return !(__x == __y);}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const error_condition& __x, const error_condition& __y) _NOEXCEPT
+{return !(__x == __y);}
+
+template <>
+struct _LIBCPP_TEMPLATE_VIS hash<error_code>
+ : public unary_function<error_code, size_t>
+{
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(const error_code& __ec) const _NOEXCEPT
+ {
+ return static_cast<size_t>(__ec.value());
+ }
+};
+
+template <>
+struct _LIBCPP_TEMPLATE_VIS hash<error_condition>
+ : public unary_function<error_condition, size_t>
+{
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(const error_condition& __ec) const _NOEXCEPT
+ {
+ return static_cast<size_t>(__ec.value());
+ }
+};
+
+// system_error
+
+class _LIBCPP_TYPE_VIS system_error
+ : public runtime_error
+{
+ error_code __ec_;
+public:
+ system_error(error_code __ec, const string& __what_arg);
+ system_error(error_code __ec, const char* __what_arg);
+ system_error(error_code __ec);
+ system_error(int __ev, const error_category& __ecat, const string& __what_arg);
+ system_error(int __ev, const error_category& __ecat, const char* __what_arg);
+ system_error(int __ev, const error_category& __ecat);
+ system_error(const system_error&) _NOEXCEPT = default;
+ ~system_error() _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY
+ const error_code& code() const _NOEXCEPT {return __ec_;}
+
+private:
+ static string __init(const error_code&, string);
+};
+
+_LIBCPP_NORETURN _LIBCPP_FUNC_VIS
+void __throw_system_error(int ev, const char* what_arg);
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_SYSTEM_ERROR
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/thread b/contrib/libs/cxxsupp/libcxxmsvc/include/thread
new file mode 100644
index 0000000000..b059cfb459
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/thread
@@ -0,0 +1,410 @@
+// -*- 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_THREAD
+#define _LIBCPP_THREAD
+
+/*
+
+ thread synopsis
+
+namespace std
+{
+
+class thread
+{
+public:
+ class id;
+ typedef pthread_t native_handle_type;
+
+ thread() noexcept;
+ template <class F, class ...Args> explicit thread(F&& f, Args&&... args);
+ ~thread();
+
+ thread(const thread&) = delete;
+ thread(thread&& t) noexcept;
+
+ thread& operator=(const thread&) = delete;
+ thread& operator=(thread&& t) noexcept;
+
+ void swap(thread& t) noexcept;
+
+ bool joinable() const noexcept;
+ void join();
+ void detach();
+ id get_id() const noexcept;
+ native_handle_type native_handle();
+
+ static unsigned hardware_concurrency() noexcept;
+};
+
+void swap(thread& x, thread& y) noexcept;
+
+class thread::id
+{
+public:
+ id() noexcept;
+};
+
+bool operator==(thread::id x, thread::id y) noexcept;
+bool operator!=(thread::id x, thread::id y) noexcept;
+bool operator< (thread::id x, thread::id y) noexcept;
+bool operator<=(thread::id x, thread::id y) noexcept;
+bool operator> (thread::id x, thread::id y) noexcept;
+bool operator>=(thread::id x, thread::id y) noexcept;
+
+template<class charT, class traits>
+basic_ostream<charT, traits>&
+operator<<(basic_ostream<charT, traits>& out, thread::id id);
+
+namespace this_thread
+{
+
+thread::id get_id() noexcept;
+
+void yield() noexcept;
+
+template <class Clock, class Duration>
+void sleep_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+template <class Rep, class Period>
+void sleep_for(const chrono::duration<Rep, Period>& rel_time);
+
+} // this_thread
+
+} // std
+
+*/
+
+#include <__assert>
+#include <__config>
+#include <__mutex_base>
+#include <__thread/poll_with_backoff.h>
+#include <__thread/timed_backoff_policy.h>
+#include <__threading_support>
+#include <__utility/forward.h>
+#include <chrono>
+#include <cstddef>
+#include <functional>
+#include <iosfwd>
+#include <memory>
+#include <system_error>
+#include <tuple>
+#include <type_traits>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+#ifdef _LIBCPP_HAS_NO_THREADS
+#error <thread> is not supported on this single threaded system
+#else // !_LIBCPP_HAS_NO_THREADS
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> class __thread_specific_ptr;
+class _LIBCPP_TYPE_VIS __thread_struct;
+class _LIBCPP_HIDDEN __thread_struct_imp;
+class __assoc_sub_state;
+
+_LIBCPP_FUNC_VIS __thread_specific_ptr<__thread_struct>& __thread_local_data();
+
+class _LIBCPP_TYPE_VIS __thread_struct
+{
+ __thread_struct_imp* __p_;
+
+ __thread_struct(const __thread_struct&);
+ __thread_struct& operator=(const __thread_struct&);
+public:
+ __thread_struct();
+ ~__thread_struct();
+
+ void notify_all_at_thread_exit(condition_variable*, mutex*);
+ void __make_ready_at_thread_exit(__assoc_sub_state*);
+};
+
+template <class _Tp>
+class __thread_specific_ptr
+{
+ __libcpp_tls_key __key_;
+
+ // Only __thread_local_data() may construct a __thread_specific_ptr
+ // and only with _Tp == __thread_struct.
+ static_assert((is_same<_Tp, __thread_struct>::value), "");
+ __thread_specific_ptr();
+ friend _LIBCPP_FUNC_VIS __thread_specific_ptr<__thread_struct>& __thread_local_data();
+
+ __thread_specific_ptr(const __thread_specific_ptr&);
+ __thread_specific_ptr& operator=(const __thread_specific_ptr&);
+
+ _LIBCPP_HIDDEN static void _LIBCPP_TLS_DESTRUCTOR_CC __at_thread_exit(void*);
+
+public:
+ typedef _Tp* pointer;
+
+ ~__thread_specific_ptr();
+
+ _LIBCPP_INLINE_VISIBILITY
+ pointer get() const {return static_cast<_Tp*>(__libcpp_tls_get(__key_));}
+ _LIBCPP_INLINE_VISIBILITY
+ pointer operator*() const {return *get();}
+ _LIBCPP_INLINE_VISIBILITY
+ pointer operator->() const {return get();}
+ void set_pointer(pointer __p);
+};
+
+template <class _Tp>
+void _LIBCPP_TLS_DESTRUCTOR_CC
+__thread_specific_ptr<_Tp>::__at_thread_exit(void* __p)
+{
+ delete static_cast<pointer>(__p);
+}
+
+template <class _Tp>
+__thread_specific_ptr<_Tp>::__thread_specific_ptr()
+{
+ int __ec =
+ __libcpp_tls_create(&__key_, &__thread_specific_ptr::__at_thread_exit);
+ if (__ec)
+ __throw_system_error(__ec, "__thread_specific_ptr construction failed");
+}
+
+template <class _Tp>
+__thread_specific_ptr<_Tp>::~__thread_specific_ptr()
+{
+ // __thread_specific_ptr is only created with a static storage duration
+ // so this destructor is only invoked during program termination. Invoking
+ // pthread_key_delete(__key_) may prevent other threads from deleting their
+ // thread local data. For this reason we leak the key.
+}
+
+template <class _Tp>
+void
+__thread_specific_ptr<_Tp>::set_pointer(pointer __p)
+{
+ _LIBCPP_ASSERT(get() == nullptr,
+ "Attempting to overwrite thread local data");
+ __libcpp_tls_set(__key_, __p);
+}
+
+template<>
+struct _LIBCPP_TEMPLATE_VIS hash<__thread_id>
+ : public unary_function<__thread_id, size_t>
+{
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(__thread_id __v) const _NOEXCEPT
+ {
+ return hash<__libcpp_thread_id>()(__v.__id_);
+ }
+};
+
+template<class _CharT, class _Traits>
+_LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, __thread_id __id)
+{return __os << __id.__id_;}
+
+class _LIBCPP_TYPE_VIS thread
+{
+ __libcpp_thread_t __t_;
+
+ thread(const thread&);
+ thread& operator=(const thread&);
+public:
+ typedef __thread_id id;
+ typedef __libcpp_thread_t native_handle_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ thread() _NOEXCEPT : __t_(_LIBCPP_NULL_THREAD) {}
+#ifndef _LIBCPP_CXX03_LANG
+ template <class _Fp, class ..._Args,
+ class = __enable_if_t<!is_same<__uncvref_t<_Fp>, thread>::value> >
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ explicit thread(_Fp&& __f, _Args&&... __args);
+#else // _LIBCPP_CXX03_LANG
+ template <class _Fp>
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ explicit thread(_Fp __f);
+#endif
+ ~thread();
+
+ _LIBCPP_INLINE_VISIBILITY
+ thread(thread&& __t) _NOEXCEPT : __t_(__t.__t_) {
+ __t.__t_ = _LIBCPP_NULL_THREAD;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ thread& operator=(thread&& __t) _NOEXCEPT {
+ if (!__libcpp_thread_isnull(&__t_))
+ terminate();
+ __t_ = __t.__t_;
+ __t.__t_ = _LIBCPP_NULL_THREAD;
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(thread& __t) _NOEXCEPT {_VSTD::swap(__t_, __t.__t_);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool joinable() const _NOEXCEPT {return !__libcpp_thread_isnull(&__t_);}
+ void join();
+ void detach();
+ _LIBCPP_INLINE_VISIBILITY
+ id get_id() const _NOEXCEPT {return __libcpp_thread_get_id(&__t_);}
+ _LIBCPP_INLINE_VISIBILITY
+ native_handle_type native_handle() _NOEXCEPT {return __t_;}
+
+ static unsigned hardware_concurrency() _NOEXCEPT;
+};
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _TSp, class _Fp, class ..._Args, size_t ..._Indices>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__thread_execute(tuple<_TSp, _Fp, _Args...>& __t, __tuple_indices<_Indices...>)
+{
+ _VSTD::__invoke(_VSTD::move(_VSTD::get<1>(__t)), _VSTD::move(_VSTD::get<_Indices>(__t))...);
+}
+
+template <class _Fp>
+_LIBCPP_INLINE_VISIBILITY
+void* __thread_proxy(void* __vp)
+{
+ // _Fp = tuple< unique_ptr<__thread_struct>, Functor, Args...>
+ unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp));
+ __thread_local_data().set_pointer(_VSTD::get<0>(*__p.get()).release());
+ typedef typename __make_tuple_indices<tuple_size<_Fp>::value, 2>::type _Index;
+ _VSTD::__thread_execute(*__p.get(), _Index());
+ return nullptr;
+}
+
+template <class _Fp, class ..._Args,
+ class
+ >
+thread::thread(_Fp&& __f, _Args&&... __args)
+{
+ typedef unique_ptr<__thread_struct> _TSPtr;
+ _TSPtr __tsp(new __thread_struct);
+ typedef tuple<_TSPtr, typename decay<_Fp>::type, typename decay<_Args>::type...> _Gp;
+ unique_ptr<_Gp> __p(
+ new _Gp(_VSTD::move(__tsp),
+ _VSTD::forward<_Fp>(__f),
+ _VSTD::forward<_Args>(__args)...));
+ int __ec = _VSTD::__libcpp_thread_create(&__t_, &__thread_proxy<_Gp>, __p.get());
+ if (__ec == 0)
+ __p.release();
+ else
+ __throw_system_error(__ec, "thread constructor failed");
+}
+
+#else // _LIBCPP_CXX03_LANG
+
+template <class _Fp>
+struct __thread_invoke_pair {
+ // This type is used to pass memory for thread local storage and a functor
+ // to a newly created thread because std::pair doesn't work with
+ // std::unique_ptr in C++03.
+ __thread_invoke_pair(_Fp& __f) : __tsp_(new __thread_struct), __fn_(__f) {}
+ unique_ptr<__thread_struct> __tsp_;
+ _Fp __fn_;
+};
+
+template <class _Fp>
+void* __thread_proxy_cxx03(void* __vp)
+{
+ unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp));
+ __thread_local_data().set_pointer(__p->__tsp_.release());
+ (__p->__fn_)();
+ return nullptr;
+}
+
+template <class _Fp>
+thread::thread(_Fp __f)
+{
+
+ typedef __thread_invoke_pair<_Fp> _InvokePair;
+ typedef unique_ptr<_InvokePair> _PairPtr;
+ _PairPtr __pp(new _InvokePair(__f));
+ int __ec = _VSTD::__libcpp_thread_create(&__t_, &__thread_proxy_cxx03<_InvokePair>, __pp.get());
+ if (__ec == 0)
+ __pp.release();
+ else
+ __throw_system_error(__ec, "thread constructor failed");
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+inline _LIBCPP_INLINE_VISIBILITY
+void swap(thread& __x, thread& __y) _NOEXCEPT {__x.swap(__y);}
+
+namespace this_thread
+{
+
+_LIBCPP_FUNC_VIS void sleep_for(const chrono::nanoseconds& __ns);
+
+template <class _Rep, class _Period>
+void
+sleep_for(const chrono::duration<_Rep, _Period>& __d)
+{
+ if (__d > chrono::duration<_Rep, _Period>::zero())
+ {
+ // 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)
+ {
+ __ns = chrono::duration_cast<chrono::nanoseconds>(__d);
+ if (__ns < __d)
+ ++__ns;
+ }
+ else
+ __ns = chrono::nanoseconds::max();
+ this_thread::sleep_for(__ns);
+ }
+}
+
+template <class _Clock, class _Duration>
+void
+sleep_until(const chrono::time_point<_Clock, _Duration>& __t)
+{
+ mutex __mut;
+ condition_variable __cv;
+ unique_lock<mutex> __lk(__mut);
+ while (_Clock::now() < __t)
+ __cv.wait_until(__lk, __t);
+}
+
+template <class _Duration>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+sleep_until(const chrono::time_point<chrono::steady_clock, _Duration>& __t)
+{
+ this_thread::sleep_for(__t - chrono::steady_clock::now());
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void yield() _NOEXCEPT {__libcpp_thread_yield();}
+
+} // namespace this_thread
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // !_LIBCPP_HAS_NO_THREADS
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_THREAD
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/tuple b/contrib/libs/cxxsupp/libcxxmsvc/include/tuple
new file mode 100644
index 0000000000..868b66d254
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/tuple
@@ -0,0 +1,1663 @@
+// -*- 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_TUPLE
+#define _LIBCPP_TUPLE
+
+/*
+ tuple synopsis
+
+namespace std
+{
+
+template <class... T>
+class tuple {
+public:
+ explicit(see-below) constexpr tuple();
+ explicit(see-below) tuple(const T&...); // constexpr in C++14
+ template <class... U>
+ explicit(see-below) tuple(U&&...); // constexpr in C++14
+ tuple(const tuple&) = default;
+ tuple(tuple&&) = default;
+ template <class... U>
+ explicit(see-below) tuple(const tuple<U...>&); // constexpr in C++14
+ template <class... U>
+ explicit(see-below) tuple(tuple<U...>&&); // constexpr in C++14
+ template <class U1, class U2>
+ explicit(see-below) tuple(const pair<U1, U2>&); // iff sizeof...(T) == 2 // constexpr in C++14
+ template <class U1, class U2>
+ explicit(see-below) tuple(pair<U1, U2>&&); // iff sizeof...(T) == 2 // constexpr in C++14
+
+ // allocator-extended constructors
+ 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&...); // constexpr in C++20
+ template <class Alloc, class... 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&); // constexpr in C++20
+ template <class Alloc>
+ 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...>&); // constexpr in C++20
+ template <class Alloc, class... 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>&); // constexpr in C++20
+ template <class Alloc, class U1, class U2>
+ explicit(see-below) tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&); // constexpr in C++20
+
+ 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...>&); // constexpr in C++20
+ template <class... U>
+ tuple& operator=(tuple<U...>&&); // constexpr in C++20
+ template <class U1, class U2>
+ 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 // constexpr in C++20
+
+ 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... TTypes, class... UTypes, template<class> class TQual, template<class> class UQual> // since C++23
+ requires requires { typename tuple<common_reference_t<TQual<TTypes>, UQual<UTypes>>...>; }
+struct basic_common_reference<tuple<TTypes...>, tuple<UTypes...>, TQual, UQual> {
+ using type = tuple<common_reference_t<TQual<TTypes>, UQual<UTypes>>...>;
+};
+
+template<class... TTypes, class... UTypes> // since C++23
+ requires requires { typename tuple<common_type_t<TTypes, UTypes>...>; }
+struct common_type<tuple<TTypes...>, tuple<UTypes...>> {
+ using type = tuple<common_type_t<TTypes, UTypes>...>;
+};
+
+template <class ...T>
+tuple(T...) -> tuple<T...>; // since C++17
+template <class T1, class T2>
+tuple(pair<T1, T2>) -> tuple<T1, T2>; // since C++17
+template <class Alloc, class ...T>
+tuple(allocator_arg_t, Alloc, T...) -> tuple<T...>; // since C++17
+template <class Alloc, class T1, class T2>
+tuple(allocator_arg_t, Alloc, pair<T1, T2>) -> tuple<T1, T2>; // since C++17
+template <class Alloc, class ...T>
+tuple(allocator_arg_t, Alloc, tuple<T...>) -> tuple<T...>; // since C++17
+
+inline constexpr unspecified ignore;
+
+template <class... T> tuple<V...> make_tuple(T&&...); // constexpr in C++14
+template <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept; // constexpr in C++14
+template <class... T> tuple<T&...> tie(T&...) noexcept; // constexpr in C++14
+template <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls); // constexpr in C++14
+
+// [tuple.apply], calling a function with a tuple of arguments:
+template <class F, class Tuple>
+ constexpr decltype(auto) apply(F&& f, Tuple&& t); // C++17
+template <class T, class Tuple>
+ constexpr T make_from_tuple(Tuple&& t); // C++17
+
+// 20.4.1.4, tuple helper classes:
+template <class T> struct tuple_size; // undefined
+template <class... T> struct tuple_size<tuple<T...>>;
+template <class T>
+ inline constexpr size_t tuple_size_v = tuple_size<T>::value; // C++17
+template <size_t I, class T> struct tuple_element; // undefined
+template <size_t I, class... T> struct tuple_element<I, tuple<T...>>;
+template <size_t I, class T>
+ using tuple_element_t = typename tuple_element <I, T>::type; // C++14
+
+// 20.4.1.5, element access:
+template <size_t I, class... T>
+ typename tuple_element<I, tuple<T...>>::type&
+ get(tuple<T...>&) noexcept; // constexpr in C++14
+template <size_t I, class... T>
+ const typename tuple_element<I, tuple<T...>>::type&
+ get(const tuple<T...>&) noexcept; // constexpr in C++14
+template <size_t I, class... T>
+ typename tuple_element<I, tuple<T...>>::type&&
+ get(tuple<T...>&&) noexcept; // constexpr in C++14
+template <size_t I, class... T>
+ const typename tuple_element<I, tuple<T...>>::type&&
+ get(const tuple<T...>&&) noexcept; // constexpr in C++14
+
+template <class T1, class... T>
+ constexpr T1& get(tuple<T...>&) noexcept; // C++14
+template <class T1, class... T>
+ constexpr const T1& get(const tuple<T...>&) noexcept; // C++14
+template <class T1, class... T>
+ constexpr T1&& get(tuple<T...>&&) noexcept; // C++14
+template <class T1, class... T>
+ constexpr const T1&& get(const tuple<T...>&&) noexcept; // C++14
+
+// 20.4.1.6, relational operators:
+template<class... T, class... U> bool operator==(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
+template<class... T, class... U> bool operator<(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14, removed in C++20
+template<class... T, class... U> bool operator!=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14, removed in C++20
+template<class... T, class... U> bool operator>(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14, removed in C++20
+template<class... T, class... U> bool operator<=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14, removed in C++20
+template<class... T, class... U> bool operator>=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14, removed in C++20
+template<class... T, class... U>
+ constexpr common_comparison_category_t<synth-three-way-result<T, U>...>
+ operator<=>(const tuple<T...>&, const tuple<U...>&); // since C++20
+
+template <class... Types, class Alloc>
+ struct uses_allocator<tuple<Types...>, Alloc>;
+
+template <class... Types>
+ void
+ swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(noexcept(x.swap(y)));
+
+} // std
+
+*/
+
+#include <__compare/common_comparison_category.h>
+#include <__compare/synth_three_way.h>
+#include <__config>
+#include <__functional/unwrap_ref.h>
+#include <__memory/allocator_arg_t.h>
+#include <__memory/uses_allocator.h>
+#include <__tuple>
+#include <__utility/forward.h>
+#include <__utility/integer_sequence.h>
+#include <__utility/move.h>
+#include <compare>
+#include <cstddef>
+#include <type_traits>
+#include <utility>
+#include <version>
+
+// TODO: remove these headers
+#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 <exception>
+#include <new>
+#include <typeinfo>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifndef _LIBCPP_CXX03_LANG
+
+
+// __tuple_leaf
+
+template <size_t _Ip, class _Hp,
+ bool=is_empty<_Hp>::value && !__libcpp_is_final<_Hp>::value
+ >
+class __tuple_leaf;
+
+template <size_t _Ip, class _Hp, bool _Ep>
+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)
+{
+ swap(__x.get(), __y.get());
+}
+
+template <size_t _Ip, class _Hp, bool>
+class __tuple_leaf
+{
+ _Hp __value_;
+
+ template <class _Tp>
+ static constexpr bool __can_bind_reference() {
+#if __has_keyword(__reference_binds_to_temporary) && !defined(__CUDACC__)
+ return !__reference_binds_to_temporary(_Hp, _Tp);
+#else
+ return true;
+#endif
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11
+ __tuple_leaf& operator=(const __tuple_leaf&);
+public:
+ _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 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 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 constexpr
+ __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
+ : __value_(__a)
+ {static_assert(!is_reference<_Hp>::value,
+ "Attempted to default construct a reference element in a tuple");}
+
+ template <class _Tp,
+ class = __enable_if_t<
+ _And<
+ _IsNotSame<__uncvref_t<_Tp>, __tuple_leaf>,
+ is_constructible<_Hp, _Tp>
+ >::value
+ >
+ >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
+ : __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_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_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_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,
+ "Attempted to uses-allocator construct a reference element in a tuple");}
+
+ __tuple_leaf(const __tuple_leaf& __t) = default;
+ __tuple_leaf(__tuple_leaf&& __t) = default;
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
+ {
+ _VSTD::swap(*this, __t);
+ return 0;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return __value_;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return __value_;}
+};
+
+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 constexpr __tuple_leaf()
+ _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) {}
+
+ template <class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY constexpr
+ __tuple_leaf(integral_constant<int, 0>, const _Alloc&) {}
+
+ template <class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY constexpr
+ __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
+ : _Hp(allocator_arg_t(), __a) {}
+
+ template <class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY constexpr
+ __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
+ : _Hp(__a) {}
+
+ template <class _Tp,
+ class = __enable_if_t<
+ _And<
+ _IsNotSame<__uncvref_t<_Tp>, __tuple_leaf>,
+ is_constructible<_Hp, _Tp>
+ >::value
+ >
+ >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
+ : _Hp(_VSTD::forward<_Tp>(__t)) {}
+
+ template <class _Tp, class _Alloc>
+ _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 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 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;
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ int
+ swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
+ {
+ _VSTD::swap(*this, __t);
+ return 0;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return static_cast<_Hp&>(*this);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return static_cast<const _Hp&>(*this);}
+};
+
+template <class ..._Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+void __swallow(_Tp&&...) _NOEXCEPT {}
+
+template <class _Tp>
+struct __all_default_constructible;
+
+template <class ..._Tp>
+struct __all_default_constructible<__tuple_types<_Tp...>>
+ : __all<is_default_constructible<_Tp>::value...>
+{ };
+
+// __tuple_impl
+
+template<class _Indx, class ..._Tp> struct __tuple_impl;
+
+template<size_t ..._Indx, class ..._Tp>
+struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
+ : public __tuple_leaf<_Indx, _Tp>...
+{
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr __tuple_impl()
+ _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
+
+ template <size_t ..._Uf, class ..._Tf,
+ size_t ..._Ul, class ..._Tl, class ..._Up>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ explicit
+ __tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
+ __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
+ _Up&&... __u)
+ _NOEXCEPT_((__all<is_nothrow_constructible<_Tf, _Up>::value...>::value &&
+ __all<is_nothrow_default_constructible<_Tl>::value...>::value)) :
+ __tuple_leaf<_Uf, _Tf>(_VSTD::forward<_Up>(__u))...,
+ __tuple_leaf<_Ul, _Tl>()...
+ {}
+
+#if defined(__NVCC__) && defined(_LIBCPP_COMPILER_MSVC)
+ // Yandex-specific: specialize the preceding constructor for the
+ // case of empty _Ul and _Tl to work around nvcc+msvc bug
+ // compiling libcxx std::map<int, int> m; m[1] = 2.
+ template <size_t ..._Uf, class ..._Tf,
+ class ..._Up>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ explicit
+ __tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
+ __tuple_indices<>, __tuple_types<>,
+ _Up&&... __u)
+ _NOEXCEPT_((__all<is_nothrow_constructible<_Tf, _Up>::value...>::value)) :
+ __tuple_leaf<_Uf, _Tf>(_VSTD::forward<_Up>(__u))...
+ {}
+ // End of Yandex-specific
+#endif
+
+ template <class _Alloc, size_t ..._Uf, class ..._Tf,
+ size_t ..._Ul, class ..._Tl, class ..._Up>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ explicit
+ __tuple_impl(allocator_arg_t, const _Alloc& __a,
+ __tuple_indices<_Uf...>, __tuple_types<_Tf...>,
+ __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
+ _Up&&... __u) :
+ __tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a,
+ _VSTD::forward<_Up>(__u))...,
+ __tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)...
+ {}
+
+ template <class _Tuple,
+ class = typename enable_if
+ <
+ __tuple_constructible<_Tuple, tuple<_Tp...> >::value
+ >::type
+ >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ __tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_constructible<_Tp, typename tuple_element<_Indx,
+ typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
+ : __tuple_leaf<_Indx, _Tp>(_VSTD::forward<typename tuple_element<_Indx,
+ typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
+ {}
+
+ template <class _Alloc, class _Tuple,
+ class = typename enable_if
+ <
+ __tuple_constructible<_Tuple, tuple<_Tp...> >::value
+ >::type
+ >
+ _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,
+ _VSTD::forward<typename tuple_element<_Indx,
+ typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
+ {}
+
+ __tuple_impl(const __tuple_impl&) = default;
+ __tuple_impl(__tuple_impl&&) = default;
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ void swap(__tuple_impl& __t)
+ _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
+ {
+ _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
+{
+ typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> _BaseT;
+
+ _BaseT __base_;
+
+ 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
+ const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT;
+ 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
+ const typename tuple_element<_Jp, tuple<_Up...> >::type&& get(const tuple<_Up...>&&) _NOEXCEPT;
+public:
+ // [tuple.cnstr]
+
+ // tuple() constructors (including allocator_arg_t variants)
+ template <template<class...> class _IsImpDefault = __is_implicitly_default_constructible, __enable_if_t<
+ _And<
+ _IsImpDefault<_Tp>... // explicit check
+ >::value
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ tuple()
+ _NOEXCEPT_(_And<is_nothrow_default_constructible<_Tp>...>::value)
+ { }
+
+ template <template<class...> class _IsImpDefault = __is_implicitly_default_constructible,
+ template<class...> class _IsDefault = is_default_constructible, __enable_if_t<
+ _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, __enable_if_t<
+ _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 _Alloc,
+ template<class...> class _IsImpDefault = __is_implicitly_default_constructible,
+ template<class...> class _IsDefault = is_default_constructible, __enable_if_t<
+ _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...>()) {}
+
+ // tuple(const T&...) constructors (including allocator_arg_t variants)
+ template <template<class...> class _And = _And, __enable_if_t<
+ _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_(_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(),
+ typename __make_tuple_types<tuple, 0>::type(),
+ __t...
+ ) {}
+
+ template <template<class...> class _And = _And, __enable_if_t<
+ _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_(_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(),
+ typename __make_tuple_types<tuple, 0>::type(),
+ __t...
+ ) {}
+
+ template <class _Alloc, template<class...> class _And = _And, __enable_if_t<
+ _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(),
+ typename __make_tuple_indices<0>::type(),
+ typename __make_tuple_types<tuple, 0>::type(),
+ __t...
+ ) {}
+
+ template <class _Alloc, template<class...> class _And = _And, __enable_if_t<
+ _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(),
+ typename __make_tuple_indices<0>::type(),
+ typename __make_tuple_types<tuple, 0>::type(),
+ __t...
+ ) {}
+
+ // 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, __enable_if_t<
+ _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, __enable_if_t<
+ _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, __enable_if_t<
+ _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, __enable_if_t<
+ _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)...) {}
+
+ // Copy and move constructors (including the allocator_arg_t variants)
+ tuple(const tuple&) = default;
+ tuple(tuple&&) = default;
+
+ template <class _Alloc, template<class...> class _And = _And, __enable_if_t<
+ _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, __enable_if_t<
+ _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, __enable_if_t<
+ _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, __enable_if_t<
+ _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, __enable_if_t<
+ _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, __enable_if_t<
+ _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, __enable_if_t<
+ _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, __enable_if_t<
+ _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, __enable_if_t<
+ _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, __enable_if_t<
+ _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, __enable_if_t<
+ _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, __enable_if_t<
+ _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, __enable_if_t<
+ _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, __enable_if_t<
+ _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, __enable_if_t<
+ _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, __enable_if_t<
+ _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, __enable_if_t<
+ _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, __enable_if_t<
+ _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;
+ }
+
+ _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... _Up, __enable_if_t<
+ _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... _Up, __enable_if_t<
+ _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;
+ }
+
+ template<class _Up1, class _Up2, class _Dep = true_type, __enable_if_t<
+ _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;
+ }
+
+ template<class _Up1, class _Up2, class _Dep = true_type, __enable_if_t<
+ _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))
+ {
+ _VSTD::get<0>(*this) = _VSTD::forward<_Up1>(__pair.first);
+ _VSTD::get<1>(*this) = _VSTD::forward<_Up2>(__pair.second);
+ return *this;
+ }
+
+ // EXTENSION
+ template<class _Up, size_t _Np, class = __enable_if_t<
+ _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))
+ {
+ _VSTD::__memberwise_copy_assign(*this, __array,
+ typename __make_tuple_indices<sizeof...(_Tp)>::type());
+ return *this;
+ }
+
+ // EXTENSION
+ template<class _Up, size_t _Np, class = void, class = __enable_if_t<
+ _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;
+ }
+
+ // [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_);}
+};
+
+template <>
+class _LIBCPP_TEMPLATE_VIS tuple<>
+{
+public:
+ _LIBCPP_INLINE_VISIBILITY constexpr
+ tuple() _NOEXCEPT = default;
+ template <class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {}
+ template <class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {}
+ template <class _Up>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ tuple(array<_Up, 0>) _NOEXCEPT {}
+ template <class _Alloc, class _Up>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ void swap(tuple&) _NOEXCEPT {}
+};
+
+#if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_CONCEPTS)
+template <class... _TTypes, class... _UTypes, template<class> class _TQual, template<class> class _UQual>
+ requires requires { typename tuple<common_reference_t<_TQual<_TTypes>, _UQual<_UTypes>>...>; }
+struct basic_common_reference<tuple<_TTypes...>, tuple<_UTypes...>, _TQual, _UQual> {
+ using type = tuple<common_reference_t<_TQual<_TTypes>, _UQual<_UTypes>>...>;
+};
+
+template <class... _TTypes, class... _UTypes>
+ requires requires { typename tuple<common_type_t<_TTypes, _UTypes>...>; }
+struct common_type<tuple<_TTypes...>, tuple<_UTypes...>> {
+ using type = tuple<common_type_t<_TTypes, _UTypes>...>;
+};
+#endif // _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+#if _LIBCPP_STD_VER > 14
+template <class ..._Tp>
+tuple(_Tp...) -> tuple<_Tp...>;
+template <class _Tp1, class _Tp2>
+tuple(pair<_Tp1, _Tp2>) -> tuple<_Tp1, _Tp2>;
+template <class _Alloc, class ..._Tp>
+tuple(allocator_arg_t, _Alloc, _Tp...) -> tuple<_Tp...>;
+template <class _Alloc, class _Tp1, class _Tp2>
+tuple(allocator_arg_t, _Alloc, pair<_Tp1, _Tp2>) -> tuple<_Tp1, _Tp2>;
+template <class _Alloc, class ..._Tp>
+tuple(allocator_arg_t, _Alloc, tuple<_Tp...>) -> tuple<_Tp...>;
+#endif
+
+template <class ..._Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+typename enable_if
+<
+ __all<__is_swappable<_Tp>::value...>::value,
+ void
+>::type
+swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
+ _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
+ {__t.swap(__u);}
+
+// get
+
+template <size_t _Ip, class ..._Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+typename tuple_element<_Ip, tuple<_Tp...> >::type&
+get(tuple<_Tp...>& __t) _NOEXCEPT
+{
+ typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type;
+ return static_cast<__tuple_leaf<_Ip, type>&>(__t.__base_).get();
+}
+
+template <size_t _Ip, class ..._Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+const typename tuple_element<_Ip, tuple<_Tp...> >::type&
+get(const tuple<_Tp...>& __t) _NOEXCEPT
+{
+ typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type;
+ return static_cast<const __tuple_leaf<_Ip, type>&>(__t.__base_).get();
+}
+
+template <size_t _Ip, class ..._Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+typename tuple_element<_Ip, tuple<_Tp...> >::type&&
+get(tuple<_Tp...>&& __t) _NOEXCEPT
+{
+ typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type;
+ return static_cast<type&&>(
+ static_cast<__tuple_leaf<_Ip, type>&&>(__t.__base_).get());
+}
+
+template <size_t _Ip, class ..._Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
+get(const tuple<_Tp...>&& __t) _NOEXCEPT
+{
+ typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type;
+ return static_cast<const type&&>(
+ static_cast<const __tuple_leaf<_Ip, type>&&>(__t.__base_).get());
+}
+
+#if _LIBCPP_STD_VER > 11
+
+namespace __find_detail {
+
+static constexpr size_t __not_found = static_cast<size_t>(-1);
+static constexpr size_t __ambiguous = __not_found - 1;
+
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr size_t __find_idx_return(size_t __curr_i, size_t __res, bool __matches) {
+ return !__matches ? __res :
+ (__res == __not_found ? __curr_i : __ambiguous);
+}
+
+template <size_t _Nx>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr size_t __find_idx(size_t __i, const bool (&__matches)[_Nx]) {
+ return __i == _Nx ? __not_found :
+ __find_idx_return(__i, __find_idx(__i + 1, __matches), __matches[__i]);
+}
+
+template <class _T1, class ..._Args>
+struct __find_exactly_one_checked {
+ static constexpr bool __matches[sizeof...(_Args)] = {is_same<_T1, _Args>::value...};
+ static constexpr size_t value = __find_detail::__find_idx(0, __matches);
+ static_assert(value != __not_found, "type not found in type list" );
+ static_assert(value != __ambiguous, "type occurs more than once in type list");
+};
+
+template <class _T1>
+struct __find_exactly_one_checked<_T1> {
+ static_assert(!is_same<_T1, _T1>::value, "type not in empty type list");
+};
+
+} // namespace __find_detail
+
+template <typename _T1, typename... _Args>
+struct __find_exactly_one_t
+ : public __find_detail::__find_exactly_one_checked<_T1, _Args...> {
+};
+
+template <class _T1, class... _Args>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr _T1& get(tuple<_Args...>& __tup) noexcept
+{
+ return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
+}
+
+template <class _T1, class... _Args>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr _T1 const& get(tuple<_Args...> const& __tup) noexcept
+{
+ return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
+}
+
+template <class _T1, class... _Args>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept
+{
+ return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
+}
+
+template <class _T1, class... _Args>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr _T1 const&& get(tuple<_Args...> const&& __tup) noexcept
+{
+ return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
+}
+
+#endif
+
+// tie
+
+template <class ..._Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+tuple<_Tp&...>
+tie(_Tp&... __t) _NOEXCEPT
+{
+ return tuple<_Tp&...>(__t...);
+}
+
+template <class _Up>
+struct __ignore_t
+{
+ template <class _Tp>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ const __ignore_t& operator=(_Tp&&) const {return *this;}
+};
+
+namespace {
+ constexpr __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>();
+} // namespace
+
+template <class... _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+tuple<typename __unwrap_ref_decay<_Tp>::type...>
+make_tuple(_Tp&&... __t)
+{
+ return tuple<typename __unwrap_ref_decay<_Tp>::type...>(_VSTD::forward<_Tp>(__t)...);
+}
+
+template <class... _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+tuple<_Tp&&...>
+forward_as_tuple(_Tp&&... __t) _NOEXCEPT
+{
+ return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...);
+}
+
+template <size_t _Ip>
+struct __tuple_equal
+{
+ template <class _Tp, class _Up>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ bool operator()(const _Tp& __x, const _Up& __y)
+ {
+ return __tuple_equal<_Ip - 1>()(__x, __y) && _VSTD::get<_Ip-1>(__x) == _VSTD::get<_Ip-1>(__y);
+ }
+};
+
+template <>
+struct __tuple_equal<0>
+{
+ template <class _Tp, class _Up>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ bool operator()(const _Tp&, const _Up&)
+ {
+ return true;
+ }
+};
+
+template <class ..._Tp, class ..._Up>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
+{
+ static_assert (sizeof...(_Tp) == sizeof...(_Up), "Can't compare tuples of different sizes");
+ return __tuple_equal<sizeof...(_Tp)>()(__x, __y);
+}
+
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// operator<=>
+
+template <class ..._Tp, class ..._Up, size_t ..._Is>
+_LIBCPP_HIDE_FROM_ABI constexpr
+auto
+__tuple_compare_three_way(const tuple<_Tp...>& __x, const tuple<_Up...>& __y, index_sequence<_Is...>) {
+ common_comparison_category_t<__synth_three_way_result<_Tp, _Up>...> __result = strong_ordering::equal;
+ static_cast<void>(((__result = _VSTD::__synth_three_way(_VSTD::get<_Is>(__x), _VSTD::get<_Is>(__y)), __result != 0) || ...));
+ return __result;
+}
+
+template <class ..._Tp, class ..._Up>
+requires (sizeof...(_Tp) == sizeof...(_Up))
+_LIBCPP_HIDE_FROM_ABI constexpr
+common_comparison_category_t<__synth_three_way_result<_Tp, _Up>...>
+operator<=>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
+{
+ return _VSTD::__tuple_compare_three_way(__x, __y, index_sequence_for<_Tp...>{});
+}
+
+#else // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+template <class ..._Tp, class ..._Up>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
+{
+ return !(__x == __y);
+}
+
+template <size_t _Ip>
+struct __tuple_less
+{
+ template <class _Tp, class _Up>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ bool operator()(const _Tp& __x, const _Up& __y)
+ {
+ const size_t __idx = tuple_size<_Tp>::value - _Ip;
+ if (_VSTD::get<__idx>(__x) < _VSTD::get<__idx>(__y))
+ return true;
+ if (_VSTD::get<__idx>(__y) < _VSTD::get<__idx>(__x))
+ return false;
+ return __tuple_less<_Ip-1>()(__x, __y);
+ }
+};
+
+template <>
+struct __tuple_less<0>
+{
+ template <class _Tp, class _Up>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ bool operator()(const _Tp&, const _Up&)
+ {
+ return false;
+ }
+};
+
+template <class ..._Tp, class ..._Up>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
+{
+ static_assert (sizeof...(_Tp) == sizeof...(_Up), "Can't compare tuples of different sizes");
+ return __tuple_less<sizeof...(_Tp)>()(__x, __y);
+}
+
+template <class ..._Tp, class ..._Up>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
+{
+ return __y < __x;
+}
+
+template <class ..._Tp, class ..._Up>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
+{
+ return !(__x < __y);
+}
+
+template <class ..._Tp, class ..._Up>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
+{
+ return !(__y < __x);
+}
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// tuple_cat
+
+template <class _Tp, class _Up> struct __tuple_cat_type;
+
+template <class ..._Ttypes, class ..._Utypes>
+struct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> >
+{
+ typedef _LIBCPP_NODEBUG tuple<_Ttypes..., _Utypes...> type;
+};
+
+template <class _ResultTuple, bool _Is_Tuple0TupleLike, class ..._Tuples>
+struct __tuple_cat_return_1
+{
+};
+
+template <class ..._Types, class _Tuple0>
+struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>
+{
+ using type _LIBCPP_NODEBUG = typename __tuple_cat_type<
+ tuple<_Types...>,
+ typename __make_tuple_types<__uncvref_t<_Tuple0> >::type
+ >::type;
+};
+
+template <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples>
+struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...>
+ : public __tuple_cat_return_1<
+ typename __tuple_cat_type<
+ tuple<_Types...>,
+ typename __make_tuple_types<__uncvref_t<_Tuple0> >::type
+ >::type,
+ __tuple_like<typename remove_reference<_Tuple1>::type>::value,
+ _Tuple1, _Tuples...>
+{
+};
+
+template <class ..._Tuples> struct __tuple_cat_return;
+
+template <class _Tuple0, class ..._Tuples>
+struct __tuple_cat_return<_Tuple0, _Tuples...>
+ : public __tuple_cat_return_1<tuple<>,
+ __tuple_like<typename remove_reference<_Tuple0>::type>::value, _Tuple0,
+ _Tuples...>
+{
+};
+
+template <>
+struct __tuple_cat_return<>
+{
+ typedef _LIBCPP_NODEBUG tuple<> type;
+};
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+tuple<>
+tuple_cat()
+{
+ return tuple<>();
+}
+
+template <class _Rp, class _Indices, class _Tuple0, class ..._Tuples>
+struct __tuple_cat_return_ref_imp;
+
+template <class ..._Types, size_t ..._I0, class _Tuple0>
+struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0>
+{
+ typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple0>::type _T0;
+ typedef tuple<_Types..., typename __apply_cv<_Tuple0,
+ typename tuple_element<_I0, _T0>::type>::type&&...> type;
+};
+
+template <class ..._Types, size_t ..._I0, class _Tuple0, class _Tuple1, class ..._Tuples>
+struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>,
+ _Tuple0, _Tuple1, _Tuples...>
+ : public __tuple_cat_return_ref_imp<
+ tuple<_Types..., typename __apply_cv<_Tuple0,
+ typename tuple_element<_I0,
+ typename remove_reference<_Tuple0>::type>::type>::type&&...>,
+ typename __make_tuple_indices<tuple_size<typename
+ remove_reference<_Tuple1>::type>::value>::type,
+ _Tuple1, _Tuples...>
+{
+};
+
+template <class _Tuple0, class ..._Tuples>
+struct __tuple_cat_return_ref
+ : public __tuple_cat_return_ref_imp<tuple<>,
+ typename __make_tuple_indices<
+ tuple_size<typename remove_reference<_Tuple0>::type>::value
+ >::type, _Tuple0, _Tuples...>
+{
+};
+
+template <class _Types, class _I0, class _J0>
+struct __tuple_cat;
+
+template <class ..._Types, size_t ..._I0, size_t ..._J0>
+struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> >
+{
+ template <class _Tuple0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
+ operator()(tuple<_Types...> __t, _Tuple0&& __t0)
+ {
+ return _VSTD::forward_as_tuple(
+ _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
+ _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
+ }
+
+ template <class _Tuple0, class _Tuple1, class ..._Tuples>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
+ operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)
+ {
+ typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple0>::type _T0;
+ typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple1>::type _T1;
+ return __tuple_cat<
+ tuple<_Types...,
+ typename __apply_cv<_Tuple0, typename tuple_element<
+ _J0, _T0>::type>::type&&...>,
+ typename __make_tuple_indices<sizeof...(_Types) +
+ tuple_size<_T0>::value>::type,
+ typename __make_tuple_indices<tuple_size<_T1>::value>::type>()(
+ _VSTD::forward_as_tuple(
+ _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
+ _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...),
+ _VSTD::forward<_Tuple1>(__t1), _VSTD::forward<_Tuples>(__tpls)...);
+ }
+};
+
+template <class _Tuple0, class... _Tuples>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+typename __tuple_cat_return<_Tuple0, _Tuples...>::type
+tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls)
+{
+ typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple0>::type _T0;
+ return __tuple_cat<tuple<>, __tuple_indices<>,
+ typename __make_tuple_indices<tuple_size<_T0>::value>::type>()
+ (tuple<>(), _VSTD::forward<_Tuple0>(__t0),
+ _VSTD::forward<_Tuples>(__tpls)...);
+}
+
+template <class ..._Tp, class _Alloc>
+struct _LIBCPP_TEMPLATE_VIS uses_allocator<tuple<_Tp...>, _Alloc>
+ : true_type {};
+
+template <class _T1, class _T2>
+template <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+pair<_T1, _T2>::pair(piecewise_construct_t,
+ tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
+ __tuple_indices<_I1...>, __tuple_indices<_I2...>)
+ : first(_VSTD::forward<_Args1>(_VSTD::get<_I1>( __first_args))...),
+ second(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
+{
+ (void)__first_args;
+ (void)__second_args;
+}
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr size_t tuple_size_v = tuple_size<_Tp>::value;
+
+#define _LIBCPP_NOEXCEPT_RETURN(...) noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; }
+
+template <class _Fn, class _Tuple, size_t ..._Id>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr decltype(auto) __apply_tuple_impl(_Fn && __f, _Tuple && __t,
+ __tuple_indices<_Id...>)
+_LIBCPP_NOEXCEPT_RETURN(
+ _VSTD::__invoke_constexpr(
+ _VSTD::forward<_Fn>(__f),
+ _VSTD::get<_Id>(_VSTD::forward<_Tuple>(__t))...)
+)
+
+template <class _Fn, class _Tuple>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr decltype(auto) apply(_Fn && __f, _Tuple && __t)
+_LIBCPP_NOEXCEPT_RETURN(
+ _VSTD::__apply_tuple_impl(
+ _VSTD::forward<_Fn>(__f), _VSTD::forward<_Tuple>(__t),
+ typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{})
+)
+
+template <class _Tp, class _Tuple, size_t... _Idx>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr _Tp __make_from_tuple_impl(_Tuple&& __t, __tuple_indices<_Idx...>)
+_LIBCPP_NOEXCEPT_RETURN(
+ _Tp(_VSTD::get<_Idx>(_VSTD::forward<_Tuple>(__t))...)
+)
+
+template <class _Tp, class _Tuple>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr _Tp make_from_tuple(_Tuple&& __t)
+_LIBCPP_NOEXCEPT_RETURN(
+ _VSTD::__make_from_tuple_impl<_Tp>(_VSTD::forward<_Tuple>(__t),
+ typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{})
+)
+
+#undef _LIBCPP_NOEXCEPT_RETURN
+
+#endif // _LIBCPP_STD_VER > 14
+
+#endif // !defined(_LIBCPP_CXX03_LANG)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_TUPLE
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/type_traits b/contrib/libs/cxxsupp/libcxxmsvc/include/type_traits
new file mode 100644
index 0000000000..df31e7654e
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/type_traits
@@ -0,0 +1,4187 @@
+// -*- 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
+#define _LIBCPP_TYPE_TRAITS
+
+/*
+ type_traits synopsis
+
+namespace std
+{
+
+ // helper class:
+ template <class T, T v> struct integral_constant;
+ typedef integral_constant<bool, true> true_type; // C++11
+ typedef integral_constant<bool, false> false_type; // C++11
+
+ template <bool B> // C++14
+ using bool_constant = integral_constant<bool, B>; // C++14
+ typedef bool_constant<true> true_type; // C++14
+ typedef bool_constant<false> false_type; // C++14
+
+ // helper traits
+ template <bool, class T = void> struct enable_if;
+ template <bool, class T, class F> struct conditional;
+
+ // Primary classification traits:
+ template <class T> struct is_void;
+ template <class T> struct is_null_pointer; // C++14
+ template <class T> struct is_integral;
+ template <class T> struct is_floating_point;
+ template <class T> struct is_array;
+ template <class T> struct is_pointer;
+ template <class T> struct is_lvalue_reference;
+ template <class T> struct is_rvalue_reference;
+ template <class T> struct is_member_object_pointer;
+ template <class T> struct is_member_function_pointer;
+ template <class T> struct is_enum;
+ template <class T> struct is_union;
+ template <class T> struct is_class;
+ template <class T> struct is_function;
+
+ // Secondary classification traits:
+ template <class T> struct is_reference;
+ template <class T> struct is_arithmetic;
+ template <class T> struct is_fundamental;
+ template <class T> struct is_member_pointer;
+ template <class T> struct is_scoped_enum; // C++2b
+ template <class T> struct is_scalar;
+ template <class T> struct is_object;
+ template <class T> struct is_compound;
+
+ // Const-volatile properties and transformations:
+ template <class T> struct is_const;
+ template <class T> struct is_volatile;
+ template <class T> struct remove_const;
+ template <class T> struct remove_volatile;
+ template <class T> struct remove_cv;
+ template <class T> struct add_const;
+ template <class T> struct add_volatile;
+ template <class T> struct add_cv;
+
+ // Reference transformations:
+ template <class T> struct remove_reference;
+ template <class T> struct add_lvalue_reference;
+ template <class T> struct add_rvalue_reference;
+
+ // Pointer transformations:
+ template <class T> struct remove_pointer;
+ template <class T> struct add_pointer;
+
+ template<class T> struct type_identity; // C++20
+ template<class T>
+ using type_identity_t = typename type_identity<T>::type; // C++20
+
+ // Integral properties:
+ template <class T> struct is_signed;
+ template <class T> struct is_unsigned;
+ template <class T> struct make_signed;
+ template <class T> struct make_unsigned;
+
+ // Array properties and transformations:
+ template <class T> struct rank;
+ template <class T, unsigned I = 0> struct extent;
+ template <class T> struct remove_extent;
+ template <class T> struct remove_all_extents;
+
+ template <class T> struct is_bounded_array; // C++20
+ template <class T> struct is_unbounded_array; // C++20
+
+ // Member introspection:
+ template <class T> struct is_pod;
+ 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; // 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;
+ template <class T> struct is_final; // C++14
+ template <class T> struct is_aggregate; // C++17
+
+ template <class T, class... Args> struct is_constructible;
+ template <class T> struct is_default_constructible;
+ template <class T> struct is_copy_constructible;
+ template <class T> struct is_move_constructible;
+ template <class T, class U> struct is_assignable;
+ template <class T> struct is_copy_assignable;
+ template <class T> struct is_move_assignable;
+ template <class T, class U> struct is_swappable_with; // C++17
+ template <class T> struct is_swappable; // C++17
+ template <class T> struct is_destructible;
+
+ template <class T, class... Args> struct is_trivially_constructible;
+ template <class T> struct is_trivially_default_constructible;
+ template <class T> struct is_trivially_copy_constructible;
+ template <class T> struct is_trivially_move_constructible;
+ template <class T, class U> struct is_trivially_assignable;
+ template <class T> struct is_trivially_copy_assignable;
+ template <class T> struct is_trivially_move_assignable;
+ template <class T> struct is_trivially_destructible;
+
+ template <class T, class... Args> struct is_nothrow_constructible;
+ template <class T> struct is_nothrow_default_constructible;
+ template <class T> struct is_nothrow_copy_constructible;
+ template <class T> struct is_nothrow_move_constructible;
+ template <class T, class U> struct is_nothrow_assignable;
+ template <class T> struct is_nothrow_copy_assignable;
+ template <class T> struct is_nothrow_move_assignable;
+ template <class T, class U> struct is_nothrow_swappable_with; // C++17
+ template <class T> struct is_nothrow_swappable; // C++17
+ template <class T> struct is_nothrow_destructible;
+
+ template <class T> struct has_virtual_destructor;
+
+ template<class T> struct has_unique_object_representations; // C++17
+
+ // Relationships between types:
+ template <class T, class U> struct is_same;
+ template <class Base, class Derived> struct is_base_of;
+
+ template <class From, class To> struct is_convertible;
+ template <typename From, typename To> struct is_nothrow_convertible; // C++20
+ template <typename From, typename To> inline constexpr bool is_nothrow_convertible_v; // C++20
+
+ template <class Fn, class... ArgTypes> struct is_invocable;
+ template <class R, class Fn, class... ArgTypes> struct is_invocable_r;
+
+ template <class Fn, class... ArgTypes> struct is_nothrow_invocable;
+ template <class R, class Fn, class... ArgTypes> struct is_nothrow_invocable_r;
+
+ // Alignment properties and transformations:
+ template <class T> struct alignment_of;
+ template <size_t Len, size_t Align = most_stringent_alignment_requirement>
+ struct aligned_storage;
+ template <size_t Len, class... Types> struct aligned_union;
+ template <class T> struct remove_cvref; // C++20
+
+ template <class T> struct decay;
+ template <class... T> struct common_type;
+ template <class T> struct underlying_type;
+ 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:
+ template <class T>
+ using remove_const_t = typename remove_const<T>::type; // C++14
+ template <class T>
+ using remove_volatile_t = typename remove_volatile<T>::type; // C++14
+ template <class T>
+ using remove_cv_t = typename remove_cv<T>::type; // C++14
+ template <class T>
+ using add_const_t = typename add_const<T>::type; // C++14
+ template <class T>
+ using add_volatile_t = typename add_volatile<T>::type; // C++14
+ template <class T>
+ using add_cv_t = typename add_cv<T>::type; // C++14
+
+ // reference modifications:
+ template <class T>
+ using remove_reference_t = typename remove_reference<T>::type; // C++14
+ template <class T>
+ using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14
+ template <class T>
+ using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14
+
+ // sign modifications:
+ template <class T>
+ using make_signed_t = typename make_signed<T>::type; // C++14
+ template <class T>
+ using make_unsigned_t = typename make_unsigned<T>::type; // C++14
+
+ // array modifications:
+ template <class T>
+ using remove_extent_t = typename remove_extent<T>::type; // C++14
+ template <class T>
+ using remove_all_extents_t = typename remove_all_extents<T>::type; // C++14
+
+ template <class T>
+ inline constexpr bool is_bounded_array_v
+ = is_bounded_array<T>::value; // C++20
+ inline constexpr bool is_unbounded_array_v
+ = is_unbounded_array<T>::value; // C++20
+
+ // pointer modifications:
+ template <class T>
+ using remove_pointer_t = typename remove_pointer<T>::type; // C++14
+ template <class T>
+ using add_pointer_t = typename add_pointer<T>::type; // C++14
+
+ // other transformations:
+ template <size_t Len, size_t Align=default-alignment>
+ using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14
+ 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
+ template <class T>
+ using decay_t = typename decay<T>::type; // C++14
+ template <bool b, class T=void>
+ using enable_if_t = typename enable_if<b,T>::type; // C++14
+ template <bool b, class T, class F>
+ using conditional_t = typename conditional<b,T,F>::type; // C++14
+ template <class... T>
+ using common_type_t = typename common_type<T...>::type; // C++14
+ 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; 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
+
+ template <class...>
+ using void_t = void; // C++17
+
+ // See C++14 20.10.4.1, primary type categories
+ template <class T> inline constexpr bool is_void_v
+ = is_void<T>::value; // C++17
+ template <class T> inline constexpr bool is_null_pointer_v
+ = is_null_pointer<T>::value; // C++17
+ template <class T> inline constexpr bool is_integral_v
+ = is_integral<T>::value; // C++17
+ template <class T> inline constexpr bool is_floating_point_v
+ = is_floating_point<T>::value; // C++17
+ template <class T> inline constexpr bool is_array_v
+ = is_array<T>::value; // C++17
+ template <class T> inline constexpr bool is_pointer_v
+ = is_pointer<T>::value; // C++17
+ template <class T> inline constexpr bool is_lvalue_reference_v
+ = is_lvalue_reference<T>::value; // C++17
+ template <class T> inline constexpr bool is_rvalue_reference_v
+ = is_rvalue_reference<T>::value; // C++17
+ template <class T> inline constexpr bool is_member_object_pointer_v
+ = is_member_object_pointer<T>::value; // C++17
+ template <class T> inline constexpr bool is_member_function_pointer_v
+ = is_member_function_pointer<T>::value; // C++17
+ template <class T> inline constexpr bool is_enum_v
+ = is_enum<T>::value; // C++17
+ template <class T> inline constexpr bool is_union_v
+ = is_union<T>::value; // C++17
+ template <class T> inline constexpr bool is_class_v
+ = is_class<T>::value; // C++17
+ template <class T> inline constexpr bool is_function_v
+ = is_function<T>::value; // C++17
+
+ // See C++14 20.10.4.2, composite type categories
+ template <class T> inline constexpr bool is_reference_v
+ = is_reference<T>::value; // C++17
+ template <class T> inline constexpr bool is_arithmetic_v
+ = is_arithmetic<T>::value; // C++17
+ template <class T> inline constexpr bool is_fundamental_v
+ = is_fundamental<T>::value; // C++17
+ template <class T> inline constexpr bool is_object_v
+ = is_object<T>::value; // C++17
+ template <class T> inline constexpr bool is_scalar_v
+ = is_scalar<T>::value; // C++17
+ template <class T> inline constexpr bool is_compound_v
+ = is_compound<T>::value; // C++17
+ template <class T> inline constexpr bool is_member_pointer_v
+ = is_member_pointer<T>::value; // C++17
+ template <class T> inline constexpr bool is_scoped_enum_v
+ = is_scoped_enum<T>::value; // C++2b
+
+ // See C++14 20.10.4.3, type properties
+ template <class T> inline constexpr bool is_const_v
+ = is_const<T>::value; // C++17
+ template <class T> inline constexpr bool is_volatile_v
+ = is_volatile<T>::value; // C++17
+ template <class T> inline constexpr bool is_trivial_v
+ = is_trivial<T>::value; // C++17
+ template <class T> inline constexpr bool is_trivially_copyable_v
+ = is_trivially_copyable<T>::value; // C++17
+ template <class T> inline constexpr bool is_standard_layout_v
+ = is_standard_layout<T>::value; // C++17
+ 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; 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
+ = is_polymorphic<T>::value; // C++17
+ template <class T> inline constexpr bool is_abstract_v
+ = is_abstract<T>::value; // C++17
+ template <class T> inline constexpr bool is_final_v
+ = is_final<T>::value; // C++17
+ template <class T> inline constexpr bool is_aggregate_v
+ = is_aggregate<T>::value; // C++17
+ template <class T> inline constexpr bool is_signed_v
+ = is_signed<T>::value; // C++17
+ template <class T> inline constexpr bool is_unsigned_v
+ = is_unsigned<T>::value; // C++17
+ template <class T, class... Args> inline constexpr bool is_constructible_v
+ = is_constructible<T, Args...>::value; // C++17
+ template <class T> inline constexpr bool is_default_constructible_v
+ = is_default_constructible<T>::value; // C++17
+ template <class T> inline constexpr bool is_copy_constructible_v
+ = is_copy_constructible<T>::value; // C++17
+ template <class T> inline constexpr bool is_move_constructible_v
+ = is_move_constructible<T>::value; // C++17
+ template <class T, class U> inline constexpr bool is_assignable_v
+ = is_assignable<T, U>::value; // C++17
+ template <class T> inline constexpr bool is_copy_assignable_v
+ = is_copy_assignable<T>::value; // C++17
+ template <class T> inline constexpr bool is_move_assignable_v
+ = is_move_assignable<T>::value; // C++17
+ template <class T, class U> inline constexpr bool is_swappable_with_v
+ = is_swappable_with<T, U>::value; // C++17
+ template <class T> inline constexpr bool is_swappable_v
+ = is_swappable<T>::value; // C++17
+ template <class T> inline constexpr bool is_destructible_v
+ = is_destructible<T>::value; // C++17
+ template <class T, class... Args> inline constexpr bool is_trivially_constructible_v
+ = is_trivially_constructible<T, Args...>::value; // C++17
+ template <class T> inline constexpr bool is_trivially_default_constructible_v
+ = is_trivially_default_constructible<T>::value; // C++17
+ template <class T> inline constexpr bool is_trivially_copy_constructible_v
+ = is_trivially_copy_constructible<T>::value; // C++17
+ template <class T> inline constexpr bool is_trivially_move_constructible_v
+ = is_trivially_move_constructible<T>::value; // C++17
+ template <class T, class U> inline constexpr bool is_trivially_assignable_v
+ = is_trivially_assignable<T, U>::value; // C++17
+ template <class T> inline constexpr bool is_trivially_copy_assignable_v
+ = is_trivially_copy_assignable<T>::value; // C++17
+ template <class T> inline constexpr bool is_trivially_move_assignable_v
+ = is_trivially_move_assignable<T>::value; // C++17
+ template <class T> inline constexpr bool is_trivially_destructible_v
+ = is_trivially_destructible<T>::value; // C++17
+ template <class T, class... Args> inline constexpr bool is_nothrow_constructible_v
+ = is_nothrow_constructible<T, Args...>::value; // C++17
+ template <class T> inline constexpr bool is_nothrow_default_constructible_v
+ = is_nothrow_default_constructible<T>::value; // C++17
+ template <class T> inline constexpr bool is_nothrow_copy_constructible_v
+ = is_nothrow_copy_constructible<T>::value; // C++17
+ template <class T> inline constexpr bool is_nothrow_move_constructible_v
+ = is_nothrow_move_constructible<T>::value; // C++17
+ template <class T, class U> inline constexpr bool is_nothrow_assignable_v
+ = is_nothrow_assignable<T, U>::value; // C++17
+ template <class T> inline constexpr bool is_nothrow_copy_assignable_v
+ = is_nothrow_copy_assignable<T>::value; // C++17
+ template <class T> inline constexpr bool is_nothrow_move_assignable_v
+ = is_nothrow_move_assignable<T>::value; // C++17
+ template <class T, class U> inline constexpr bool is_nothrow_swappable_with_v
+ = is_nothrow_swappable_with<T, U>::value; // C++17
+ template <class T> inline constexpr bool is_nothrow_swappable_v
+ = is_nothrow_swappable<T>::value; // C++17
+ template <class T> inline constexpr bool is_nothrow_destructible_v
+ = is_nothrow_destructible<T>::value; // C++17
+ template <class T> inline constexpr bool has_virtual_destructor_v
+ = has_virtual_destructor<T>::value; // C++17
+ template<class T> inline constexpr bool has_unique_object_representations_v // C++17
+ = has_unique_object_representations<T>::value;
+
+ // See C++14 20.10.5, type property queries
+ template <class T> inline constexpr size_t alignment_of_v
+ = alignment_of<T>::value; // C++17
+ template <class T> inline constexpr size_t rank_v
+ = rank<T>::value; // C++17
+ template <class T, unsigned I = 0> inline constexpr size_t extent_v
+ = extent<T, I>::value; // C++17
+
+ // See C++14 20.10.6, type relations
+ template <class T, class U> inline constexpr bool is_same_v
+ = is_same<T, U>::value; // C++17
+ template <class Base, class Derived> inline constexpr bool is_base_of_v
+ = is_base_of<Base, Derived>::value; // C++17
+ template <class From, class To> inline constexpr bool is_convertible_v
+ = is_convertible<From, To>::value; // C++17
+ template <class Fn, class... ArgTypes> inline constexpr bool is_invocable_v
+ = is_invocable<Fn, ArgTypes...>::value; // C++17
+ template <class R, class Fn, class... ArgTypes> inline constexpr bool is_invocable_r_v
+ = is_invocable_r<R, Fn, ArgTypes...>::value; // C++17
+ template <class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_v
+ = is_nothrow_invocable<Fn, ArgTypes...>::value; // C++17
+ template <class R, class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_r_v
+ = is_nothrow_invocable_r<R, Fn, ArgTypes...>::value; // C++17
+
+ // [meta.logical], logical operator traits:
+ template<class... B> struct conjunction; // C++17
+ template<class... B>
+ inline constexpr bool conjunction_v = conjunction<B...>::value; // C++17
+ template<class... B> struct disjunction; // C++17
+ template<class... B>
+ inline constexpr bool disjunction_v = disjunction<B...>::value; // C++17
+ template<class B> struct negation; // C++17
+ template<class B>
+ inline constexpr bool negation_v = negation<B>::value; // C++17
+
+}
+
+*/
+#include <__config>
+#include <cstddef>
+#include <version>
+#include <__utility/declval.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning(push)
+#pragma warning(disable: 4296)
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS pair;
+template <class _Tp> class _LIBCPP_TEMPLATE_VIS reference_wrapper;
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
+
+template <class _Tp, _Tp __v>
+struct _LIBCPP_TEMPLATE_VIS integral_constant
+{
+ static _LIBCPP_CONSTEXPR const _Tp value = __v;
+ typedef _Tp value_type;
+ typedef integral_constant type;
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;}
+#if _LIBCPP_STD_VER > 11
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr value_type operator ()() const _NOEXCEPT {return value;}
+#endif
+};
+
+template <class _Tp, _Tp __v>
+_LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
+
+#if _LIBCPP_STD_VER > 14
+template <bool __b>
+using bool_constant = integral_constant<bool, __b>;
+#define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)>
+#else
+#define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)>
+#endif
+
+template <bool, class _Tp = void> struct _LIBCPP_TEMPLATE_VIS enable_if {};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS enable_if<true, _Tp> {typedef _Tp type;};
+
+template <bool _Bp, class _Tp = void> using __enable_if_t _LIBCPP_NODEBUG = typename enable_if<_Bp, _Tp>::type;
+
+#if _LIBCPP_STD_VER > 11
+template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
+#endif
+
+typedef _LIBCPP_BOOL_CONSTANT(true) true_type;
+typedef _LIBCPP_BOOL_CONSTANT(false) false_type;
+
+template <bool _Val>
+using _BoolConstant _LIBCPP_NODEBUG = integral_constant<bool, _Val>;
+
+template <bool> struct _MetaBase;
+template <>
+struct _MetaBase<true> {
+ template <class _Tp, class _Up>
+ using _SelectImpl _LIBCPP_NODEBUG = _Tp;
+ template <template <class...> class _FirstFn, template <class...> class, class ..._Args>
+ using _SelectApplyImpl _LIBCPP_NODEBUG = _FirstFn<_Args...>;
+ template <class _First, class...>
+ using _FirstImpl _LIBCPP_NODEBUG = _First;
+ template <class, class _Second, class...>
+ using _SecondImpl _LIBCPP_NODEBUG = _Second;
+ template <class _Result, class _First, class ..._Rest>
+ using _OrImpl _LIBCPP_NODEBUG = typename _MetaBase<_First::value != true && sizeof...(_Rest) != 0>::template _OrImpl<_First, _Rest...>;
+ template <class _Result, class _First, class ..._Rest>
+ using _AndImpl _LIBCPP_NODEBUG = typename _MetaBase<_First::value == true && sizeof...(_Rest) != 0>::template _AndImpl<_First, _Rest...>;
+};
+
+template <>
+struct _MetaBase<false> {
+ template <class _Tp, class _Up>
+ using _SelectImpl _LIBCPP_NODEBUG = _Up;
+ template <template <class...> class, template <class...> class _SecondFn, class ..._Args>
+ using _SelectApplyImpl _LIBCPP_NODEBUG = _SecondFn<_Args...>;
+ template <class _Result, class ...>
+ using _OrImpl _LIBCPP_NODEBUG = _Result;
+ template <class _Result, class ...>
+ using _AndImpl _LIBCPP_NODEBUG = _Result;
+};
+// Workaround for MSVC. Sometimes compiler thinks that sizeof...(Type) is parameter pack rather than the number.
+// So it doesn't allow sizeof...(Type) in expression that goes into the boolean template parameter of _MetaBase.
+// This simple wrapper allows us to hide sizeof... from the compiler.
+template<class... _Pack>
+struct _Sizeof {
+ static constexpr size_t value = sizeof...(_Pack);
+};
+// CUDA headers use libc++ internals.
+#ifdef __CUDACC__
+template <bool _Cond, class _Ret = void>
+using __lazy_enable_if _LIBCPP_NODEBUG = __enable_if_t<_Cond, _Ret>;
+#endif
+template <bool _Cond, class _IfRes, class _ElseRes>
+using _If _LIBCPP_NODEBUG = typename _MetaBase<_Cond>::template _SelectImpl<_IfRes, _ElseRes>;
+template <class ..._Rest>
+using _Or _LIBCPP_NODEBUG = typename _MetaBase< _Sizeof<_Rest...>::value != 0 >::template _OrImpl<false_type, _Rest...>;
+template <class _Pred>
+struct _Not : _BoolConstant<!_Pred::value> {};
+template <class ..._Args>
+using _FirstType _LIBCPP_NODEBUG = typename _MetaBase<(_Sizeof<_Args...>::value >= 1)>::template _FirstImpl<_Args...>;
+template <class ..._Args>
+using _SecondType _LIBCPP_NODEBUG = typename _MetaBase<(_Sizeof<_Args...>::value >= 2)>::template _SecondImpl<_Args...>;
+
+// fold-based implementation fails on multiple compilers.
+#if 1
+template <class ..._Rest>
+using _And _LIBCPP_NODEBUG = typename _MetaBase< _Sizeof<_Rest...>::value != 0 >::template _AndImpl<true_type, _Rest...>;
+#else
+template <class ...> using __expand_to_true = true_type;
+template <class ..._Pred>
+__expand_to_true<__enable_if_t<std::bool_constant<_Pred::value>::value>...> __and_helper(int);
+template <class ...>
+false_type __and_helper(...);
+template <class ..._Pred>
+using _And _LIBCPP_NODEBUG = decltype(__and_helper<std::bool_constant<_Pred::value>...>(0));
+#endif
+
+template <template <class...> class _Func, class ..._Args>
+struct _Lazy : _Func<_Args...> {};
+
+// Member detector base
+
+template <template <class...> class _Templ, class ..._Args, class = _Templ<_Args...> >
+true_type __sfinae_test_impl(int);
+template <template <class...> class, class ...>
+false_type __sfinae_test_impl(...);
+
+template <template <class ...> class _Templ, class ..._Args>
+using _IsValidExpansion _LIBCPP_NODEBUG = decltype(__sfinae_test_impl<_Templ, _Args...>(0));
+
+template <class>
+struct __void_t { typedef void type; };
+
+template <class _Tp>
+struct __identity { typedef _Tp type; };
+
+template <class _Tp>
+using __identity_t _LIBCPP_NODEBUG = typename __identity<_Tp>::type;
+
+template <class _Tp, bool>
+struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {};
+
+
+template <bool _Bp, class _If, class _Then>
+ struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;};
+template <class _If, class _Then>
+ struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {typedef _Then type;};
+
+#if _LIBCPP_STD_VER > 11
+template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type;
+#endif
+
+// is_same
+
+#if __has_keyword(__is_same) && !defined(__CUDACC__)
+
+template <class _Tp, class _Up>
+struct _LIBCPP_TEMPLATE_VIS is_same : _BoolConstant<__is_same(_Tp, _Up)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp, class _Up>
+inline constexpr bool is_same_v = __is_same(_Tp, _Up);
+#endif
+
+#else
+
+template <class _Tp, class _Up> struct _LIBCPP_TEMPLATE_VIS is_same : public false_type {};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_same<_Tp, _Tp> : public true_type {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp, class _Up>
+inline constexpr bool is_same_v = is_same<_Tp, _Up>::value;
+#endif
+
+#endif // __is_same
+// _IsSame<T,U> has the same effect as is_same<T,U> but instantiates fewer types:
+// is_same<A,B> and is_same<C,D> are guaranteed to be different types, but
+// _IsSame<A,B> and _IsSame<C,D> are the same type (namely, false_type).
+// Neither GCC nor Clang can mangle the __is_same builtin, so _IsSame
+// mustn't be directly used anywhere that contributes to name-mangling
+// (such as in a dependent return type).
+
+template <class _Tp, class _Up>
+using _IsSame = _BoolConstant<
+#if defined(__clang__) && !defined(__CUDACC__)
+ __is_same(_Tp, _Up)
+#else
+ is_same<_Tp, _Up>::value
+#endif
+>;
+
+template <class _Tp, class _Up>
+using _IsNotSame = _BoolConstant<
+#if defined(__clang__) && !defined(__CUDACC__)
+ !__is_same(_Tp, _Up)
+#else
+ !is_same<_Tp, _Up>::value
+#endif
+>;
+
+
+template <class _Tp>
+using __test_for_primary_template = __enable_if_t<
+ _IsSame<_Tp, typename _Tp::__primary_template>::value
+ >;
+template <class _Tp>
+using __is_primary_template = _IsValidExpansion<
+ __test_for_primary_template, _Tp
+ >;
+
+// helper class
+
+struct __two {char __lx[2];};
+
+// is_const
+
+#if __has_keyword(__is_const) && !defined(__CUDACC__)
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_const : _BoolConstant<__is_const(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_const_v = __is_const(_Tp);
+#endif
+
+#else
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const : public false_type {};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_const_v = is_const<_Tp>::value;
+#endif
+
+#endif // __has_keyword(__is_const)
+
+// is_volatile
+
+#if __has_keyword(__is_volatile) && !defined(__CUDACC__)
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_volatile : _BoolConstant<__is_volatile(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_volatile_v = __is_volatile(_Tp);
+#endif
+
+#else
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile : public false_type {};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_volatile_v = is_volatile<_Tp>::value;
+#endif
+
+#endif // __has_keyword(__is_volatile)
+
+// remove_const
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const<const _Tp> {typedef _Tp type;};
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
+#endif
+
+// remove_volatile
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;};
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
+#endif
+
+// remove_cv
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
+{typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
+#endif
+
+// is_void
+
+#if __has_keyword(__is_void) && !defined(__CUDACC__)
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_void : _BoolConstant<__is_void(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_void_v = __is_void(_Tp);
+#endif
+
+#else
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_void
+ : public is_same<typename remove_cv<_Tp>::type, void> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_void_v = is_void<_Tp>::value;
+#endif
+
+#endif // __has_keyword(__is_void)
+
+// __is_nullptr_t
+
+template <class _Tp> struct __is_nullptr_t_impl : public false_type {};
+template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t
+ : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_null_pointer
+ : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value;
+#endif
+#endif // _LIBCPP_STD_VER > 11
+
+// is_integral
+
+#if __has_keyword(__is_integral) && !defined(__CUDACC__)
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_integral : _BoolConstant<__is_integral(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_integral_v = __is_integral(_Tp);
+#endif
+
+#else
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_integral
+ : public _BoolConstant<__libcpp_is_integral<typename remove_cv<_Tp>::type>::value> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_integral_v = is_integral<_Tp>::value;
+#endif
+
+#endif // __has_keyword(__is_integral)
+
+// [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
+// <concepts> implements __libcpp_floating_point
+
+template <class _Tp> struct __libcpp_is_floating_point : public false_type {};
+template <> struct __libcpp_is_floating_point<float> : public true_type {};
+template <> struct __libcpp_is_floating_point<double> : public true_type {};
+template <> struct __libcpp_is_floating_point<long double> : public true_type {};
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_floating_point
+ : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value;
+#endif
+
+// is_array
+
+#if __has_keyword(__is_array) && !defined(__CUDACC__)
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_array : _BoolConstant<__is_array(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_array_v = __is_array(_Tp);
+#endif
+
+#else
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array
+ : public false_type {};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]>
+ : public true_type {};
+template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[_Np]>
+ : public true_type {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_array_v = is_array<_Tp>::value;
+#endif
+
+#endif // __has_keyword(__is_array)
+
+// is_pointer
+
+// Before AppleClang 12.0.5, __is_pointer didn't work for Objective-C types.
+#if __has_keyword(__is_pointer) && \
+ !(defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1205) && \
+ !defined(__CUDACC__)
+
+template<class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_pointer : _BoolConstant<__is_pointer(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_pointer_v = __is_pointer(_Tp);
+#endif
+
+#else // __has_keyword(__is_pointer)
+
+template <class _Tp> struct __libcpp_is_pointer : public false_type {};
+template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
+
+template <class _Tp> struct __libcpp_remove_objc_qualifiers { typedef _Tp type; };
+#if defined(_LIBCPP_HAS_OBJC_ARC)
+template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __strong> { typedef _Tp type; };
+template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __weak> { typedef _Tp type; };
+template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __autoreleasing> { typedef _Tp type; };
+template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __unsafe_unretained> { typedef _Tp type; };
+#endif
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pointer
+ : public __libcpp_is_pointer<typename __libcpp_remove_objc_qualifiers<typename remove_cv<_Tp>::type>::type> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_pointer_v = is_pointer<_Tp>::value;
+#endif
+
+#endif // __has_keyword(__is_pointer)
+
+// is_reference
+
+#if __has_keyword(__is_lvalue_reference) && \
+ __has_keyword(__is_rvalue_reference) && \
+ __has_keyword(__is_reference) && !defined(__CUDACC__)
+
+template<class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> { };
+
+template<class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : _BoolConstant<__is_rvalue_reference(_Tp)> { };
+
+template<class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_reference : _BoolConstant<__is_reference(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_reference_v = __is_reference(_Tp);
+template <class _Tp>
+inline constexpr bool is_lvalue_reference_v = __is_lvalue_reference(_Tp);
+template <class _Tp>
+inline constexpr bool is_rvalue_reference_v = __is_rvalue_reference(_Tp);
+#endif
+
+#else // __has_keyword(__is_lvalue_reference) && etc...
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {};
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {};
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_reference_v = is_reference<_Tp>::value;
+
+template <class _Tp>
+inline constexpr bool is_lvalue_reference_v = is_lvalue_reference<_Tp>::value;
+
+template <class _Tp>
+inline constexpr bool is_rvalue_reference_v = is_rvalue_reference<_Tp>::value;
+#endif
+
+#endif // __has_keyword(__is_lvalue_reference) && etc...
+
+// is_union
+
+#if __has_feature(is_union) || defined(_LIBCPP_COMPILER_GCC)
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
+ : public integral_constant<bool, __is_union(_Tp)> {};
+
+#else
+
+template <class _Tp> struct __libcpp_union : public false_type {};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
+ : public __libcpp_union<typename remove_cv<_Tp>::type> {};
+
+#endif
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_union_v = is_union<_Tp>::value;
+#endif
+
+// is_class
+
+#if __has_feature(is_class) || defined(_LIBCPP_COMPILER_GCC)
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
+ : public integral_constant<bool, __is_class(_Tp)> {};
+
+#else
+
+namespace __is_class_imp
+{
+template <class _Tp> char __test(int _Tp::*);
+template <class _Tp> __two __test(...);
+}
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
+ : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
+
+#endif
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_class_v = is_class<_Tp>::value;
+#endif
+
+// is_function
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning(push)
+#pragma warning(disable: 4180)
+#endif
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_function
+ : public _BoolConstant<
+#if defined(__clang__) && !defined(__CUDACC__)
+ __is_function(_Tp)
+#else
+ !(is_reference<_Tp>::value || is_const<const _Tp>::value)
+#endif
+ > {};
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning(pop)
+#endif
+
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_function_v = is_function<_Tp>::value;
+#endif
+
+template <class _Tp> struct __libcpp_is_member_pointer {
+ enum {
+ __is_member = false,
+ __is_func = false,
+ __is_obj = false
+ };
+};
+template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> {
+ enum {
+ __is_member = true,
+ __is_func = is_function<_Tp>::value,
+ __is_obj = !__is_func,
+ };
+};
+
+#if __has_keyword(__is_member_function_pointer) && !defined(__CUDACC__)
+
+template<class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer
+ : _BoolConstant<__is_member_function_pointer(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_member_function_pointer_v = __is_member_function_pointer(_Tp);
+#endif
+
+#else // __has_keyword(__is_member_function_pointer)
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer
+ : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_func > {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_member_function_pointer_v = is_member_function_pointer<_Tp>::value;
+#endif
+
+#endif // __has_keyword(__is_member_function_pointer)
+
+// is_member_pointer
+
+#if __has_keyword(__is_member_pointer) && !defined(__CUDACC__)
+
+template<class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_member_pointer : _BoolConstant<__is_member_pointer(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_member_pointer_v = __is_member_pointer(_Tp);
+#endif
+
+#else // __has_keyword(__is_member_pointer)
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer
+ : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_member > {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value;
+#endif
+
+#endif // __has_keyword(__is_member_pointer)
+
+// is_member_object_pointer
+
+#if __has_keyword(__is_member_object_pointer) && !defined(__CUDACC__)
+
+template<class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer
+ : _BoolConstant<__is_member_object_pointer(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_member_object_pointer_v = __is_member_object_pointer(_Tp);
+#endif
+
+#else // __has_keyword(__is_member_object_pointer)
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer
+ : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_obj > {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_member_object_pointer_v = is_member_object_pointer<_Tp>::value;
+#endif
+
+#endif // __has_keyword(__is_member_object_pointer)
+
+// is_enum
+
+#if __has_feature(is_enum) || defined(_LIBCPP_COMPILER_GCC)
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
+ : public integral_constant<bool, __is_enum(_Tp)> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_enum_v = __is_enum(_Tp);
+#endif
+
+#else
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
+ : public integral_constant<bool, !is_void<_Tp>::value &&
+ !is_integral<_Tp>::value &&
+ !is_floating_point<_Tp>::value &&
+ !is_array<_Tp>::value &&
+ !is_pointer<_Tp>::value &&
+ !is_reference<_Tp>::value &&
+ !is_member_pointer<_Tp>::value &&
+ !is_union<_Tp>::value &&
+ !is_class<_Tp>::value &&
+ !is_function<_Tp>::value > {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_enum_v = is_enum<_Tp>::value;
+#endif
+
+#endif // __has_feature(is_enum) || defined(_LIBCPP_COMPILER_GCC)
+
+// is_arithmetic
+
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_arithmetic
+ : public integral_constant<bool, is_integral<_Tp>::value ||
+ is_floating_point<_Tp>::value> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value;
+#endif
+
+// is_fundamental
+
+// 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) && !defined(__CUDACC__)
+
+template<class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_fundamental : _BoolConstant<__is_fundamental(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_fundamental_v = __is_fundamental(_Tp);
+#endif
+
+#else // __has_keyword(__is_fundamental)
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_fundamental
+ : public integral_constant<bool, is_void<_Tp>::value ||
+ __is_nullptr_t<_Tp>::value ||
+ is_arithmetic<_Tp>::value> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value;
+#endif
+
+#endif // __has_keyword(__is_fundamental)
+
+// is_scalar
+
+// In C++03 nullptr_t is library-provided but must still count as "scalar."
+#if __has_keyword(__is_scalar) && !defined(_LIBCPP_CXX03_LANG) && !defined(__CUDACC__)
+
+template<class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_scalar : _BoolConstant<__is_scalar(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_scalar_v = __is_scalar(_Tp);
+#endif
+
+#else // __has_keyword(__is_scalar)
+
+template <class _Tp> struct __is_block : false_type {};
+#if defined(_LIBCPP_HAS_EXTENSION_BLOCKS)
+template <class _Rp, class ..._Args> struct __is_block<_Rp (^)(_Args...)> : true_type {};
+#endif
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_scalar
+ : public integral_constant<bool, is_arithmetic<_Tp>::value ||
+ is_member_pointer<_Tp>::value ||
+ is_pointer<_Tp>::value ||
+ __is_nullptr_t<_Tp>::value ||
+ __is_block<_Tp>::value ||
+ is_enum<_Tp>::value > {};
+
+template <> struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_scalar_v = is_scalar<_Tp>::value;
+#endif
+
+#endif // __has_keyword(__is_scalar)
+
+// is_object
+
+#if __has_keyword(__is_object) && !defined(__CUDACC__)
+
+template<class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_object : _BoolConstant<__is_object(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_object_v = __is_object(_Tp);
+#endif
+
+#else // __has_keyword(__is_object)
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_object
+ : public integral_constant<bool, is_scalar<_Tp>::value ||
+ is_array<_Tp>::value ||
+ is_union<_Tp>::value ||
+ is_class<_Tp>::value > {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_object_v = is_object<_Tp>::value;
+#endif
+
+#endif // __has_keyword(__is_object)
+
+// is_compound
+
+// >= 11 because in C++03 nullptr isn't actually nullptr
+#if __has_keyword(__is_compound) && !defined(_LIBCPP_CXX03_LANG) && !defined(__CUDACC__)
+
+template<class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_compound : _BoolConstant<__is_compound(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_compound_v = __is_compound(_Tp);
+#endif
+
+#else // __has_keyword(__is_compound)
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_compound
+ : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_compound_v = is_compound<_Tp>::value;
+#endif
+
+#endif // __has_keyword(__is_compound)
+
+// __is_referenceable [defns.referenceable]
+
+struct __is_referenceable_impl {
+ template <class _Tp> static _Tp& __test(int);
+ template <class _Tp> static __two __test(...);
+};
+
+template <class _Tp>
+struct __is_referenceable : integral_constant<bool,
+ _IsNotSame<decltype(__is_referenceable_impl::__test<_Tp>(0)), __two>::value> {};
+
+
+// add_const
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_const {
+ typedef _LIBCPP_NODEBUG const _Tp type;
+};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using add_const_t = typename add_const<_Tp>::type;
+#endif
+
+// add_volatile
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_volatile {
+ typedef _LIBCPP_NODEBUG volatile _Tp type;
+};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
+#endif
+
+// add_cv
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_cv {
+ typedef _LIBCPP_NODEBUG const volatile _Tp type;
+};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
+#endif
+
+// remove_reference
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _LIBCPP_NODEBUG _Tp type;};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _LIBCPP_NODEBUG _Tp type;};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _LIBCPP_NODEBUG _Tp type;};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
+#endif
+
+// add_lvalue_reference
+
+template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _LIBCPP_NODEBUG _Tp type; };
+template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG _Tp& type; };
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference
+{typedef _LIBCPP_NODEBUG typename __add_lvalue_reference_impl<_Tp>::type type;};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
+#endif
+
+template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _LIBCPP_NODEBUG _Tp type; };
+template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG _Tp&& type; };
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference
+{typedef _LIBCPP_NODEBUG typename __add_rvalue_reference_impl<_Tp>::type type;};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
+#endif
+
+template <class _Tp>
+struct __unconstref {
+ typedef _LIBCPP_NODEBUG typename remove_const<typename remove_reference<_Tp>::type>::type type;
+};
+
+template <class _Tp>
+using __uncvref_t _LIBCPP_NODEBUG = typename remove_cv<typename remove_reference<_Tp>::type>::type;
+
+// __is_same_uncvref
+
+template <class _Tp, class _Up>
+struct __is_same_uncvref : _IsSame<__uncvref_t<_Tp>, __uncvref_t<_Up> > {};
+
+// C++20, enabled for C++17 in Arcadia
+#if _LIBCPP_STD_VER > 14
+// remove_cvref - same as __uncvref
+template <class _Tp>
+struct remove_cvref {
+ using type _LIBCPP_NODEBUG = __uncvref_t<_Tp>;
+};
+
+template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type;
+#endif
+
+
+struct __any
+{
+ __any(...);
+};
+
+// remove_pointer
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _LIBCPP_NODEBUG _Tp type;};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {typedef _LIBCPP_NODEBUG _Tp type;};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {typedef _LIBCPP_NODEBUG _Tp type;};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {typedef _LIBCPP_NODEBUG _Tp type;};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {typedef _LIBCPP_NODEBUG _Tp type;};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
+#endif
+
+// add_pointer
+
+template <class _Tp,
+ bool = __is_referenceable<_Tp>::value ||
+ _IsSame<typename remove_cv<_Tp>::type, void>::value>
+struct __add_pointer_impl
+ {typedef _LIBCPP_NODEBUG typename remove_reference<_Tp>::type* type;};
+template <class _Tp> struct __add_pointer_impl<_Tp, false>
+ {typedef _LIBCPP_NODEBUG _Tp type;};
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_pointer
+ {typedef _LIBCPP_NODEBUG typename __add_pointer_impl<_Tp>::type type;};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
+#endif
+
+// type_identity
+#if _LIBCPP_STD_VER > 17
+template<class _Tp> struct type_identity { typedef _Tp type; };
+template<class _Tp> using type_identity_t = typename type_identity<_Tp>::type;
+#endif
+
+// is_signed
+
+#if __has_keyword(__is_signed) && !defined(__CUDACC__)
+
+template<class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_signed : _BoolConstant<__is_signed(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_signed_v = __is_signed(_Tp);
+#endif
+
+#else // __has_keyword(__is_signed)
+
+template <class _Tp, bool = is_integral<_Tp>::value>
+struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {};
+
+template <class _Tp>
+struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point
+
+template <class _Tp, bool = is_arithmetic<_Tp>::value>
+struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {};
+
+template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {};
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_signed : public __libcpp_is_signed<_Tp> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_signed_v = is_signed<_Tp>::value;
+#endif
+
+#endif // __has_keyword(__is_signed)
+
+// 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) && !defined(__CUDACC__)
+
+template<class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_unsigned : _BoolConstant<__is_unsigned(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_unsigned_v = __is_unsigned(_Tp);
+#endif
+
+#else // __has_keyword(__is_unsigned)
+
+template <class _Tp, bool = is_integral<_Tp>::value>
+struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {};
+
+template <class _Tp>
+struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point
+
+template <class _Tp, bool = is_arithmetic<_Tp>::value>
+struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {};
+
+template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {};
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unsigned : public __libcpp_is_unsigned<_Tp> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value;
+#endif
+
+#endif // __has_keyword(__is_unsigned)
+
+// rank
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank
+ : public integral_constant<size_t, 0> {};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]>
+ : public integral_constant<size_t, rank<_Tp>::value + 1> {};
+template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]>
+ : public integral_constant<size_t, rank<_Tp>::value + 1> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr size_t rank_v = rank<_Tp>::value;
+#endif
+
+// extent
+
+#if __has_keyword(__array_extent) && !defined(__CUDACC__)
+
+template<class _Tp, size_t _Dim = 0>
+struct _LIBCPP_TEMPLATE_VIS extent
+ : integral_constant<size_t, __array_extent(_Tp, _Dim)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp, unsigned _Ip = 0>
+inline constexpr size_t extent_v = __array_extent(_Tp, _Ip);
+#endif
+
+#else // __has_keyword(__array_extent)
+
+template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TEMPLATE_VIS extent
+ : public integral_constant<size_t, 0> {};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0>
+ : public integral_constant<size_t, 0> {};
+template <class _Tp, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], _Ip>
+ : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
+template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], 0>
+ : public integral_constant<size_t, _Np> {};
+template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], _Ip>
+ : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp, unsigned _Ip = 0>
+inline constexpr size_t extent_v = extent<_Tp, _Ip>::value;
+#endif
+
+#endif // __has_keyword(__array_extent)
+
+// remove_extent
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent
+ {typedef _Tp type;};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]>
+ {typedef _Tp type;};
+template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]>
+ {typedef _Tp type;};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
+#endif
+
+// remove_all_extents
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents
+ {typedef _Tp type;};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]>
+ {typedef typename remove_all_extents<_Tp>::type type;};
+template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]>
+ {typedef typename remove_all_extents<_Tp>::type type;};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
+#endif
+
+#if _LIBCPP_STD_VER > 17
+// is_bounded_array
+
+template <class> struct _LIBCPP_TEMPLATE_VIS is_bounded_array : false_type {};
+template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_bounded_array<_Tp[_Np]> : true_type {};
+
+template <class _Tp>
+inline constexpr
+bool is_bounded_array_v = is_bounded_array<_Tp>::value;
+
+// is_unbounded_array
+
+template <class> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array : false_type {};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array<_Tp[]> : true_type {};
+
+template <class _Tp>
+inline constexpr
+bool is_unbounded_array_v = is_unbounded_array<_Tp>::value;
+#endif
+
+// decay
+
+template <class _Up, bool>
+struct __decay {
+ typedef _LIBCPP_NODEBUG typename remove_cv<_Up>::type type;
+};
+
+template <class _Up>
+struct __decay<_Up, true> {
+public:
+ typedef _LIBCPP_NODEBUG typename conditional
+ <
+ is_array<_Up>::value,
+ typename remove_extent<_Up>::type*,
+ typename conditional
+ <
+ is_function<_Up>::value,
+ typename add_pointer<_Up>::type,
+ typename remove_cv<_Up>::type
+ >::type
+ >::type type;
+};
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS decay
+{
+private:
+ typedef _LIBCPP_NODEBUG typename remove_reference<_Tp>::type _Up;
+public:
+ typedef _LIBCPP_NODEBUG typename __decay<_Up, __is_referenceable<_Up>::value>::type type;
+};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using decay_t = typename decay<_Tp>::type;
+#endif
+
+// is_abstract
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract
+ : public integral_constant<bool, __is_abstract(_Tp)> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_abstract_v = is_abstract<_Tp>::value;
+#endif
+
+// is_final
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
+__libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
+is_final : public integral_constant<bool, __is_final(_Tp)> {};
+#endif
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_final_v = is_final<_Tp>::value;
+#endif
+
+// is_aggregate
+#if _LIBCPP_STD_VER > 14
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
+is_aggregate : public integral_constant<bool, __is_aggregate(_Tp)> {};
+
+template <class _Tp>
+inline constexpr bool is_aggregate_v = is_aggregate<_Tp>::value;
+
+#endif // _LIBCPP_STD_VER > 14
+
+// is_base_of
+
+template <class _Bp, class _Dp>
+struct _LIBCPP_TEMPLATE_VIS is_base_of
+ : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Bp, class _Dp>
+inline constexpr bool is_base_of_v = is_base_of<_Bp, _Dp>::value;
+#endif
+
+// __is_core_convertible
+
+// [conv.general]/3 says "E is convertible to T" whenever "T t=E;" is well-formed.
+// We can't test for that, but we can test implicit convertibility by passing it
+// to a function. Notice that __is_core_convertible<void,void> is false,
+// and __is_core_convertible<immovable-type,immovable-type> is true in C++17 and later.
+
+template <class _Tp, class _Up, class = void>
+struct __is_core_convertible : public false_type {};
+
+template <class _Tp, class _Up>
+struct __is_core_convertible<_Tp, _Up, decltype(
+ static_cast<void(*)(_Up)>(0) ( static_cast<_Tp(*)()>(0)() )
+)> : public true_type {};
+
+// is_convertible
+
+#if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
+
+template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
+ : public integral_constant<bool, __is_convertible_to(_T1, _T2)> {};
+
+#else // __has_feature(is_convertible_to)
+
+namespace __is_convertible_imp
+{
+template <class _Tp> void __test_convert(_Tp);
+
+template <class _From, class _To, class = void>
+struct __is_convertible_test : public false_type {};
+
+template <class _From, class _To>
+struct __is_convertible_test<_From, _To,
+ decltype(__is_convertible_imp::__test_convert<_To>(declval<_From>()))> : public true_type
+{};
+
+template <class _Tp, bool _IsArray = is_array<_Tp>::value,
+ bool _IsFunction = is_function<_Tp>::value,
+ bool _IsVoid = is_void<_Tp>::value>
+ struct __is_array_function_or_void {enum {value = 0};};
+template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
+template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
+template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
+}
+
+template <class _Tp,
+ unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
+struct __is_convertible_check
+{
+ static const size_t __v = 0;
+};
+
+template <class _Tp>
+struct __is_convertible_check<_Tp, 0>
+{
+ static const size_t __v = sizeof(_Tp);
+};
+
+template <class _T1, class _T2,
+ unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
+ unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
+struct __is_convertible
+ : public integral_constant<bool,
+ __is_convertible_imp::__is_convertible_test<_T1, _T2>::value
+ >
+{};
+
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
+
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
+
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
+
+template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
+ : public __is_convertible<_T1, _T2>
+{
+ static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
+ static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
+};
+
+#endif // __has_feature(is_convertible_to)
+
+#if _LIBCPP_STD_VER > 14
+template <class _From, class _To>
+inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value;
+#endif
+
+// is_nothrow_convertible
+
+#if _LIBCPP_STD_VER > 17
+
+template <typename _Tp>
+static void __test_noexcept(_Tp) noexcept;
+
+template<typename _Fm, typename _To>
+static bool_constant<noexcept(_VSTD::__test_noexcept<_To>(declval<_Fm>()))>
+__is_nothrow_convertible_test();
+
+template <typename _Fm, typename _To>
+struct __is_nothrow_convertible_helper: decltype(__is_nothrow_convertible_test<_Fm, _To>())
+{ };
+
+template <typename _Fm, typename _To>
+struct is_nothrow_convertible : _Or<
+ _And<is_void<_To>, is_void<_Fm>>,
+ _Lazy<_And, is_convertible<_Fm, _To>, __is_nothrow_convertible_helper<_Fm, _To>>
+>::type { };
+
+template <typename _Fm, typename _To>
+inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_Fm, _To>::value;
+
+#endif // _LIBCPP_STD_VER > 17
+
+// is_empty
+
+#if __has_feature(is_empty) || defined(_LIBCPP_COMPILER_GCC)
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_empty
+ : public integral_constant<bool, __is_empty(_Tp)> {};
+
+#else // __has_feature(is_empty)
+
+template <class _Tp>
+struct __is_empty1
+ : public _Tp
+{
+ double __lx;
+};
+
+struct __is_empty2
+{
+ double __lx;
+};
+
+template <class _Tp, bool = is_class<_Tp>::value>
+struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
+
+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)
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_empty_v = is_empty<_Tp>::value;
+#endif
+
+// is_polymorphic
+
+#if __has_feature(is_polymorphic) || defined(_LIBCPP_COMPILER_MSVC)
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_polymorphic
+ : public integral_constant<bool, __is_polymorphic(_Tp)> {};
+
+#else
+
+template<typename _Tp> char &__is_polymorphic_impl(
+ typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0,
+ int>::type);
+template<typename _Tp> __two &__is_polymorphic_impl(...);
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_polymorphic
+ : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {};
+
+#endif // __has_feature(is_polymorphic)
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value;
+#endif
+
+// has_virtual_destructor
+
+#if __has_feature(has_virtual_destructor) || defined(_LIBCPP_COMPILER_GCC)
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
+ : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
+
+#else
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
+ : public false_type {};
+
+#endif
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool has_virtual_destructor_v = has_virtual_destructor<_Tp>::value;
+#endif
+
+// has_unique_object_representations
+
+#if _LIBCPP_STD_VER > 14
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations
+ : public integral_constant<bool,
+ __has_unique_object_representations(remove_cv_t<remove_all_extents_t<_Tp>>)> {};
+
+template <class _Tp>
+inline constexpr bool has_unique_object_representations_v = has_unique_object_representations<_Tp>::value;
+
+#endif
+
+// alignment_of
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS alignment_of
+ : public integral_constant<size_t, _LIBCPP_ALIGNOF(_Tp)> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value;
+#endif
+
+// aligned_storage
+
+template <class _Hp, class _Tp>
+struct __type_list
+{
+ typedef _Hp _Head;
+ typedef _Tp _Tail;
+};
+
+struct __nat
+{
+#ifndef _LIBCPP_CXX03_LANG
+ __nat() = delete;
+ __nat(const __nat&) = delete;
+ __nat& operator=(const __nat&) = delete;
+ ~__nat() = delete;
+#endif
+};
+
+template <class _Tp>
+struct __align_type
+{
+ static const size_t value = _LIBCPP_PREFERRED_ALIGNOF(_Tp);
+ typedef _Tp type;
+};
+
+struct __struct_double {long double __lx;};
+struct __struct_double4 {double __lx[4];};
+
+typedef
+ __type_list<__align_type<unsigned char>,
+ __type_list<__align_type<unsigned short>,
+ __type_list<__align_type<unsigned int>,
+ __type_list<__align_type<unsigned long>,
+ __type_list<__align_type<unsigned long long>,
+ __type_list<__align_type<double>,
+ __type_list<__align_type<long double>,
+ __type_list<__align_type<__struct_double>,
+ __type_list<__align_type<__struct_double4>,
+ __type_list<__align_type<int*>,
+ __nat
+ > > > > > > > > > > __all_types;
+
+template <size_t _Align>
+struct _ALIGNAS(_Align) __fallback_overaligned {};
+
+template <class _TL, size_t _Align> struct __find_pod;
+
+template <class _Hp, size_t _Align>
+struct __find_pod<__type_list<_Hp, __nat>, _Align>
+{
+ typedef typename conditional<
+ _Align == _Hp::value,
+ typename _Hp::type,
+ __fallback_overaligned<_Align>
+ >::type type;
+};
+
+template <class _Hp, class _Tp, size_t _Align>
+struct __find_pod<__type_list<_Hp, _Tp>, _Align>
+{
+ typedef typename conditional<
+ _Align == _Hp::value,
+ typename _Hp::type,
+ typename __find_pod<_Tp, _Align>::type
+ >::type type;
+};
+
+template <class _TL, size_t _Len> struct __find_max_align;
+
+template <class _Hp, size_t _Len>
+struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
+
+template <size_t _Len, size_t _A1, size_t _A2>
+struct __select_align
+{
+private:
+ static const size_t __min = _A2 < _A1 ? _A2 : _A1;
+ static const size_t __max = _A1 < _A2 ? _A2 : _A1;
+public:
+ static const size_t value = _Len < __max ? __min : __max;
+};
+
+template <class _Hp, class _Tp, size_t _Len>
+struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
+ : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
+
+template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
+struct _LIBCPP_TEMPLATE_VIS aligned_storage
+{
+ typedef typename __find_pod<__all_types, _Align>::type _Aligner;
+ union type
+ {
+ _Aligner __align;
+ unsigned char __data[(_Len + _Align - 1)/_Align * _Align];
+ };
+};
+
+#if _LIBCPP_STD_VER > 11
+template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
+ using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
+#endif
+
+// MSVC compiler doesn't support more that 4 byte alignment on the stack on Win32.
+// If you try to pass parameter which is aligned by alignas to 8 or more bytes
+// on Win32, MSVC throws compile error C2719.
+// To avoid this compile error we delete all alignas specializations and use
+// union alignment instead. Just like for double, this will mean that 8 bytes
+// aligned types will only be aligned to 4 bytes on the stack.
+// Larger alignments will generate assert error which is allowed by the standard
+// since it is implementation-defined behavior. Default _Align argument will never
+// be more than 8 bytes on Win32 and so will not generate assert errors.
+#if !(defined(_LIBCPP_COMPILER_MSVC) && defined(_M_IX86))
+
+#define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
+template <size_t _Len>\
+struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\
+{\
+ struct _ALIGNAS(n) type\
+ {\
+ unsigned char __lx[(_Len + n - 1)/n * n];\
+ };\
+}
+
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
+// PE/COFF does not support alignment beyond 8192 (=0x2000)
+#if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
+#endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF)
+
+#undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
+#endif // !(defined(_LIBCPP_COMPILER_MSVC) && defined(_M_IX86))
+
+
+// aligned_union
+
+template <size_t _I0, size_t ..._In>
+struct __static_max;
+
+template <size_t _I0>
+struct __static_max<_I0>
+{
+ static const size_t value = _I0;
+};
+
+template <size_t _I0, size_t _I1, size_t ..._In>
+struct __static_max<_I0, _I1, _In...>
+{
+ static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
+ __static_max<_I1, _In...>::value;
+};
+
+template <size_t _Len, class _Type0, class ..._Types>
+struct aligned_union
+{
+ static const size_t alignment_value = __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0),
+ _LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value;
+ static const size_t __len = __static_max<_Len, sizeof(_Type0),
+ sizeof(_Types)...>::value;
+ typedef typename aligned_storage<__len, alignment_value>::type type;
+};
+
+#if _LIBCPP_STD_VER > 11
+template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
+#endif
+
+template <class _Tp>
+struct __numeric_type
+{
+ static void __test(...);
+ static float __test(float);
+ static double __test(char);
+ static double __test(int);
+ static double __test(unsigned);
+ static double __test(long);
+ static double __test(unsigned long);
+ static double __test(long long);
+ static double __test(unsigned long long);
+ static double __test(double);
+ static long double __test(long double);
+
+ typedef decltype(__test(declval<_Tp>())) type;
+ static const bool value = _IsNotSame<type, void>::value;
+};
+
+template <>
+struct __numeric_type<void>
+{
+ static const bool value = true;
+};
+
+// __promote
+
+template <class _A1, class _A2 = void, class _A3 = void,
+ bool = __numeric_type<_A1>::value &&
+ __numeric_type<_A2>::value &&
+ __numeric_type<_A3>::value>
+class __promote_imp
+{
+public:
+ static const bool value = false;
+};
+
+template <class _A1, class _A2, class _A3>
+class __promote_imp<_A1, _A2, _A3, true>
+{
+private:
+ typedef typename __promote_imp<_A1>::type __type1;
+ typedef typename __promote_imp<_A2>::type __type2;
+ typedef typename __promote_imp<_A3>::type __type3;
+public:
+ typedef decltype(__type1() + __type2() + __type3()) type;
+ static const bool value = true;
+};
+
+template <class _A1, class _A2>
+class __promote_imp<_A1, _A2, void, true>
+{
+private:
+ typedef typename __promote_imp<_A1>::type __type1;
+ typedef typename __promote_imp<_A2>::type __type2;
+public:
+ typedef decltype(__type1() + __type2()) type;
+ static const bool value = true;
+};
+
+template <class _A1>
+class __promote_imp<_A1, void, void, true>
+{
+public:
+ typedef typename __numeric_type<_A1>::type type;
+ static const bool value = true;
+};
+
+template <class _A1, class _A2 = void, class _A3 = void>
+class __promote : public __promote_imp<_A1, _A2, _A3> {};
+
+// make_signed / make_unsigned
+
+typedef
+ __type_list<signed char,
+ __type_list<signed short,
+ __type_list<signed int,
+ __type_list<signed long,
+ __type_list<signed long long,
+#ifndef _LIBCPP_HAS_NO_INT128
+ __type_list<__int128_t,
+#endif
+ __nat
+#ifndef _LIBCPP_HAS_NO_INT128
+ >
+#endif
+ > > > > > __signed_types;
+
+typedef
+ __type_list<unsigned char,
+ __type_list<unsigned short,
+ __type_list<unsigned int,
+ __type_list<unsigned long,
+ __type_list<unsigned long long,
+#ifndef _LIBCPP_HAS_NO_INT128
+ __type_list<__uint128_t,
+#endif
+ __nat
+#ifndef _LIBCPP_HAS_NO_INT128
+ >
+#endif
+ > > > > > __unsigned_types;
+
+template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
+
+template <class _Hp, class _Tp, size_t _Size>
+struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
+{
+ typedef _LIBCPP_NODEBUG _Hp type;
+};
+
+template <class _Hp, class _Tp, size_t _Size>
+struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
+{
+ typedef _LIBCPP_NODEBUG typename __find_first<_Tp, _Size>::type type;
+};
+
+template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
+ bool = is_volatile<typename remove_reference<_Tp>::type>::value>
+struct __apply_cv
+{
+ typedef _LIBCPP_NODEBUG _Up type;
+};
+
+template <class _Tp, class _Up>
+struct __apply_cv<_Tp, _Up, true, false>
+{
+ typedef _LIBCPP_NODEBUG const _Up type;
+};
+
+template <class _Tp, class _Up>
+struct __apply_cv<_Tp, _Up, false, true>
+{
+ typedef volatile _Up type;
+};
+
+template <class _Tp, class _Up>
+struct __apply_cv<_Tp, _Up, true, true>
+{
+ typedef const volatile _Up type;
+};
+
+template <class _Tp, class _Up>
+struct __apply_cv<_Tp&, _Up, false, false>
+{
+ typedef _Up& type;
+};
+
+template <class _Tp, class _Up>
+struct __apply_cv<_Tp&, _Up, true, false>
+{
+ typedef const _Up& type;
+};
+
+template <class _Tp, class _Up>
+struct __apply_cv<_Tp&, _Up, false, true>
+{
+ typedef volatile _Up& type;
+};
+
+template <class _Tp, class _Up>
+struct __apply_cv<_Tp&, _Up, true, true>
+{
+ typedef const volatile _Up& type;
+};
+
+template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
+struct __make_signed {};
+
+template <class _Tp>
+struct __make_signed<_Tp, true>
+{
+ typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
+};
+
+template <> struct __make_signed<bool, true> {};
+template <> struct __make_signed< signed short, true> {typedef short type;};
+template <> struct __make_signed<unsigned short, true> {typedef short type;};
+template <> struct __make_signed< signed int, true> {typedef int type;};
+template <> struct __make_signed<unsigned int, true> {typedef int type;};
+template <> struct __make_signed< signed long, true> {typedef long type;};
+template <> struct __make_signed<unsigned long, true> {typedef long type;};
+template <> struct __make_signed< signed long long, true> {typedef long long type;};
+template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
+#ifndef _LIBCPP_HAS_NO_INT128
+template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;};
+template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;};
+#endif
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS make_signed
+{
+ typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
+};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
+#endif
+
+template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
+struct __make_unsigned {};
+
+template <class _Tp>
+struct __make_unsigned<_Tp, true>
+{
+ typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
+};
+
+template <> struct __make_unsigned<bool, true> {};
+template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;};
+template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;};
+template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;};
+template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;};
+template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;};
+template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
+template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
+template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
+#ifndef _LIBCPP_HAS_NO_INT128
+template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;};
+template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;};
+#endif
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS make_unsigned
+{
+ typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
+};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+template <class _Tp>
+_LIBCPP_HIDE_FROM_ABI 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
+
+#if _LIBCPP_STD_VER > 17
+// Let COND_RES(X, Y) be:
+template <class _Tp, class _Up>
+using __cond_type = decltype(false ? declval<_Tp>() : declval<_Up>());
+
+template <class _Tp, class _Up, class = void>
+struct __common_type3 {};
+
+// sub-bullet 4 - "if COND_RES(CREF(D1), CREF(D2)) denotes a type..."
+template <class _Tp, class _Up>
+struct __common_type3<_Tp, _Up, void_t<__cond_type<const _Tp&, const _Up&>>>
+{
+ using type = remove_cvref_t<__cond_type<const _Tp&, const _Up&>>;
+};
+
+template <class _Tp, class _Up, class = void>
+struct __common_type2_imp : __common_type3<_Tp, _Up> {};
+#else
+template <class _Tp, class _Up, class = void>
+struct __common_type2_imp {};
+#endif
+
+// sub-bullet 3 - "if decay_t<decltype(false ? declval<D1>() : declval<D2>())> ..."
+template <class _Tp, class _Up>
+struct __common_type2_imp<_Tp, _Up,
+ typename __void_t<decltype(
+ true ? declval<_Tp>() : declval<_Up>()
+ )>::type>
+{
+ typedef _LIBCPP_NODEBUG typename decay<decltype(
+ true ? declval<_Tp>() : declval<_Up>()
+ )>::type type;
+};
+
+template <class, class = void>
+struct __common_type_impl {};
+
+// Clang provides variadic templates in C++03 as an extension.
+#if !defined(_LIBCPP_CXX03_LANG) || defined(__clang__)
+# define _LIBCPP_OPTIONAL_PACK(...) , __VA_ARGS__
+template <class... _Tp>
+struct __common_types;
+template <class... _Tp>
+struct _LIBCPP_TEMPLATE_VIS common_type;
+#else
+# define _LIBCPP_OPTIONAL_PACK(...)
+struct __no_arg;
+template <class _Tp, class _Up, class = __no_arg>
+struct __common_types;
+template <class _Tp = __no_arg, class _Up = __no_arg, class _Vp = __no_arg,
+ class _Unused = __no_arg>
+struct common_type {
+ static_assert(sizeof(_Unused) == 0,
+ "common_type accepts at most 3 arguments in C++03");
+};
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Up>
+struct __common_type_impl<
+ __common_types<_Tp, _Up>,
+ typename __void_t<typename common_type<_Tp, _Up>::type>::type>
+{
+ typedef typename common_type<_Tp, _Up>::type type;
+};
+
+template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)>
+struct __common_type_impl<
+ __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>,
+ typename __void_t<typename common_type<_Tp, _Up>::type>::type>
+ : __common_type_impl<__common_types<typename common_type<_Tp, _Up>::type,
+ _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {
+};
+
+// bullet 1 - sizeof...(Tp) == 0
+
+template <>
+struct _LIBCPP_TEMPLATE_VIS common_type<> {};
+
+// bullet 2 - sizeof...(Tp) == 1
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS common_type<_Tp>
+ : public common_type<_Tp, _Tp> {};
+
+// sub-bullet 1 - "If is_same_v<T1, D1> is false or ..."
+template <class _Tp, class _Up>
+struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up>
+ : conditional<
+ _IsSame<_Tp, typename decay<_Tp>::type>::value && _IsSame<_Up, typename decay<_Up>::type>::value,
+ // Fix for MSVC which thinks that std::common_type<int, void>::type == void.
+ __common_type2_imp<_Tp, _Up, typename conditional<is_void<_Tp>::value ^ is_void<_Up>::value, int, void>::type>,
+ common_type<typename decay<_Tp>::type, typename decay<_Up>::type>
+ >::type
+{};
+
+// bullet 4 - sizeof...(Tp) > 2
+
+template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)>
+struct _LIBCPP_TEMPLATE_VIS
+ common_type<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>
+ : __common_type_impl<
+ __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {};
+
+#undef _LIBCPP_OPTIONAL_PACK
+
+#if _LIBCPP_STD_VER > 11
+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 !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 // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// is_assignable
+
+template<typename, typename _Tp> struct __select_2nd { typedef _LIBCPP_NODEBUG _Tp type; };
+
+#if __has_keyword(__is_assignable)
+
+template<class _Tp, class _Up>
+struct _LIBCPP_TEMPLATE_VIS is_assignable : _BoolConstant<__is_assignable(_Tp, _Up)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp, class _Arg>
+inline constexpr bool is_assignable_v = __is_assignable(_Tp, _Arg);
+#endif
+
+#else // __has_keyword(__is_assignable)
+
+template <class _Tp, class _Arg>
+typename __select_2nd<decltype((declval<_Tp>() = declval<_Arg>())), true_type>::type
+__is_assignable_test(int);
+
+template <class, class>
+false_type __is_assignable_test(...);
+
+
+template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
+struct __is_assignable_imp
+ : public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {};
+
+template <class _Tp, class _Arg>
+struct __is_assignable_imp<_Tp, _Arg, true>
+ : public false_type
+{
+};
+
+#ifdef _LIBCPP_COMPILER_MSVC
+template <class _Tp, class _Arg>
+struct is_assignable
+ : public _VSTD::integral_constant<bool, __is_assignable(_Tp, _Arg)> {};
+#else
+template <class _Tp, class _Arg>
+struct is_assignable
+ : public __is_assignable_imp<_Tp, _Arg> {};
+#endif
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp, class _Arg>
+inline constexpr bool is_assignable_v = is_assignable<_Tp, _Arg>::value;
+#endif
+
+#endif // __has_keyword(__is_assignable)
+
+// is_copy_assignable
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_copy_assignable
+ : public is_assignable<typename add_lvalue_reference<_Tp>::type,
+ typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value;
+#endif
+
+// is_move_assignable
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_move_assignable
+ : public is_assignable<typename add_lvalue_reference<_Tp>::type,
+ typename add_rvalue_reference<_Tp>::type> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value;
+#endif
+
+// is_destructible
+
+#if __has_keyword(__is_destructible)
+
+template<class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_destructible : _BoolConstant<__is_destructible(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_destructible_v = __is_destructible(_Tp);
+#endif
+
+#else // __has_keyword(__is_destructible)
+
+// if it's a reference, return true
+// if it's a function, return false
+// if it's void, return false
+// if it's an array of unknown bound, return false
+// Otherwise, return "declval<_Up&>().~_Up()" is well-formed
+// where _Up is remove_all_extents<_Tp>::type
+
+#if defined(_LIBCPP_COMPILER_MSVC)
+
+template <typename _Tp>
+struct is_destructible : integral_constant<bool, __is_destructible(_Tp)> {};
+
+#else
+
+template <class>
+struct __is_destructible_apply { typedef int type; };
+
+template <typename _Tp>
+struct __is_destructor_wellformed {
+ template <typename _Tp1>
+ static char __test (
+ typename __is_destructible_apply<decltype(declval<_Tp1&>().~_Tp1())>::type
+ );
+
+ template <typename _Tp1>
+ static __two __test (...);
+
+ static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
+};
+
+template <class _Tp, bool>
+struct __destructible_imp;
+
+template <class _Tp>
+struct __destructible_imp<_Tp, false>
+ : public integral_constant<bool,
+ __is_destructor_wellformed<typename remove_all_extents<_Tp>::type>::value> {};
+
+template <class _Tp>
+struct __destructible_imp<_Tp, true>
+ : public true_type {};
+
+template <class _Tp, bool>
+struct __destructible_false;
+
+template <class _Tp>
+struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, is_reference<_Tp>::value> {};
+
+template <class _Tp>
+struct __destructible_false<_Tp, true> : public false_type {};
+
+template <class _Tp>
+struct is_destructible
+ : public __destructible_false<_Tp, is_function<_Tp>::value> {};
+
+template <class _Tp>
+struct is_destructible<_Tp[]>
+ : public false_type {};
+
+template <>
+struct is_destructible<void>
+ : public false_type {};
+
+#endif
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_destructible_v = is_destructible<_Tp>::value;
+#endif
+
+#endif // __has_keyword(__is_destructible)
+
+template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr>
+struct __member_pointer_traits_imp
+{
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
+{
+ typedef _Class _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false>
+{
+ typedef _Class _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param..., ...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
+{
+ typedef _Class const _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false>
+{
+ typedef _Class const _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param..., ...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
+{
+ typedef _Class volatile _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false>
+{
+ typedef _Class volatile _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param..., ...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
+{
+ typedef _Class const volatile _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false>
+{
+ typedef _Class const volatile _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param..., ...);
+};
+
+#if __has_feature(cxx_reference_qualified_functions) || defined(_LIBCPP_COMPILER_GCC)
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
+{
+ typedef _Class& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false>
+{
+ typedef _Class& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param..., ...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
+{
+ typedef _Class const& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false>
+{
+ typedef _Class const& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param..., ...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
+{
+ typedef _Class volatile& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false>
+{
+ typedef _Class volatile& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param..., ...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
+{
+ typedef _Class const volatile& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false>
+{
+ typedef _Class const volatile& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param..., ...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
+{
+ typedef _Class&& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false>
+{
+ typedef _Class&& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param..., ...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
+{
+ typedef _Class const&& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false>
+{
+ typedef _Class const&& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param..., ...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
+{
+ typedef _Class volatile&& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false>
+{
+ typedef _Class volatile&& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param..., ...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
+{
+ typedef _Class const volatile&& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false>
+{
+ typedef _Class const volatile&& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param..., ...);
+};
+
+#endif // __has_feature(cxx_reference_qualified_functions) || defined(_LIBCPP_COMPILER_GCC)
+
+
+template <class _Rp, class _Class>
+struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
+{
+ typedef _Class _ClassType;
+ typedef _Rp _ReturnType;
+};
+
+template <class _MP>
+struct __member_pointer_traits
+ : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
+ is_member_function_pointer<_MP>::value,
+ is_member_object_pointer<_MP>::value>
+{
+// typedef ... _ClassType;
+// typedef ... _ReturnType;
+// typedef ... _FnType;
+};
+
+
+template <class _DecayedFp>
+struct __member_pointer_class_type {};
+
+template <class _Ret, class _ClassType>
+struct __member_pointer_class_type<_Ret _ClassType::*> {
+ typedef _ClassType type;
+};
+
+// template <class T, class... Args> struct is_constructible;
+
+template <class _Tp, class ..._Args>
+struct _LIBCPP_TEMPLATE_VIS is_constructible
+ : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
+{ };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp, class ..._Args>
+inline constexpr bool is_constructible_v = is_constructible<_Tp, _Args...>::value;
+#endif
+
+// is_default_constructible
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_default_constructible
+ : public is_constructible<_Tp>
+ {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_default_constructible_v = is_default_constructible<_Tp>::value;
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+// First of all, we can't implement this check in C++03 mode because the {}
+// default initialization syntax isn't valid.
+// Second, we implement the trait in a funny manner with two defaulted template
+// arguments to workaround Clang's PR43454.
+template <class _Tp>
+void __test_implicit_default_constructible(_Tp);
+
+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_type>
+ : true_type
+{ };
+
+template <class _Tp>
+struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), false_type>
+ : false_type
+{ };
+#endif // !C++03
+
+// is_copy_constructible
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_copy_constructible
+ : public is_constructible<_Tp,
+ typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_copy_constructible_v = is_copy_constructible<_Tp>::value;
+#endif
+
+// is_move_constructible
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_move_constructible
+ : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
+ {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_move_constructible_v = is_move_constructible<_Tp>::value;
+#endif
+
+// is_trivially_constructible
+
+template <class _Tp, class... _Args>
+struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
+ : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
+{
+};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp, class... _Args>
+inline constexpr bool is_trivially_constructible_v = is_trivially_constructible<_Tp, _Args...>::value;
+#endif
+
+// is_trivially_default_constructible
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible
+ : public is_trivially_constructible<_Tp>
+ {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_trivially_default_constructible_v = is_trivially_default_constructible<_Tp>::value;
+#endif
+
+// is_trivially_copy_constructible
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible
+ : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
+ {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_trivially_copy_constructible_v = is_trivially_copy_constructible<_Tp>::value;
+#endif
+
+// is_trivially_move_constructible
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible
+ : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
+ {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_trivially_move_constructible_v = is_trivially_move_constructible<_Tp>::value;
+#endif
+
+// is_trivially_assignable
+
+template <class _Tp, class _Arg>
+struct is_trivially_assignable
+ : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
+{ };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp, class _Arg>
+inline constexpr bool is_trivially_assignable_v = is_trivially_assignable<_Tp, _Arg>::value;
+#endif
+
+// is_trivially_copy_assignable
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable
+ : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
+ typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_trivially_copy_assignable_v = is_trivially_copy_assignable<_Tp>::value;
+#endif
+
+// is_trivially_move_assignable
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable
+ : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
+ typename add_rvalue_reference<_Tp>::type>
+ {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_trivially_move_assignable_v = is_trivially_move_assignable<_Tp>::value;
+#endif
+
+// is_trivially_destructible
+
+#if __has_keyword(__is_trivially_destructible)
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
+ : public integral_constant<bool, __is_trivially_destructible(_Tp)> {};
+
+#elif __has_feature(has_trivial_destructor) || defined(_LIBCPP_COMPILER_GCC)
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
+ : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {};
+
+#else
+
+template <class _Tp> struct __libcpp_trivial_destructor
+ : public integral_constant<bool, is_scalar<_Tp>::value ||
+ is_reference<_Tp>::value> {};
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
+ : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible<_Tp[]>
+ : public false_type {};
+
+#endif
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_trivially_destructible_v = is_trivially_destructible<_Tp>::value;
+#endif
+
+// is_nothrow_constructible
+
+#if __has_keyword(__is_nothrow_constructible)
+
+template <class _Tp, class... _Args>
+struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
+ : public integral_constant<bool, __is_nothrow_constructible(_Tp, _Args...)> {};
+
+#else
+
+template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
+
+template <class _Tp, class... _Args>
+struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>
+ : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
+{
+};
+
+template <class _Tp>
+void __implicit_conversion_to(_Tp) noexcept { }
+
+template <class _Tp, class _Arg>
+struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
+ : public integral_constant<bool, noexcept(_VSTD::__implicit_conversion_to<_Tp>(declval<_Arg>()))>
+{
+};
+
+template <class _Tp, bool _IsReference, class... _Args>
+struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...>
+ : public false_type
+{
+};
+
+template <class _Tp, class... _Args>
+struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
+ : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...>
+{
+};
+
+template <class _Tp, size_t _Ns>
+struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]>
+ : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp>
+{
+};
+
+#endif // _LIBCPP_HAS_NO_NOEXCEPT
+
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp, class ..._Args>
+inline constexpr bool is_nothrow_constructible_v = is_nothrow_constructible<_Tp, _Args...>::value;
+#endif
+
+// is_nothrow_default_constructible
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible
+ : public is_nothrow_constructible<_Tp>
+ {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_nothrow_default_constructible_v = is_nothrow_default_constructible<_Tp>::value;
+#endif
+
+// is_nothrow_copy_constructible
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible
+ : public is_nothrow_constructible<_Tp,
+ typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_nothrow_copy_constructible_v = is_nothrow_copy_constructible<_Tp>::value;
+#endif
+
+// is_nothrow_move_constructible
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible
+ : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
+ {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_nothrow_move_constructible_v = is_nothrow_move_constructible<_Tp>::value;
+#endif
+
+// is_nothrow_assignable
+
+#if __has_keyword(__is_nothrow_assignable)
+
+template <class _Tp, class _Arg>
+struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
+ : public integral_constant<bool, __is_nothrow_assignable(_Tp, _Arg)> {};
+
+#else
+
+template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
+
+template <class _Tp, class _Arg>
+struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
+ : public false_type
+{
+};
+
+template <class _Tp, class _Arg>
+struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
+ : public integral_constant<bool, noexcept(declval<_Tp>() = declval<_Arg>()) >
+{
+};
+
+template <class _Tp, class _Arg>
+struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
+ : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
+{
+};
+
+#endif // _LIBCPP_HAS_NO_NOEXCEPT
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp, class _Arg>
+inline constexpr bool is_nothrow_assignable_v = is_nothrow_assignable<_Tp, _Arg>::value;
+#endif
+
+// is_nothrow_copy_assignable
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable
+ : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
+ typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_nothrow_copy_assignable_v = is_nothrow_copy_assignable<_Tp>::value;
+#endif
+
+// is_nothrow_move_assignable
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable
+ : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
+ typename add_rvalue_reference<_Tp>::type>
+ {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_nothrow_move_assignable_v = is_nothrow_move_assignable<_Tp>::value;
+#endif
+
+// is_nothrow_destructible
+
+#if !defined(_LIBCPP_CXX03_LANG)
+
+template <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
+
+template <class _Tp>
+struct __libcpp_is_nothrow_destructible<false, _Tp>
+ : public false_type
+{
+};
+
+template <class _Tp>
+struct __libcpp_is_nothrow_destructible<true, _Tp>
+ : public integral_constant<bool, noexcept(declval<_Tp>().~_Tp()) >
+{
+};
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
+ : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
+{
+};
+
+template <class _Tp, size_t _Ns>
+struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[_Ns]>
+ : public is_nothrow_destructible<_Tp>
+{
+};
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&>
+ : public true_type
+{
+};
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&>
+ : public true_type
+{
+};
+
+#else
+
+template <class _Tp> struct __libcpp_nothrow_destructor
+ : public integral_constant<bool, is_scalar<_Tp>::value ||
+ is_reference<_Tp>::value> {};
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
+ : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]>
+ : public false_type {};
+
+#endif
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_nothrow_destructible_v = is_nothrow_destructible<_Tp>::value;
+#endif
+
+// is_pod
+
+#if __has_feature(is_pod) || defined(_LIBCPP_COMPILER_GCC)
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
+ : public integral_constant<bool, __is_pod(_Tp)> {};
+
+#else
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
+ : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value &&
+ is_trivially_copy_constructible<_Tp>::value &&
+ is_trivially_copy_assignable<_Tp>::value &&
+ is_trivially_destructible<_Tp>::value> {};
+
+#endif
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_pod_v = is_pod<_Tp>::value;
+#endif
+
+// 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
+template <class _Tp>
+_LIBCPP_DEPRECATED_IN_CXX17 inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value;
+#endif // _LIBCPP_STD_VER > 14
+#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
+
+// is_standard_layout;
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout
+#if __has_feature(is_standard_layout) || defined(_LIBCPP_COMPILER_GCC)
+ : public integral_constant<bool, __is_standard_layout(_Tp)>
+#else
+ : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
+#endif
+ {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value;
+#endif
+
+// is_trivially_copyable;
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable
+ : public integral_constant<bool, __is_trivially_copyable(_Tp)>
+ {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_trivially_copyable_v = is_trivially_copyable<_Tp>::value;
+#endif
+
+// is_trivial;
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivial
+#if __has_feature(is_trivial) || defined(_LIBCPP_COMPILER_GCC)
+ : public integral_constant<bool, __is_trivial(_Tp)>
+#else
+ : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
+ is_trivially_default_constructible<_Tp>::value>
+#endif
+ {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_trivial_v = is_trivial<_Tp>::value;
+#endif
+
+template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
+template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
+template <class _Tp> struct __is_reference_wrapper
+ : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {};
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Fp, class _A0,
+ class _DecayFp = typename decay<_Fp>::type,
+ class _DecayA0 = typename decay<_A0>::type,
+ class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
+using __enable_if_bullet1 = typename enable_if
+ <
+ is_member_function_pointer<_DecayFp>::value
+ && is_base_of<_ClassT, _DecayA0>::value
+ >::type;
+
+template <class _Fp, class _A0,
+ class _DecayFp = typename decay<_Fp>::type,
+ class _DecayA0 = typename decay<_A0>::type>
+using __enable_if_bullet2 = typename enable_if
+ <
+ is_member_function_pointer<_DecayFp>::value
+ && __is_reference_wrapper<_DecayA0>::value
+ >::type;
+
+template <class _Fp, class _A0,
+ class _DecayFp = typename decay<_Fp>::type,
+ class _DecayA0 = typename decay<_A0>::type,
+ class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
+using __enable_if_bullet3 = typename enable_if
+ <
+ is_member_function_pointer<_DecayFp>::value
+ && !is_base_of<_ClassT, _DecayA0>::value
+ && !__is_reference_wrapper<_DecayA0>::value
+ >::type;
+
+template <class _Fp, class _A0,
+ class _DecayFp = typename decay<_Fp>::type,
+ class _DecayA0 = typename decay<_A0>::type,
+ class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
+using __enable_if_bullet4 = typename enable_if
+ <
+ is_member_object_pointer<_DecayFp>::value
+ && is_base_of<_ClassT, _DecayA0>::value
+ >::type;
+
+template <class _Fp, class _A0,
+ class _DecayFp = typename decay<_Fp>::type,
+ class _DecayA0 = typename decay<_A0>::type>
+using __enable_if_bullet5 = typename enable_if
+ <
+ is_member_object_pointer<_DecayFp>::value
+ && __is_reference_wrapper<_DecayA0>::value
+ >::type;
+
+template <class _Fp, class _A0,
+ class _DecayFp = typename decay<_Fp>::type,
+ class _DecayA0 = typename decay<_A0>::type,
+ class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
+using __enable_if_bullet6 = typename enable_if
+ <
+ is_member_object_pointer<_DecayFp>::value
+ && !is_base_of<_ClassT, _DecayA0>::value
+ && !__is_reference_wrapper<_DecayA0>::value
+ >::type;
+
+// __invoke forward declarations
+
+// fall back - none of the bullets
+
+template <class ..._Args>
+auto __invoke(__any, _Args&& ...__args) -> __nat;
+
+template <class ..._Args>
+auto __invoke_constexpr(__any, _Args&& ...__args) -> __nat;
+
+// bullets 1, 2 and 3
+
+template <class _Fp, class _A0, class ..._Args,
+ class = __enable_if_bullet1<_Fp, _A0>>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
+__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
+ noexcept(noexcept((static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...)))
+ -> decltype( (static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...))
+ { 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)
+ noexcept(noexcept((static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...)))
+ -> decltype( (static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...))
+ { 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)
+ noexcept(noexcept((__a0.get().*__f)(static_cast<_Args&&>(__args)...)))
+ -> decltype( (__a0.get().*__f)(static_cast<_Args&&>(__args)...))
+ { 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)
+ noexcept(noexcept((__a0.get().*__f)(static_cast<_Args&&>(__args)...)))
+ -> decltype( (__a0.get().*__f)(static_cast<_Args&&>(__args)...))
+ { 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)
+ noexcept(noexcept(((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...)))
+ -> decltype( ((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...))
+ { 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)
+ noexcept(noexcept(((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...)))
+ -> decltype( ((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...))
+ { return ((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...); }
+
+// bullets 4, 5 and 6
+
+template <class _Fp, class _A0,
+ class = __enable_if_bullet4<_Fp, _A0>>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
+__invoke(_Fp&& __f, _A0&& __a0)
+ noexcept(noexcept(static_cast<_A0&&>(__a0).*__f))
+ -> decltype( static_cast<_A0&&>(__a0).*__f)
+ { 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)
+ noexcept(noexcept(static_cast<_A0&&>(__a0).*__f))
+ -> decltype( static_cast<_A0&&>(__a0).*__f)
+ { return static_cast<_A0&&>(__a0).*__f; }
+
+template <class _Fp, class _A0,
+ class = __enable_if_bullet5<_Fp, _A0>>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
+__invoke(_Fp&& __f, _A0&& __a0)
+ noexcept(noexcept(__a0.get().*__f))
+ -> decltype( __a0.get().*__f)
+ { return __a0.get().*__f; }
+
+template <class _Fp, class _A0,
+ class = __enable_if_bullet5<_Fp, _A0>>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR auto
+__invoke_constexpr(_Fp&& __f, _A0&& __a0)
+ noexcept(noexcept(__a0.get().*__f))
+ -> decltype( __a0.get().*__f)
+ { return __a0.get().*__f; }
+
+template <class _Fp, class _A0,
+ class = __enable_if_bullet6<_Fp, _A0>>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
+__invoke(_Fp&& __f, _A0&& __a0)
+ noexcept(noexcept((*static_cast<_A0&&>(__a0)).*__f))
+ -> decltype( (*static_cast<_A0&&>(__a0)).*__f)
+ { 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)
+ noexcept(noexcept((*static_cast<_A0&&>(__a0)).*__f))
+ -> decltype( (*static_cast<_A0&&>(__a0)).*__f)
+ { return (*static_cast<_A0&&>(__a0)).*__f; }
+
+// bullet 7
+
+template <class _Fp, class ..._Args>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
+__invoke(_Fp&& __f, _Args&& ...__args)
+ noexcept(noexcept(static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...)))
+ -> decltype( static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...))
+ { 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)
+ noexcept(noexcept(static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...)))
+ -> decltype( static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...))
+ { return static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...); }
+
+// __invokable
+template <class _Ret, class _Fp, class ..._Args>
+struct __invokable_r
+{
+ template <class _XFp, class ..._XArgs>
+ static auto __try_call(int) -> decltype(
+ _VSTD::__invoke(declval<_XFp>(), declval<_XArgs>()...));
+ template <class _XFp, class ..._XArgs>
+ static __nat __try_call(...);
+
+ // FIXME: Check that _Ret, _Fp, and _Args... are all complete types, cv void,
+ // or incomplete array types as required by the standard.
+ using _Result = decltype(__try_call<_Fp, _Args...>(0));
+
+ using type =
+ typename conditional<
+ _IsNotSame<_Result, __nat>::value,
+ typename conditional<
+ is_void<_Ret>::value,
+ true_type,
+ is_convertible<_Result, _Ret>
+ >::type,
+ false_type
+ >::type;
+ static const bool value = type::value;
+};
+template <class _Fp, class ..._Args>
+using __invokable = __invokable_r<void, _Fp, _Args...>;
+
+template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class ..._Args>
+struct __nothrow_invokable_r_imp {
+ static const bool value = false;
+};
+
+template <class _Ret, class _Fp, class ..._Args>
+struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
+{
+ typedef __nothrow_invokable_r_imp _ThisT;
+
+ template <class _Tp>
+ static void __test_noexcept(_Tp) noexcept;
+
+ static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(
+ _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(declval<_Fp>(), declval<_Args>()...));
+};
+
+template <class _Ret, class _Fp, class ..._Args>
+using __nothrow_invokable_r =
+ __nothrow_invokable_r_imp<
+ __invokable_r<_Ret, _Fp, _Args...>::value,
+ is_void<_Ret>::value,
+ _Ret, _Fp, _Args...
+ >;
+
+template <class _Fp, class ..._Args>
+using __nothrow_invokable =
+ __nothrow_invokable_r_imp<
+ __invokable<_Fp, _Args...>::value,
+ true, void, _Fp, _Args...
+ >;
+
+template <class _Fp, class ..._Args>
+struct __invoke_of
+ : public enable_if<
+ __invokable<_Fp, _Args...>::value,
+ typename __invokable_r<void, _Fp, _Args...>::_Result>
+{
+};
+
+#endif // _LIBCPP_CXX03_LANG
+
+// 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
+
+template <class _Fp, class ..._Args>
+class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)>
+ : public __invoke_of<_Fp, _Args...>
+{
+};
+
+#else // C++03
+
+template <class _Fn, bool, bool>
+class __result_of
+{
+};
+
+template <class _Fn, class ..._Args>
+class __result_of<_Fn(_Args...), true, false>
+{
+public:
+ typedef decltype(declval<_Fn>()(declval<_Args>()...)) type;
+};
+
+template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
+struct __result_of_mp;
+
+// member function pointer
+
+template <class _MP, class _Tp>
+struct __result_of_mp<_MP, _Tp, true>
+{
+ using type = typename __member_pointer_traits<_MP>::_ReturnType;
+};
+
+// member data pointer
+
+template <class _MP, class _Tp, bool>
+struct __result_of_mdp;
+
+template <class _Rp, class _Class, class _Tp>
+struct __result_of_mdp<_Rp _Class::*, _Tp, false>
+{
+ 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>
+{
+ using type = typename __apply_cv<_Tp, _Rp>::type&;
+};
+
+template <class _Rp, class _Class, class _Tp>
+struct __result_of_mp<_Rp _Class::*, _Tp, false>
+ : public __result_of_mdp<_Rp _Class::*, _Tp,
+ is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
+{
+};
+
+template <class _Fn, class _Tp>
+class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer
+ : public __result_of_mp<typename remove_reference<_Fn>::type,
+ _Tp,
+ is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
+{
+};
+
+template <class _Fn, class _Tp, class ..._Args>
+class __result_of<_Fn(_Tp, _Args...), false, true> // _Fn must be member pointer
+ : public __result_of_mp<typename remove_reference<_Fn>::type,
+ _Tp,
+ is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
+{
+};
+
+template <class _Fn, class ..._Args>
+class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_Args...)>
+ : public __result_of<_Fn(_Args...),
+ is_class<typename remove_reference<_Fn>::type>::value ||
+ is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
+ is_member_pointer<typename remove_reference<_Fn>::type>::value
+ >
+{
+};
+
+#endif // C++03
+
+#if _LIBCPP_STD_VER > 11
+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
+
+// invoke_result
+
+template <class _Fn, class... _Args>
+struct _LIBCPP_TEMPLATE_VIS invoke_result
+ : __invoke_of<_Fn, _Args...>
+{
+};
+
+template <class _Fn, class... _Args>
+using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
+
+// is_invocable
+
+template <class _Fn, class ..._Args>
+struct _LIBCPP_TEMPLATE_VIS is_invocable
+ : integral_constant<bool, __invokable<_Fn, _Args...>::value> {};
+
+template <class _Ret, class _Fn, class ..._Args>
+struct _LIBCPP_TEMPLATE_VIS is_invocable_r
+ : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {};
+
+template <class _Fn, class ..._Args>
+inline constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value;
+
+template <class _Ret, class _Fn, class ..._Args>
+inline constexpr bool is_invocable_r_v = is_invocable_r<_Ret, _Fn, _Args...>::value;
+
+// is_nothrow_invocable
+
+template <class _Fn, class ..._Args>
+struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable
+ : integral_constant<bool, __nothrow_invokable<_Fn, _Args...>::value> {};
+
+template <class _Ret, class _Fn, class ..._Args>
+struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable_r
+ : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {};
+
+template <class _Fn, class ..._Args>
+inline constexpr bool is_nothrow_invocable_v = is_nothrow_invocable<_Fn, _Args...>::value;
+
+template <class _Ret, class _Fn, class ..._Args>
+inline constexpr bool is_nothrow_invocable_r_v = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value;
+
+#endif // _LIBCPP_STD_VER > 14
+
+// __swappable
+
+template <class _Tp> struct __is_swappable;
+template <class _Tp> struct __is_nothrow_swappable;
+
+
+#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
+_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);
+
+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);
+
+namespace __detail
+{
+// ALL generic swap overloads MUST already have a declaration available at this point.
+
+template <class _Tp, class _Up = _Tp,
+ bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value>
+struct __swappable_with
+{
+ template <class _LHS, class _RHS>
+ static decltype(swap(declval<_LHS>(), declval<_RHS>()))
+ __test_swap(int);
+ template <class, class>
+ static __nat __test_swap(long);
+
+ // Extra parens are needed for the C++03 definition of decltype.
+ typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1;
+ typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2;
+
+ static const bool value = _IsNotSame<__swap1, __nat>::value
+ && _IsNotSame<__swap2, __nat>::value;
+};
+
+template <class _Tp, class _Up>
+struct __swappable_with<_Tp, _Up, false> : false_type {};
+
+template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value>
+struct __nothrow_swappable_with {
+ static const bool value =
+#ifndef _LIBCPP_HAS_NO_NOEXCEPT
+ noexcept(swap(declval<_Tp>(), declval<_Up>()))
+ && noexcept(swap(declval<_Up>(), declval<_Tp>()));
+#else
+ false;
+#endif
+};
+
+template <class _Tp, class _Up>
+struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {};
+
+} // namespace __detail
+
+template <class _Tp>
+struct __is_swappable
+ : public integral_constant<bool, __detail::__swappable_with<_Tp&>::value>
+{
+};
+
+template <class _Tp>
+struct __is_nothrow_swappable
+ : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value>
+{
+};
+
+#if _LIBCPP_STD_VER > 14
+
+template <class _Tp, class _Up>
+struct _LIBCPP_TEMPLATE_VIS is_swappable_with
+ : public integral_constant<bool, __detail::__swappable_with<_Tp, _Up>::value>
+{
+};
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_swappable
+ : public conditional<
+ __is_referenceable<_Tp>::value,
+ is_swappable_with<
+ typename add_lvalue_reference<_Tp>::type,
+ typename add_lvalue_reference<_Tp>::type>,
+ false_type
+ >::type
+{
+};
+
+template <class _Tp, class _Up>
+struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable_with
+ : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp, _Up>::value>
+{
+};
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable
+ : public conditional<
+ __is_referenceable<_Tp>::value,
+ is_nothrow_swappable_with<
+ typename add_lvalue_reference<_Tp>::type,
+ typename add_lvalue_reference<_Tp>::type>,
+ false_type
+ >::type
+{
+};
+
+template <class _Tp, class _Up>
+inline constexpr bool is_swappable_with_v = is_swappable_with<_Tp, _Up>::value;
+
+template <class _Tp>
+inline constexpr bool is_swappable_v = is_swappable<_Tp>::value;
+
+template <class _Tp, class _Up>
+inline constexpr bool is_nothrow_swappable_with_v = is_nothrow_swappable_with<_Tp, _Up>::value;
+
+template <class _Tp>
+inline constexpr bool is_nothrow_swappable_v = is_nothrow_swappable<_Tp>::value;
+
+#endif // _LIBCPP_STD_VER > 14
+
+template <class _Tp, bool = is_enum<_Tp>::value> struct __underlying_type_impl;
+
+template <class _Tp>
+struct __underlying_type_impl<_Tp, false> {};
+
+template <class _Tp>
+struct __underlying_type_impl<_Tp, true>
+{
+ typedef __underlying_type(_Tp) type;
+};
+
+template <class _Tp>
+struct underlying_type : __underlying_type_impl<_Tp, is_enum<_Tp>::value> {};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
+#endif
+
+template <class _Tp, bool = is_enum<_Tp>::value>
+struct __sfinae_underlying_type
+{
+ typedef typename underlying_type<_Tp>::type type;
+ typedef decltype(((type)1) + 0) __promoted_type;
+};
+
+template <class _Tp>
+struct __sfinae_underlying_type<_Tp, false> {};
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+int __convert_to_integral(int __val) { return __val; }
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+unsigned __convert_to_integral(unsigned __val) { return __val; }
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+long __convert_to_integral(long __val) { return __val; }
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+unsigned long __convert_to_integral(unsigned long __val) { return __val; }
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+long long __convert_to_integral(long long __val) { return __val; }
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+unsigned long long __convert_to_integral(unsigned long long __val) {return __val; }
+
+template<typename _Fp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename enable_if<is_floating_point<_Fp>::value, long long>::type
+ __convert_to_integral(_Fp __val) { return __val; }
+
+#ifndef _LIBCPP_HAS_NO_INT128
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+__int128_t __convert_to_integral(__int128_t __val) { return __val; }
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+__uint128_t __convert_to_integral(__uint128_t __val) { return __val; }
+#endif
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename __sfinae_underlying_type<_Tp>::__promoted_type
+__convert_to_integral(_Tp __val) { return __val; }
+
+// is_scoped_enum [meta.unary.prop]
+
+#if _LIBCPP_STD_VER > 20
+template <class _Tp, bool = is_enum_v<_Tp> >
+struct __is_scoped_enum_helper : false_type {};
+
+template <class _Tp>
+struct __is_scoped_enum_helper<_Tp, true>
+ : public bool_constant<!is_convertible_v<_Tp, underlying_type_t<_Tp> > > {};
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_scoped_enum
+ : public __is_scoped_enum_helper<_Tp> {};
+
+template <class _Tp>
+inline constexpr bool is_scoped_enum_v = is_scoped_enum<_Tp>::value;
+#endif
+
+#if _LIBCPP_STD_VER > 14
+
+template <class... _Args>
+struct conjunction : _And<_Args...> {};
+template<class... _Args>
+inline constexpr bool conjunction_v = conjunction<_Args...>::value;
+
+template <class... _Args>
+struct disjunction : _Or<_Args...> {};
+template<class... _Args>
+inline constexpr bool disjunction_v = disjunction<_Args...>::value;
+
+template <class _Tp>
+struct negation : _Not<_Tp> {};
+template<class _Tp>
+inline constexpr bool negation_v = negation<_Tp>::value;
+#endif // _LIBCPP_STD_VER > 14
+
+// These traits are used in __tree and __hash_table
+struct __extract_key_fail_tag {};
+struct __extract_key_self_tag {};
+struct __extract_key_first_tag {};
+
+template <class _ValTy, class _Key,
+ class _RawValTy = typename __unconstref<_ValTy>::type>
+struct __can_extract_key
+ : conditional<_IsSame<_RawValTy, _Key>::value, __extract_key_self_tag,
+ __extract_key_fail_tag>::type {};
+
+template <class _Pair, class _Key, class _First, class _Second>
+struct __can_extract_key<_Pair, _Key, pair<_First, _Second> >
+ : conditional<_IsSame<typename remove_const<_First>::type, _Key>::value,
+ __extract_key_first_tag, __extract_key_fail_tag>::type {};
+
+// __can_extract_map_key uses true_type/false_type instead of the tags.
+// It returns true if _Key != _ContainerValueTy (the container is a map not a set)
+// and _ValTy == _Key.
+template <class _ValTy, class _Key, class _ContainerValueTy,
+ class _RawValTy = typename __unconstref<_ValTy>::type>
+struct __can_extract_map_key
+ : integral_constant<bool, _IsSame<_RawValTy, _Key>::value> {};
+
+// This specialization returns __extract_key_fail_tag for non-map containers
+// because _Key == _ContainerValueTy
+template <class _ValTy, class _Key, class _RawValTy>
+struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy>
+ : false_type {};
+
+#ifndef _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED
+#if _LIBCPP_STD_VER > 17
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr bool is_constant_evaluated() noexcept {
+ return __builtin_is_constant_evaluated();
+}
+#endif
+
+inline _LIBCPP_CONSTEXPR
+bool __libcpp_is_constant_evaluated() _NOEXCEPT { return __builtin_is_constant_evaluated(); }
+#else
+inline _LIBCPP_CONSTEXPR
+bool __libcpp_is_constant_evaluated() _NOEXCEPT { return false; }
+#endif
+
+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
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning(pop)
+#endif
+
+#endif // _LIBCPP_TYPE_TRAITS
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/typeindex b/contrib/libs/cxxsupp/libcxxmsvc/include/typeindex
new file mode 100644
index 0000000000..b5dcd8496a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/typeindex
@@ -0,0 +1,115 @@
+// -*- 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_TYPEINDEX
+#define _LIBCPP_TYPEINDEX
+
+/*
+
+ typeindex synopsis
+
+namespace std
+{
+
+class type_index
+{
+public:
+ type_index(const type_info& rhs) noexcept;
+
+ bool operator==(const type_index& rhs) const noexcept;
+ bool operator!=(const type_index& rhs) const noexcept;
+ bool operator< (const type_index& rhs) const noexcept;
+ bool operator<=(const type_index& rhs) const noexcept;
+ bool operator> (const type_index& rhs) const noexcept;
+ bool operator>=(const type_index& rhs) const noexcept;
+
+ size_t hash_code() const noexcept;
+ const char* name() const noexcept;
+};
+
+template <>
+struct hash<type_index>
+ : public unary_function<type_index, size_t>
+{
+ size_t operator()(type_index index) const noexcept;
+};
+
+} // std
+
+*/
+
+#include <__config>
+#include <__functional/unary_function.h>
+#include <compare>
+#include <typeinfo>
+#include <version>
+
+// TODO: remove these headers
+#include <__functional/binary_function.h>
+#include <__functional/invoke.h>
+#include <__functional/operations.h>
+#include <__functional/reference_wrapper.h>
+#include <__functional/weak_result_type.h>
+#include <__memory/allocator_arg_t.h>
+#include <__memory/uses_allocator.h>
+#include <new>
+#include <utility>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+class _LIBCPP_TEMPLATE_VIS type_index
+{
+ const type_info* __t_;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ type_index(const type_info& __y) _NOEXCEPT : __t_(&__y) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const type_index& __y) const _NOEXCEPT
+ {return *__t_ == *__y.__t_;}
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const type_index& __y) const _NOEXCEPT
+ {return *__t_ != *__y.__t_;}
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator< (const type_index& __y) const _NOEXCEPT
+ {return __t_->before(*__y.__t_);}
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator<=(const type_index& __y) const _NOEXCEPT
+ {return !__y.__t_->before(*__t_);}
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator> (const type_index& __y) const _NOEXCEPT
+ {return __y.__t_->before(*__t_);}
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator>=(const type_index& __y) const _NOEXCEPT
+ {return !__t_->before(*__y.__t_);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_t hash_code() const _NOEXCEPT {return __t_->hash_code();}
+ _LIBCPP_INLINE_VISIBILITY
+ const char* name() const _NOEXCEPT {return __t_->name();}
+};
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
+
+template <>
+struct _LIBCPP_TEMPLATE_VIS hash<type_index>
+ : public unary_function<type_index, size_t>
+{
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(type_index __index) const _NOEXCEPT
+ {return __index.hash_code();}
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_TYPEINDEX
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/typeinfo b/contrib/libs/cxxsupp/libcxxmsvc/include/typeinfo
new file mode 100644
index 0000000000..7efe626da6
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/typeinfo
@@ -0,0 +1,407 @@
+// -*- 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_TYPEINFO
+#define __LIBCPP_TYPEINFO
+
+/*
+
+ typeinfo synopsis
+
+namespace std {
+
+class type_info
+{
+public:
+ virtual ~type_info();
+
+ bool operator==(const type_info& rhs) const noexcept;
+ bool operator!=(const type_info& rhs) const noexcept;
+
+ bool before(const type_info& rhs) const noexcept;
+ size_t hash_code() const noexcept;
+ const char* name() const noexcept;
+
+ type_info(const type_info& rhs) = delete;
+ type_info& operator=(const type_info& rhs) = delete;
+};
+
+class bad_cast
+ : public exception
+{
+public:
+ bad_cast() noexcept;
+ bad_cast(const bad_cast&) noexcept;
+ bad_cast& operator=(const bad_cast&) noexcept;
+ virtual const char* what() const noexcept;
+};
+
+class bad_typeid
+ : public exception
+{
+public:
+ bad_typeid() noexcept;
+ bad_typeid(const bad_typeid&) noexcept;
+ bad_typeid& operator=(const bad_typeid&) noexcept;
+ virtual const char* what() const noexcept;
+};
+
+} // std
+
+*/
+
+#include <__availability>
+#include <__config>
+#include <cstddef>
+#include <cstdint>
+#include <exception>
+#include <type_traits>
+
+#ifdef _LIBCPP_NO_EXCEPTIONS
+#include <cstdlib>
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if defined(_LIBCPP_ABI_VCRUNTIME)
+#include <vcruntime_typeinfo.h>
+#else
+
+namespace std // purposefully not using versioning namespace
+{
+
+
+#if defined(_LIBCPP_ABI_MICROSOFT)
+
+class _LIBCPP_EXCEPTION_ABI type_info
+{
+ type_info& operator=(const type_info&);
+ type_info(const type_info&);
+
+ mutable struct {
+ const char *__undecorated_name;
+ const char __decorated_name[1];
+ } __data;
+
+ int __compare(const type_info &__rhs) const _NOEXCEPT;
+
+public:
+ _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE
+ virtual ~type_info();
+
+ const char *name() const _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool before(const type_info& __arg) const _NOEXCEPT {
+ return __compare(__arg) < 0;
+ }
+
+ size_t hash_code() const _NOEXCEPT;
+
+#ifdef __EMSCRIPTEN__
+ // XXX Emscripten: adding `always_inline` fixes
+ // https://github.com/emscripten-core/emscripten/issues/13330
+ __attribute__((always_inline))
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const type_info& __arg) const _NOEXCEPT {
+ return __compare(__arg) == 0;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const type_info& __arg) const _NOEXCEPT
+ { return !operator==(__arg); }
+};
+
+#else // !defined(_LIBCPP_ABI_MICROSOFT)
+
+// ========================================================================== //
+// Implementations
+// ========================================================================== //
+// ------------------------------------------------------------------------- //
+// Unique
+// (_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 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
+// a deep string comparison.
+// -------------------------------------------------------------------------- //
+// NonUnique
+// (_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION = 2)
+// -------------------------------------------------------------------------- //
+// This implementation of type_info does not assume there is always a unique
+// copy of the RTTI for a given type inside a program. For various reasons
+// the linker may have failed to merge every copy of a types RTTI
+// (For example: -Bsymbolic or llvm.org/PR37398). Under this assumption, two
+// type_infos are equal if their addresses are equal or if a deep string
+// comparison is equal.
+// -------------------------------------------------------------------------- //
+// 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. 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.
+//
+// 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.
+//
+// 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.
+#ifndef _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION
+
+ // Windows binaries can't merge typeinfos, so use the NonUnique implementation.
+# ifdef _LIBCPP_OBJECT_FORMAT_COFF
+# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 2
+
+ // On arm64 on Apple platforms, use the special NonUniqueARMRTTIBit implementation.
+# elif defined(__APPLE__) && defined(__LP64__) && !defined(__x86_64__)
+# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 3
+
+ // On all other platforms, assume the Itanium C++ ABI and use the Unique implementation.
+# else
+# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 1
+# endif
+#endif
+
+struct __type_info_implementations {
+ struct __string_impl_base {
+ typedef const char* __type_name_t;
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
+ _LIBCPP_CONSTEXPR static const char* __type_name_to_string(__type_name_t __v) _NOEXCEPT {
+ return __v;
+ }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
+ _LIBCPP_CONSTEXPR static __type_name_t __string_to_type_name(const char* __v) _NOEXCEPT {
+ return __v;
+ }
+ };
+
+ struct __unique_impl : __string_impl_base {
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
+ static size_t __hash(__type_name_t __v) _NOEXCEPT {
+ return reinterpret_cast<size_t>(__v);
+ }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
+ static bool __eq(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
+ return __lhs == __rhs;
+ }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
+ static bool __lt(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
+ return __lhs < __rhs;
+ }
+ };
+
+ struct __non_unique_impl : __string_impl_base {
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
+ static size_t __hash(__type_name_t __ptr) _NOEXCEPT {
+ size_t __hash = 5381;
+ while (unsigned char __c = static_cast<unsigned char>(*__ptr++))
+ __hash = (__hash * 33) ^ __c;
+ return __hash;
+ }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
+ static bool __eq(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
+ return __lhs == __rhs || __builtin_strcmp(__lhs, __rhs) == 0;
+ }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
+ static bool __lt(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
+ return __builtin_strcmp(__lhs, __rhs) < 0;
+ }
+ };
+
+ struct __non_unique_arm_rtti_bit_impl {
+ typedef uintptr_t __type_name_t;
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
+ static const char* __type_name_to_string(__type_name_t __v) _NOEXCEPT {
+ return reinterpret_cast<const char*>(__v &
+ ~__non_unique_rtti_bit::value);
+ }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
+ static __type_name_t __string_to_type_name(const char* __v) _NOEXCEPT {
+ return reinterpret_cast<__type_name_t>(__v);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
+ static size_t __hash(__type_name_t __v) _NOEXCEPT {
+ if (__is_type_name_unique(__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) || __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) || __is_type_name_unique(__rhs))
+ return __lhs < __rhs;
+ return __builtin_strcmp(__type_name_to_string(__lhs), __type_name_to_string(__rhs)) < 0;
+ }
+
+ private:
+ // The unique bit is the top bit. It is expected that __type_name_t is 64 bits when
+ // this implementation is actually used.
+ typedef integral_constant<__type_name_t,
+ (1ULL << ((__CHAR_BIT__ * sizeof(__type_name_t)) - 1))> __non_unique_rtti_bit;
+
+ _LIBCPP_INLINE_VISIBILITY
+ static bool __is_type_name_unique(__type_name_t __lhs) _NOEXCEPT {
+ return !(__lhs & __non_unique_rtti_bit::value);
+ }
+ };
+
+ typedef
+#if _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 1
+ __unique_impl
+#elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 2
+ __non_unique_impl
+#elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 3
+ __non_unique_arm_rtti_bit_impl
+#else
+# error invalid configuration for _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION
+#endif
+ __impl;
+};
+
+class _LIBCPP_EXCEPTION_ABI type_info
+{
+ type_info& operator=(const type_info&);
+ type_info(const type_info&);
+
+ protected:
+ typedef __type_info_implementations::__impl __impl;
+
+ __impl::__type_name_t __type_name;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit type_info(const char* __n)
+ : __type_name(__impl::__string_to_type_name(__n)) {}
+
+public:
+ _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE
+ virtual ~type_info();
+
+ _LIBCPP_INLINE_VISIBILITY
+ const char* name() const _NOEXCEPT
+ {
+ return __impl::__type_name_to_string(__type_name);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool before(const type_info& __arg) const _NOEXCEPT
+ {
+ return __impl::__lt(__type_name, __arg.__type_name);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_t hash_code() const _NOEXCEPT
+ {
+ return __impl::__hash(__type_name);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const type_info& __arg) const _NOEXCEPT
+ {
+ return __impl::__eq(__type_name, __arg.__type_name);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const type_info& __arg) const _NOEXCEPT
+ { return !operator==(__arg); }
+};
+#endif // defined(_LIBCPP_ABI_MICROSOFT)
+
+class _LIBCPP_EXCEPTION_ABI bad_cast
+ : public exception
+{
+public:
+#ifdef _LIBCPP_ABI_MICROSOFT
+ bad_cast() _NOEXCEPT {}
+ virtual ~bad_cast() _NOEXCEPT {}
+ virtual const char* what() const _NOEXCEPT
+ {
+ return "std::bad_cast";
+ }
+#else
+ bad_cast() _NOEXCEPT;
+ bad_cast(const bad_cast&) _NOEXCEPT = default;
+ virtual ~bad_cast() _NOEXCEPT;
+ virtual const char* what() const _NOEXCEPT;
+#endif
+};
+
+class _LIBCPP_EXCEPTION_ABI bad_typeid
+ : public exception
+{
+public:
+#ifdef _LIBCPP_ABI_MICROSOFT
+ bad_typeid() _NOEXCEPT {}
+ virtual ~bad_typeid() _NOEXCEPT {}
+ virtual const char* what() const _NOEXCEPT
+ {
+ return "std::bad_typeid";
+ }
+#else
+ bad_typeid() _NOEXCEPT;
+ virtual ~bad_typeid() _NOEXCEPT;
+ virtual const char* what() const _NOEXCEPT;
+#endif
+};
+
+} // namespace std
+
+#ifdef _LIBCPP_ABI_MICROSOFT
+class type_info : public std::type_info {};
+#endif
+
+#endif // defined(_LIBCPP_ABI_VCRUNTIME)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
+void __throw_bad_cast()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw bad_cast();
+#else
+ _VSTD::abort();
+#endif
+}
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // __LIBCPP_TYPEINFO
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/unordered_map b/contrib/libs/cxxsupp/libcxxmsvc/include/unordered_map
new file mode 100644
index 0000000000..c854548950
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/unordered_map
@@ -0,0 +1,2619 @@
+// -*- 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_UNORDERED_MAP
+#define _LIBCPP_UNORDERED_MAP
+
+/*
+
+ unordered_map synopsis
+
+#include <initializer_list>
+
+namespace std
+{
+
+template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+ class Alloc = allocator<pair<const Key, T>>>
+class unordered_map
+{
+public:
+ // types
+ typedef Key key_type;
+ typedef T mapped_type;
+ typedef Hash hasher;
+ typedef Pred key_equal;
+ typedef Alloc allocator_type;
+ typedef pair<const key_type, mapped_type> value_type;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef typename allocator_traits<allocator_type>::pointer pointer;
+ typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
+ typedef typename allocator_traits<allocator_type>::size_type size_type;
+ typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+ typedef /unspecified/ iterator;
+ typedef /unspecified/ const_iterator;
+ typedef /unspecified/ local_iterator;
+ typedef /unspecified/ const_local_iterator;
+
+ typedef unspecified node_type; // C++17
+ typedef INSERT_RETURN_TYPE<iterator, node_type> insert_return_type; // C++17
+
+ unordered_map()
+ noexcept(
+ is_nothrow_default_constructible<hasher>::value &&
+ is_nothrow_default_constructible<key_equal>::value &&
+ is_nothrow_default_constructible<allocator_type>::value);
+ explicit unordered_map(size_type n, const hasher& hf = hasher(),
+ const key_equal& eql = key_equal(),
+ const allocator_type& a = allocator_type());
+ template <class InputIterator>
+ unordered_map(InputIterator f, InputIterator l,
+ size_type n = 0, const hasher& hf = hasher(),
+ const key_equal& eql = key_equal(),
+ const allocator_type& a = allocator_type());
+ explicit unordered_map(const allocator_type&);
+ unordered_map(const unordered_map&);
+ unordered_map(const unordered_map&, const Allocator&);
+ unordered_map(unordered_map&&)
+ noexcept(
+ is_nothrow_move_constructible<hasher>::value &&
+ is_nothrow_move_constructible<key_equal>::value &&
+ is_nothrow_move_constructible<allocator_type>::value);
+ unordered_map(unordered_map&&, const Allocator&);
+ unordered_map(initializer_list<value_type>, size_type n = 0,
+ const hasher& hf = hasher(), const key_equal& eql = key_equal(),
+ const allocator_type& a = allocator_type());
+ unordered_map(size_type n, const allocator_type& a)
+ : unordered_map(n, hasher(), key_equal(), a) {} // C++14
+ unordered_map(size_type n, const hasher& hf, const allocator_type& a)
+ : unordered_map(n, hf, key_equal(), a) {} // C++14
+ template <class InputIterator>
+ unordered_map(InputIterator f, InputIterator l, size_type n, const allocator_type& a)
+ : unordered_map(f, l, n, hasher(), key_equal(), a) {} // C++14
+ template <class InputIterator>
+ unordered_map(InputIterator f, InputIterator l, size_type n, const hasher& hf,
+ const allocator_type& a)
+ : unordered_map(f, l, n, hf, key_equal(), a) {} // C++14
+ unordered_map(initializer_list<value_type> il, size_type n, const allocator_type& a)
+ : unordered_map(il, n, hasher(), key_equal(), a) {} // C++14
+ unordered_map(initializer_list<value_type> il, size_type n, const hasher& hf,
+ const allocator_type& a)
+ : unordered_map(il, n, hf, key_equal(), a) {} // C++14
+ ~unordered_map();
+ unordered_map& operator=(const unordered_map&);
+ unordered_map& operator=(unordered_map&&)
+ noexcept(
+ allocator_type::propagate_on_container_move_assignment::value &&
+ is_nothrow_move_assignable<allocator_type>::value &&
+ is_nothrow_move_assignable<hasher>::value &&
+ is_nothrow_move_assignable<key_equal>::value);
+ unordered_map& operator=(initializer_list<value_type>);
+
+ allocator_type get_allocator() const noexcept;
+
+ bool empty() const noexcept;
+ size_type size() const noexcept;
+ size_type max_size() const noexcept;
+
+ iterator begin() noexcept;
+ iterator end() noexcept;
+ const_iterator begin() const noexcept;
+ const_iterator end() const noexcept;
+ const_iterator cbegin() const noexcept;
+ const_iterator cend() const noexcept;
+
+ template <class... Args>
+ pair<iterator, bool> emplace(Args&&... args);
+ template <class... Args>
+ iterator emplace_hint(const_iterator position, Args&&... args);
+ pair<iterator, bool> insert(const value_type& obj);
+ template <class P>
+ pair<iterator, bool> insert(P&& obj);
+ iterator insert(const_iterator hint, const value_type& obj);
+ template <class P>
+ iterator insert(const_iterator hint, P&& obj);
+ template <class InputIterator>
+ void insert(InputIterator first, InputIterator last);
+ void insert(initializer_list<value_type>);
+
+ node_type extract(const_iterator position); // C++17
+ node_type extract(const key_type& x); // C++17
+ insert_return_type insert(node_type&& nh); // C++17
+ iterator insert(const_iterator hint, node_type&& nh); // C++17
+
+ template <class... Args>
+ pair<iterator, bool> try_emplace(const key_type& k, Args&&... args); // C++17
+ template <class... Args>
+ pair<iterator, bool> try_emplace(key_type&& k, Args&&... args); // C++17
+ template <class... Args>
+ iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17
+ template <class... Args>
+ iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args); // C++17
+ template <class M>
+ pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj); // C++17
+ template <class M>
+ pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj); // C++17
+ template <class M>
+ iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj); // C++17
+ template <class M>
+ iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); // C++17
+
+ iterator erase(const_iterator position);
+ iterator erase(iterator position); // C++14
+ size_type erase(const key_type& k);
+ iterator erase(const_iterator first, const_iterator last);
+ void clear() noexcept;
+
+ template<class H2, class P2>
+ void merge(unordered_map<Key, T, H2, P2, Allocator>& source); // C++17
+ template<class H2, class P2>
+ void merge(unordered_map<Key, T, H2, P2, Allocator>&& source); // C++17
+ template<class H2, class P2>
+ void merge(unordered_multimap<Key, T, H2, P2, Allocator>& source); // C++17
+ template<class H2, class P2>
+ void merge(unordered_multimap<Key, T, H2, P2, Allocator>&& source); // C++17
+
+ void swap(unordered_map&)
+ noexcept(
+ (!allocator_type::propagate_on_container_swap::value ||
+ __is_nothrow_swappable<allocator_type>::value) &&
+ __is_nothrow_swappable<hasher>::value &&
+ __is_nothrow_swappable<key_equal>::value);
+
+ hasher hash_function() const;
+ key_equal key_eq() const;
+
+ iterator find(const key_type& k);
+ const_iterator find(const key_type& k) const;
+ template<typename K>
+ iterator find(const K& x); // C++20
+ template<typename K>
+ const_iterator find(const K& x) const; // C++20
+ size_type count(const key_type& k) const;
+ template<typename K>
+ size_type count(const K& k) const; // C++20
+ bool contains(const key_type& k) const; // C++20
+ template<typename K>
+ bool contains(const K& k) const; // C++20
+ pair<iterator, iterator> equal_range(const key_type& k);
+ pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+ template<typename K>
+ pair<iterator, iterator> equal_range(const K& k); // C++20
+ template<typename K>
+ pair<const_iterator, const_iterator> equal_range(const K& k) const; // C++20
+
+ mapped_type& operator[](const key_type& k);
+ mapped_type& operator[](key_type&& k);
+
+ mapped_type& at(const key_type& k);
+ const mapped_type& at(const key_type& k) const;
+
+ size_type bucket_count() const noexcept;
+ size_type max_bucket_count() const noexcept;
+
+ size_type bucket_size(size_type n) const;
+ size_type bucket(const key_type& k) const;
+
+ local_iterator begin(size_type n);
+ local_iterator end(size_type n);
+ const_local_iterator begin(size_type n) const;
+ const_local_iterator end(size_type n) const;
+ const_local_iterator cbegin(size_type n) const;
+ const_local_iterator cend(size_type n) const;
+
+ float load_factor() const noexcept;
+ float max_load_factor() const noexcept;
+ void max_load_factor(float z);
+ void rehash(size_type n);
+ void reserve(size_type n);
+};
+
+template<class InputIterator,
+ class Hash = hash<iter_key_t<InputIterator>>, class Pred = equal_to<iter_key_t<InputIterator>>,
+ class Allocator = allocator<iter_to_alloc_t<InputIterator>>>
+unordered_map(InputIterator, InputIterator, typename see below::size_type = see below,
+ Hash = Hash(), Pred = Pred(), Allocator = Allocator())
+ -> unordered_map<iter_key_t<InputIterator>, iter_value_t<InputIterator>, Hash, Pred,
+ Allocator>; // C++17
+
+template<class Key, class T, class Hash = hash<Key>,
+ class Pred = equal_to<Key>, class Allocator = allocator<pair<const Key, T>>>
+unordered_map(initializer_list<pair<const Key, T>>, typename see below::size_type = see below,
+ Hash = Hash(), Pred = Pred(), Allocator = Allocator())
+ -> unordered_map<Key, T, Hash, Pred, Allocator>; // C++17
+
+template<class InputIterator, class Allocator>
+unordered_map(InputIterator, InputIterator, typename see below::size_type, Allocator)
+ -> unordered_map<iter_key_t<InputIterator>, iter_val_t<InputIterator>,
+ hash<iter_key_t<InputIterator>>, equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17
+
+template<class InputIterator, class Allocator>
+unordered_map(InputIterator, InputIterator, Allocator)
+ -> unordered_map<iter_key_t<InputIterator>, iter_val_t<InputIterator>,
+ hash<iter_key_t<InputIterator>>, equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17
+
+template<class InputIterator, class Hash, class Allocator>
+unordered_map(InputIterator, InputIterator, typename see below::size_type, Hash, Allocator)
+ -> unordered_map<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Hash,
+ equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17
+
+template<class Key, class T, typename Allocator>
+unordered_map(initializer_list<pair<const Key, T>>, typename see below::size_type, Allocator)
+ -> unordered_map<Key, T, hash<Key>, equal_to<Key>, Allocator>; // C++17
+
+template<class Key, class T, typename Allocator>
+unordered_map(initializer_list<pair<const Key, T>>, Allocator)
+ -> unordered_map<Key, T, hash<Key>, equal_to<Key>, Allocator>; // C++17
+
+template<class Key, class T, class Hash, class Allocator>
+unordered_map(initializer_list<pair<const Key, T>>, typename see below::size_type, Hash, Allocator)
+ -> unordered_map<Key, T, Hash, equal_to<Key>, Allocator>; // C++17
+
+template <class Key, class T, class Hash, class Pred, class Alloc>
+ void swap(unordered_map<Key, T, Hash, Pred, Alloc>& x,
+ unordered_map<Key, T, Hash, Pred, Alloc>& y)
+ noexcept(noexcept(x.swap(y)));
+
+template <class Key, class T, class Hash, class Pred, class Alloc>
+ bool
+ operator==(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
+ const unordered_map<Key, T, Hash, Pred, Alloc>& y);
+
+template <class Key, class T, class Hash, class Pred, class Alloc>
+ bool
+ operator!=(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
+ const unordered_map<Key, T, Hash, Pred, Alloc>& y);
+
+template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+ class Alloc = allocator<pair<const Key, T>>>
+class unordered_multimap
+{
+public:
+ // types
+ typedef Key key_type;
+ typedef T mapped_type;
+ typedef Hash hasher;
+ typedef Pred key_equal;
+ typedef Alloc allocator_type;
+ typedef pair<const key_type, mapped_type> value_type;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef typename allocator_traits<allocator_type>::pointer pointer;
+ typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
+ typedef typename allocator_traits<allocator_type>::size_type size_type;
+ typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+ typedef /unspecified/ iterator;
+ typedef /unspecified/ const_iterator;
+ typedef /unspecified/ local_iterator;
+ typedef /unspecified/ const_local_iterator;
+
+ typedef unspecified node_type; // C++17
+
+ unordered_multimap()
+ noexcept(
+ is_nothrow_default_constructible<hasher>::value &&
+ is_nothrow_default_constructible<key_equal>::value &&
+ is_nothrow_default_constructible<allocator_type>::value);
+ explicit unordered_multimap(size_type n, const hasher& hf = hasher(),
+ const key_equal& eql = key_equal(),
+ const allocator_type& a = allocator_type());
+ template <class InputIterator>
+ unordered_multimap(InputIterator f, InputIterator l,
+ size_type n = 0, const hasher& hf = hasher(),
+ const key_equal& eql = key_equal(),
+ const allocator_type& a = allocator_type());
+ explicit unordered_multimap(const allocator_type&);
+ unordered_multimap(const unordered_multimap&);
+ unordered_multimap(const unordered_multimap&, const Allocator&);
+ unordered_multimap(unordered_multimap&&)
+ noexcept(
+ is_nothrow_move_constructible<hasher>::value &&
+ is_nothrow_move_constructible<key_equal>::value &&
+ is_nothrow_move_constructible<allocator_type>::value);
+ unordered_multimap(unordered_multimap&&, const Allocator&);
+ unordered_multimap(initializer_list<value_type>, size_type n = 0,
+ const hasher& hf = hasher(), const key_equal& eql = key_equal(),
+ const allocator_type& a = allocator_type());
+ unordered_multimap(size_type n, const allocator_type& a)
+ : unordered_multimap(n, hasher(), key_equal(), a) {} // C++14
+ unordered_multimap(size_type n, const hasher& hf, const allocator_type& a)
+ : unordered_multimap(n, hf, key_equal(), a) {} // C++14
+ template <class InputIterator>
+ unordered_multimap(InputIterator f, InputIterator l, size_type n, const allocator_type& a)
+ : unordered_multimap(f, l, n, hasher(), key_equal(), a) {} // C++14
+ template <class InputIterator>
+ unordered_multimap(InputIterator f, InputIterator l, size_type n, const hasher& hf,
+ const allocator_type& a)
+ : unordered_multimap(f, l, n, hf, key_equal(), a) {} // C++14
+ unordered_multimap(initializer_list<value_type> il, size_type n, const allocator_type& a)
+ : unordered_multimap(il, n, hasher(), key_equal(), a) {} // C++14
+ unordered_multimap(initializer_list<value_type> il, size_type n, const hasher& hf,
+ const allocator_type& a)
+ : unordered_multimap(il, n, hf, key_equal(), a) {} // C++14
+ ~unordered_multimap();
+ unordered_multimap& operator=(const unordered_multimap&);
+ unordered_multimap& operator=(unordered_multimap&&)
+ noexcept(
+ allocator_type::propagate_on_container_move_assignment::value &&
+ is_nothrow_move_assignable<allocator_type>::value &&
+ is_nothrow_move_assignable<hasher>::value &&
+ is_nothrow_move_assignable<key_equal>::value);
+ unordered_multimap& operator=(initializer_list<value_type>);
+
+ allocator_type get_allocator() const noexcept;
+
+ bool empty() const noexcept;
+ size_type size() const noexcept;
+ size_type max_size() const noexcept;
+
+ iterator begin() noexcept;
+ iterator end() noexcept;
+ const_iterator begin() const noexcept;
+ const_iterator end() const noexcept;
+ const_iterator cbegin() const noexcept;
+ const_iterator cend() const noexcept;
+
+ template <class... Args>
+ iterator emplace(Args&&... args);
+ template <class... Args>
+ iterator emplace_hint(const_iterator position, Args&&... args);
+ iterator insert(const value_type& obj);
+ template <class P>
+ iterator insert(P&& obj);
+ iterator insert(const_iterator hint, const value_type& obj);
+ template <class P>
+ iterator insert(const_iterator hint, P&& obj);
+ template <class InputIterator>
+ void insert(InputIterator first, InputIterator last);
+ void insert(initializer_list<value_type>);
+
+ node_type extract(const_iterator position); // C++17
+ node_type extract(const key_type& x); // C++17
+ iterator insert(node_type&& nh); // C++17
+ iterator insert(const_iterator hint, node_type&& nh); // C++17
+
+ iterator erase(const_iterator position);
+ iterator erase(iterator position); // C++14
+ size_type erase(const key_type& k);
+ iterator erase(const_iterator first, const_iterator last);
+ void clear() noexcept;
+
+ template<class H2, class P2>
+ void merge(unordered_multimap<Key, T, H2, P2, Allocator>& source); // C++17
+ template<class H2, class P2>
+ void merge(unordered_multimap<Key, T, H2, P2, Allocator>&& source); // C++17
+ template<class H2, class P2>
+ void merge(unordered_map<Key, T, H2, P2, Allocator>& source); // C++17
+ template<class H2, class P2>
+ void merge(unordered_map<Key, T, H2, P2, Allocator>&& source); // C++17
+
+ void swap(unordered_multimap&)
+ noexcept(
+ (!allocator_type::propagate_on_container_swap::value ||
+ __is_nothrow_swappable<allocator_type>::value) &&
+ __is_nothrow_swappable<hasher>::value &&
+ __is_nothrow_swappable<key_equal>::value);
+
+ hasher hash_function() const;
+ key_equal key_eq() const;
+
+ iterator find(const key_type& k);
+ const_iterator find(const key_type& k) const;
+ template<typename K>
+ iterator find(const K& x); // C++20
+ template<typename K>
+ const_iterator find(const K& x) const; // C++20
+ size_type count(const key_type& k) const;
+ template<typename K>
+ size_type count(const K& k) const; // C++20
+ bool contains(const key_type& k) const; // C++20
+ template<typename K>
+ bool contains(const K& k) const; // C++20
+ pair<iterator, iterator> equal_range(const key_type& k);
+ pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+ template<typename K>
+ pair<iterator, iterator> equal_range(const K& k); // C++20
+ template<typename K>
+ pair<const_iterator, const_iterator> equal_range(const K& k) const; // C++20
+
+ size_type bucket_count() const noexcept;
+ size_type max_bucket_count() const noexcept;
+
+ size_type bucket_size(size_type n) const;
+ size_type bucket(const key_type& k) const;
+
+ local_iterator begin(size_type n);
+ local_iterator end(size_type n);
+ const_local_iterator begin(size_type n) const;
+ const_local_iterator end(size_type n) const;
+ const_local_iterator cbegin(size_type n) const;
+ const_local_iterator cend(size_type n) const;
+
+ float load_factor() const noexcept;
+ float max_load_factor() const noexcept;
+ void max_load_factor(float z);
+ void rehash(size_type n);
+ void reserve(size_type n);
+};
+
+template<class InputIterator,
+ class Hash = hash<iter_key_t<InputIterator>>, class Pred = equal_to<iter_key_t<InputIterator>>,
+ class Allocator = allocator<iter_to_alloc_t<InputIterator>>>
+unordered_multimap(InputIterator, InputIterator, typename see below::size_type = see below,
+ Hash = Hash(), Pred = Pred(), Allocator = Allocator())
+ -> unordered_multimap<iter_key_t<InputIterator>, iter_value_t<InputIterator>, Hash, Pred,
+ Allocator>; // C++17
+
+template<class Key, class T, class Hash = hash<Key>,
+ class Pred = equal_to<Key>, class Allocator = allocator<pair<const Key, T>>>
+unordered_multimap(initializer_list<pair<const Key, T>>, typename see below::size_type = see below,
+ Hash = Hash(), Pred = Pred(), Allocator = Allocator())
+ -> unordered_multimap<Key, T, Hash, Pred, Allocator>; // C++17
+
+template<class InputIterator, class Allocator>
+unordered_multimap(InputIterator, InputIterator, typename see below::size_type, Allocator)
+ -> unordered_multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>,
+ hash<iter_key_t<InputIterator>>, equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17
+
+template<class InputIterator, class Allocator>
+unordered_multimap(InputIterator, InputIterator, Allocator)
+ -> unordered_multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>,
+ hash<iter_key_t<InputIterator>>, equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17
+
+template<class InputIterator, class Hash, class Allocator>
+unordered_multimap(InputIterator, InputIterator, typename see below::size_type, Hash, Allocator)
+ -> unordered_multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Hash,
+ equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17
+
+template<class Key, class T, typename Allocator>
+unordered_multimap(initializer_list<pair<const Key, T>>, typename see below::size_type, Allocator)
+ -> unordered_multimap<Key, T, hash<Key>, equal_to<Key>, Allocator>; // C++17
+
+template<class Key, class T, typename Allocator>
+unordered_multimap(initializer_list<pair<const Key, T>>, Allocator)
+ -> unordered_multimap<Key, T, hash<Key>, equal_to<Key>, Allocator>; // C++17
+
+template<class Key, class T, class Hash, class Allocator>
+unordered_multimap(initializer_list<pair<const Key, T>>, typename see below::size_type, Hash,
+ Allocator)
+ -> unordered_multimap<Key, T, Hash, equal_to<Key>, Allocator>; // C++17
+
+template <class Key, class T, class Hash, class Pred, class Alloc>
+ void swap(unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
+ unordered_multimap<Key, T, Hash, Pred, Alloc>& y)
+ noexcept(noexcept(x.swap(y)));
+
+template <class K, class T, class H, class P, class A, class Predicate>
+ typename unordered_map<K, T, H, P, A>::size_type
+ erase_if(unordered_map<K, T, H, P, A>& c, Predicate pred); // C++20
+
+template <class K, class T, class H, class P, class A, class Predicate>
+ typename unordered_multimap<K, T, H, P, A>::size_type
+ erase_if(unordered_multimap<K, T, H, P, A>& c, Predicate pred); // C++20
+
+template <class Key, class T, class Hash, class Pred, class Alloc>
+ bool
+ operator==(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
+ const unordered_multimap<Key, T, Hash, Pred, Alloc>& y);
+
+template <class Key, class T, class Hash, class Pred, class Alloc>
+ bool
+ operator!=(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
+ const unordered_multimap<Key, T, Hash, Pred, Alloc>& y);
+
+} // std
+
+*/
+
+#include <__algorithm/is_permutation.h>
+#include <__assert>
+#include <__config>
+#include <__debug>
+#include <__functional/is_transparent.h>
+#include <__hash_table>
+#include <__iterator/iterator_traits.h>
+#include <__memory/addressof.h>
+#include <__node_handle>
+#include <__utility/forward.h>
+#include <compare>
+#include <functional>
+#include <iterator> // __libcpp_erase_if_container
+#include <stdexcept>
+#include <tuple>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Key, class _Cp, class _Hash, class _Pred,
+ bool = is_empty<_Hash>::value && !__libcpp_is_final<_Hash>::value>
+class __unordered_map_hasher
+ : private _Hash
+{
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ __unordered_map_hasher()
+ _NOEXCEPT_(is_nothrow_default_constructible<_Hash>::value)
+ : _Hash() {}
+ _LIBCPP_INLINE_VISIBILITY
+ __unordered_map_hasher(const _Hash& __h)
+ _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value)
+ : _Hash(__h) {}
+ _LIBCPP_INLINE_VISIBILITY
+ const _Hash& hash_function() const _NOEXCEPT {return *this;}
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(const _Cp& __x) const
+ {return static_cast<const _Hash&>(*this)(__x.__get_value().first);}
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(const _Key& __x) const
+ {return static_cast<const _Hash&>(*this)(__x);}
+#if _LIBCPP_STD_VER > 17
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(const _K2& __x) const
+ {return static_cast<const _Hash&>(*this)(__x);}
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(__unordered_map_hasher& __y)
+ _NOEXCEPT_(__is_nothrow_swappable<_Hash>::value)
+ {
+ using _VSTD::swap;
+ swap(static_cast<_Hash&>(*this), static_cast<_Hash&>(__y));
+ }
+};
+
+template <class _Key, class _Cp, class _Hash, class _Pred>
+class __unordered_map_hasher<_Key, _Cp, _Hash, _Pred, false>
+{
+ _Hash __hash_;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ __unordered_map_hasher()
+ _NOEXCEPT_(is_nothrow_default_constructible<_Hash>::value)
+ : __hash_() {}
+ _LIBCPP_INLINE_VISIBILITY
+ __unordered_map_hasher(const _Hash& __h)
+ _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value)
+ : __hash_(__h) {}
+ _LIBCPP_INLINE_VISIBILITY
+ const _Hash& hash_function() const _NOEXCEPT {return __hash_;}
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(const _Cp& __x) const
+ {return __hash_(__x.__get_value().first);}
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(const _Key& __x) const
+ {return __hash_(__x);}
+#if _LIBCPP_STD_VER > 17
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(const _K2& __x) const
+ {return __hash_(__x);}
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(__unordered_map_hasher& __y)
+ _NOEXCEPT_(__is_nothrow_swappable<_Hash>::value)
+ {
+ using _VSTD::swap;
+ swap(__hash_, __y.__hash_);
+ }
+};
+
+template <class _Key, class _Cp, class _Hash, class _Pred, bool __b>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(__unordered_map_hasher<_Key, _Cp, _Hash, _Pred, __b>& __x,
+ __unordered_map_hasher<_Key, _Cp, _Hash, _Pred, __b>& __y)
+ _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+ __x.swap(__y);
+}
+
+template <class _Key, class _Cp, class _Pred, class _Hash,
+ bool = is_empty<_Pred>::value && !__libcpp_is_final<_Pred>::value>
+class __unordered_map_equal
+ : private _Pred
+{
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ __unordered_map_equal()
+ _NOEXCEPT_(is_nothrow_default_constructible<_Pred>::value)
+ : _Pred() {}
+ _LIBCPP_INLINE_VISIBILITY
+ __unordered_map_equal(const _Pred& __p)
+ _NOEXCEPT_(is_nothrow_copy_constructible<_Pred>::value)
+ : _Pred(__p) {}
+ _LIBCPP_INLINE_VISIBILITY
+ const _Pred& key_eq() const _NOEXCEPT {return *this;}
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _Cp& __x, const _Cp& __y) const
+ {return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y.__get_value().first);}
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _Cp& __x, const _Key& __y) const
+ {return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y);}
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _Key& __x, const _Cp& __y) const
+ {return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first);}
+#if _LIBCPP_STD_VER > 17
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _Cp& __x, const _K2& __y) const
+ {return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y);}
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _K2& __x, const _Cp& __y) const
+ {return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first);}
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _Key& __x, const _K2& __y) const
+ {return static_cast<const _Pred&>(*this)(__x, __y);}
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _K2& __x, const _Key& __y) const
+ {return static_cast<const _Pred&>(*this)(__x, __y);}
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(__unordered_map_equal& __y)
+ _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)
+ {
+ using _VSTD::swap;
+ swap(static_cast<_Pred&>(*this), static_cast<_Pred&>(__y));
+ }
+};
+
+template <class _Key, class _Cp, class _Pred, class _Hash>
+class __unordered_map_equal<_Key, _Cp, _Pred, _Hash, false>
+{
+ _Pred __pred_;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ __unordered_map_equal()
+ _NOEXCEPT_(is_nothrow_default_constructible<_Pred>::value)
+ : __pred_() {}
+ _LIBCPP_INLINE_VISIBILITY
+ __unordered_map_equal(const _Pred& __p)
+ _NOEXCEPT_(is_nothrow_copy_constructible<_Pred>::value)
+ : __pred_(__p) {}
+ _LIBCPP_INLINE_VISIBILITY
+ const _Pred& key_eq() const _NOEXCEPT {return __pred_;}
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _Cp& __x, const _Cp& __y) const
+ {return __pred_(__x.__get_value().first, __y.__get_value().first);}
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _Cp& __x, const _Key& __y) const
+ {return __pred_(__x.__get_value().first, __y);}
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _Key& __x, const _Cp& __y) const
+ {return __pred_(__x, __y.__get_value().first);}
+#if _LIBCPP_STD_VER > 17
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _Cp& __x, const _K2& __y) const
+ {return __pred_(__x.__get_value().first, __y);}
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _K2& __x, const _Cp& __y) const
+ {return __pred_(__x, __y.__get_value().first);}
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _Key& __x, const _K2& __y) const
+ {return __pred_(__x, __y);}
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _K2& __x, const _Key& __y) const
+ {return __pred_(__x, __y);}
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(__unordered_map_equal& __y)
+ _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)
+ {
+ using _VSTD::swap;
+ swap(__pred_, __y.__pred_);
+ }
+};
+
+template <class _Key, class _Cp, class _Pred, class _Hash, bool __b>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(__unordered_map_equal<_Key, _Cp, _Pred, _Hash, __b>& __x,
+ __unordered_map_equal<_Key, _Cp, _Pred, _Hash, __b>& __y)
+ _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+ __x.swap(__y);
+}
+
+template <class _Alloc>
+class __hash_map_node_destructor
+{
+ typedef _Alloc allocator_type;
+ typedef allocator_traits<allocator_type> __alloc_traits;
+
+public:
+
+ typedef typename __alloc_traits::pointer pointer;
+private:
+
+ allocator_type& __na_;
+
+ __hash_map_node_destructor& operator=(const __hash_map_node_destructor&);
+
+public:
+ bool __first_constructed;
+ bool __second_constructed;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __hash_map_node_destructor(allocator_type& __na) _NOEXCEPT
+ : __na_(__na),
+ __first_constructed(false),
+ __second_constructed(false)
+ {}
+
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_map_node_destructor(__hash_node_destructor<allocator_type>&& __x)
+ _NOEXCEPT
+ : __na_(__x.__na_),
+ __first_constructed(__x.__value_constructed),
+ __second_constructed(__x.__value_constructed)
+ {
+ __x.__value_constructed = false;
+ }
+#else // _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_map_node_destructor(const __hash_node_destructor<allocator_type>& __x)
+ : __na_(__x.__na_),
+ __first_constructed(__x.__value_constructed),
+ __second_constructed(__x.__value_constructed)
+ {
+ const_cast<bool&>(__x.__value_constructed) = false;
+ }
+#endif // _LIBCPP_CXX03_LANG
+
+ _LIBCPP_INLINE_VISIBILITY
+ void operator()(pointer __p) _NOEXCEPT
+ {
+ if (__second_constructed)
+ __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__get_value().second));
+ if (__first_constructed)
+ __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__get_value().first));
+ if (__p)
+ __alloc_traits::deallocate(__na_, __p, 1);
+ }
+};
+
+#ifndef _LIBCPP_CXX03_LANG
+template <class _Key, class _Tp>
+struct _LIBCPP_STANDALONE_DEBUG __hash_value_type
+{
+ typedef _Key key_type;
+ typedef _Tp mapped_type;
+ typedef pair<const key_type, mapped_type> value_type;
+ typedef pair<key_type&, mapped_type&> __nc_ref_pair_type;
+ typedef pair<key_type&&, mapped_type&&> __nc_rref_pair_type;
+
+private:
+ value_type __cc;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ value_type& __get_value()
+ {
+#if _LIBCPP_STD_VER > 14
+ return *_VSTD::launder(_VSTD::addressof(__cc));
+#else
+ return __cc;
+#endif
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ const value_type& __get_value() const
+ {
+#if _LIBCPP_STD_VER > 14
+ return *_VSTD::launder(_VSTD::addressof(__cc));
+#else
+ return __cc;
+#endif
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __nc_ref_pair_type __ref()
+ {
+ value_type& __v = __get_value();
+ return __nc_ref_pair_type(const_cast<key_type&>(__v.first), __v.second);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __nc_rref_pair_type __move()
+ {
+ value_type& __v = __get_value();
+ return __nc_rref_pair_type(
+ _VSTD::move(const_cast<key_type&>(__v.first)),
+ _VSTD::move(__v.second));
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_value_type& operator=(const __hash_value_type& __v)
+ {
+ __ref() = __v.__get_value();
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_value_type& operator=(__hash_value_type&& __v)
+ {
+ __ref() = __v.__move();
+ return *this;
+ }
+
+ template <class _ValueTp,
+ class = typename enable_if<
+ __is_same_uncvref<_ValueTp, value_type>::value
+ >::type
+ >
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_value_type& operator=(_ValueTp&& __v)
+ {
+ __ref() = _VSTD::forward<_ValueTp>(__v);
+ return *this;
+ }
+
+private:
+ __hash_value_type(const __hash_value_type& __v) = delete;
+ __hash_value_type(__hash_value_type&& __v) = delete;
+ template <class ..._Args>
+ explicit __hash_value_type(_Args&& ...__args) = delete;
+
+ ~__hash_value_type() = delete;
+};
+
+#else
+
+template <class _Key, class _Tp>
+struct __hash_value_type
+{
+ typedef _Key key_type;
+ typedef _Tp mapped_type;
+ typedef pair<const key_type, mapped_type> value_type;
+
+private:
+ value_type __cc;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ value_type& __get_value() { return __cc; }
+ _LIBCPP_INLINE_VISIBILITY
+ const value_type& __get_value() const { return __cc; }
+
+private:
+ ~__hash_value_type();
+};
+
+#endif
+
+template <class _HashIterator>
+class _LIBCPP_TEMPLATE_VIS __hash_map_iterator
+{
+ _HashIterator __i_;
+
+ typedef __hash_node_types_from_iterator<_HashIterator> _NodeTypes;
+
+public:
+ typedef forward_iterator_tag iterator_category;
+ typedef typename _NodeTypes::__map_value_type value_type;
+ typedef typename _NodeTypes::difference_type difference_type;
+ typedef value_type& reference;
+ typedef typename _NodeTypes::__map_value_type_pointer pointer;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_map_iterator() _NOEXCEPT {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_map_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ reference operator*() const {return __i_->__get_value();}
+ _LIBCPP_INLINE_VISIBILITY
+ pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__get_value());}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_map_iterator& operator++() {++__i_; return *this;}
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_map_iterator operator++(int)
+ {
+ __hash_map_iterator __t(*this);
+ ++(*this);
+ return __t;
+ }
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const __hash_map_iterator& __x, const __hash_map_iterator& __y)
+ {return __x.__i_ == __y.__i_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y)
+ {return __x.__i_ != __y.__i_;}
+
+ template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_map;
+ template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;
+ template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator;
+ template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;
+ template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator;
+};
+
+template <class _HashIterator>
+class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator
+{
+ _HashIterator __i_;
+
+ typedef __hash_node_types_from_iterator<_HashIterator> _NodeTypes;
+
+public:
+ typedef forward_iterator_tag iterator_category;
+ typedef typename _NodeTypes::__map_value_type value_type;
+ typedef typename _NodeTypes::difference_type difference_type;
+ typedef const value_type& reference;
+ typedef typename _NodeTypes::__const_map_value_type_pointer pointer;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_map_const_iterator() _NOEXCEPT {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_map_const_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {}
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_map_const_iterator(
+ __hash_map_iterator<typename _HashIterator::__non_const_iterator> __i)
+ _NOEXCEPT
+ : __i_(__i.__i_) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ reference operator*() const {return __i_->__get_value();}
+ _LIBCPP_INLINE_VISIBILITY
+ pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__get_value());}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_map_const_iterator& operator++() {++__i_; return *this;}
+ _LIBCPP_INLINE_VISIBILITY
+ __hash_map_const_iterator operator++(int)
+ {
+ __hash_map_const_iterator __t(*this);
+ ++(*this);
+ return __t;
+ }
+
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator==(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y)
+ {return __x.__i_ == __y.__i_;}
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y)
+ {return __x.__i_ != __y.__i_;}
+
+ template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_map;
+ template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;
+ template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator;
+ template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;
+};
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+class unordered_multimap;
+
+template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
+ class _Alloc = allocator<pair<const _Key, _Tp> > >
+class _LIBCPP_TEMPLATE_VIS unordered_map
+{
+public:
+ // types
+ typedef _Key key_type;
+ typedef _Tp mapped_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;
+ static_assert((is_same<value_type, typename allocator_type::value_type>::value),
+ "Invalid allocator::value_type");
+
+private:
+ typedef __hash_value_type<key_type, mapped_type> __value_type;
+ typedef __unordered_map_hasher<key_type, __value_type, hasher, key_equal> __hasher;
+ typedef __unordered_map_equal<key_type, __value_type, key_equal, hasher> __key_equal;
+ typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
+ __value_type>::type __allocator_type;
+
+ typedef __hash_table<__value_type, __hasher,
+ __key_equal, __allocator_type> __table;
+
+ __table __table_;
+
+ typedef typename __table::_NodeTypes _NodeTypes;
+ typedef typename __table::__node_pointer __node_pointer;
+ typedef typename __table::__node_const_pointer __node_const_pointer;
+ typedef typename __table::__node_traits __node_traits;
+ typedef typename __table::__node_allocator __node_allocator;
+ typedef typename __table::__node __node;
+ typedef __hash_map_node_destructor<__node_allocator> _Dp;
+ typedef unique_ptr<__node, _Dp> __node_holder;
+ typedef allocator_traits<allocator_type> __alloc_traits;
+
+ static_assert((is_same<typename __table::__container_value_type, value_type>::value), "");
+ static_assert((is_same<typename __table::__node_value_type, __value_type>::value), "");
+public:
+ typedef typename __alloc_traits::pointer pointer;
+ typedef typename __alloc_traits::const_pointer const_pointer;
+ typedef typename __table::size_type size_type;
+ typedef typename __table::difference_type difference_type;
+
+ typedef __hash_map_iterator<typename __table::iterator> iterator;
+ typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator;
+ typedef __hash_map_iterator<typename __table::local_iterator> local_iterator;
+ typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator;
+
+#if _LIBCPP_STD_VER > 14
+ typedef __map_node_handle<__node, allocator_type> node_type;
+ typedef __insert_return_type<iterator, node_type> insert_return_type;
+#endif
+
+ template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>
+ friend class _LIBCPP_TEMPLATE_VIS unordered_map;
+ template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>
+ friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;
+
+ _LIBCPP_INLINE_VISIBILITY
+ unordered_map()
+ _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
+ {
+ _VSTD::__debug_db_insert_c(this);
+ }
+ explicit unordered_map(size_type __n, const hasher& __hf = hasher(),
+ const key_equal& __eql = key_equal());
+ unordered_map(size_type __n, const hasher& __hf,
+ const key_equal& __eql,
+ const allocator_type& __a);
+ template <class _InputIterator>
+ unordered_map(_InputIterator __first, _InputIterator __last);
+ template <class _InputIterator>
+ unordered_map(_InputIterator __first, _InputIterator __last,
+ size_type __n, const hasher& __hf = hasher(),
+ const key_equal& __eql = key_equal());
+ template <class _InputIterator>
+ unordered_map(_InputIterator __first, _InputIterator __last,
+ size_type __n, const hasher& __hf,
+ const key_equal& __eql,
+ const allocator_type& __a);
+ _LIBCPP_INLINE_VISIBILITY
+ explicit unordered_map(const allocator_type& __a);
+ unordered_map(const unordered_map& __u);
+ unordered_map(const unordered_map& __u, const allocator_type& __a);
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ unordered_map(unordered_map&& __u)
+ _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
+ unordered_map(unordered_map&& __u, const allocator_type& __a);
+ unordered_map(initializer_list<value_type> __il);
+ unordered_map(initializer_list<value_type> __il, size_type __n,
+ const hasher& __hf = hasher(), const key_equal& __eql = key_equal());
+ 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
+#if _LIBCPP_STD_VER > 11
+ _LIBCPP_INLINE_VISIBILITY
+ unordered_map(size_type __n, const allocator_type& __a)
+ : unordered_map(__n, hasher(), key_equal(), __a) {}
+ _LIBCPP_INLINE_VISIBILITY
+ unordered_map(size_type __n, const hasher& __hf, const allocator_type& __a)
+ : unordered_map(__n, __hf, key_equal(), __a) {}
+ template <class _InputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ unordered_map(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a)
+ : unordered_map(__first, __last, __n, hasher(), key_equal(), __a) {}
+ template <class _InputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ unordered_map(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf,
+ const allocator_type& __a)
+ : unordered_map(__first, __last, __n, __hf, key_equal(), __a) {}
+ _LIBCPP_INLINE_VISIBILITY
+ unordered_map(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
+ : unordered_map(__il, __n, hasher(), key_equal(), __a) {}
+ _LIBCPP_INLINE_VISIBILITY
+ unordered_map(initializer_list<value_type> __il, size_type __n, const hasher& __hf,
+ const allocator_type& __a)
+ : unordered_map(__il, __n, __hf, key_equal(), __a) {}
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ ~unordered_map() {
+ static_assert(sizeof(__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), "");
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ unordered_map& operator=(const unordered_map& __u)
+ {
+#ifndef _LIBCPP_CXX03_LANG
+ __table_ = __u.__table_;
+#else
+ if (this != _VSTD::addressof(__u)) {
+ __table_.clear();
+ __table_.hash_function() = __u.__table_.hash_function();
+ __table_.key_eq() = __u.__table_.key_eq();
+ __table_.max_load_factor() = __u.__table_.max_load_factor();
+ __table_.__copy_assign_alloc(__u.__table_);
+ insert(__u.begin(), __u.end());
+ }
+#endif
+ return *this;
+ }
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ unordered_map& operator=(unordered_map&& __u)
+ _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
+ _LIBCPP_INLINE_VISIBILITY
+ unordered_map& operator=(initializer_list<value_type> __il);
+#endif // _LIBCPP_CXX03_LANG
+
+ _LIBCPP_INLINE_VISIBILITY
+ allocator_type get_allocator() const _NOEXCEPT
+ {return allocator_type(__table_.__node_alloc());}
+
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+ bool empty() const _NOEXCEPT {return __table_.size() == 0;}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type size() const _NOEXCEPT {return __table_.size();}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type max_size() const _NOEXCEPT {return __table_.max_size();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator begin() _NOEXCEPT {return __table_.begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator end() _NOEXCEPT {return __table_.end();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator begin() const _NOEXCEPT {return __table_.begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator end() const _NOEXCEPT {return __table_.end();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator cend() const _NOEXCEPT {return __table_.end();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool> insert(const value_type& __x)
+ {return __table_.__insert_unique(__x);}
+
+ iterator insert(const_iterator __p, const value_type& __x) {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
+ "unordered_map::insert(const_iterator, const value_type&) called with an iterator not "
+ "referring to this unordered_map");
+ ((void)__p);
+ return insert(__x).first;
+ }
+
+ template <class _InputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ void insert(_InputIterator __first, _InputIterator __last);
+
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ void insert(initializer_list<value_type> __il)
+ {insert(__il.begin(), __il.end());}
+
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool> insert(value_type&& __x)
+ {return __table_.__insert_unique(_VSTD::move(__x));}
+
+ iterator insert(const_iterator __p, value_type&& __x) {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
+ "unordered_map::insert(const_iterator, const value_type&) called with an iterator not"
+ " referring to this unordered_map");
+ ((void)__p);
+ return __table_.__insert_unique(_VSTD::move(__x)).first;
+ }
+
+ template <class _Pp,
+ class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool> insert(_Pp&& __x)
+ {return __table_.__insert_unique(_VSTD::forward<_Pp>(__x));}
+
+ template <class _Pp,
+ class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const_iterator __p, _Pp&& __x)
+ {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
+ "unordered_map::insert(const_iterator, value_type&&) called with an iterator not"
+ " referring to this unordered_map");
+ ((void)__p);
+ return insert(_VSTD::forward<_Pp>(__x)).first;
+ }
+
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool> emplace(_Args&&... __args) {
+ return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...);
+ }
+
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator emplace_hint(const_iterator __p, _Args&&... __args) {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
+ "unordered_map::emplace_hint(const_iterator, args...) called with an iterator not"
+ " referring to this unordered_map");
+ ((void)__p);
+ return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;
+ }
+
+#endif // _LIBCPP_CXX03_LANG
+
+#if _LIBCPP_STD_VER > 14
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args)
+ {
+ return __table_.__emplace_unique_key_args(__k, piecewise_construct,
+ _VSTD::forward_as_tuple(__k),
+ _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
+ }
+
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args)
+ {
+ return __table_.__emplace_unique_key_args(__k, piecewise_construct,
+ _VSTD::forward_as_tuple(_VSTD::move(__k)),
+ _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
+ }
+
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args)
+ {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__h)) == this,
+ "unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not"
+ " referring to this unordered_map");
+ ((void)__h);
+ return try_emplace(__k, _VSTD::forward<_Args>(__args)...).first;
+ }
+
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args)
+ {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__h)) == this,
+ "unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not"
+ " referring to this unordered_map");
+ ((void)__h);
+ return try_emplace(_VSTD::move(__k), _VSTD::forward<_Args>(__args)...).first;
+ }
+
+ template <class _Vp>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool> insert_or_assign(const key_type& __k, _Vp&& __v)
+ {
+ pair<iterator, bool> __res = __table_.__emplace_unique_key_args(__k,
+ __k, _VSTD::forward<_Vp>(__v));
+ if (!__res.second) {
+ __res.first->second = _VSTD::forward<_Vp>(__v);
+ }
+ return __res;
+ }
+
+ template <class _Vp>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool> insert_or_assign(key_type&& __k, _Vp&& __v)
+ {
+ pair<iterator, bool> __res = __table_.__emplace_unique_key_args(__k,
+ _VSTD::move(__k), _VSTD::forward<_Vp>(__v));
+ if (!__res.second) {
+ __res.first->second = _VSTD::forward<_Vp>(__v);
+ }
+ return __res;
+ }
+
+ template <class _Vp>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert_or_assign(const_iterator, const key_type& __k, _Vp&& __v)
+ {
+ // FIXME: Add debug mode checking for the iterator input
+ return insert_or_assign(__k, _VSTD::forward<_Vp>(__v)).first;
+ }
+
+ template <class _Vp>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert_or_assign(const_iterator, key_type&& __k, _Vp&& __v)
+ {
+ // FIXME: Add debug mode checking for the iterator input
+ return insert_or_assign(_VSTD::move(__k), _VSTD::forward<_Vp>(__v)).first;
+ }
+#endif // _LIBCPP_STD_VER > 14
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator erase(const_iterator __p) {return __table_.erase(__p.__i_);}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator erase(iterator __p) {return __table_.erase(__p.__i_);}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator erase(const_iterator __first, const_iterator __last)
+ {return __table_.erase(__first.__i_, __last.__i_);}
+ _LIBCPP_INLINE_VISIBILITY
+ void clear() _NOEXCEPT {__table_.clear();}
+
+#if _LIBCPP_STD_VER > 14
+ _LIBCPP_INLINE_VISIBILITY
+ insert_return_type insert(node_type&& __nh)
+ {
+ _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
+ "node_type with incompatible allocator passed to unordered_map::insert()");
+ return __table_.template __node_handle_insert_unique<
+ node_type, insert_return_type>(_VSTD::move(__nh));
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const_iterator __hint, node_type&& __nh)
+ {
+ _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
+ "node_type with incompatible allocator passed to unordered_map::insert()");
+ return __table_.template __node_handle_insert_unique<node_type>(
+ __hint.__i_, _VSTD::move(__nh));
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ node_type extract(key_type const& __key)
+ {
+ return __table_.template __node_handle_extract<node_type>(__key);
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ node_type extract(const_iterator __it)
+ {
+ return __table_.template __node_handle_extract<node_type>(
+ __it.__i_);
+ }
+
+ template <class _H2, class _P2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(unordered_map<key_type, mapped_type, _H2, _P2, allocator_type>& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ return __table_.__node_handle_merge_unique(__source.__table_);
+ }
+ template <class _H2, class _P2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(unordered_map<key_type, mapped_type, _H2, _P2, allocator_type>&& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ return __table_.__node_handle_merge_unique(__source.__table_);
+ }
+ template <class _H2, class _P2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(unordered_multimap<key_type, mapped_type, _H2, _P2, allocator_type>& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ return __table_.__node_handle_merge_unique(__source.__table_);
+ }
+ template <class _H2, class _P2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(unordered_multimap<key_type, mapped_type, _H2, _P2, allocator_type>&& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ return __table_.__node_handle_merge_unique(__source.__table_);
+ }
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(unordered_map& __u)
+ _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
+ { __table_.swap(__u.__table_);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ hasher hash_function() const
+ {return __table_.hash_function().hash_function();}
+ _LIBCPP_INLINE_VISIBILITY
+ key_equal key_eq() const
+ {return __table_.key_eq().key_eq();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator find(const key_type& __k) {return __table_.find(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator find(const key_type& __k) const {return __table_.find(__k);}
+#if _LIBCPP_STD_VER > 17
+ template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator find(const _K2& __k) {return __table_.find(__k);}
+ template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator find(const _K2& __k) const {return __table_.find(__k);}
+#endif // _LIBCPP_STD_VER > 17
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
+#if _LIBCPP_STD_VER > 17
+ template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ size_type count(const _K2& __k) const {return __table_.__count_unique(__k);}
+#endif // _LIBCPP_STD_VER > 17
+
+#if _LIBCPP_STD_VER > 17
+ _LIBCPP_INLINE_VISIBILITY
+ bool contains(const key_type& __k) const {return find(__k) != end();}
+
+ template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ bool contains(const _K2& __k) const {return find(__k) != end();}
+#endif // _LIBCPP_STD_VER > 17
+
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, iterator> equal_range(const key_type& __k)
+ {return __table_.__equal_range_unique(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
+ {return __table_.__equal_range_unique(__k);}
+#if _LIBCPP_STD_VER > 17
+ template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, iterator> equal_range(const _K2& __k)
+ {return __table_.__equal_range_unique(__k);}
+ template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<const_iterator, const_iterator> equal_range(const _K2& __k) const
+ {return __table_.__equal_range_unique(__k);}
+#endif // _LIBCPP_STD_VER > 17
+
+ mapped_type& operator[](const key_type& __k);
+#ifndef _LIBCPP_CXX03_LANG
+ mapped_type& operator[](key_type&& __k);
+#endif
+
+ mapped_type& at(const key_type& __k);
+ const mapped_type& at(const key_type& __k) const;
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type bucket_size(size_type __n) const
+ {return __table_.bucket_size(__n);}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ local_iterator begin(size_type __n) {return __table_.begin(__n);}
+ _LIBCPP_INLINE_VISIBILITY
+ local_iterator end(size_type __n) {return __table_.end(__n);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_local_iterator begin(size_type __n) const {return __table_.cbegin(__n);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_local_iterator end(size_type __n) const {return __table_.cend(__n);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_local_iterator cend(size_type __n) const {return __table_.cend(__n);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ float load_factor() const _NOEXCEPT {return __table_.load_factor();}
+ _LIBCPP_INLINE_VISIBILITY
+ float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
+ _LIBCPP_INLINE_VISIBILITY
+ void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
+ _LIBCPP_INLINE_VISIBILITY
+ void rehash(size_type __n) {__table_.rehash(__n);}
+ _LIBCPP_INLINE_VISIBILITY
+ void reserve(size_type __n) {__table_.reserve(__n);}
+
+#if _LIBCPP_DEBUG_LEVEL == 2
+
+ bool __dereferenceable(const const_iterator* __i) const
+ {return __table_.__dereferenceable(_VSTD::addressof(__i->__i_));}
+ bool __decrementable(const const_iterator* __i) const
+ {return __table_.__decrementable(_VSTD::addressof(__i->__i_));}
+ bool __addable(const const_iterator* __i, ptrdiff_t __n) const
+ {return __table_.__addable(_VSTD::addressof(__i->__i_), __n);}
+ bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
+ {return __table_.__addable(_VSTD::addressof(__i->__i_), __n);}
+
+#endif // _LIBCPP_DEBUG_LEVEL == 2
+
+private:
+
+#ifdef _LIBCPP_CXX03_LANG
+ __node_holder __construct_node_with_key(const key_type& __k);
+#endif
+};
+
+#if _LIBCPP_STD_VER >= 17
+template<class _InputIterator,
+ class _Hash = hash<__iter_key_type<_InputIterator>>,
+ class _Pred = equal_to<__iter_key_type<_InputIterator>>,
+ class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = enable_if_t<!__is_allocator<_Hash>::value>,
+ class = enable_if_t<!is_integral<_Hash>::value>,
+ class = enable_if_t<!__is_allocator<_Pred>::value>,
+ class = enable_if_t<__is_allocator<_Allocator>::value>>
+unordered_map(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type = 0,
+ _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
+ -> unordered_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Hash, _Pred, _Allocator>;
+
+template<class _Key, class _Tp, class _Hash = hash<remove_const_t<_Key>>,
+ class _Pred = equal_to<remove_const_t<_Key>>,
+ class _Allocator = allocator<pair<const _Key, _Tp>>,
+ class = enable_if_t<!__is_allocator<_Hash>::value>,
+ class = enable_if_t<!is_integral<_Hash>::value>,
+ class = enable_if_t<!__is_allocator<_Pred>::value>,
+ class = enable_if_t<__is_allocator<_Allocator>::value>>
+unordered_map(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type = 0,
+ _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
+ -> unordered_map<remove_const_t<_Key>, _Tp, _Hash, _Pred, _Allocator>;
+
+template<class _InputIterator, class _Allocator,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = enable_if_t<__is_allocator<_Allocator>::value>>
+unordered_map(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator)
+ -> unordered_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
+ hash<__iter_key_type<_InputIterator>>, equal_to<__iter_key_type<_InputIterator>>, _Allocator>;
+
+template<class _InputIterator, class _Allocator,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = enable_if_t<__is_allocator<_Allocator>::value>>
+unordered_map(_InputIterator, _InputIterator, _Allocator)
+ -> unordered_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
+ hash<__iter_key_type<_InputIterator>>, equal_to<__iter_key_type<_InputIterator>>, _Allocator>;
+
+template<class _InputIterator, class _Hash, class _Allocator,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = enable_if_t<!__is_allocator<_Hash>::value>,
+ class = enable_if_t<!is_integral<_Hash>::value>,
+ class = enable_if_t<__is_allocator<_Allocator>::value>>
+unordered_map(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
+ -> unordered_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
+ _Hash, equal_to<__iter_key_type<_InputIterator>>, _Allocator>;
+
+template<class _Key, class _Tp, class _Allocator,
+ class = enable_if_t<__is_allocator<_Allocator>::value>>
+unordered_map(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Allocator)
+ -> unordered_map<remove_const_t<_Key>, _Tp,
+ hash<remove_const_t<_Key>>,
+ equal_to<remove_const_t<_Key>>, _Allocator>;
+
+template<class _Key, class _Tp, class _Allocator,
+ class = enable_if_t<__is_allocator<_Allocator>::value>>
+unordered_map(initializer_list<pair<_Key, _Tp>>, _Allocator)
+ -> unordered_map<remove_const_t<_Key>, _Tp,
+ hash<remove_const_t<_Key>>,
+ equal_to<remove_const_t<_Key>>, _Allocator>;
+
+template<class _Key, class _Tp, class _Hash, class _Allocator,
+ class = enable_if_t<!__is_allocator<_Hash>::value>,
+ class = enable_if_t<!is_integral<_Hash>::value>,
+ class = enable_if_t<__is_allocator<_Allocator>::value>>
+unordered_map(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
+ -> unordered_map<remove_const_t<_Key>, _Tp, _Hash,
+ equal_to<remove_const_t<_Key>>, _Allocator>;
+#endif
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
+ size_type __n, const hasher& __hf, const key_equal& __eql)
+ : __table_(__hf, __eql)
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__n);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
+ size_type __n, const hasher& __hf, const key_equal& __eql,
+ const allocator_type& __a)
+ : __table_(__hf, __eql, typename __table::allocator_type(__a))
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__n);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+inline
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
+ const allocator_type& __a)
+ : __table_(typename __table::allocator_type(__a))
+{
+ _VSTD::__debug_db_insert_c(this);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
+ _InputIterator __first, _InputIterator __last)
+{
+ _VSTD::__debug_db_insert_c(this);
+ insert(__first, __last);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
+ _InputIterator __first, _InputIterator __last, size_type __n,
+ const hasher& __hf, const key_equal& __eql)
+ : __table_(__hf, __eql)
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__n);
+ insert(__first, __last);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
+ _InputIterator __first, _InputIterator __last, size_type __n,
+ const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
+ : __table_(__hf, __eql, typename __table::allocator_type(__a))
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__n);
+ insert(__first, __last);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
+ const unordered_map& __u)
+ : __table_(__u.__table_)
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__u.bucket_count());
+ insert(__u.begin(), __u.end());
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
+ const unordered_map& __u, const allocator_type& __a)
+ : __table_(__u.__table_, typename __table::allocator_type(__a))
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__u.bucket_count());
+ insert(__u.begin(), __u.end());
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+inline
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
+ unordered_map&& __u)
+ _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
+ : __table_(_VSTD::move(__u.__table_))
+{
+ _VSTD::__debug_db_insert_c(this);
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __get_db()->swap(this, _VSTD::addressof(__u));
+#endif
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
+ unordered_map&& __u, const allocator_type& __a)
+ : __table_(_VSTD::move(__u.__table_), typename __table::allocator_type(__a))
+{
+ _VSTD::__debug_db_insert_c(this);
+ if (__a != __u.get_allocator())
+ {
+ iterator __i = __u.begin();
+ while (__u.size() != 0) {
+ __table_.__emplace_unique(
+ __u.__table_.remove((__i++).__i_)->__value_.__move());
+ }
+ }
+#if _LIBCPP_DEBUG_LEVEL == 2
+ else
+ __get_db()->swap(this, _VSTD::addressof(__u));
+#endif
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
+ initializer_list<value_type> __il)
+{
+ _VSTD::__debug_db_insert_c(this);
+ insert(__il.begin(), __il.end());
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
+ initializer_list<value_type> __il, size_type __n, const hasher& __hf,
+ const key_equal& __eql)
+ : __table_(__hf, __eql)
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__n);
+ insert(__il.begin(), __il.end());
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
+ initializer_list<value_type> __il, size_type __n, const hasher& __hf,
+ const key_equal& __eql, const allocator_type& __a)
+ : __table_(__hf, __eql, typename __table::allocator_type(__a))
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__n);
+ insert(__il.begin(), __il.end());
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+inline
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(unordered_map&& __u)
+ _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
+{
+ __table_ = _VSTD::move(__u.__table_);
+ return *this;
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+inline
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(
+ initializer_list<value_type> __il)
+{
+ __table_.__assign_unique(__il.begin(), __il.end());
+ return *this;
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+inline
+void
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
+ _InputIterator __last)
+{
+ for (; __first != __last; ++__first)
+ __table_.__insert_unique(*__first);
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+_Tp&
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k)
+{
+ return __table_.__emplace_unique_key_args(__k,
+ piecewise_construct, _VSTD::forward_as_tuple(__k),
+ _VSTD::forward_as_tuple()).first->__get_value().second;
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+_Tp&
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&& __k)
+{
+ return __table_.__emplace_unique_key_args(__k,
+ piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__k)),
+ _VSTD::forward_as_tuple()).first->__get_value().second;
+}
+#else // _LIBCPP_CXX03_LANG
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const key_type& __k)
+{
+ __node_allocator& __na = __table_.__node_alloc();
+ __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
+ __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().first), __k);
+ __h.get_deleter().__first_constructed = true;
+ __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().second));
+ __h.get_deleter().__second_constructed = true;
+ return __h;
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+_Tp&
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k)
+{
+ iterator __i = find(__k);
+ if (__i != end())
+ return __i->second;
+ __node_holder __h = __construct_node_with_key(__k);
+ pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get());
+ __h.release();
+ return __r.first->second;
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+_Tp&
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k)
+{
+ iterator __i = find(__k);
+ if (__i == end())
+ __throw_out_of_range("unordered_map::at: key not found");
+ return __i->second;
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+const _Tp&
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k) const
+{
+ const_iterator __i = find(__k);
+ if (__i == end())
+ __throw_out_of_range("unordered_map::at: key not found");
+ return __i->second;
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
+ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
+ _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+ __x.swap(__y);
+}
+
+#if _LIBCPP_STD_VER > 17
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc,
+ class _Predicate>
+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 _VSTD::__libcpp_erase_if_container(__c, __pred);
+}
+#endif
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+bool
+operator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
+ const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
+{
+ if (__x.size() != __y.size())
+ return false;
+ typedef typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator
+ const_iterator;
+ for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end();
+ __i != __ex; ++__i)
+ {
+ const_iterator __j = __y.find(__i->first);
+ if (__j == __ey || !(*__i == *__j))
+ return false;
+ }
+ return true;
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
+ const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
+{
+ return !(__x == __y);
+}
+
+template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
+ class _Alloc = allocator<pair<const _Key, _Tp> > >
+class _LIBCPP_TEMPLATE_VIS unordered_multimap
+{
+public:
+ // types
+ typedef _Key key_type;
+ typedef _Tp mapped_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;
+ static_assert((is_same<value_type, typename allocator_type::value_type>::value),
+ "Invalid allocator::value_type");
+
+private:
+ typedef __hash_value_type<key_type, mapped_type> __value_type;
+ typedef __unordered_map_hasher<key_type, __value_type, hasher, key_equal> __hasher;
+ typedef __unordered_map_equal<key_type, __value_type, key_equal, hasher> __key_equal;
+ typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
+ __value_type>::type __allocator_type;
+
+ typedef __hash_table<__value_type, __hasher,
+ __key_equal, __allocator_type> __table;
+
+ __table __table_;
+
+ typedef typename __table::_NodeTypes _NodeTypes;
+ typedef typename __table::__node_traits __node_traits;
+ typedef typename __table::__node_allocator __node_allocator;
+ typedef typename __table::__node __node;
+ typedef __hash_map_node_destructor<__node_allocator> _Dp;
+ typedef unique_ptr<__node, _Dp> __node_holder;
+ typedef allocator_traits<allocator_type> __alloc_traits;
+ static_assert((is_same<typename __node_traits::size_type,
+ typename __alloc_traits::size_type>::value),
+ "Allocator uses different size_type for different types");
+public:
+ typedef typename __alloc_traits::pointer pointer;
+ typedef typename __alloc_traits::const_pointer const_pointer;
+ typedef typename __table::size_type size_type;
+ typedef typename __table::difference_type difference_type;
+
+ typedef __hash_map_iterator<typename __table::iterator> iterator;
+ typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator;
+ typedef __hash_map_iterator<typename __table::local_iterator> local_iterator;
+ typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator;
+
+#if _LIBCPP_STD_VER > 14
+ typedef __map_node_handle<__node, allocator_type> node_type;
+#endif
+
+ template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>
+ friend class _LIBCPP_TEMPLATE_VIS unordered_map;
+ template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>
+ friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;
+
+ _LIBCPP_INLINE_VISIBILITY
+ unordered_multimap()
+ _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
+ {
+ _VSTD::__debug_db_insert_c(this);
+ }
+ explicit unordered_multimap(size_type __n, const hasher& __hf = hasher(),
+ const key_equal& __eql = key_equal());
+ unordered_multimap(size_type __n, const hasher& __hf,
+ const key_equal& __eql,
+ const allocator_type& __a);
+ template <class _InputIterator>
+ unordered_multimap(_InputIterator __first, _InputIterator __last);
+ template <class _InputIterator>
+ unordered_multimap(_InputIterator __first, _InputIterator __last,
+ size_type __n, const hasher& __hf = hasher(),
+ const key_equal& __eql = key_equal());
+ template <class _InputIterator>
+ unordered_multimap(_InputIterator __first, _InputIterator __last,
+ size_type __n, const hasher& __hf,
+ const key_equal& __eql,
+ const allocator_type& __a);
+ _LIBCPP_INLINE_VISIBILITY
+ explicit unordered_multimap(const allocator_type& __a);
+ unordered_multimap(const unordered_multimap& __u);
+ unordered_multimap(const unordered_multimap& __u, const allocator_type& __a);
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ unordered_multimap(unordered_multimap&& __u)
+ _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
+ unordered_multimap(unordered_multimap&& __u, const allocator_type& __a);
+ unordered_multimap(initializer_list<value_type> __il);
+ unordered_multimap(initializer_list<value_type> __il, size_type __n,
+ const hasher& __hf = hasher(),
+ const key_equal& __eql = key_equal());
+ 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
+#if _LIBCPP_STD_VER > 11
+ _LIBCPP_INLINE_VISIBILITY
+ unordered_multimap(size_type __n, const allocator_type& __a)
+ : unordered_multimap(__n, hasher(), key_equal(), __a) {}
+ _LIBCPP_INLINE_VISIBILITY
+ unordered_multimap(size_type __n, const hasher& __hf, const allocator_type& __a)
+ : unordered_multimap(__n, __hf, key_equal(), __a) {}
+ template <class _InputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a)
+ : unordered_multimap(__first, __last, __n, hasher(), key_equal(), __a) {}
+ template <class _InputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf,
+ const allocator_type& __a)
+ : unordered_multimap(__first, __last, __n, __hf, key_equal(), __a) {}
+ _LIBCPP_INLINE_VISIBILITY
+ unordered_multimap(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
+ : unordered_multimap(__il, __n, hasher(), key_equal(), __a) {}
+ _LIBCPP_INLINE_VISIBILITY
+ unordered_multimap(initializer_list<value_type> __il, size_type __n, const hasher& __hf,
+ const allocator_type& __a)
+ : unordered_multimap(__il, __n, __hf, key_equal(), __a) {}
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ ~unordered_multimap() {
+ static_assert(sizeof(__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), "");
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ unordered_multimap& operator=(const unordered_multimap& __u)
+ {
+#ifndef _LIBCPP_CXX03_LANG
+ __table_ = __u.__table_;
+#else
+ if (this != _VSTD::addressof(__u)) {
+ __table_.clear();
+ __table_.hash_function() = __u.__table_.hash_function();
+ __table_.key_eq() = __u.__table_.key_eq();
+ __table_.max_load_factor() = __u.__table_.max_load_factor();
+ __table_.__copy_assign_alloc(__u.__table_);
+ insert(__u.begin(), __u.end());
+ }
+#endif
+ return *this;
+ }
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ unordered_multimap& operator=(unordered_multimap&& __u)
+ _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
+ _LIBCPP_INLINE_VISIBILITY
+ unordered_multimap& operator=(initializer_list<value_type> __il);
+#endif // _LIBCPP_CXX03_LANG
+
+ _LIBCPP_INLINE_VISIBILITY
+ allocator_type get_allocator() const _NOEXCEPT
+ {return allocator_type(__table_.__node_alloc());}
+
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+ bool empty() const _NOEXCEPT {return __table_.size() == 0;}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type size() const _NOEXCEPT {return __table_.size();}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type max_size() const _NOEXCEPT {return __table_.max_size();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator begin() _NOEXCEPT {return __table_.begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator end() _NOEXCEPT {return __table_.end();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator begin() const _NOEXCEPT {return __table_.begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator end() const _NOEXCEPT {return __table_.end();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator cend() const _NOEXCEPT {return __table_.end();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const_iterator __p, const value_type& __x)
+ {return __table_.__insert_multi(__p.__i_, __x);}
+
+ template <class _InputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ void insert(_InputIterator __first, _InputIterator __last);
+
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ void insert(initializer_list<value_type> __il)
+ {insert(__il.begin(), __il.end());}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(value_type&& __x) {return __table_.__insert_multi(_VSTD::move(__x));}
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const_iterator __p, value_type&& __x)
+ {return __table_.__insert_multi(__p.__i_, _VSTD::move(__x));}
+
+ template <class _Pp,
+ class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(_Pp&& __x)
+ {return __table_.__insert_multi(_VSTD::forward<_Pp>(__x));}
+
+ template <class _Pp,
+ class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const_iterator __p, _Pp&& __x)
+ {return __table_.__insert_multi(__p.__i_, _VSTD::forward<_Pp>(__x));}
+
+ template <class... _Args>
+ iterator emplace(_Args&&... __args) {
+ return __table_.__emplace_multi(_VSTD::forward<_Args>(__args)...);
+ }
+
+ template <class... _Args>
+ iterator emplace_hint(const_iterator __p, _Args&&... __args) {
+ return __table_.__emplace_hint_multi(__p.__i_, _VSTD::forward<_Args>(__args)...);
+ }
+#endif // _LIBCPP_CXX03_LANG
+
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator erase(const_iterator __p) {return __table_.erase(__p.__i_);}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator erase(iterator __p) {return __table_.erase(__p.__i_);}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator erase(const_iterator __first, const_iterator __last)
+ {return __table_.erase(__first.__i_, __last.__i_);}
+ _LIBCPP_INLINE_VISIBILITY
+ void clear() _NOEXCEPT {__table_.clear();}
+
+#if _LIBCPP_STD_VER > 14
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(node_type&& __nh)
+ {
+ _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
+ "node_type with incompatible allocator passed to unordered_multimap::insert()");
+ return __table_.template __node_handle_insert_multi<node_type>(
+ _VSTD::move(__nh));
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const_iterator __hint, node_type&& __nh)
+ {
+ _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
+ "node_type with incompatible allocator passed to unordered_multimap::insert()");
+ return __table_.template __node_handle_insert_multi<node_type>(
+ __hint.__i_, _VSTD::move(__nh));
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ node_type extract(key_type const& __key)
+ {
+ return __table_.template __node_handle_extract<node_type>(__key);
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ node_type extract(const_iterator __it)
+ {
+ return __table_.template __node_handle_extract<node_type>(
+ __it.__i_);
+ }
+
+ template <class _H2, class _P2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(unordered_multimap<key_type, mapped_type, _H2, _P2, allocator_type>& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ return __table_.__node_handle_merge_multi(__source.__table_);
+ }
+ template <class _H2, class _P2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(unordered_multimap<key_type, mapped_type, _H2, _P2, allocator_type>&& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ return __table_.__node_handle_merge_multi(__source.__table_);
+ }
+ template <class _H2, class _P2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(unordered_map<key_type, mapped_type, _H2, _P2, allocator_type>& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ return __table_.__node_handle_merge_multi(__source.__table_);
+ }
+ template <class _H2, class _P2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(unordered_map<key_type, mapped_type, _H2, _P2, allocator_type>&& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ return __table_.__node_handle_merge_multi(__source.__table_);
+ }
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(unordered_multimap& __u)
+ _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
+ {__table_.swap(__u.__table_);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ hasher hash_function() const
+ {return __table_.hash_function().hash_function();}
+ _LIBCPP_INLINE_VISIBILITY
+ key_equal key_eq() const
+ {return __table_.key_eq().key_eq();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator find(const key_type& __k) {return __table_.find(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator find(const key_type& __k) const {return __table_.find(__k);}
+#if _LIBCPP_STD_VER > 17
+ template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator find(const _K2& __k) {return __table_.find(__k);}
+ template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator find(const _K2& __k) const {return __table_.find(__k);}
+#endif // _LIBCPP_STD_VER > 17
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
+#if _LIBCPP_STD_VER > 17
+ template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ size_type count(const _K2& __k) const {return __table_.__count_multi(__k);}
+#endif // _LIBCPP_STD_VER > 17
+
+#if _LIBCPP_STD_VER > 17
+ _LIBCPP_INLINE_VISIBILITY
+ bool contains(const key_type& __k) const {return find(__k) != end();}
+
+ template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ bool contains(const _K2& __k) const {return find(__k) != end();}
+#endif // _LIBCPP_STD_VER > 17
+
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, iterator> equal_range(const key_type& __k)
+ {return __table_.__equal_range_multi(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
+ {return __table_.__equal_range_multi(__k);}
+#if _LIBCPP_STD_VER > 17
+ template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, iterator> equal_range(const _K2& __k)
+ {return __table_.__equal_range_multi(__k);}
+ template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<const_iterator, const_iterator> equal_range(const _K2& __k) const
+ {return __table_.__equal_range_multi(__k);}
+#endif // _LIBCPP_STD_VER > 17
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type max_bucket_count() const _NOEXCEPT
+ {return __table_.max_bucket_count();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type bucket_size(size_type __n) const
+ {return __table_.bucket_size(__n);}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ local_iterator begin(size_type __n) {return __table_.begin(__n);}
+ _LIBCPP_INLINE_VISIBILITY
+ local_iterator end(size_type __n) {return __table_.end(__n);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_local_iterator begin(size_type __n) const {return __table_.cbegin(__n);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_local_iterator end(size_type __n) const {return __table_.cend(__n);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_local_iterator cend(size_type __n) const {return __table_.cend(__n);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ float load_factor() const _NOEXCEPT {return __table_.load_factor();}
+ _LIBCPP_INLINE_VISIBILITY
+ float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
+ _LIBCPP_INLINE_VISIBILITY
+ void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
+ _LIBCPP_INLINE_VISIBILITY
+ void rehash(size_type __n) {__table_.rehash(__n);}
+ _LIBCPP_INLINE_VISIBILITY
+ void reserve(size_type __n) {__table_.reserve(__n);}
+
+#if _LIBCPP_DEBUG_LEVEL == 2
+
+ bool __dereferenceable(const const_iterator* __i) const
+ {return __table_.__dereferenceable(_VSTD::addressof(__i->__i_));}
+ bool __decrementable(const const_iterator* __i) const
+ {return __table_.__decrementable(_VSTD::addressof(__i->__i_));}
+ bool __addable(const const_iterator* __i, ptrdiff_t __n) const
+ {return __table_.__addable(_VSTD::addressof(__i->__i_), __n);}
+ bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
+ {return __table_.__addable(_VSTD::addressof(__i->__i_), __n);}
+
+#endif // _LIBCPP_DEBUG_LEVEL == 2
+
+
+};
+
+#if _LIBCPP_STD_VER >= 17
+template<class _InputIterator,
+ class _Hash = hash<__iter_key_type<_InputIterator>>,
+ class _Pred = equal_to<__iter_key_type<_InputIterator>>,
+ class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = enable_if_t<!__is_allocator<_Hash>::value>,
+ class = enable_if_t<!is_integral<_Hash>::value>,
+ class = enable_if_t<!__is_allocator<_Pred>::value>,
+ class = enable_if_t<__is_allocator<_Allocator>::value>>
+unordered_multimap(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type = 0,
+ _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
+ -> unordered_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Hash, _Pred, _Allocator>;
+
+template<class _Key, class _Tp, class _Hash = hash<remove_const_t<_Key>>,
+ class _Pred = equal_to<remove_const_t<_Key>>,
+ class _Allocator = allocator<pair<const _Key, _Tp>>,
+ class = enable_if_t<!__is_allocator<_Hash>::value>,
+ class = enable_if_t<!is_integral<_Hash>::value>,
+ class = enable_if_t<!__is_allocator<_Pred>::value>,
+ class = enable_if_t<__is_allocator<_Allocator>::value>>
+unordered_multimap(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type = 0,
+ _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
+ -> unordered_multimap<remove_const_t<_Key>, _Tp, _Hash, _Pred, _Allocator>;
+
+template<class _InputIterator, class _Allocator,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = enable_if_t<__is_allocator<_Allocator>::value>>
+unordered_multimap(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator)
+ -> unordered_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
+ hash<__iter_key_type<_InputIterator>>, equal_to<__iter_key_type<_InputIterator>>, _Allocator>;
+
+template<class _InputIterator, class _Allocator,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = enable_if_t<__is_allocator<_Allocator>::value>>
+unordered_multimap(_InputIterator, _InputIterator, _Allocator)
+ -> unordered_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
+ hash<__iter_key_type<_InputIterator>>, equal_to<__iter_key_type<_InputIterator>>, _Allocator>;
+
+template<class _InputIterator, class _Hash, class _Allocator,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = enable_if_t<!__is_allocator<_Hash>::value>,
+ class = enable_if_t<!is_integral<_Hash>::value>,
+ class = enable_if_t<__is_allocator<_Allocator>::value>>
+unordered_multimap(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
+ -> unordered_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
+ _Hash, equal_to<__iter_key_type<_InputIterator>>, _Allocator>;
+
+template<class _Key, class _Tp, class _Allocator,
+ class = enable_if_t<__is_allocator<_Allocator>::value>>
+unordered_multimap(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Allocator)
+ -> unordered_multimap<remove_const_t<_Key>, _Tp,
+ hash<remove_const_t<_Key>>,
+ equal_to<remove_const_t<_Key>>, _Allocator>;
+
+template<class _Key, class _Tp, class _Allocator,
+ class = enable_if_t<__is_allocator<_Allocator>::value>>
+unordered_multimap(initializer_list<pair<_Key, _Tp>>, _Allocator)
+ -> unordered_multimap<remove_const_t<_Key>, _Tp,
+ hash<remove_const_t<_Key>>,
+ equal_to<remove_const_t<_Key>>, _Allocator>;
+
+template<class _Key, class _Tp, class _Hash, class _Allocator,
+ class = enable_if_t<!__is_allocator<_Hash>::value>,
+ class = enable_if_t<!is_integral<_Hash>::value>,
+ class = enable_if_t<__is_allocator<_Allocator>::value>>
+unordered_multimap(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
+ -> unordered_multimap<remove_const_t<_Key>, _Tp, _Hash,
+ equal_to<remove_const_t<_Key>>, _Allocator>;
+#endif
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
+ size_type __n, const hasher& __hf, const key_equal& __eql)
+ : __table_(__hf, __eql)
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__n);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
+ size_type __n, const hasher& __hf, const key_equal& __eql,
+ const allocator_type& __a)
+ : __table_(__hf, __eql, typename __table::allocator_type(__a))
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__n);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
+ _InputIterator __first, _InputIterator __last)
+{
+ _VSTD::__debug_db_insert_c(this);
+ insert(__first, __last);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
+ _InputIterator __first, _InputIterator __last, size_type __n,
+ const hasher& __hf, const key_equal& __eql)
+ : __table_(__hf, __eql)
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__n);
+ insert(__first, __last);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
+ _InputIterator __first, _InputIterator __last, size_type __n,
+ const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
+ : __table_(__hf, __eql, typename __table::allocator_type(__a))
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__n);
+ insert(__first, __last);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+inline
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
+ const allocator_type& __a)
+ : __table_(typename __table::allocator_type(__a))
+{
+ _VSTD::__debug_db_insert_c(this);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
+ const unordered_multimap& __u)
+ : __table_(__u.__table_)
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__u.bucket_count());
+ insert(__u.begin(), __u.end());
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
+ const unordered_multimap& __u, const allocator_type& __a)
+ : __table_(__u.__table_, typename __table::allocator_type(__a))
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__u.bucket_count());
+ insert(__u.begin(), __u.end());
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+inline
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
+ unordered_multimap&& __u)
+ _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
+ : __table_(_VSTD::move(__u.__table_))
+{
+ _VSTD::__debug_db_insert_c(this);
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __get_db()->swap(this, _VSTD::addressof(__u));
+#endif
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
+ unordered_multimap&& __u, const allocator_type& __a)
+ : __table_(_VSTD::move(__u.__table_), typename __table::allocator_type(__a))
+{
+ _VSTD::__debug_db_insert_c(this);
+ if (__a != __u.get_allocator())
+ {
+ iterator __i = __u.begin();
+ while (__u.size() != 0)
+ {
+ __table_.__insert_multi(
+ __u.__table_.remove((__i++).__i_)->__value_.__move());
+ }
+ }
+#if _LIBCPP_DEBUG_LEVEL == 2
+ else
+ __get_db()->swap(this, _VSTD::addressof(__u));
+#endif
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
+ initializer_list<value_type> __il)
+{
+ _VSTD::__debug_db_insert_c(this);
+ insert(__il.begin(), __il.end());
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
+ initializer_list<value_type> __il, size_type __n, const hasher& __hf,
+ const key_equal& __eql)
+ : __table_(__hf, __eql)
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__n);
+ insert(__il.begin(), __il.end());
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
+ initializer_list<value_type> __il, size_type __n, const hasher& __hf,
+ const key_equal& __eql, const allocator_type& __a)
+ : __table_(__hf, __eql, typename __table::allocator_type(__a))
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__n);
+ insert(__il.begin(), __il.end());
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+inline
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(unordered_multimap&& __u)
+ _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
+{
+ __table_ = _VSTD::move(__u.__table_);
+ return *this;
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+inline
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(
+ initializer_list<value_type> __il)
+{
+ __table_.__assign_multi(__il.begin(), __il.end());
+ return *this;
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+inline
+void
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
+ _InputIterator __last)
+{
+ for (; __first != __last; ++__first)
+ __table_.__insert_multi(*__first);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
+ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
+ _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+ __x.swap(__y);
+}
+
+#if _LIBCPP_STD_VER > 17
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc,
+ class _Predicate>
+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 _VSTD::__libcpp_erase_if_container(__c, __pred);
+}
+#endif
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+bool
+operator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
+ const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
+{
+ if (__x.size() != __y.size())
+ return false;
+ typedef typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator
+ const_iterator;
+ typedef pair<const_iterator, const_iterator> _EqRng;
+ for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;)
+ {
+ _EqRng __xeq = __x.equal_range(__i->first);
+ _EqRng __yeq = __y.equal_range(__i->first);
+ if (_VSTD::distance(__xeq.first, __xeq.second) !=
+ _VSTD::distance(__yeq.first, __yeq.second) ||
+ !_VSTD::is_permutation(__xeq.first, __xeq.second, __yeq.first))
+ return false;
+ __i = __xeq.second;
+ }
+ return true;
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
+ const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
+{
+ return !(__x == __y);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_UNORDERED_MAP
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/unordered_set b/contrib/libs/cxxsupp/libcxxmsvc/include/unordered_set
new file mode 100644
index 0000000000..2f902cc793
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/unordered_set
@@ -0,0 +1,1807 @@
+// -*- 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_UNORDERED_SET
+#define _LIBCPP_UNORDERED_SET
+
+/*
+
+ unordered_set synopsis
+
+#include <initializer_list>
+
+namespace std
+{
+
+template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+ class Alloc = allocator<Value>>
+class unordered_set
+{
+public:
+ // types
+ typedef Value key_type;
+ typedef key_type value_type;
+ typedef Hash hasher;
+ typedef Pred key_equal;
+ typedef Alloc allocator_type;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef typename allocator_traits<allocator_type>::pointer pointer;
+ typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
+ typedef typename allocator_traits<allocator_type>::size_type size_type;
+ typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+ typedef /unspecified/ iterator;
+ typedef /unspecified/ const_iterator;
+ typedef /unspecified/ local_iterator;
+ typedef /unspecified/ const_local_iterator;
+
+ typedef unspecified node_type unspecified; // C++17
+ typedef INSERT_RETURN_TYPE<iterator, node_type> insert_return_type; // C++17
+
+ unordered_set()
+ noexcept(
+ is_nothrow_default_constructible<hasher>::value &&
+ is_nothrow_default_constructible<key_equal>::value &&
+ is_nothrow_default_constructible<allocator_type>::value);
+ explicit unordered_set(size_type n, const hasher& hf = hasher(),
+ const key_equal& eql = key_equal(),
+ const allocator_type& a = allocator_type());
+ template <class InputIterator>
+ unordered_set(InputIterator f, InputIterator l,
+ size_type n = 0, const hasher& hf = hasher(),
+ const key_equal& eql = key_equal(),
+ const allocator_type& a = allocator_type());
+ explicit unordered_set(const allocator_type&);
+ unordered_set(const unordered_set&);
+ unordered_set(const unordered_set&, const Allocator&);
+ unordered_set(unordered_set&&)
+ noexcept(
+ is_nothrow_move_constructible<hasher>::value &&
+ is_nothrow_move_constructible<key_equal>::value &&
+ is_nothrow_move_constructible<allocator_type>::value);
+ unordered_set(unordered_set&&, const Allocator&);
+ unordered_set(initializer_list<value_type>, size_type n = 0,
+ const hasher& hf = hasher(), const key_equal& eql = key_equal(),
+ const allocator_type& a = allocator_type());
+ unordered_set(size_type n, const allocator_type& a); // C++14
+ unordered_set(size_type n, const hasher& hf, const allocator_type& a); // C++14
+ template <class InputIterator>
+ unordered_set(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14
+ template <class InputIterator>
+ unordered_set(InputIterator f, InputIterator l, size_type n,
+ const hasher& hf, const allocator_type& a); // C++14
+ unordered_set(initializer_list<value_type> il, size_type n, const allocator_type& a); // C++14
+ unordered_set(initializer_list<value_type> il, size_type n,
+ const hasher& hf, const allocator_type& a); // C++14
+ ~unordered_set();
+ unordered_set& operator=(const unordered_set&);
+ unordered_set& operator=(unordered_set&&)
+ noexcept(
+ allocator_type::propagate_on_container_move_assignment::value &&
+ is_nothrow_move_assignable<allocator_type>::value &&
+ is_nothrow_move_assignable<hasher>::value &&
+ is_nothrow_move_assignable<key_equal>::value);
+ unordered_set& operator=(initializer_list<value_type>);
+
+ allocator_type get_allocator() const noexcept;
+
+ bool empty() const noexcept;
+ size_type size() const noexcept;
+ size_type max_size() const noexcept;
+
+ iterator begin() noexcept;
+ iterator end() noexcept;
+ const_iterator begin() const noexcept;
+ const_iterator end() const noexcept;
+ const_iterator cbegin() const noexcept;
+ const_iterator cend() const noexcept;
+
+ template <class... Args>
+ pair<iterator, bool> emplace(Args&&... args);
+ template <class... Args>
+ iterator emplace_hint(const_iterator position, Args&&... args);
+ pair<iterator, bool> insert(const value_type& obj);
+ pair<iterator, bool> insert(value_type&& obj);
+ iterator insert(const_iterator hint, const value_type& obj);
+ iterator insert(const_iterator hint, value_type&& obj);
+ template <class InputIterator>
+ void insert(InputIterator first, InputIterator last);
+ void insert(initializer_list<value_type>);
+
+ node_type extract(const_iterator position); // C++17
+ node_type extract(const key_type& x); // C++17
+ insert_return_type insert(node_type&& nh); // C++17
+ iterator insert(const_iterator hint, node_type&& nh); // C++17
+
+ iterator erase(const_iterator position);
+ iterator erase(iterator position); // C++14
+ size_type erase(const key_type& k);
+ iterator erase(const_iterator first, const_iterator last);
+ void clear() noexcept;
+
+ template<class H2, class P2>
+ void merge(unordered_set<Key, H2, P2, Allocator>& source); // C++17
+ template<class H2, class P2>
+ void merge(unordered_set<Key, H2, P2, Allocator>&& source); // C++17
+ template<class H2, class P2>
+ void merge(unordered_multiset<Key, H2, P2, Allocator>& source); // C++17
+ template<class H2, class P2>
+ void merge(unordered_multiset<Key, H2, P2, Allocator>&& source); // C++17
+
+ void swap(unordered_set&)
+ noexcept(allocator_traits<Allocator>::is_always_equal::value &&
+ noexcept(swap(declval<hasher&>(), declval<hasher&>())) &&
+ noexcept(swap(declval<key_equal&>(), declval<key_equal&>()))); // C++17
+
+ hasher hash_function() const;
+ key_equal key_eq() const;
+
+ iterator find(const key_type& k);
+ const_iterator find(const key_type& k) const;
+ template<typename K>
+ iterator find(const K& x); // C++20
+ template<typename K>
+ const_iterator find(const K& x) const; // C++20
+ size_type count(const key_type& k) const;
+ template<typename K>
+ size_type count(const K& k) const; // C++20
+ bool contains(const key_type& k) const; // C++20
+ template<typename K>
+ bool contains(const K& k) const; // C++20
+ pair<iterator, iterator> equal_range(const key_type& k);
+ pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+ template<typename K>
+ pair<iterator, iterator> equal_range(const K& k); // C++20
+ template<typename K>
+ pair<const_iterator, const_iterator> equal_range(const K& k) const; // C++20
+
+ size_type bucket_count() const noexcept;
+ size_type max_bucket_count() const noexcept;
+
+ size_type bucket_size(size_type n) const;
+ size_type bucket(const key_type& k) const;
+
+ local_iterator begin(size_type n);
+ local_iterator end(size_type n);
+ const_local_iterator begin(size_type n) const;
+ const_local_iterator end(size_type n) const;
+ const_local_iterator cbegin(size_type n) const;
+ const_local_iterator cend(size_type n) const;
+
+ float load_factor() const noexcept;
+ float max_load_factor() const noexcept;
+ void max_load_factor(float z);
+ void rehash(size_type n);
+ void reserve(size_type n);
+};
+
+template<class InputIterator,
+ class Hash = hash<typename iterator_traits<InputIterator>::value_type>,
+ class Pred = equal_to<typename iterator_traits<InputIterator>::value_type>,
+ class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
+unordered_set(InputIterator, InputIterator, typename see below::size_type = see below,
+ Hash = Hash(), Pred = Pred(), Allocator = Allocator())
+ -> unordered_set<typename iterator_traits<InputIterator>::value_type,
+ Hash, Pred, Allocator>; // C++17
+
+template<class T, class Hash = hash<T>,
+ class Pred = equal_to<T>, class Allocator = allocator<T>>
+unordered_set(initializer_list<T>, typename see below::size_type = see below,
+ Hash = Hash(), Pred = Pred(), Allocator = Allocator())
+ -> unordered_set<T, Hash, Pred, Allocator>; // C++17
+
+template<class InputIterator, class Allocator>
+unordered_set(InputIterator, InputIterator, typename see below::size_type, Allocator)
+ -> unordered_set<typename iterator_traits<InputIterator>::value_type,
+ hash<typename iterator_traits<InputIterator>::value_type>,
+ equal_to<typename iterator_traits<InputIterator>::value_type>,
+ Allocator>; // C++17
+
+template<class InputIterator, class Hash, class Allocator>
+unordered_set(InputIterator, InputIterator, typename see below::size_type,
+ Hash, Allocator)
+ -> unordered_set<typename iterator_traits<InputIterator>::value_type, Hash,
+ equal_to<typename iterator_traits<InputIterator>::value_type>,
+ Allocator>; // C++17
+
+template<class T, class Allocator>
+unordered_set(initializer_list<T>, typename see below::size_type, Allocator)
+ -> unordered_set<T, hash<T>, equal_to<T>, Allocator>; // C++17
+
+template<class T, class Hash, class Allocator>
+unordered_set(initializer_list<T>, typename see below::size_type, Hash, Allocator)
+ -> unordered_set<T, Hash, equal_to<T>, Allocator>; // C++17
+
+template <class Value, class Hash, class Pred, class Alloc>
+ void swap(unordered_set<Value, Hash, Pred, Alloc>& x,
+ unordered_set<Value, Hash, Pred, Alloc>& y)
+ noexcept(noexcept(x.swap(y)));
+
+template <class Value, class Hash, class Pred, class Alloc>
+ bool
+ operator==(const unordered_set<Value, Hash, Pred, Alloc>& x,
+ const unordered_set<Value, Hash, Pred, Alloc>& y);
+
+template <class Value, class Hash, class Pred, class Alloc>
+ bool
+ operator!=(const unordered_set<Value, Hash, Pred, Alloc>& x,
+ const unordered_set<Value, Hash, Pred, Alloc>& y);
+
+template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+ class Alloc = allocator<Value>>
+class unordered_multiset
+{
+public:
+ // types
+ typedef Value key_type;
+ typedef key_type value_type;
+ typedef Hash hasher;
+ typedef Pred key_equal;
+ typedef Alloc allocator_type;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef typename allocator_traits<allocator_type>::pointer pointer;
+ typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
+ typedef typename allocator_traits<allocator_type>::size_type size_type;
+ typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+ typedef /unspecified/ iterator;
+ typedef /unspecified/ const_iterator;
+ typedef /unspecified/ local_iterator;
+ typedef /unspecified/ const_local_iterator;
+
+ typedef unspecified node_type unspecified; // C++17
+
+ unordered_multiset()
+ noexcept(
+ is_nothrow_default_constructible<hasher>::value &&
+ is_nothrow_default_constructible<key_equal>::value &&
+ is_nothrow_default_constructible<allocator_type>::value);
+ explicit unordered_multiset(size_type n, const hasher& hf = hasher(),
+ const key_equal& eql = key_equal(),
+ const allocator_type& a = allocator_type());
+ template <class InputIterator>
+ unordered_multiset(InputIterator f, InputIterator l,
+ size_type n = 0, const hasher& hf = hasher(),
+ const key_equal& eql = key_equal(),
+ const allocator_type& a = allocator_type());
+ explicit unordered_multiset(const allocator_type&);
+ unordered_multiset(const unordered_multiset&);
+ unordered_multiset(const unordered_multiset&, const Allocator&);
+ unordered_multiset(unordered_multiset&&)
+ noexcept(
+ is_nothrow_move_constructible<hasher>::value &&
+ is_nothrow_move_constructible<key_equal>::value &&
+ is_nothrow_move_constructible<allocator_type>::value);
+ unordered_multiset(unordered_multiset&&, const Allocator&);
+ unordered_multiset(initializer_list<value_type>, size_type n = /see below/,
+ const hasher& hf = hasher(), const key_equal& eql = key_equal(),
+ const allocator_type& a = allocator_type());
+ unordered_multiset(size_type n, const allocator_type& a); // C++14
+ unordered_multiset(size_type n, const hasher& hf, const allocator_type& a); // C++14
+ template <class InputIterator>
+ unordered_multiset(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14
+ template <class InputIterator>
+ unordered_multiset(InputIterator f, InputIterator l, size_type n,
+ const hasher& hf, const allocator_type& a); // C++14
+ unordered_multiset(initializer_list<value_type> il, size_type n, const allocator_type& a); // C++14
+ unordered_multiset(initializer_list<value_type> il, size_type n,
+ const hasher& hf, const allocator_type& a); // C++14
+ ~unordered_multiset();
+ unordered_multiset& operator=(const unordered_multiset&);
+ unordered_multiset& operator=(unordered_multiset&&)
+ noexcept(
+ allocator_type::propagate_on_container_move_assignment::value &&
+ is_nothrow_move_assignable<allocator_type>::value &&
+ is_nothrow_move_assignable<hasher>::value &&
+ is_nothrow_move_assignable<key_equal>::value);
+ unordered_multiset& operator=(initializer_list<value_type>);
+
+ allocator_type get_allocator() const noexcept;
+
+ bool empty() const noexcept;
+ size_type size() const noexcept;
+ size_type max_size() const noexcept;
+
+ iterator begin() noexcept;
+ iterator end() noexcept;
+ const_iterator begin() const noexcept;
+ const_iterator end() const noexcept;
+ const_iterator cbegin() const noexcept;
+ const_iterator cend() const noexcept;
+
+ template <class... Args>
+ iterator emplace(Args&&... args);
+ template <class... Args>
+ iterator emplace_hint(const_iterator position, Args&&... args);
+ iterator insert(const value_type& obj);
+ iterator insert(value_type&& obj);
+ iterator insert(const_iterator hint, const value_type& obj);
+ iterator insert(const_iterator hint, value_type&& obj);
+ template <class InputIterator>
+ void insert(InputIterator first, InputIterator last);
+ void insert(initializer_list<value_type>);
+
+ node_type extract(const_iterator position); // C++17
+ node_type extract(const key_type& x); // C++17
+ iterator insert(node_type&& nh); // C++17
+ iterator insert(const_iterator hint, node_type&& nh); // C++17
+
+ iterator erase(const_iterator position);
+ iterator erase(iterator position); // C++14
+ size_type erase(const key_type& k);
+ iterator erase(const_iterator first, const_iterator last);
+ void clear() noexcept;
+
+ template<class H2, class P2>
+ void merge(unordered_multiset<Key, H2, P2, Allocator>& source); // C++17
+ template<class H2, class P2>
+ void merge(unordered_multiset<Key, H2, P2, Allocator>&& source); // C++17
+ template<class H2, class P2>
+ void merge(unordered_set<Key, H2, P2, Allocator>& source); // C++17
+ template<class H2, class P2>
+ void merge(unordered_set<Key, H2, P2, Allocator>&& source); // C++17
+
+ void swap(unordered_multiset&)
+ noexcept(allocator_traits<Allocator>::is_always_equal::value &&
+ noexcept(swap(declval<hasher&>(), declval<hasher&>())) &&
+ noexcept(swap(declval<key_equal&>(), declval<key_equal&>()))); // C++17
+
+ hasher hash_function() const;
+ key_equal key_eq() const;
+
+ iterator find(const key_type& k);
+ const_iterator find(const key_type& k) const;
+ template<typename K>
+ iterator find(const K& x); // C++20
+ template<typename K>
+ const_iterator find(const K& x) const; // C++20
+ size_type count(const key_type& k) const;
+ template<typename K>
+ size_type count(const K& k) const; // C++20
+ bool contains(const key_type& k) const; // C++20
+ template<typename K>
+ bool contains(const K& k) const; // C++20
+ pair<iterator, iterator> equal_range(const key_type& k);
+ pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+ template<typename K>
+ pair<iterator, iterator> equal_range(const K& k); // C++20
+ template<typename K>
+ pair<const_iterator, const_iterator> equal_range(const K& k) const; // C++20
+
+ size_type bucket_count() const noexcept;
+ size_type max_bucket_count() const noexcept;
+
+ size_type bucket_size(size_type n) const;
+ size_type bucket(const key_type& k) const;
+
+ local_iterator begin(size_type n);
+ local_iterator end(size_type n);
+ const_local_iterator begin(size_type n) const;
+ const_local_iterator end(size_type n) const;
+ const_local_iterator cbegin(size_type n) const;
+ const_local_iterator cend(size_type n) const;
+
+ float load_factor() const noexcept;
+ float max_load_factor() const noexcept;
+ void max_load_factor(float z);
+ void rehash(size_type n);
+ void reserve(size_type n);
+};
+
+template<class InputIterator,
+ class Hash = hash<typename iterator_traits<InputIterator>::value_type>,
+ class Pred = equal_to<typename iterator_traits<InputIterator>::value_type>,
+ class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
+unordered_multiset(InputIterator, InputIterator, see below::size_type = see below,
+ Hash = Hash(), Pred = Pred(), Allocator = Allocator())
+ -> unordered_multiset<typename iterator_traits<InputIterator>::value_type,
+ Hash, Pred, Allocator>; // C++17
+
+template<class T, class Hash = hash<T>,
+ class Pred = equal_to<T>, class Allocator = allocator<T>>
+unordered_multiset(initializer_list<T>, typename see below::size_type = see below,
+ Hash = Hash(), Pred = Pred(), Allocator = Allocator())
+ -> unordered_multiset<T, Hash, Pred, Allocator>; // C++17
+
+template<class InputIterator, class Allocator>
+unordered_multiset(InputIterator, InputIterator, typename see below::size_type, Allocator)
+ -> unordered_multiset<typename iterator_traits<InputIterator>::value_type,
+ hash<typename iterator_traits<InputIterator>::value_type>,
+ equal_to<typename iterator_traits<InputIterator>::value_type>,
+ Allocator>; // C++17
+
+template<class InputIterator, class Hash, class Allocator>
+unordered_multiset(InputIterator, InputIterator, typename see below::size_type,
+ Hash, Allocator)
+ -> unordered_multiset<typename iterator_traits<InputIterator>::value_type, Hash,
+ equal_to<typename iterator_traits<InputIterator>::value_type>, Allocator>; // C++17
+
+template<class T, class Allocator>
+unordered_multiset(initializer_list<T>, typename see below::size_type, Allocator)
+ -> unordered_multiset<T, hash<T>, equal_to<T>, Allocator>; // C++17
+
+template<class T, class Hash, class Allocator>
+unordered_multiset(initializer_list<T>, typename see below::size_type, Hash, Allocator)
+ -> unordered_multiset<T, Hash, equal_to<T>, Allocator>; // C++17
+
+template <class Value, class Hash, class Pred, class Alloc>
+ void swap(unordered_multiset<Value, Hash, Pred, Alloc>& x,
+ unordered_multiset<Value, Hash, Pred, Alloc>& y)
+ noexcept(noexcept(x.swap(y)));
+
+template <class K, class T, class H, class P, class A, class Predicate>
+ typename unordered_set<K, T, H, P, A>::size_type
+ erase_if(unordered_set<K, T, H, P, A>& c, Predicate pred); // C++20
+
+template <class K, class T, class H, class P, class A, class Predicate>
+ typename unordered_multiset<K, T, H, P, A>::size_type
+ erase_if(unordered_multiset<K, T, H, P, A>& c, Predicate pred); // C++20
+
+
+template <class Value, class Hash, class Pred, class Alloc>
+ bool
+ operator==(const unordered_multiset<Value, Hash, Pred, Alloc>& x,
+ const unordered_multiset<Value, Hash, Pred, Alloc>& y);
+
+template <class Value, class Hash, class Pred, class Alloc>
+ bool
+ operator!=(const unordered_multiset<Value, Hash, Pred, Alloc>& x,
+ const unordered_multiset<Value, Hash, Pred, Alloc>& y);
+} // std
+
+*/
+
+#include <__algorithm/is_permutation.h>
+#include <__assert>
+#include <__config>
+#include <__debug>
+#include <__functional/is_transparent.h>
+#include <__hash_table>
+#include <__memory/addressof.h>
+#include <__node_handle>
+#include <__utility/forward.h>
+#include <compare>
+#include <functional>
+#include <iterator> // __libcpp_erase_if_container
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+class unordered_multiset;
+
+template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>,
+ class _Alloc = allocator<_Value> >
+class _LIBCPP_TEMPLATE_VIS unordered_set
+{
+public:
+ // types
+ typedef _Value key_type;
+ typedef key_type value_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),
+ "Invalid allocator::value_type");
+
+private:
+ typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
+
+ __table __table_;
+
+public:
+ typedef typename __table::pointer pointer;
+ typedef typename __table::const_pointer const_pointer;
+ typedef typename __table::size_type size_type;
+ typedef typename __table::difference_type difference_type;
+
+ typedef typename __table::const_iterator iterator;
+ typedef typename __table::const_iterator const_iterator;
+ typedef typename __table::const_local_iterator local_iterator;
+ typedef typename __table::const_local_iterator const_local_iterator;
+
+#if _LIBCPP_STD_VER > 14
+ typedef __set_node_handle<typename __table::__node, allocator_type> node_type;
+ typedef __insert_return_type<iterator, node_type> insert_return_type;
+#endif
+
+ template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
+ friend class _LIBCPP_TEMPLATE_VIS unordered_set;
+ template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
+ friend class _LIBCPP_TEMPLATE_VIS unordered_multiset;
+
+ _LIBCPP_INLINE_VISIBILITY
+ unordered_set()
+ _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
+ {
+ _VSTD::__debug_db_insert_c(this);
+ }
+ explicit unordered_set(size_type __n, const hasher& __hf = hasher(),
+ const key_equal& __eql = key_equal());
+#if _LIBCPP_STD_VER > 11
+ inline _LIBCPP_INLINE_VISIBILITY
+ unordered_set(size_type __n, const allocator_type& __a)
+ : unordered_set(__n, hasher(), key_equal(), __a) {}
+ inline _LIBCPP_INLINE_VISIBILITY
+ unordered_set(size_type __n, const hasher& __hf, const allocator_type& __a)
+ : unordered_set(__n, __hf, key_equal(), __a) {}
+#endif
+ unordered_set(size_type __n, const hasher& __hf, const key_equal& __eql,
+ const allocator_type& __a);
+ template <class _InputIterator>
+ unordered_set(_InputIterator __first, _InputIterator __last);
+ template <class _InputIterator>
+ unordered_set(_InputIterator __first, _InputIterator __last,
+ size_type __n, const hasher& __hf = hasher(),
+ const key_equal& __eql = key_equal());
+ template <class _InputIterator>
+ unordered_set(_InputIterator __first, _InputIterator __last,
+ size_type __n, const hasher& __hf, const key_equal& __eql,
+ const allocator_type& __a);
+#if _LIBCPP_STD_VER > 11
+ template <class _InputIterator>
+ inline _LIBCPP_INLINE_VISIBILITY
+ unordered_set(_InputIterator __first, _InputIterator __last,
+ size_type __n, const allocator_type& __a)
+ : unordered_set(__first, __last, __n, hasher(), key_equal(), __a) {}
+ template <class _InputIterator>
+ unordered_set(_InputIterator __first, _InputIterator __last,
+ size_type __n, const hasher& __hf, const allocator_type& __a)
+ : unordered_set(__first, __last, __n, __hf, key_equal(), __a) {}
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ explicit unordered_set(const allocator_type& __a);
+ unordered_set(const unordered_set& __u);
+ unordered_set(const unordered_set& __u, const allocator_type& __a);
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ unordered_set(unordered_set&& __u)
+ _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
+ unordered_set(unordered_set&& __u, const allocator_type& __a);
+ unordered_set(initializer_list<value_type> __il);
+ unordered_set(initializer_list<value_type> __il, size_type __n,
+ const hasher& __hf = hasher(),
+ const key_equal& __eql = key_equal());
+ unordered_set(initializer_list<value_type> __il, size_type __n,
+ const hasher& __hf, const key_equal& __eql,
+ const allocator_type& __a);
+#if _LIBCPP_STD_VER > 11
+ inline _LIBCPP_INLINE_VISIBILITY
+ unordered_set(initializer_list<value_type> __il, size_type __n,
+ const allocator_type& __a)
+ : unordered_set(__il, __n, hasher(), key_equal(), __a) {}
+ inline _LIBCPP_INLINE_VISIBILITY
+ unordered_set(initializer_list<value_type> __il, size_type __n,
+ const hasher& __hf, const allocator_type& __a)
+ : unordered_set(__il, __n, __hf, key_equal(), __a) {}
+#endif
+#endif // _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ ~unordered_set() {
+ static_assert(sizeof(__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ unordered_set& operator=(const unordered_set& __u)
+ {
+ __table_ = __u.__table_;
+ return *this;
+ }
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ unordered_set& operator=(unordered_set&& __u)
+ _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
+ _LIBCPP_INLINE_VISIBILITY
+ unordered_set& operator=(initializer_list<value_type> __il);
+#endif // _LIBCPP_CXX03_LANG
+
+ _LIBCPP_INLINE_VISIBILITY
+ allocator_type get_allocator() const _NOEXCEPT
+ {return allocator_type(__table_.__node_alloc());}
+
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+ bool empty() const _NOEXCEPT {return __table_.size() == 0;}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type size() const _NOEXCEPT {return __table_.size();}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type max_size() const _NOEXCEPT {return __table_.max_size();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator begin() _NOEXCEPT {return __table_.begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator end() _NOEXCEPT {return __table_.end();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator begin() const _NOEXCEPT {return __table_.begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator end() const _NOEXCEPT {return __table_.end();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator cend() const _NOEXCEPT {return __table_.end();}
+
+#ifndef _LIBCPP_CXX03_LANG
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool> emplace(_Args&&... __args)
+ {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...);}
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+#if _LIBCPP_DEBUG_LEVEL == 2
+ iterator emplace_hint(const_iterator __p, _Args&&... __args)
+ {
+ _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
+ "unordered_set::emplace_hint(const_iterator, args...) called with an iterator not"
+ " referring to this unordered_set");
+ return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;
+ }
+#else
+ iterator emplace_hint(const_iterator, _Args&&... __args)
+ {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool> insert(value_type&& __x)
+ {return __table_.__insert_unique(_VSTD::move(__x));}
+ _LIBCPP_INLINE_VISIBILITY
+#if _LIBCPP_DEBUG_LEVEL == 2
+ iterator insert(const_iterator __p, value_type&& __x)
+ {
+ _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
+ "unordered_set::insert(const_iterator, value_type&&) called with an iterator not"
+ " referring to this unordered_set");
+ return insert(_VSTD::move(__x)).first;
+ }
+#else
+ iterator insert(const_iterator, value_type&& __x)
+ {return insert(_VSTD::move(__x)).first;}
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ void insert(initializer_list<value_type> __il)
+ {insert(__il.begin(), __il.end());}
+#endif // _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, bool> insert(const value_type& __x)
+ {return __table_.__insert_unique(__x);}
+
+ _LIBCPP_INLINE_VISIBILITY
+#if _LIBCPP_DEBUG_LEVEL == 2
+ iterator insert(const_iterator __p, const value_type& __x)
+ {
+ _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
+ "unordered_set::insert(const_iterator, const value_type&) called with an iterator not"
+ " referring to this unordered_set");
+ return insert(__x).first;
+ }
+#else
+ iterator insert(const_iterator, const value_type& __x)
+ {return insert(__x).first;}
+#endif
+ template <class _InputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ void insert(_InputIterator __first, _InputIterator __last);
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator erase(const_iterator __p) {return __table_.erase(__p);}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator erase(const_iterator __first, const_iterator __last)
+ {return __table_.erase(__first, __last);}
+ _LIBCPP_INLINE_VISIBILITY
+ void clear() _NOEXCEPT {__table_.clear();}
+
+#if _LIBCPP_STD_VER > 14
+ _LIBCPP_INLINE_VISIBILITY
+ insert_return_type insert(node_type&& __nh)
+ {
+ _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
+ "node_type with incompatible allocator passed to unordered_set::insert()");
+ return __table_.template __node_handle_insert_unique<
+ node_type, insert_return_type>(_VSTD::move(__nh));
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const_iterator __h, node_type&& __nh)
+ {
+ _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
+ "node_type with incompatible allocator passed to unordered_set::insert()");
+ return __table_.template __node_handle_insert_unique<node_type>(
+ __h, _VSTD::move(__nh));
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ node_type extract(key_type const& __key)
+ {
+ return __table_.template __node_handle_extract<node_type>(__key);
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ node_type extract(const_iterator __it)
+ {
+ return __table_.template __node_handle_extract<node_type>(__it);
+ }
+
+ template<class _H2, class _P2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(unordered_set<key_type, _H2, _P2, allocator_type>& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ __table_.__node_handle_merge_unique(__source.__table_);
+ }
+ template<class _H2, class _P2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(unordered_set<key_type, _H2, _P2, allocator_type>&& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ __table_.__node_handle_merge_unique(__source.__table_);
+ }
+ template<class _H2, class _P2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ __table_.__node_handle_merge_unique(__source.__table_);
+ }
+ template<class _H2, class _P2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>&& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ __table_.__node_handle_merge_unique(__source.__table_);
+ }
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(unordered_set& __u)
+ _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
+ {__table_.swap(__u.__table_);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ hasher hash_function() const {return __table_.hash_function();}
+ _LIBCPP_INLINE_VISIBILITY
+ key_equal key_eq() const {return __table_.key_eq();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator find(const key_type& __k) {return __table_.find(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator find(const key_type& __k) const {return __table_.find(__k);}
+#if _LIBCPP_STD_VER > 17
+ template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator find(const _K2& __k) {return __table_.find(__k);}
+ template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator find(const _K2& __k) const {return __table_.find(__k);}
+#endif // _LIBCPP_STD_VER > 17
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
+#if _LIBCPP_STD_VER > 17
+ template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ size_type count(const _K2& __k) const {return __table_.__count_unique(__k);}
+#endif // _LIBCPP_STD_VER > 17
+
+#if _LIBCPP_STD_VER > 17
+ _LIBCPP_INLINE_VISIBILITY
+ bool contains(const key_type& __k) const {return find(__k) != end();}
+
+ template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ bool contains(const _K2& __k) const {return find(__k) != end();}
+#endif // _LIBCPP_STD_VER > 17
+
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, iterator> equal_range(const key_type& __k)
+ {return __table_.__equal_range_unique(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
+ {return __table_.__equal_range_unique(__k);}
+#if _LIBCPP_STD_VER > 17
+ template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, iterator> equal_range(const _K2& __k)
+ {return __table_.__equal_range_unique(__k);}
+ template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<const_iterator, const_iterator> equal_range(const _K2& __k) const
+ {return __table_.__equal_range_unique(__k);}
+#endif // _LIBCPP_STD_VER > 17
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type bucket_size(size_type __n) const {return __table_.bucket_size(__n);}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ local_iterator begin(size_type __n) {return __table_.begin(__n);}
+ _LIBCPP_INLINE_VISIBILITY
+ local_iterator end(size_type __n) {return __table_.end(__n);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_local_iterator begin(size_type __n) const {return __table_.cbegin(__n);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_local_iterator end(size_type __n) const {return __table_.cend(__n);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_local_iterator cend(size_type __n) const {return __table_.cend(__n);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ float load_factor() const _NOEXCEPT {return __table_.load_factor();}
+ _LIBCPP_INLINE_VISIBILITY
+ float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
+ _LIBCPP_INLINE_VISIBILITY
+ void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
+ _LIBCPP_INLINE_VISIBILITY
+ void rehash(size_type __n) {__table_.rehash(__n);}
+ _LIBCPP_INLINE_VISIBILITY
+ void reserve(size_type __n) {__table_.reserve(__n);}
+
+#if _LIBCPP_DEBUG_LEVEL == 2
+
+ bool __dereferenceable(const const_iterator* __i) const
+ {return __table_.__dereferenceable(__i);}
+ bool __decrementable(const const_iterator* __i) const
+ {return __table_.__decrementable(__i);}
+ bool __addable(const const_iterator* __i, ptrdiff_t __n) const
+ {return __table_.__addable(__i, __n);}
+ bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
+ {return __table_.__addable(__i, __n);}
+
+#endif // _LIBCPP_DEBUG_LEVEL == 2
+
+};
+
+#if _LIBCPP_STD_VER >= 17
+template<class _InputIterator,
+ class _Hash = hash<__iter_value_type<_InputIterator>>,
+ class _Pred = equal_to<__iter_value_type<_InputIterator>>,
+ class _Allocator = allocator<__iter_value_type<_InputIterator>>,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = enable_if_t<!__is_allocator<_Hash>::value>,
+ class = enable_if_t<!is_integral<_Hash>::value>,
+ class = enable_if_t<!__is_allocator<_Pred>::value>,
+ class = enable_if_t<__is_allocator<_Allocator>::value>>
+unordered_set(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type = 0,
+ _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
+ -> unordered_set<__iter_value_type<_InputIterator>, _Hash, _Pred, _Allocator>;
+
+template<class _Tp, class _Hash = hash<_Tp>,
+ class _Pred = equal_to<_Tp>,
+ class _Allocator = allocator<_Tp>,
+ class = enable_if_t<!__is_allocator<_Hash>::value>,
+ class = enable_if_t<!is_integral<_Hash>::value>,
+ class = enable_if_t<!__is_allocator<_Pred>::value>,
+ class = enable_if_t<__is_allocator<_Allocator>::value>>
+unordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type = 0,
+ _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
+ -> unordered_set<_Tp, _Hash, _Pred, _Allocator>;
+
+template<class _InputIterator, class _Allocator,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = enable_if_t<__is_allocator<_Allocator>::value>>
+unordered_set(_InputIterator, _InputIterator,
+ typename allocator_traits<_Allocator>::size_type, _Allocator)
+ -> unordered_set<__iter_value_type<_InputIterator>,
+ hash<__iter_value_type<_InputIterator>>,
+ equal_to<__iter_value_type<_InputIterator>>,
+ _Allocator>;
+
+template<class _InputIterator, class _Hash, class _Allocator,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = enable_if_t<!__is_allocator<_Hash>::value>,
+ class = enable_if_t<!is_integral<_Hash>::value>,
+ class = enable_if_t<__is_allocator<_Allocator>::value>>
+unordered_set(_InputIterator, _InputIterator,
+ typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
+ -> unordered_set<__iter_value_type<_InputIterator>, _Hash,
+ equal_to<__iter_value_type<_InputIterator>>,
+ _Allocator>;
+
+template<class _Tp, class _Allocator,
+ class = enable_if_t<__is_allocator<_Allocator>::value>>
+unordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Allocator)
+ -> unordered_set<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>;
+
+template<class _Tp, class _Hash, class _Allocator,
+ class = enable_if_t<!__is_allocator<_Hash>::value>,
+ class = enable_if_t<!is_integral<_Hash>::value>,
+ class = enable_if_t<__is_allocator<_Allocator>::value>>
+unordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
+ -> unordered_set<_Tp, _Hash, equal_to<_Tp>, _Allocator>;
+#endif
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,
+ const hasher& __hf, const key_equal& __eql)
+ : __table_(__hf, __eql)
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__n);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,
+ const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
+ : __table_(__hf, __eql, __a)
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__n);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
+ _InputIterator __first, _InputIterator __last)
+{
+ _VSTD::__debug_db_insert_c(this);
+ insert(__first, __last);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
+ _InputIterator __first, _InputIterator __last, size_type __n,
+ const hasher& __hf, const key_equal& __eql)
+ : __table_(__hf, __eql)
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__n);
+ insert(__first, __last);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
+ _InputIterator __first, _InputIterator __last, size_type __n,
+ const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
+ : __table_(__hf, __eql, __a)
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__n);
+ insert(__first, __last);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+inline
+unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
+ const allocator_type& __a)
+ : __table_(__a)
+{
+ _VSTD::__debug_db_insert_c(this);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
+ const unordered_set& __u)
+ : __table_(__u.__table_)
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__u.bucket_count());
+ insert(__u.begin(), __u.end());
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
+ const unordered_set& __u, const allocator_type& __a)
+ : __table_(__u.__table_, __a)
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__u.bucket_count());
+ insert(__u.begin(), __u.end());
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+inline
+unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
+ unordered_set&& __u)
+ _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
+ : __table_(_VSTD::move(__u.__table_))
+{
+ _VSTD::__debug_db_insert_c(this);
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __get_db()->swap(this, _VSTD::addressof(__u));
+#endif
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
+ unordered_set&& __u, const allocator_type& __a)
+ : __table_(_VSTD::move(__u.__table_), __a)
+{
+ _VSTD::__debug_db_insert_c(this);
+ if (__a != __u.get_allocator())
+ {
+ iterator __i = __u.begin();
+ while (__u.size() != 0)
+ __table_.__insert_unique(_VSTD::move(__u.__table_.remove(__i++)->__value_));
+ }
+#if _LIBCPP_DEBUG_LEVEL == 2
+ else
+ __get_db()->swap(this, _VSTD::addressof(__u));
+#endif
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
+ initializer_list<value_type> __il)
+{
+ _VSTD::__debug_db_insert_c(this);
+ insert(__il.begin(), __il.end());
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
+ initializer_list<value_type> __il, size_type __n, const hasher& __hf,
+ const key_equal& __eql)
+ : __table_(__hf, __eql)
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__n);
+ insert(__il.begin(), __il.end());
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
+ initializer_list<value_type> __il, size_type __n, const hasher& __hf,
+ const key_equal& __eql, const allocator_type& __a)
+ : __table_(__hf, __eql, __a)
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__n);
+ insert(__il.begin(), __il.end());
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+inline
+unordered_set<_Value, _Hash, _Pred, _Alloc>&
+unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(unordered_set&& __u)
+ _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
+{
+ __table_ = _VSTD::move(__u.__table_);
+ return *this;
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+inline
+unordered_set<_Value, _Hash, _Pred, _Alloc>&
+unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(
+ initializer_list<value_type> __il)
+{
+ __table_.__assign_unique(__il.begin(), __il.end());
+ return *this;
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+inline
+void
+unordered_set<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
+ _InputIterator __last)
+{
+ for (; __first != __last; ++__first)
+ __table_.__insert_unique(*__first);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
+ unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
+ _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+ __x.swap(__y);
+}
+
+#if _LIBCPP_STD_VER > 17
+template <class _Value, class _Hash, class _Pred, class _Alloc,
+ class _Predicate>
+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 _VSTD::__libcpp_erase_if_container(__c, __pred);
+}
+#endif
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+bool
+operator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
+ const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
+{
+ if (__x.size() != __y.size())
+ return false;
+ typedef typename unordered_set<_Value, _Hash, _Pred, _Alloc>::const_iterator
+ const_iterator;
+ for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end();
+ __i != __ex; ++__i)
+ {
+ const_iterator __j = __y.find(*__i);
+ if (__j == __ey || !(*__i == *__j))
+ return false;
+ }
+ return true;
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
+ const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
+{
+ return !(__x == __y);
+}
+
+template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>,
+ class _Alloc = allocator<_Value> >
+class _LIBCPP_TEMPLATE_VIS unordered_multiset
+{
+public:
+ // types
+ typedef _Value key_type;
+ typedef key_type value_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),
+ "Invalid allocator::value_type");
+
+private:
+ typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
+
+ __table __table_;
+
+public:
+ typedef typename __table::pointer pointer;
+ typedef typename __table::const_pointer const_pointer;
+ typedef typename __table::size_type size_type;
+ typedef typename __table::difference_type difference_type;
+
+ typedef typename __table::const_iterator iterator;
+ typedef typename __table::const_iterator const_iterator;
+ typedef typename __table::const_local_iterator local_iterator;
+ typedef typename __table::const_local_iterator const_local_iterator;
+
+#if _LIBCPP_STD_VER > 14
+ typedef __set_node_handle<typename __table::__node, allocator_type> node_type;
+#endif
+
+ template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
+ friend class _LIBCPP_TEMPLATE_VIS unordered_set;
+ template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
+ friend class _LIBCPP_TEMPLATE_VIS unordered_multiset;
+
+ _LIBCPP_INLINE_VISIBILITY
+ unordered_multiset()
+ _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
+ {
+ _VSTD::__debug_db_insert_c(this);
+ }
+ explicit unordered_multiset(size_type __n, const hasher& __hf = hasher(),
+ const key_equal& __eql = key_equal());
+ unordered_multiset(size_type __n, const hasher& __hf,
+ const key_equal& __eql, const allocator_type& __a);
+#if _LIBCPP_STD_VER > 11
+ inline _LIBCPP_INLINE_VISIBILITY
+ unordered_multiset(size_type __n, const allocator_type& __a)
+ : unordered_multiset(__n, hasher(), key_equal(), __a) {}
+ inline _LIBCPP_INLINE_VISIBILITY
+ unordered_multiset(size_type __n, const hasher& __hf, const allocator_type& __a)
+ : unordered_multiset(__n, __hf, key_equal(), __a) {}
+#endif
+ template <class _InputIterator>
+ unordered_multiset(_InputIterator __first, _InputIterator __last);
+ template <class _InputIterator>
+ unordered_multiset(_InputIterator __first, _InputIterator __last,
+ size_type __n, const hasher& __hf = hasher(),
+ const key_equal& __eql = key_equal());
+ template <class _InputIterator>
+ unordered_multiset(_InputIterator __first, _InputIterator __last,
+ size_type __n , const hasher& __hf,
+ const key_equal& __eql, const allocator_type& __a);
+#if _LIBCPP_STD_VER > 11
+ template <class _InputIterator>
+ inline _LIBCPP_INLINE_VISIBILITY
+ unordered_multiset(_InputIterator __first, _InputIterator __last,
+ size_type __n, const allocator_type& __a)
+ : unordered_multiset(__first, __last, __n, hasher(), key_equal(), __a) {}
+ template <class _InputIterator>
+ inline _LIBCPP_INLINE_VISIBILITY
+ unordered_multiset(_InputIterator __first, _InputIterator __last,
+ size_type __n, const hasher& __hf, const allocator_type& __a)
+ : unordered_multiset(__first, __last, __n, __hf, key_equal(), __a) {}
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ explicit unordered_multiset(const allocator_type& __a);
+ unordered_multiset(const unordered_multiset& __u);
+ unordered_multiset(const unordered_multiset& __u, const allocator_type& __a);
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ unordered_multiset(unordered_multiset&& __u)
+ _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
+ unordered_multiset(unordered_multiset&& __u, const allocator_type& __a);
+ unordered_multiset(initializer_list<value_type> __il);
+ unordered_multiset(initializer_list<value_type> __il, size_type __n,
+ const hasher& __hf = hasher(),
+ const key_equal& __eql = key_equal());
+ unordered_multiset(initializer_list<value_type> __il, size_type __n,
+ const hasher& __hf, const key_equal& __eql,
+ const allocator_type& __a);
+#if _LIBCPP_STD_VER > 11
+ inline _LIBCPP_INLINE_VISIBILITY
+ unordered_multiset(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
+ : unordered_multiset(__il, __n, hasher(), key_equal(), __a) {}
+ inline _LIBCPP_INLINE_VISIBILITY
+ 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
+ _LIBCPP_INLINE_VISIBILITY
+ ~unordered_multiset() {
+ static_assert(sizeof(__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ unordered_multiset& operator=(const unordered_multiset& __u)
+ {
+ __table_ = __u.__table_;
+ return *this;
+ }
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ 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
+
+ _LIBCPP_INLINE_VISIBILITY
+ allocator_type get_allocator() const _NOEXCEPT
+ {return allocator_type(__table_.__node_alloc());}
+
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+ bool empty() const _NOEXCEPT {return __table_.size() == 0;}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type size() const _NOEXCEPT {return __table_.size();}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type max_size() const _NOEXCEPT {return __table_.max_size();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator begin() _NOEXCEPT {return __table_.begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator end() _NOEXCEPT {return __table_.end();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator begin() const _NOEXCEPT {return __table_.begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator end() const _NOEXCEPT {return __table_.end();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator cend() const _NOEXCEPT {return __table_.end();}
+
+#ifndef _LIBCPP_CXX03_LANG
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator emplace(_Args&&... __args)
+ {return __table_.__emplace_multi(_VSTD::forward<_Args>(__args)...);}
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator emplace_hint(const_iterator __p, _Args&&... __args)
+ {return __table_.__emplace_hint_multi(__p, _VSTD::forward<_Args>(__args)...);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(value_type&& __x) {return __table_.__insert_multi(_VSTD::move(__x));}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const_iterator __p, value_type&& __x)
+ {return __table_.__insert_multi(__p, _VSTD::move(__x));}
+ _LIBCPP_INLINE_VISIBILITY
+ void insert(initializer_list<value_type> __il)
+ {insert(__il.begin(), __il.end());}
+#endif // _LIBCPP_CXX03_LANG
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const_iterator __p, const value_type& __x)
+ {return __table_.__insert_multi(__p, __x);}
+
+ template <class _InputIterator>
+ _LIBCPP_INLINE_VISIBILITY
+ void insert(_InputIterator __first, _InputIterator __last);
+
+#if _LIBCPP_STD_VER > 14
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(node_type&& __nh)
+ {
+ _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
+ "node_type with incompatible allocator passed to unordered_multiset::insert()");
+ return __table_.template __node_handle_insert_multi<node_type>(
+ _VSTD::move(__nh));
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const_iterator __hint, node_type&& __nh)
+ {
+ _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
+ "node_type with incompatible allocator passed to unordered_multiset::insert()");
+ return __table_.template __node_handle_insert_multi<node_type>(
+ __hint, _VSTD::move(__nh));
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ node_type extract(const_iterator __position)
+ {
+ return __table_.template __node_handle_extract<node_type>(
+ __position);
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ node_type extract(key_type const& __key)
+ {
+ return __table_.template __node_handle_extract<node_type>(__key);
+ }
+
+ template <class _H2, class _P2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ return __table_.__node_handle_merge_multi(__source.__table_);
+ }
+ template <class _H2, class _P2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>&& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ return __table_.__node_handle_merge_multi(__source.__table_);
+ }
+ template <class _H2, class _P2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(unordered_set<key_type, _H2, _P2, allocator_type>& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ return __table_.__node_handle_merge_multi(__source.__table_);
+ }
+ template <class _H2, class _P2>
+ _LIBCPP_INLINE_VISIBILITY
+ void merge(unordered_set<key_type, _H2, _P2, allocator_type>&& __source)
+ {
+ _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
+ "merging container with incompatible allocator");
+ return __table_.__node_handle_merge_multi(__source.__table_);
+ }
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator erase(const_iterator __p) {return __table_.erase(__p);}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator erase(const_iterator __first, const_iterator __last)
+ {return __table_.erase(__first, __last);}
+ _LIBCPP_INLINE_VISIBILITY
+ void clear() _NOEXCEPT {__table_.clear();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(unordered_multiset& __u)
+ _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
+ {__table_.swap(__u.__table_);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ hasher hash_function() const {return __table_.hash_function();}
+ _LIBCPP_INLINE_VISIBILITY
+ key_equal key_eq() const {return __table_.key_eq();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator find(const key_type& __k) {return __table_.find(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator find(const key_type& __k) const {return __table_.find(__k);}
+#if _LIBCPP_STD_VER > 17
+ template<class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator find(const _K2& __k) {return __table_.find(__k);}
+ template<class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator find(const _K2& __k) const {return __table_.find(__k);}
+#endif // _LIBCPP_STD_VER > 17
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
+#if _LIBCPP_STD_VER > 17
+ template<class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ size_type count(const _K2& __k) const {return __table_.__count_multi(__k);}
+#endif // _LIBCPP_STD_VER > 17
+
+#if _LIBCPP_STD_VER > 17
+ _LIBCPP_INLINE_VISIBILITY
+ bool contains(const key_type& __k) const {return find(__k) != end();}
+
+ template<class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ bool contains(const _K2& __k) const {return find(__k) != end();}
+#endif // _LIBCPP_STD_VER > 17
+
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, iterator> equal_range(const key_type& __k)
+ {return __table_.__equal_range_multi(__k);}
+ _LIBCPP_INLINE_VISIBILITY
+ pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
+ {return __table_.__equal_range_multi(__k);}
+#if _LIBCPP_STD_VER > 17
+ template<class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<iterator, iterator> equal_range(const _K2& __k)
+ {return __table_.__equal_range_multi(__k);}
+ template<class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
+ _LIBCPP_INLINE_VISIBILITY
+ pair<const_iterator, const_iterator> equal_range(const _K2& __k) const
+ {return __table_.__equal_range_multi(__k);}
+#endif // _LIBCPP_STD_VER > 17
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type bucket_size(size_type __n) const {return __table_.bucket_size(__n);}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ local_iterator begin(size_type __n) {return __table_.begin(__n);}
+ _LIBCPP_INLINE_VISIBILITY
+ local_iterator end(size_type __n) {return __table_.end(__n);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_local_iterator begin(size_type __n) const {return __table_.cbegin(__n);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_local_iterator end(size_type __n) const {return __table_.cend(__n);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_local_iterator cend(size_type __n) const {return __table_.cend(__n);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ float load_factor() const _NOEXCEPT {return __table_.load_factor();}
+ _LIBCPP_INLINE_VISIBILITY
+ float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
+ _LIBCPP_INLINE_VISIBILITY
+ void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
+ _LIBCPP_INLINE_VISIBILITY
+ void rehash(size_type __n) {__table_.rehash(__n);}
+ _LIBCPP_INLINE_VISIBILITY
+ void reserve(size_type __n) {__table_.reserve(__n);}
+
+#if _LIBCPP_DEBUG_LEVEL == 2
+
+ bool __dereferenceable(const const_iterator* __i) const
+ {return __table_.__dereferenceable(__i);}
+ bool __decrementable(const const_iterator* __i) const
+ {return __table_.__decrementable(__i);}
+ bool __addable(const const_iterator* __i, ptrdiff_t __n) const
+ {return __table_.__addable(__i, __n);}
+ bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
+ {return __table_.__addable(__i, __n);}
+
+#endif // _LIBCPP_DEBUG_LEVEL == 2
+
+};
+
+#if _LIBCPP_STD_VER >= 17
+template<class _InputIterator,
+ class _Hash = hash<__iter_value_type<_InputIterator>>,
+ class _Pred = equal_to<__iter_value_type<_InputIterator>>,
+ class _Allocator = allocator<__iter_value_type<_InputIterator>>,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = enable_if_t<!__is_allocator<_Hash>::value>,
+ class = enable_if_t<!is_integral<_Hash>::value>,
+ class = enable_if_t<!__is_allocator<_Pred>::value>,
+ class = enable_if_t<__is_allocator<_Allocator>::value>>
+unordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type = 0,
+ _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
+ -> unordered_multiset<__iter_value_type<_InputIterator>, _Hash, _Pred, _Allocator>;
+
+template<class _Tp, class _Hash = hash<_Tp>,
+ class _Pred = equal_to<_Tp>, class _Allocator = allocator<_Tp>,
+ class = enable_if_t<!__is_allocator<_Hash>::value>,
+ class = enable_if_t<!is_integral<_Hash>::value>,
+ class = enable_if_t<!__is_allocator<_Pred>::value>,
+ class = enable_if_t<__is_allocator<_Allocator>::value>>
+unordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type = 0,
+ _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
+ -> unordered_multiset<_Tp, _Hash, _Pred, _Allocator>;
+
+template<class _InputIterator, class _Allocator,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = enable_if_t<__is_allocator<_Allocator>::value>>
+unordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator)
+ -> unordered_multiset<__iter_value_type<_InputIterator>,
+ hash<__iter_value_type<_InputIterator>>,
+ equal_to<__iter_value_type<_InputIterator>>,
+ _Allocator>;
+
+template<class _InputIterator, class _Hash, class _Allocator,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = enable_if_t<!__is_allocator<_Hash>::value>,
+ class = enable_if_t<!is_integral<_Hash>::value>,
+ class = enable_if_t<__is_allocator<_Allocator>::value>>
+unordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type,
+ _Hash, _Allocator)
+ -> unordered_multiset<__iter_value_type<_InputIterator>, _Hash,
+ equal_to<__iter_value_type<_InputIterator>>,
+ _Allocator>;
+
+template<class _Tp, class _Allocator,
+ class = enable_if_t<__is_allocator<_Allocator>::value>>
+unordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Allocator)
+ -> unordered_multiset<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>;
+
+template<class _Tp, class _Hash, class _Allocator,
+ class = enable_if_t<!__is_allocator<_Hash>::value>,
+ class = enable_if_t<!is_integral<_Hash>::value>,
+ class = enable_if_t<__is_allocator<_Allocator>::value>>
+unordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
+ -> unordered_multiset<_Tp, _Hash, equal_to<_Tp>, _Allocator>;
+#endif
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
+ size_type __n, const hasher& __hf, const key_equal& __eql)
+ : __table_(__hf, __eql)
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__n);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
+ size_type __n, const hasher& __hf, const key_equal& __eql,
+ const allocator_type& __a)
+ : __table_(__hf, __eql, __a)
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__n);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
+ _InputIterator __first, _InputIterator __last)
+{
+ _VSTD::__debug_db_insert_c(this);
+ insert(__first, __last);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
+ _InputIterator __first, _InputIterator __last, size_type __n,
+ const hasher& __hf, const key_equal& __eql)
+ : __table_(__hf, __eql)
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__n);
+ insert(__first, __last);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
+ _InputIterator __first, _InputIterator __last, size_type __n,
+ const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
+ : __table_(__hf, __eql, __a)
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__n);
+ insert(__first, __last);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+inline
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
+ const allocator_type& __a)
+ : __table_(__a)
+{
+ _VSTD::__debug_db_insert_c(this);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
+ const unordered_multiset& __u)
+ : __table_(__u.__table_)
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__u.bucket_count());
+ insert(__u.begin(), __u.end());
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
+ const unordered_multiset& __u, const allocator_type& __a)
+ : __table_(__u.__table_, __a)
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__u.bucket_count());
+ insert(__u.begin(), __u.end());
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+inline
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
+ unordered_multiset&& __u)
+ _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
+ : __table_(_VSTD::move(__u.__table_))
+{
+ _VSTD::__debug_db_insert_c(this);
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __get_db()->swap(this, _VSTD::addressof(__u));
+#endif
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
+ unordered_multiset&& __u, const allocator_type& __a)
+ : __table_(_VSTD::move(__u.__table_), __a)
+{
+ _VSTD::__debug_db_insert_c(this);
+ if (__a != __u.get_allocator())
+ {
+ iterator __i = __u.begin();
+ while (__u.size() != 0)
+ __table_.__insert_multi(_VSTD::move(__u.__table_.remove(__i++)->__value_));
+ }
+#if _LIBCPP_DEBUG_LEVEL == 2
+ else
+ __get_db()->swap(this, _VSTD::addressof(__u));
+#endif
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
+ initializer_list<value_type> __il)
+{
+ _VSTD::__debug_db_insert_c(this);
+ insert(__il.begin(), __il.end());
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
+ initializer_list<value_type> __il, size_type __n, const hasher& __hf,
+ const key_equal& __eql)
+ : __table_(__hf, __eql)
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__n);
+ insert(__il.begin(), __il.end());
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
+ initializer_list<value_type> __il, size_type __n, const hasher& __hf,
+ const key_equal& __eql, const allocator_type& __a)
+ : __table_(__hf, __eql, __a)
+{
+ _VSTD::__debug_db_insert_c(this);
+ __table_.rehash(__n);
+ insert(__il.begin(), __il.end());
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+inline
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>&
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(
+ unordered_multiset&& __u)
+ _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
+{
+ __table_ = _VSTD::move(__u.__table_);
+ return *this;
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+inline
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>&
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(
+ initializer_list<value_type> __il)
+{
+ __table_.__assign_multi(__il.begin(), __il.end());
+ return *this;
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+inline
+void
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
+ _InputIterator __last)
+{
+ for (; __first != __last; ++__first)
+ __table_.__insert_multi(*__first);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
+ unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
+ _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+ __x.swap(__y);
+}
+
+#if _LIBCPP_STD_VER > 17
+template <class _Value, class _Hash, class _Pred, class _Alloc,
+ class _Predicate>
+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 _VSTD::__libcpp_erase_if_container(__c, __pred);
+}
+#endif
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+bool
+operator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
+ const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
+{
+ if (__x.size() != __y.size())
+ return false;
+ typedef typename unordered_multiset<_Value, _Hash, _Pred, _Alloc>::const_iterator
+ const_iterator;
+ typedef pair<const_iterator, const_iterator> _EqRng;
+ for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;)
+ {
+ _EqRng __xeq = __x.equal_range(*__i);
+ _EqRng __yeq = __y.equal_range(*__i);
+ if (_VSTD::distance(__xeq.first, __xeq.second) !=
+ _VSTD::distance(__yeq.first, __yeq.second) ||
+ !_VSTD::is_permutation(__xeq.first, __xeq.second, __yeq.first))
+ return false;
+ __i = __xeq.second;
+ }
+ return true;
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
+ const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
+{
+ return !(__x == __y);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_UNORDERED_SET
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/unwind.h b/contrib/libs/cxxsupp/libcxxmsvc/include/unwind.h
new file mode 100644
index 0000000000..c608202230
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/unwind.h
@@ -0,0 +1,7 @@
+#pragma once
+
+#if defined(__IOS__)
+#include_next <unwind.h>
+#else
+#include <contrib/libs/cxxsupp/libcxxrt/unwind.h>
+#endif
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/utility b/contrib/libs/cxxsupp/libcxxmsvc/include/utility
new file mode 100644
index 0000000000..ab19e2bc6f
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/utility
@@ -0,0 +1,251 @@
+// -*- 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
+#define _LIBCPP_UTILITY
+
+/*
+ utility synopsis
+
+#include <initializer_list>
+
+namespace std
+{
+
+template <class T>
+ void
+ swap(T& a, T& b);
+
+namespace rel_ops
+{
+ template<class T> bool operator!=(const T&, const T&);
+ template<class T> bool operator> (const T&, const T&);
+ template<class T> bool operator<=(const T&, const T&);
+ template<class T> bool operator>=(const T&, const T&);
+}
+
+template<class T>
+void
+swap(T& a, T& b) noexcept(is_nothrow_move_constructible<T>::value &&
+ is_nothrow_move_assignable<T>::value);
+
+template <class T, size_t N>
+void
+swap(T (&a)[N], T (&b)[N]) noexcept(noexcept(swap(*a, *b)));
+
+template <class T> T&& forward(typename remove_reference<T>::type& t) noexcept; // constexpr in C++14
+template <class T> T&& forward(typename remove_reference<T>::type&& t) noexcept; // constexpr in C++14
+
+template <class T> typename remove_reference<T>::type&& move(T&&) noexcept; // constexpr in C++14
+
+template <class T>
+ typename conditional
+ <
+ !is_nothrow_move_constructible<T>::value && is_copy_constructible<T>::value,
+ const T&,
+ T&&
+ >::type
+ move_if_noexcept(T& x) noexcept; // constexpr in C++14
+
+template <class T> constexpr add_const_t<T>& as_const(T& t) noexcept; // C++17
+template <class T> void as_const(const T&&) = delete; // C++17
+
+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
+{
+ typedef T1 first_type;
+ typedef T2 second_type;
+
+ T1 first;
+ T2 second;
+
+ pair(const pair&) = default;
+ pair(pair&&) = default;
+ explicit(see-below) constexpr pair();
+ explicit(see-below) pair(const T1& x, const T2& y); // constexpr in C++14
+ template <class U = T1, class V = T2> explicit(see-below) pair(U&&, V&&); // constexpr in C++14
+ template <class U, class V> explicit(see-below) pair(const pair<U, V>& p); // constexpr in C++14
+ 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); // constexpr in C++20
+
+ 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); // 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>); // constexpr in C++20
+};
+
+template<class T1, class T2, class U1, class U2, template<class> class TQual, template<class> class UQual>
+struct basic_common_reference<pair<T1, T2>, pair<U1, U2>, TQual, UQual>; // since C++23
+
+template<class T1, class T2, class U1, class U2>
+struct common_type<pair<T1, T2>, pair<U1, U2>>; // since C++23
+
+template<class T1, class T2> pair(T1, T2) -> pair<T1, T2>;
+
+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, removed in C++20
+template <class T1, class T2> bool operator< (const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14, removed in C++20
+template <class T1, class T2> bool operator> (const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14, removed in C++20
+template <class T1, class T2> bool operator>=(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14, removed in C++20
+template <class T1, class T2> bool operator<=(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14, removed in C++20
+template <class T1, class T2>
+ constexpr common_comparison_type_t<synth-three-way-result<T1>,
+ synth-three-way-result<T2>>
+ operator<=>(const pair<T1,T2>&, const pair<T1,T2>&); // C++20
+
+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))); // constexpr in C++20
+
+struct piecewise_construct_t { explicit piecewise_construct_t() = default; };
+inline constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
+
+template <class T> struct tuple_size;
+template <size_t I, class T> struct tuple_element;
+
+template <class T1, class T2> struct tuple_size<pair<T1, T2> >;
+template <class T1, class T2> struct tuple_element<0, pair<T1, T2> >;
+template <class T1, class T2> struct tuple_element<1, pair<T1, T2> >;
+
+template<size_t I, class T1, class T2>
+ typename tuple_element<I, pair<T1, T2> >::type&
+ get(pair<T1, T2>&) noexcept; // constexpr in C++14
+
+template<size_t I, class T1, class T2>
+ const typename tuple_element<I, pair<T1, T2> >::type&
+ get(const pair<T1, T2>&) noexcept; // constexpr in C++14
+
+template<size_t I, class T1, class T2>
+ typename tuple_element<I, pair<T1, T2> >::type&&
+ get(pair<T1, T2>&&) noexcept; // constexpr in C++14
+
+template<size_t I, class T1, class T2>
+ const typename tuple_element<I, pair<T1, T2> >::type&&
+ get(const pair<T1, T2>&&) noexcept; // constexpr in C++14
+
+template<class T1, class T2>
+ constexpr T1& get(pair<T1, T2>&) noexcept; // C++14
+
+template<class T1, class T2>
+ constexpr const T1& get(const pair<T1, T2>&) noexcept; // C++14
+
+template<class T1, class T2>
+ constexpr T1&& get(pair<T1, T2>&&) noexcept; // C++14
+
+template<class T1, class T2>
+ constexpr const T1&& get(const pair<T1, T2>&&) noexcept; // C++14
+
+template<class T1, class T2>
+ constexpr T1& get(pair<T2, T1>&) noexcept; // C++14
+
+template<class T1, class T2>
+ constexpr const T1& get(const pair<T2, T1>&) noexcept; // C++14
+
+template<class T1, class T2>
+ constexpr T1&& get(pair<T2, T1>&&) noexcept; // C++14
+
+template<class T1, class T2>
+ constexpr const T1&& get(const pair<T2, T1>&&) noexcept; // C++14
+
+// C++14
+
+template<class T, T... I>
+struct integer_sequence
+{
+ typedef T value_type;
+
+ static constexpr size_t size() noexcept;
+};
+
+template<size_t... I>
+ using index_sequence = integer_sequence<size_t, I...>;
+
+template<class T, T N>
+ using make_integer_sequence = integer_sequence<T, 0, 1, ..., N-1>;
+template<size_t N>
+ using make_index_sequence = make_integer_sequence<size_t, N>;
+
+template<class... T>
+ using index_sequence_for = make_index_sequence<sizeof...(T)>;
+
+template<class T, class U=T>
+ constexpr T exchange(T& obj, U&& new_value)
+ noexcept(is_nothrow_move_constructible<T>::value && is_nothrow_assignable<T&, U>::value); // constexpr in C++17, noexcept in C++23
+
+// 20.2.7, in-place construction // C++17
+struct in_place_t {
+ explicit in_place_t() = default;
+};
+inline constexpr in_place_t in_place{};
+template <class T>
+ struct in_place_type_t {
+ explicit in_place_type_t() = default;
+ };
+template <class T>
+ inline constexpr in_place_type_t<T> in_place_type{};
+template <size_t I>
+ struct in_place_index_t {
+ explicit in_place_index_t() = default;
+ };
+template <size_t I>
+ inline constexpr in_place_index_t<I> in_place_index{};
+
+// [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 <__utility/as_const.h>
+#include <__utility/auto_cast.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/priority_tag.h>
+#include <__utility/rel_ops.h>
+#include <__utility/swap.h>
+#include <__utility/to_underlying.h>
+#include <__utility/transaction.h>
+#include <__utility/unreachable.h>
+#include <compare>
+#include <initializer_list>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#endif // _LIBCPP_UTILITY
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/valarray b/contrib/libs/cxxsupp/libcxxmsvc/include/valarray
new file mode 100644
index 0000000000..90740f2e56
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/valarray
@@ -0,0 +1,4943 @@
+// -*- 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_VALARRAY
+#define _LIBCPP_VALARRAY
+
+/*
+ valarray synopsis
+
+namespace std
+{
+
+template<class T>
+class valarray
+{
+public:
+ typedef T value_type;
+
+ // construct/destroy:
+ valarray();
+ explicit valarray(size_t n);
+ valarray(const value_type& x, size_t n);
+ valarray(const value_type* px, size_t n);
+ valarray(const valarray& v);
+ valarray(valarray&& v) noexcept;
+ valarray(const slice_array<value_type>& sa);
+ valarray(const gslice_array<value_type>& ga);
+ valarray(const mask_array<value_type>& ma);
+ valarray(const indirect_array<value_type>& ia);
+ valarray(initializer_list<value_type> il);
+ ~valarray();
+
+ // assignment:
+ valarray& operator=(const valarray& v);
+ valarray& operator=(valarray&& v) noexcept;
+ valarray& operator=(initializer_list<value_type> il);
+ valarray& operator=(const value_type& x);
+ valarray& operator=(const slice_array<value_type>& sa);
+ valarray& operator=(const gslice_array<value_type>& ga);
+ valarray& operator=(const mask_array<value_type>& ma);
+ valarray& operator=(const indirect_array<value_type>& ia);
+
+ // element access:
+ const value_type& operator[](size_t i) const;
+ value_type& operator[](size_t i);
+
+ // subset operations:
+ valarray operator[](slice s) const;
+ slice_array<value_type> operator[](slice s);
+ valarray operator[](const gslice& gs) const;
+ gslice_array<value_type> operator[](const gslice& gs);
+ valarray operator[](const valarray<bool>& vb) const;
+ mask_array<value_type> operator[](const valarray<bool>& vb);
+ valarray operator[](const valarray<size_t>& vs) const;
+ indirect_array<value_type> operator[](const valarray<size_t>& vs);
+
+ // unary operators:
+ valarray operator+() const;
+ valarray operator-() const;
+ valarray operator~() const;
+ valarray<bool> operator!() const;
+
+ // computed assignment:
+ valarray& operator*= (const value_type& x);
+ valarray& operator/= (const value_type& x);
+ valarray& operator%= (const value_type& x);
+ valarray& operator+= (const value_type& x);
+ valarray& operator-= (const value_type& x);
+ valarray& operator^= (const value_type& x);
+ valarray& operator&= (const value_type& x);
+ valarray& operator|= (const value_type& x);
+ valarray& operator<<=(const value_type& x);
+ valarray& operator>>=(const value_type& x);
+
+ valarray& operator*= (const valarray& v);
+ valarray& operator/= (const valarray& v);
+ valarray& operator%= (const valarray& v);
+ valarray& operator+= (const valarray& v);
+ valarray& operator-= (const valarray& v);
+ valarray& operator^= (const valarray& v);
+ valarray& operator|= (const valarray& v);
+ valarray& operator&= (const valarray& v);
+ valarray& operator<<=(const valarray& v);
+ valarray& operator>>=(const valarray& v);
+
+ // member functions:
+ void swap(valarray& v) noexcept;
+
+ size_t size() const;
+
+ value_type sum() const;
+ value_type min() const;
+ value_type max() const;
+
+ valarray shift (int i) const;
+ valarray cshift(int i) const;
+ valarray apply(value_type f(value_type)) const;
+ valarray apply(value_type f(const value_type&)) const;
+ void resize(size_t n, value_type x = value_type());
+};
+
+template<class T, size_t cnt> valarray(const T(&)[cnt], size_t) -> valarray<T>;
+
+class slice
+{
+public:
+ slice();
+ slice(size_t start, size_t size, size_t stride);
+
+ size_t start() const;
+ size_t size() const;
+ size_t stride() const;
+};
+
+template <class T>
+class slice_array
+{
+public:
+ typedef T value_type;
+
+ const slice_array& operator=(const slice_array& sa) const;
+ void operator= (const valarray<value_type>& v) const;
+ void operator*= (const valarray<value_type>& v) const;
+ void operator/= (const valarray<value_type>& v) const;
+ void operator%= (const valarray<value_type>& v) const;
+ void operator+= (const valarray<value_type>& v) const;
+ void operator-= (const valarray<value_type>& v) const;
+ void operator^= (const valarray<value_type>& v) const;
+ void operator&= (const valarray<value_type>& v) const;
+ void operator|= (const valarray<value_type>& v) const;
+ void operator<<=(const valarray<value_type>& v) const;
+ void operator>>=(const valarray<value_type>& v) const;
+
+ void operator=(const value_type& x) const;
+ void operator=(const valarray<T>& val_arr) const;
+
+ slice_array() = delete;
+};
+
+class gslice
+{
+public:
+ gslice();
+ gslice(size_t start, const valarray<size_t>& size,
+ const valarray<size_t>& stride);
+
+ size_t start() const;
+ valarray<size_t> size() const;
+ valarray<size_t> stride() const;
+};
+
+template <class T>
+class gslice_array
+{
+public:
+ typedef T value_type;
+
+ void operator= (const valarray<value_type>& v) const;
+ void operator*= (const valarray<value_type>& v) const;
+ void operator/= (const valarray<value_type>& v) const;
+ void operator%= (const valarray<value_type>& v) const;
+ void operator+= (const valarray<value_type>& v) const;
+ void operator-= (const valarray<value_type>& v) const;
+ void operator^= (const valarray<value_type>& v) const;
+ void operator&= (const valarray<value_type>& v) const;
+ void operator|= (const valarray<value_type>& v) const;
+ void operator<<=(const valarray<value_type>& v) const;
+ void operator>>=(const valarray<value_type>& v) const;
+
+ gslice_array(const gslice_array& ga);
+ ~gslice_array();
+ const gslice_array& operator=(const gslice_array& ga) const;
+ void operator=(const value_type& x) const;
+
+ gslice_array() = delete;
+};
+
+template <class T>
+class mask_array
+{
+public:
+ typedef T value_type;
+
+ void operator= (const valarray<value_type>& v) const;
+ void operator*= (const valarray<value_type>& v) const;
+ void operator/= (const valarray<value_type>& v) const;
+ void operator%= (const valarray<value_type>& v) const;
+ void operator+= (const valarray<value_type>& v) const;
+ void operator-= (const valarray<value_type>& v) const;
+ void operator^= (const valarray<value_type>& v) const;
+ void operator&= (const valarray<value_type>& v) const;
+ void operator|= (const valarray<value_type>& v) const;
+ void operator<<=(const valarray<value_type>& v) const;
+ void operator>>=(const valarray<value_type>& v) const;
+
+ mask_array(const mask_array& ma);
+ ~mask_array();
+ const mask_array& operator=(const mask_array& ma) const;
+ void operator=(const value_type& x) const;
+
+ mask_array() = delete;
+};
+
+template <class T>
+class indirect_array
+{
+public:
+ typedef T value_type;
+
+ void operator= (const valarray<value_type>& v) const;
+ void operator*= (const valarray<value_type>& v) const;
+ void operator/= (const valarray<value_type>& v) const;
+ void operator%= (const valarray<value_type>& v) const;
+ void operator+= (const valarray<value_type>& v) const;
+ void operator-= (const valarray<value_type>& v) const;
+ void operator^= (const valarray<value_type>& v) const;
+ void operator&= (const valarray<value_type>& v) const;
+ void operator|= (const valarray<value_type>& v) const;
+ void operator<<=(const valarray<value_type>& v) const;
+ void operator>>=(const valarray<value_type>& v) const;
+
+ indirect_array(const indirect_array& ia);
+ ~indirect_array();
+ const indirect_array& operator=(const indirect_array& ia) const;
+ void operator=(const value_type& x) const;
+
+ indirect_array() = delete;
+};
+
+template<class T> void swap(valarray<T>& x, valarray<T>& y) noexcept;
+
+template<class T> valarray<T> operator* (const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<T> operator* (const valarray<T>& x, const T& y);
+template<class T> valarray<T> operator* (const T& x, const valarray<T>& y);
+
+template<class T> valarray<T> operator/ (const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<T> operator/ (const valarray<T>& x, const T& y);
+template<class T> valarray<T> operator/ (const T& x, const valarray<T>& y);
+
+template<class T> valarray<T> operator% (const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<T> operator% (const valarray<T>& x, const T& y);
+template<class T> valarray<T> operator% (const T& x, const valarray<T>& y);
+
+template<class T> valarray<T> operator+ (const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<T> operator+ (const valarray<T>& x, const T& y);
+template<class T> valarray<T> operator+ (const T& x, const valarray<T>& y);
+
+template<class T> valarray<T> operator- (const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<T> operator- (const valarray<T>& x, const T& y);
+template<class T> valarray<T> operator- (const T& x, const valarray<T>& y);
+
+template<class T> valarray<T> operator^ (const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<T> operator^ (const valarray<T>& x, const T& y);
+template<class T> valarray<T> operator^ (const T& x, const valarray<T>& y);
+
+template<class T> valarray<T> operator& (const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<T> operator& (const valarray<T>& x, const T& y);
+template<class T> valarray<T> operator& (const T& x, const valarray<T>& y);
+
+template<class T> valarray<T> operator| (const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<T> operator| (const valarray<T>& x, const T& y);
+template<class T> valarray<T> operator| (const T& x, const valarray<T>& y);
+
+template<class T> valarray<T> operator<<(const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<T> operator<<(const valarray<T>& x, const T& y);
+template<class T> valarray<T> operator<<(const T& x, const valarray<T>& y);
+
+template<class T> valarray<T> operator>>(const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<T> operator>>(const valarray<T>& x, const T& y);
+template<class T> valarray<T> operator>>(const T& x, const valarray<T>& y);
+
+template<class T> valarray<bool> operator&&(const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<bool> operator&&(const valarray<T>& x, const T& y);
+template<class T> valarray<bool> operator&&(const T& x, const valarray<T>& y);
+
+template<class T> valarray<bool> operator||(const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<bool> operator||(const valarray<T>& x, const T& y);
+template<class T> valarray<bool> operator||(const T& x, const valarray<T>& y);
+
+template<class T> valarray<bool> operator==(const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<bool> operator==(const valarray<T>& x, const T& y);
+template<class T> valarray<bool> operator==(const T& x, const valarray<T>& y);
+
+template<class T> valarray<bool> operator!=(const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<bool> operator!=(const valarray<T>& x, const T& y);
+template<class T> valarray<bool> operator!=(const T& x, const valarray<T>& y);
+
+template<class T> valarray<bool> operator< (const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<bool> operator< (const valarray<T>& x, const T& y);
+template<class T> valarray<bool> operator< (const T& x, const valarray<T>& y);
+
+template<class T> valarray<bool> operator> (const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<bool> operator> (const valarray<T>& x, const T& y);
+template<class T> valarray<bool> operator> (const T& x, const valarray<T>& y);
+
+template<class T> valarray<bool> operator<=(const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<bool> operator<=(const valarray<T>& x, const T& y);
+template<class T> valarray<bool> operator<=(const T& x, const valarray<T>& y);
+
+template<class T> valarray<bool> operator>=(const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<bool> operator>=(const valarray<T>& x, const T& y);
+template<class T> valarray<bool> operator>=(const T& x, const valarray<T>& y);
+
+template<class T> valarray<T> abs (const valarray<T>& x);
+template<class T> valarray<T> acos (const valarray<T>& x);
+template<class T> valarray<T> asin (const valarray<T>& x);
+template<class T> valarray<T> atan (const valarray<T>& x);
+
+template<class T> valarray<T> atan2(const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<T> atan2(const valarray<T>& x, const T& y);
+template<class T> valarray<T> atan2(const T& x, const valarray<T>& y);
+
+template<class T> valarray<T> cos (const valarray<T>& x);
+template<class T> valarray<T> cosh (const valarray<T>& x);
+template<class T> valarray<T> exp (const valarray<T>& x);
+template<class T> valarray<T> log (const valarray<T>& x);
+template<class T> valarray<T> log10(const valarray<T>& x);
+
+template<class T> valarray<T> pow(const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<T> pow(const valarray<T>& x, const T& y);
+template<class T> valarray<T> pow(const T& x, const valarray<T>& y);
+
+template<class T> valarray<T> sin (const valarray<T>& x);
+template<class T> valarray<T> sinh (const valarray<T>& x);
+template<class T> valarray<T> sqrt (const valarray<T>& x);
+template<class T> valarray<T> tan (const valarray<T>& x);
+template<class T> valarray<T> tanh (const valarray<T>& x);
+
+template <class T> unspecified1 begin(valarray<T>& v);
+template <class T> unspecified2 begin(const valarray<T>& v);
+template <class T> unspecified1 end(valarray<T>& v);
+template <class T> unspecified2 end(const valarray<T>& v);
+
+} // std
+
+*/
+
+#include <__algorithm/copy.h>
+#include <__algorithm/count.h>
+#include <__algorithm/fill.h>
+#include <__algorithm/max_element.h>
+#include <__algorithm/min.h>
+#include <__algorithm/min_element.h>
+#include <__algorithm/unwrap_iter.h>
+#include <__config>
+#include <cmath>
+#include <cstddef>
+#include <functional>
+#include <initializer_list>
+#include <new>
+#include <version>
+
+#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 _LIBCPP_TEMPLATE_VIS valarray;
+
+class _LIBCPP_TEMPLATE_VIS slice
+{
+ size_t __start_;
+ size_t __size_;
+ size_t __stride_;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ slice()
+ : __start_(0),
+ __size_(0),
+ __stride_(0)
+ {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ slice(size_t __start, size_t __size, size_t __stride)
+ : __start_(__start),
+ __size_(__size),
+ __stride_(__stride)
+ {}
+
+ _LIBCPP_INLINE_VISIBILITY size_t start() const {return __start_;}
+ _LIBCPP_INLINE_VISIBILITY size_t size() const {return __size_;}
+ _LIBCPP_INLINE_VISIBILITY size_t stride() const {return __stride_;}
+};
+
+template <class _Tp> class _LIBCPP_TEMPLATE_VIS slice_array;
+class _LIBCPP_TYPE_VIS gslice;
+template <class _Tp> class _LIBCPP_TEMPLATE_VIS gslice_array;
+template <class _Tp> class _LIBCPP_TEMPLATE_VIS mask_array;
+template <class _Tp> class _LIBCPP_TEMPLATE_VIS indirect_array;
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp*
+begin(valarray<_Tp>& __v);
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+const _Tp*
+begin(const valarray<_Tp>& __v);
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp*
+end(valarray<_Tp>& __v);
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+const _Tp*
+end(const valarray<_Tp>& __v);
+
+template <class _Op, class _A0>
+struct _UnaryOp
+{
+ typedef typename _Op::__result_type __result_type;
+ typedef typename decay<__result_type>::type value_type;
+
+ _Op __op_;
+ _A0 __a0_;
+
+ _LIBCPP_INLINE_VISIBILITY
+ _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]);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_t size() const {return __a0_.size();}
+};
+
+template <class _Op, class _A0, class _A1>
+struct _BinaryOp
+{
+ typedef typename _Op::__result_type __result_type;
+ typedef typename decay<__result_type>::type value_type;
+
+ _Op __op_;
+ _A0 __a0_;
+ _A1 __a1_;
+
+ _LIBCPP_INLINE_VISIBILITY
+ _BinaryOp(const _Op& __op, const _A0& __a0, const _A1& __a1)
+ : __op_(__op), __a0_(__a0), __a1_(__a1) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_t size() const {return __a0_.size();}
+};
+
+template <class _Tp>
+class __scalar_expr
+{
+public:
+ typedef _Tp value_type;
+ typedef const _Tp& __result_type;
+private:
+ const value_type& __t_;
+ size_t __s_;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ 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_;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_t size() const {return __s_;}
+};
+
+template <class _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
+{
+ typedef _Tp __result_type;
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp operator()(const _Tp& __x) const
+ {return ~__x;}
+};
+
+template <class _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
+{
+ 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
+{
+private:
+ _Fp __f_;
+public:
+ typedef _Tp __result_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __apply_expr(_Fp __f) : __f_(__f) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp operator()(const _Tp& __x) const
+ {return __f_(__x);}
+};
+
+template <class _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
+{
+ typedef _Tp __result_type;
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp operator()(const _Tp& __x) const
+ {return acos(__x);}
+};
+
+template <class _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
+{
+ typedef _Tp __result_type;
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp operator()(const _Tp& __x) const
+ {return atan(__x);}
+};
+
+template <class _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
+{
+ typedef _Tp __result_type;
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp operator()(const _Tp& __x) const
+ {return cos(__x);}
+};
+
+template <class _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
+{
+ typedef _Tp __result_type;
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp operator()(const _Tp& __x) const
+ {return exp(__x);}
+};
+
+template <class _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
+{
+ typedef _Tp __result_type;
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp operator()(const _Tp& __x) const
+ {return log10(__x);}
+};
+
+template <class _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
+{
+ typedef _Tp __result_type;
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp operator()(const _Tp& __x) const
+ {return sin(__x);}
+};
+
+template <class _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
+{
+ typedef _Tp __result_type;
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp operator()(const _Tp& __x) const
+ {return sqrt(__x);}
+};
+
+template <class _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
+{
+ typedef _Tp __result_type;
+ _LIBCPP_INLINE_VISIBILITY
+ _Tp operator()(const _Tp& __x) const
+ {return tanh(__x);}
+};
+
+template <class _ValExpr>
+class __slice_expr
+{
+ typedef typename remove_reference<_ValExpr>::type _RmExpr;
+public:
+ typedef typename _RmExpr::value_type value_type;
+ typedef value_type __result_type;
+
+private:
+ _ValExpr __expr_;
+ size_t __start_;
+ size_t __size_;
+ size_t __stride_;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __slice_expr(const slice& __sl, const _RmExpr& __e)
+ : __expr_(__e),
+ __start_(__sl.start()),
+ __size_(__sl.size()),
+ __stride_(__sl.stride())
+ {}
+public:
+
+ _LIBCPP_INLINE_VISIBILITY
+ __result_type operator[](size_t __i) const
+ {return __expr_[__start_ + __i * __stride_];}
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_t size() const {return __size_;}
+
+ template <class> friend class __val_expr;
+ template <class> friend class _LIBCPP_TEMPLATE_VIS valarray;
+};
+
+template <class _ValExpr>
+class __mask_expr;
+
+template <class _ValExpr>
+class __indirect_expr;
+
+template <class _ValExpr>
+class __shift_expr
+{
+ typedef typename remove_reference<_ValExpr>::type _RmExpr;
+public:
+ typedef typename _RmExpr::value_type value_type;
+ typedef value_type __result_type;
+
+private:
+ _ValExpr __expr_;
+ size_t __size_;
+ ptrdiff_t __ul_;
+ ptrdiff_t __sn_;
+ ptrdiff_t __n_;
+ static const ptrdiff_t _Np = static_cast<ptrdiff_t>(
+ sizeof(ptrdiff_t) * __CHAR_BIT__ - 1);
+
+ _LIBCPP_INLINE_VISIBILITY
+ __shift_expr(int __n, const _RmExpr& __e)
+ : __expr_(__e),
+ __size_(__e.size()),
+ __n_(__n)
+ {
+ ptrdiff_t __neg_n = static_cast<ptrdiff_t>(__n_ >> _Np);
+ __sn_ = __neg_n | static_cast<ptrdiff_t>(static_cast<size_t>(-__n_) >> _Np);
+ __ul_ = ((__size_ - __n_) & ~__neg_n) | ((__n_ + 1) & __neg_n);
+ }
+public:
+
+ _LIBCPP_INLINE_VISIBILITY
+ __result_type operator[](size_t __j) const
+ {
+ ptrdiff_t __i = static_cast<ptrdiff_t>(__j);
+ ptrdiff_t __m = (__sn_ * __i - __ul_) >> _Np;
+ return (__expr_[(__i + __n_) & __m] & __m) | (value_type() & ~__m);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_t size() const {return __size_;}
+
+ template <class> friend class __val_expr;
+};
+
+template <class _ValExpr>
+class __cshift_expr
+{
+ typedef typename remove_reference<_ValExpr>::type _RmExpr;
+public:
+ typedef typename _RmExpr::value_type value_type;
+ typedef value_type __result_type;
+
+private:
+ _ValExpr __expr_;
+ size_t __size_;
+ size_t __m_;
+ size_t __o1_;
+ size_t __o2_;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __cshift_expr(int __n, const _RmExpr& __e)
+ : __expr_(__e),
+ __size_(__e.size())
+ {
+ __n %= static_cast<int>(__size_);
+ if (__n >= 0)
+ {
+ __m_ = __size_ - __n;
+ __o1_ = __n;
+ __o2_ = __n - __size_;
+ }
+ else
+ {
+ __m_ = -__n;
+ __o1_ = __n + __size_;
+ __o2_ = __n;
+ }
+ }
+public:
+
+ _LIBCPP_INLINE_VISIBILITY
+ __result_type operator[](size_t __i) const
+ {
+ if (__i < __m_)
+ return __expr_[__i + __o1_];
+ return __expr_[__i + __o2_];
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_t size() const {return __size_;}
+
+ template <class> friend class __val_expr;
+};
+
+template<class _ValExpr>
+class __val_expr;
+
+template<class _ValExpr>
+struct __is_val_expr : false_type {};
+
+template<class _ValExpr>
+struct __is_val_expr<__val_expr<_ValExpr> > : true_type {};
+
+template<class _Tp>
+struct __is_val_expr<valarray<_Tp> > : true_type {};
+
+template<class _Tp>
+class _LIBCPP_TEMPLATE_VIS valarray
+{
+public:
+ typedef _Tp value_type;
+ typedef _Tp __result_type;
+
+private:
+ value_type* __begin_;
+ value_type* __end_;
+
+public:
+ // construct/destroy:
+ _LIBCPP_INLINE_VISIBILITY
+ valarray() : __begin_(nullptr), __end_(nullptr) {}
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ explicit valarray(size_t __n);
+ _LIBCPP_INLINE_VISIBILITY
+ valarray(const value_type& __x, size_t __n);
+ valarray(const value_type* __p, size_t __n);
+ valarray(const valarray& __v);
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ valarray(valarray&& __v) _NOEXCEPT;
+ valarray(initializer_list<value_type> __il);
+#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);
+ valarray(const indirect_array<value_type>& __ia);
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ ~valarray();
+
+ // assignment:
+ valarray& operator=(const valarray& __v);
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ valarray& operator=(valarray&& __v) _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ valarray& operator=(initializer_list<value_type>);
+#endif // _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ valarray& operator=(const value_type& __x);
+ _LIBCPP_INLINE_VISIBILITY
+ valarray& operator=(const slice_array<value_type>& __sa);
+ _LIBCPP_INLINE_VISIBILITY
+ valarray& operator=(const gslice_array<value_type>& __ga);
+ _LIBCPP_INLINE_VISIBILITY
+ valarray& operator=(const mask_array<value_type>& __ma);
+ _LIBCPP_INLINE_VISIBILITY
+ valarray& operator=(const indirect_array<value_type>& __ia);
+ template <class _ValExpr>
+ _LIBCPP_INLINE_VISIBILITY
+ valarray& operator=(const __val_expr<_ValExpr>& __v);
+
+ // element access:
+ _LIBCPP_INLINE_VISIBILITY
+ const value_type& operator[](size_t __i) const {return __begin_[__i];}
+
+ _LIBCPP_INLINE_VISIBILITY
+ value_type& operator[](size_t __i) {return __begin_[__i];}
+
+ // subset operations:
+ _LIBCPP_INLINE_VISIBILITY
+ __val_expr<__slice_expr<const valarray&> > operator[](slice __s) const;
+ _LIBCPP_INLINE_VISIBILITY
+ slice_array<value_type> operator[](slice __s);
+ _LIBCPP_INLINE_VISIBILITY
+ __val_expr<__indirect_expr<const valarray&> > operator[](const gslice& __gs) const;
+ _LIBCPP_INLINE_VISIBILITY
+ gslice_array<value_type> operator[](const gslice& __gs);
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ __val_expr<__indirect_expr<const valarray&> > operator[](gslice&& __gs) const;
+ _LIBCPP_INLINE_VISIBILITY
+ gslice_array<value_type> operator[](gslice&& __gs);
+#endif // _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ __val_expr<__mask_expr<const valarray&> > operator[](const valarray<bool>& __vb) const;
+ _LIBCPP_INLINE_VISIBILITY
+ mask_array<value_type> operator[](const valarray<bool>& __vb);
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ __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
+ _LIBCPP_INLINE_VISIBILITY
+ __val_expr<__indirect_expr<const valarray&> > operator[](const valarray<size_t>& __vs) const;
+ _LIBCPP_INLINE_VISIBILITY
+ indirect_array<value_type> operator[](const valarray<size_t>& __vs);
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ __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
+
+ // unary operators:
+ valarray operator+() const;
+ valarray operator-() const;
+ valarray operator~() const;
+ valarray<bool> operator!() const;
+
+ // computed assignment:
+ _LIBCPP_INLINE_VISIBILITY
+ valarray& operator*= (const value_type& __x);
+ _LIBCPP_INLINE_VISIBILITY
+ valarray& operator/= (const value_type& __x);
+ _LIBCPP_INLINE_VISIBILITY
+ valarray& operator%= (const value_type& __x);
+ _LIBCPP_INLINE_VISIBILITY
+ valarray& operator+= (const value_type& __x);
+ _LIBCPP_INLINE_VISIBILITY
+ valarray& operator-= (const value_type& __x);
+ _LIBCPP_INLINE_VISIBILITY
+ valarray& operator^= (const value_type& __x);
+ _LIBCPP_INLINE_VISIBILITY
+ valarray& operator&= (const value_type& __x);
+ _LIBCPP_INLINE_VISIBILITY
+ valarray& operator|= (const value_type& __x);
+ _LIBCPP_INLINE_VISIBILITY
+ valarray& operator<<=(const value_type& __x);
+ _LIBCPP_INLINE_VISIBILITY
+ valarray& operator>>=(const value_type& __x);
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ valarray&
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator*= (const _Expr& __v);
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ valarray&
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator/= (const _Expr& __v);
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ valarray&
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator%= (const _Expr& __v);
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ valarray&
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator+= (const _Expr& __v);
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ valarray&
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator-= (const _Expr& __v);
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ valarray&
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator^= (const _Expr& __v);
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ valarray&
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator|= (const _Expr& __v);
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ valarray&
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator&= (const _Expr& __v);
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ valarray&
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator<<= (const _Expr& __v);
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ valarray&
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator>>= (const _Expr& __v);
+
+ // member functions:
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(valarray& __v) _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_t size() const {return static_cast<size_t>(__end_ - __begin_);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ value_type sum() const;
+ _LIBCPP_INLINE_VISIBILITY
+ value_type min() const;
+ _LIBCPP_INLINE_VISIBILITY
+ value_type max() const;
+
+ valarray shift (int __i) const;
+ valarray cshift(int __i) const;
+ valarray apply(value_type __f(value_type)) const;
+ valarray apply(value_type __f(const value_type&)) const;
+ void resize(size_t __n, value_type __x = value_type());
+
+private:
+ template <class> friend class _LIBCPP_TEMPLATE_VIS valarray;
+ template <class> friend class _LIBCPP_TEMPLATE_VIS slice_array;
+ template <class> friend class _LIBCPP_TEMPLATE_VIS gslice_array;
+ template <class> friend class _LIBCPP_TEMPLATE_VIS mask_array;
+ template <class> friend class __mask_expr;
+ template <class> friend class _LIBCPP_TEMPLATE_VIS indirect_array;
+ template <class> friend class __indirect_expr;
+ template <class> friend class __val_expr;
+
+ template <class _Up>
+ friend
+ _Up*
+ begin(valarray<_Up>& __v);
+
+ template <class _Up>
+ friend
+ const _Up*
+ begin(const valarray<_Up>& __v);
+
+ template <class _Up>
+ friend
+ _Up*
+ end(valarray<_Up>& __v);
+
+ template <class _Up>
+ friend
+ const _Up*
+ end(const valarray<_Up>& __v);
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __clear(size_t __capacity);
+ valarray& __assign_range(const value_type* __f, const value_type* __l);
+};
+
+#if _LIBCPP_STD_VER > 14
+template<class _Tp, size_t _Size>
+valarray(const _Tp(&)[_Size], size_t) -> valarray<_Tp>;
+#endif
+
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void valarray<size_t>::resize(size_t, size_t))
+
+template <class _Op, class _Tp>
+struct _UnaryOp<_Op, valarray<_Tp> >
+{
+ typedef typename _Op::__result_type __result_type;
+ typedef typename decay<__result_type>::type value_type;
+
+ _Op __op_;
+ const valarray<_Tp>& __a0_;
+
+ _LIBCPP_INLINE_VISIBILITY
+ _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]);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_t size() const {return __a0_.size();}
+};
+
+template <class _Op, class _Tp, class _A1>
+struct _BinaryOp<_Op, valarray<_Tp>, _A1>
+{
+ typedef typename _Op::__result_type __result_type;
+ typedef typename decay<__result_type>::type value_type;
+
+ _Op __op_;
+ const valarray<_Tp>& __a0_;
+ _A1 __a1_;
+
+ _LIBCPP_INLINE_VISIBILITY
+ _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const _A1& __a1)
+ : __op_(__op), __a0_(__a0), __a1_(__a1) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_t size() const {return __a0_.size();}
+};
+
+template <class _Op, class _A0, class _Tp>
+struct _BinaryOp<_Op, _A0, valarray<_Tp> >
+{
+ typedef typename _Op::__result_type __result_type;
+ typedef typename decay<__result_type>::type value_type;
+
+ _Op __op_;
+ _A0 __a0_;
+ const valarray<_Tp>& __a1_;
+
+ _LIBCPP_INLINE_VISIBILITY
+ _BinaryOp(const _Op& __op, const _A0& __a0, const valarray<_Tp>& __a1)
+ : __op_(__op), __a0_(__a0), __a1_(__a1) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_t size() const {return __a0_.size();}
+};
+
+template <class _Op, class _Tp>
+struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> >
+{
+ typedef typename _Op::__result_type __result_type;
+ typedef typename decay<__result_type>::type value_type;
+
+ _Op __op_;
+ const valarray<_Tp>& __a0_;
+ const valarray<_Tp>& __a1_;
+
+ _LIBCPP_INLINE_VISIBILITY
+ _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const valarray<_Tp>& __a1)
+ : __op_(__op), __a0_(__a0), __a1_(__a1) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_t size() const {return __a0_.size();}
+};
+
+// slice_array
+
+template <class _Tp>
+class _LIBCPP_TEMPLATE_VIS slice_array
+{
+public:
+ typedef _Tp value_type;
+
+private:
+ value_type* __vp_;
+ size_t __size_;
+ size_t __stride_;
+
+public:
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator*=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator/=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator%=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator+=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator-=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator^=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator&=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator|=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator<<=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator>>=(const _Expr& __v) const;
+
+ slice_array(slice_array const&) = default;
+
+ _LIBCPP_INLINE_VISIBILITY
+ const slice_array& operator=(const slice_array& __sa) const;
+
+ _LIBCPP_INLINE_VISIBILITY
+ void operator=(const value_type& __x) const;
+
+ _LIBCPP_INLINE_VISIBILITY
+ void operator=(const valarray<value_type>& __va) const;
+
+private:
+ _LIBCPP_INLINE_VISIBILITY
+ slice_array(const slice& __sl, const valarray<value_type>& __v)
+ : __vp_(const_cast<value_type*>(__v.__begin_ + __sl.start())),
+ __size_(__sl.size()),
+ __stride_(__sl.stride())
+ {}
+
+ template <class> friend class valarray;
+ template <class> friend class sliceExpr;
+};
+
+template <class _Tp>
+inline
+const slice_array<_Tp>&
+slice_array<_Tp>::operator=(const slice_array& __sa) const
+{
+ value_type* __t = __vp_;
+ const value_type* __s = __sa.__vp_;
+ for (size_t __n = __size_; __n; --__n, __t += __stride_, __s += __sa.__stride_)
+ *__t = *__s;
+ return *this;
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+slice_array<_Tp>::operator=(const _Expr& __v) const
+{
+ value_type* __t = __vp_;
+ for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
+ *__t = __v[__i];
+}
+
+template <class _Tp>
+inline void
+slice_array<_Tp>::operator=(const valarray<value_type>& __va) const
+{
+ value_type* __t = __vp_;
+ for (size_t __i = 0; __i < __va.size(); ++__i, __t += __stride_)
+ *__t = __va[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+slice_array<_Tp>::operator*=(const _Expr& __v) const
+{
+ value_type* __t = __vp_;
+ for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
+ *__t *= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+slice_array<_Tp>::operator/=(const _Expr& __v) const
+{
+ value_type* __t = __vp_;
+ for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
+ *__t /= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+slice_array<_Tp>::operator%=(const _Expr& __v) const
+{
+ value_type* __t = __vp_;
+ for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
+ *__t %= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+slice_array<_Tp>::operator+=(const _Expr& __v) const
+{
+ value_type* __t = __vp_;
+ for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
+ *__t += __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+slice_array<_Tp>::operator-=(const _Expr& __v) const
+{
+ value_type* __t = __vp_;
+ for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
+ *__t -= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+slice_array<_Tp>::operator^=(const _Expr& __v) const
+{
+ value_type* __t = __vp_;
+ for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
+ *__t ^= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+slice_array<_Tp>::operator&=(const _Expr& __v) const
+{
+ value_type* __t = __vp_;
+ for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
+ *__t &= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+slice_array<_Tp>::operator|=(const _Expr& __v) const
+{
+ value_type* __t = __vp_;
+ for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
+ *__t |= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+slice_array<_Tp>::operator<<=(const _Expr& __v) const
+{
+ value_type* __t = __vp_;
+ for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
+ *__t <<= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+slice_array<_Tp>::operator>>=(const _Expr& __v) const
+{
+ value_type* __t = __vp_;
+ for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
+ *__t >>= __v[__i];
+}
+
+template <class _Tp>
+inline
+void
+slice_array<_Tp>::operator=(const value_type& __x) const
+{
+ value_type* __t = __vp_;
+ for (size_t __n = __size_; __n; --__n, __t += __stride_)
+ *__t = __x;
+}
+
+// gslice
+
+class _LIBCPP_TYPE_VIS gslice
+{
+ valarray<size_t> __size_;
+ valarray<size_t> __stride_;
+ valarray<size_t> __1d_;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ gslice() {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ gslice(size_t __start, const valarray<size_t>& __size,
+ const valarray<size_t>& __stride)
+ : __size_(__size),
+ __stride_(__stride)
+ {__init(__start);}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+ _LIBCPP_INLINE_VISIBILITY
+ gslice(size_t __start, const valarray<size_t>& __size,
+ valarray<size_t>&& __stride)
+ : __size_(__size),
+ __stride_(move(__stride))
+ {__init(__start);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ gslice(size_t __start, valarray<size_t>&& __size,
+ const valarray<size_t>& __stride)
+ : __size_(move(__size)),
+ __stride_(__stride)
+ {__init(__start);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ gslice(size_t __start, valarray<size_t>&& __size,
+ valarray<size_t>&& __stride)
+ : __size_(move(__size)),
+ __stride_(move(__stride))
+ {__init(__start);}
+
+#endif // _LIBCPP_CXX03_LANG
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_t start() const {return __1d_.size() ? __1d_[0] : 0;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ valarray<size_t> size() const {return __size_;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ valarray<size_t> stride() const {return __stride_;}
+
+private:
+ void __init(size_t __start);
+
+ template <class> friend class gslice_array;
+ template <class> friend class valarray;
+ template <class> friend class __val_expr;
+};
+
+// gslice_array
+
+template <class _Tp>
+class _LIBCPP_TEMPLATE_VIS gslice_array
+{
+public:
+ typedef _Tp value_type;
+
+private:
+ value_type* __vp_;
+ valarray<size_t> __1d_;
+
+public:
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator*=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator/=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator%=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator+=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator-=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator^=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator&=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator|=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator<<=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator>>=(const _Expr& __v) const;
+
+ _LIBCPP_INLINE_VISIBILITY
+ const gslice_array& operator=(const gslice_array& __ga) const;
+
+ _LIBCPP_INLINE_VISIBILITY
+ void operator=(const value_type& __x) const;
+
+ gslice_array(const gslice_array&) = default;
+
+private:
+ gslice_array(const gslice& __gs, const valarray<value_type>& __v)
+ : __vp_(const_cast<value_type*>(__v.__begin_)),
+ __1d_(__gs.__1d_)
+ {}
+
+#ifndef _LIBCPP_CXX03_LANG
+ gslice_array(gslice&& __gs, const valarray<value_type>& __v)
+ : __vp_(const_cast<value_type*>(__v.__begin_)),
+ __1d_(move(__gs.__1d_))
+ {}
+#endif // _LIBCPP_CXX03_LANG
+
+ template <class> friend class valarray;
+};
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+gslice_array<_Tp>::operator=(const _Expr& __v) const
+{
+ typedef const size_t* _Ip;
+ size_t __j = 0;
+ for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
+ __vp_[*__i] = __v[__j];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+gslice_array<_Tp>::operator*=(const _Expr& __v) const
+{
+ typedef const size_t* _Ip;
+ size_t __j = 0;
+ for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
+ __vp_[*__i] *= __v[__j];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+gslice_array<_Tp>::operator/=(const _Expr& __v) const
+{
+ typedef const size_t* _Ip;
+ size_t __j = 0;
+ for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
+ __vp_[*__i] /= __v[__j];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+gslice_array<_Tp>::operator%=(const _Expr& __v) const
+{
+ typedef const size_t* _Ip;
+ size_t __j = 0;
+ for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
+ __vp_[*__i] %= __v[__j];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+gslice_array<_Tp>::operator+=(const _Expr& __v) const
+{
+ typedef const size_t* _Ip;
+ size_t __j = 0;
+ for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
+ __vp_[*__i] += __v[__j];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+gslice_array<_Tp>::operator-=(const _Expr& __v) const
+{
+ typedef const size_t* _Ip;
+ size_t __j = 0;
+ for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
+ __vp_[*__i] -= __v[__j];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+gslice_array<_Tp>::operator^=(const _Expr& __v) const
+{
+ typedef const size_t* _Ip;
+ size_t __j = 0;
+ for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
+ __vp_[*__i] ^= __v[__j];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+gslice_array<_Tp>::operator&=(const _Expr& __v) const
+{
+ typedef const size_t* _Ip;
+ size_t __j = 0;
+ for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
+ __vp_[*__i] &= __v[__j];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+gslice_array<_Tp>::operator|=(const _Expr& __v) const
+{
+ typedef const size_t* _Ip;
+ size_t __j = 0;
+ for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
+ __vp_[*__i] |= __v[__j];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+gslice_array<_Tp>::operator<<=(const _Expr& __v) const
+{
+ typedef const size_t* _Ip;
+ size_t __j = 0;
+ for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
+ __vp_[*__i] <<= __v[__j];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+gslice_array<_Tp>::operator>>=(const _Expr& __v) const
+{
+ typedef const size_t* _Ip;
+ size_t __j = 0;
+ for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
+ __vp_[*__i] >>= __v[__j];
+}
+
+template <class _Tp>
+inline
+const gslice_array<_Tp>&
+gslice_array<_Tp>::operator=(const gslice_array& __ga) const
+{
+ typedef const size_t* _Ip;
+ const value_type* __s = __ga.__vp_;
+ for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ga.__1d_.__begin_;
+ __i != __e; ++__i, ++__j)
+ __vp_[*__i] = __s[*__j];
+ return *this;
+}
+
+template <class _Tp>
+inline
+void
+gslice_array<_Tp>::operator=(const value_type& __x) const
+{
+ typedef const size_t* _Ip;
+ for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)
+ __vp_[*__i] = __x;
+}
+
+// mask_array
+
+template <class _Tp>
+class _LIBCPP_TEMPLATE_VIS mask_array
+{
+public:
+ typedef _Tp value_type;
+
+private:
+ value_type* __vp_;
+ valarray<size_t> __1d_;
+
+public:
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator*=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator/=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator%=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator+=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator-=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator^=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator&=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator|=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator<<=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator>>=(const _Expr& __v) const;
+
+ mask_array(const mask_array&) = default;
+
+ _LIBCPP_INLINE_VISIBILITY
+ const mask_array& operator=(const mask_array& __ma) const;
+
+ _LIBCPP_INLINE_VISIBILITY
+ void operator=(const value_type& __x) const;
+
+private:
+ _LIBCPP_INLINE_VISIBILITY
+ mask_array(const valarray<bool>& __vb, const valarray<value_type>& __v)
+ : __vp_(const_cast<value_type*>(__v.__begin_)),
+ __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true)))
+ {
+ size_t __j = 0;
+ for (size_t __i = 0; __i < __vb.size(); ++__i)
+ if (__vb[__i])
+ __1d_[__j++] = __i;
+ }
+
+ template <class> friend class valarray;
+};
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+mask_array<_Tp>::operator=(const _Expr& __v) const
+{
+ size_t __n = __1d_.size();
+ for (size_t __i = 0; __i < __n; ++__i)
+ __vp_[__1d_[__i]] = __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+mask_array<_Tp>::operator*=(const _Expr& __v) const
+{
+ size_t __n = __1d_.size();
+ for (size_t __i = 0; __i < __n; ++__i)
+ __vp_[__1d_[__i]] *= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+mask_array<_Tp>::operator/=(const _Expr& __v) const
+{
+ size_t __n = __1d_.size();
+ for (size_t __i = 0; __i < __n; ++__i)
+ __vp_[__1d_[__i]] /= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+mask_array<_Tp>::operator%=(const _Expr& __v) const
+{
+ size_t __n = __1d_.size();
+ for (size_t __i = 0; __i < __n; ++__i)
+ __vp_[__1d_[__i]] %= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+mask_array<_Tp>::operator+=(const _Expr& __v) const
+{
+ size_t __n = __1d_.size();
+ for (size_t __i = 0; __i < __n; ++__i)
+ __vp_[__1d_[__i]] += __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+mask_array<_Tp>::operator-=(const _Expr& __v) const
+{
+ size_t __n = __1d_.size();
+ for (size_t __i = 0; __i < __n; ++__i)
+ __vp_[__1d_[__i]] -= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+mask_array<_Tp>::operator^=(const _Expr& __v) const
+{
+ size_t __n = __1d_.size();
+ for (size_t __i = 0; __i < __n; ++__i)
+ __vp_[__1d_[__i]] ^= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+mask_array<_Tp>::operator&=(const _Expr& __v) const
+{
+ size_t __n = __1d_.size();
+ for (size_t __i = 0; __i < __n; ++__i)
+ __vp_[__1d_[__i]] &= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+mask_array<_Tp>::operator|=(const _Expr& __v) const
+{
+ size_t __n = __1d_.size();
+ for (size_t __i = 0; __i < __n; ++__i)
+ __vp_[__1d_[__i]] |= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+mask_array<_Tp>::operator<<=(const _Expr& __v) const
+{
+ size_t __n = __1d_.size();
+ for (size_t __i = 0; __i < __n; ++__i)
+ __vp_[__1d_[__i]] <<= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+mask_array<_Tp>::operator>>=(const _Expr& __v) const
+{
+ size_t __n = __1d_.size();
+ for (size_t __i = 0; __i < __n; ++__i)
+ __vp_[__1d_[__i]] >>= __v[__i];
+}
+
+template <class _Tp>
+inline
+const mask_array<_Tp>&
+mask_array<_Tp>::operator=(const mask_array& __ma) const
+{
+ size_t __n = __1d_.size();
+ for (size_t __i = 0; __i < __n; ++__i)
+ __vp_[__1d_[__i]] = __ma.__vp_[__1d_[__i]];
+ return *this;
+}
+
+template <class _Tp>
+inline
+void
+mask_array<_Tp>::operator=(const value_type& __x) const
+{
+ size_t __n = __1d_.size();
+ for (size_t __i = 0; __i < __n; ++__i)
+ __vp_[__1d_[__i]] = __x;
+}
+
+template <class _ValExpr>
+class __mask_expr
+{
+ typedef typename remove_reference<_ValExpr>::type _RmExpr;
+public:
+ typedef typename _RmExpr::value_type value_type;
+ typedef value_type __result_type;
+
+private:
+ _ValExpr __expr_;
+ valarray<size_t> __1d_;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __mask_expr(const valarray<bool>& __vb, const _RmExpr& __e)
+ : __expr_(__e),
+ __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true)))
+ {
+ size_t __j = 0;
+ for (size_t __i = 0; __i < __vb.size(); ++__i)
+ if (__vb[__i])
+ __1d_[__j++] = __i;
+ }
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ __result_type operator[](size_t __i) const
+ {return __expr_[__1d_[__i]];}
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_t size() const {return __1d_.size();}
+
+ template <class> friend class __val_expr;
+ template <class> friend class valarray;
+};
+
+// indirect_array
+
+template <class _Tp>
+class _LIBCPP_TEMPLATE_VIS indirect_array
+{
+public:
+ typedef _Tp value_type;
+
+private:
+ value_type* __vp_;
+ valarray<size_t> __1d_;
+
+public:
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator*=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator/=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator%=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator+=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator-=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator^=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator&=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator|=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator<<=(const _Expr& __v) const;
+
+ template <class _Expr>
+ typename enable_if
+ <
+ __is_val_expr<_Expr>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator>>=(const _Expr& __v) const;
+
+ indirect_array(const indirect_array&) = default;
+
+ _LIBCPP_INLINE_VISIBILITY
+ const indirect_array& operator=(const indirect_array& __ia) const;
+
+ _LIBCPP_INLINE_VISIBILITY
+ void operator=(const value_type& __x) const;
+
+private:
+ _LIBCPP_INLINE_VISIBILITY
+ indirect_array(const valarray<size_t>& __ia, const valarray<value_type>& __v)
+ : __vp_(const_cast<value_type*>(__v.__begin_)),
+ __1d_(__ia)
+ {}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+ _LIBCPP_INLINE_VISIBILITY
+ indirect_array(valarray<size_t>&& __ia, const valarray<value_type>& __v)
+ : __vp_(const_cast<value_type*>(__v.__begin_)),
+ __1d_(move(__ia))
+ {}
+
+#endif // _LIBCPP_CXX03_LANG
+
+ template <class> friend class valarray;
+};
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+indirect_array<_Tp>::operator=(const _Expr& __v) const
+{
+ size_t __n = __1d_.size();
+ for (size_t __i = 0; __i < __n; ++__i)
+ __vp_[__1d_[__i]] = __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+indirect_array<_Tp>::operator*=(const _Expr& __v) const
+{
+ size_t __n = __1d_.size();
+ for (size_t __i = 0; __i < __n; ++__i)
+ __vp_[__1d_[__i]] *= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+indirect_array<_Tp>::operator/=(const _Expr& __v) const
+{
+ size_t __n = __1d_.size();
+ for (size_t __i = 0; __i < __n; ++__i)
+ __vp_[__1d_[__i]] /= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+indirect_array<_Tp>::operator%=(const _Expr& __v) const
+{
+ size_t __n = __1d_.size();
+ for (size_t __i = 0; __i < __n; ++__i)
+ __vp_[__1d_[__i]] %= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+indirect_array<_Tp>::operator+=(const _Expr& __v) const
+{
+ size_t __n = __1d_.size();
+ for (size_t __i = 0; __i < __n; ++__i)
+ __vp_[__1d_[__i]] += __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+indirect_array<_Tp>::operator-=(const _Expr& __v) const
+{
+ size_t __n = __1d_.size();
+ for (size_t __i = 0; __i < __n; ++__i)
+ __vp_[__1d_[__i]] -= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+indirect_array<_Tp>::operator^=(const _Expr& __v) const
+{
+ size_t __n = __1d_.size();
+ for (size_t __i = 0; __i < __n; ++__i)
+ __vp_[__1d_[__i]] ^= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+indirect_array<_Tp>::operator&=(const _Expr& __v) const
+{
+ size_t __n = __1d_.size();
+ for (size_t __i = 0; __i < __n; ++__i)
+ __vp_[__1d_[__i]] &= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+indirect_array<_Tp>::operator|=(const _Expr& __v) const
+{
+ size_t __n = __1d_.size();
+ for (size_t __i = 0; __i < __n; ++__i)
+ __vp_[__1d_[__i]] |= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+indirect_array<_Tp>::operator<<=(const _Expr& __v) const
+{
+ size_t __n = __1d_.size();
+ for (size_t __i = 0; __i < __n; ++__i)
+ __vp_[__1d_[__i]] <<= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ void
+>::type
+indirect_array<_Tp>::operator>>=(const _Expr& __v) const
+{
+ size_t __n = __1d_.size();
+ for (size_t __i = 0; __i < __n; ++__i)
+ __vp_[__1d_[__i]] >>= __v[__i];
+}
+
+template <class _Tp>
+inline
+const indirect_array<_Tp>&
+indirect_array<_Tp>::operator=(const indirect_array& __ia) const
+{
+ typedef const size_t* _Ip;
+ const value_type* __s = __ia.__vp_;
+ for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ia.__1d_.__begin_;
+ __i != __e; ++__i, ++__j)
+ __vp_[*__i] = __s[*__j];
+ return *this;
+}
+
+template <class _Tp>
+inline
+void
+indirect_array<_Tp>::operator=(const value_type& __x) const
+{
+ typedef const size_t* _Ip;
+ for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)
+ __vp_[*__i] = __x;
+}
+
+template <class _ValExpr>
+class __indirect_expr
+{
+ typedef typename remove_reference<_ValExpr>::type _RmExpr;
+public:
+ typedef typename _RmExpr::value_type value_type;
+ typedef value_type __result_type;
+
+private:
+ _ValExpr __expr_;
+ valarray<size_t> __1d_;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __indirect_expr(const valarray<size_t>& __ia, const _RmExpr& __e)
+ : __expr_(__e),
+ __1d_(__ia)
+ {}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+ _LIBCPP_INLINE_VISIBILITY
+ __indirect_expr(valarray<size_t>&& __ia, const _RmExpr& __e)
+ : __expr_(__e),
+ __1d_(move(__ia))
+ {}
+
+#endif // _LIBCPP_CXX03_LANG
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ __result_type operator[](size_t __i) const
+ {return __expr_[__1d_[__i]];}
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_t size() const {return __1d_.size();}
+
+ template <class> friend class __val_expr;
+ template <class> friend class _LIBCPP_TEMPLATE_VIS valarray;
+};
+
+template<class _ValExpr>
+class __val_expr
+{
+ typedef typename remove_reference<_ValExpr>::type _RmExpr;
+
+ _ValExpr __expr_;
+public:
+ typedef typename _RmExpr::value_type value_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
+ {return __expr_[__i];}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __val_expr<__slice_expr<_ValExpr> > operator[](slice __s) const
+ {
+ typedef __slice_expr<_ValExpr> _NewExpr;
+ return __val_expr< _NewExpr >(_NewExpr(__s, __expr_));
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __val_expr<__indirect_expr<_ValExpr> > operator[](const gslice& __gs) const
+ {
+ typedef __indirect_expr<_ValExpr> _NewExpr;
+ return __val_expr<_NewExpr >(_NewExpr(__gs.__1d_, __expr_));
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __val_expr<__mask_expr<_ValExpr> > operator[](const valarray<bool>& __vb) const
+ {
+ typedef __mask_expr<_ValExpr> _NewExpr;
+ return __val_expr< _NewExpr >( _NewExpr(__vb, __expr_));
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __val_expr<__indirect_expr<_ValExpr> > operator[](const valarray<size_t>& __vs) const
+ {
+ typedef __indirect_expr<_ValExpr> _NewExpr;
+ return __val_expr< _NewExpr >(_NewExpr(__vs, __expr_));
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __val_expr<_UnaryOp<__unary_plus<value_type>, _ValExpr> >
+ operator+() const
+ {
+ typedef _UnaryOp<__unary_plus<value_type>, _ValExpr> _NewExpr;
+ return __val_expr<_NewExpr>(_NewExpr(__unary_plus<value_type>(), __expr_));
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __val_expr<_UnaryOp<negate<value_type>, _ValExpr> >
+ operator-() const
+ {
+ typedef _UnaryOp<negate<value_type>, _ValExpr> _NewExpr;
+ return __val_expr<_NewExpr>(_NewExpr(negate<value_type>(), __expr_));
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __val_expr<_UnaryOp<__bit_not<value_type>, _ValExpr> >
+ operator~() const
+ {
+ typedef _UnaryOp<__bit_not<value_type>, _ValExpr> _NewExpr;
+ return __val_expr<_NewExpr>(_NewExpr(__bit_not<value_type>(), __expr_));
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __val_expr<_UnaryOp<logical_not<value_type>, _ValExpr> >
+ operator!() const
+ {
+ typedef _UnaryOp<logical_not<value_type>, _ValExpr> _NewExpr;
+ return __val_expr<_NewExpr>(_NewExpr(logical_not<value_type>(), __expr_));
+ }
+
+ operator valarray<__result_type>() const;
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_t size() const {return __expr_.size();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __result_type sum() const
+ {
+ size_t __n = __expr_.size();
+ __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
+ {
+ size_t __n = size();
+ __result_type __r = __n ? (*this)[0] : __result_type();
+ for (size_t __i = 1; __i < __n; ++__i)
+ {
+ __result_type __x = __expr_[__i];
+ if (__x < __r)
+ __r = __x;
+ }
+ return __r;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __result_type max() const
+ {
+ size_t __n = size();
+ __result_type __r = __n ? (*this)[0] : __result_type();
+ for (size_t __i = 1; __i < __n; ++__i)
+ {
+ __result_type __x = __expr_[__i];
+ if (__r < __x)
+ __r = __x;
+ }
+ return __r;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __val_expr<__shift_expr<_ValExpr> > shift (int __i) const
+ {return __val_expr<__shift_expr<_ValExpr> >(__shift_expr<_ValExpr>(__i, __expr_));}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __val_expr<__cshift_expr<_ValExpr> > cshift(int __i) const
+ {return __val_expr<__cshift_expr<_ValExpr> >(__cshift_expr<_ValExpr>(__i, __expr_));}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(value_type)>, _ValExpr> >
+ apply(value_type __f(value_type)) const
+ {
+ typedef __apply_expr<value_type, value_type(*)(value_type)> _Op;
+ typedef _UnaryOp<_Op, _ValExpr> _NewExpr;
+ return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(const value_type&)>, _ValExpr> >
+ apply(value_type __f(const value_type&)) const
+ {
+ typedef __apply_expr<value_type, value_type(*)(const value_type&)> _Op;
+ typedef _UnaryOp<_Op, _ValExpr> _NewExpr;
+ return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));
+ }
+};
+
+template<class _ValExpr>
+__val_expr<_ValExpr>::operator valarray<typename __val_expr<_ValExpr>::__result_type>() const
+{
+ valarray<__result_type> __r;
+ size_t __n = __expr_.size();
+ if (__n)
+ {
+ __r.__begin_ =
+ __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]);
+ }
+ return __r;
+}
+
+// valarray
+
+template <class _Tp>
+inline
+valarray<_Tp>::valarray(size_t __n)
+ : __begin_(nullptr),
+ __end_(nullptr)
+{
+ if (__n)
+ {
+ __begin_ = __end_ = allocator<value_type>().allocate(__n);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ for (size_t __n_left = __n; __n_left; --__n_left, ++__end_)
+ ::new ((void*)__end_) value_type();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __clear(__n);
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ }
+}
+
+template <class _Tp>
+inline
+valarray<_Tp>::valarray(const value_type& __x, size_t __n)
+ : __begin_(nullptr),
+ __end_(nullptr)
+{
+ resize(__n, __x);
+}
+
+template <class _Tp>
+valarray<_Tp>::valarray(const value_type* __p, size_t __n)
+ : __begin_(nullptr),
+ __end_(nullptr)
+{
+ if (__n)
+ {
+ __begin_ = __end_ = allocator<value_type>().allocate(__n);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#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
+ }
+ catch (...)
+ {
+ __clear(__n);
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ }
+}
+
+template <class _Tp>
+valarray<_Tp>::valarray(const valarray& __v)
+ : __begin_(nullptr),
+ __end_(nullptr)
+{
+ if (__v.size())
+ {
+ __begin_ = __end_ = allocator<value_type>().allocate(__v.size());
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#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
+ }
+ catch (...)
+ {
+ __clear(__v.size());
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ }
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Tp>
+inline
+valarray<_Tp>::valarray(valarray&& __v) _NOEXCEPT
+ : __begin_(__v.__begin_),
+ __end_(__v.__end_)
+{
+ __v.__begin_ = __v.__end_ = nullptr;
+}
+
+template <class _Tp>
+valarray<_Tp>::valarray(initializer_list<value_type> __il)
+ : __begin_(nullptr),
+ __end_(nullptr)
+{
+ const size_t __n = __il.size();
+ if (__n)
+ {
+ __begin_ = __end_ = allocator<value_type>().allocate(__n);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#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);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __clear(__n);
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ }
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _Tp>
+valarray<_Tp>::valarray(const slice_array<value_type>& __sa)
+ : __begin_(nullptr),
+ __end_(nullptr)
+{
+ const size_t __n = __sa.__size_;
+ if (__n)
+ {
+ __begin_ = __end_ = allocator<value_type>().allocate(__n);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#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);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __clear(__n);
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ }
+}
+
+template <class _Tp>
+valarray<_Tp>::valarray(const gslice_array<value_type>& __ga)
+ : __begin_(nullptr),
+ __end_(nullptr)
+{
+ const size_t __n = __ga.__1d_.size();
+ if (__n)
+ {
+ __begin_ = __end_ = allocator<value_type>().allocate(__n);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#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_;
+ __i != __e; ++__i, ++__end_)
+ ::new ((void*)__end_) value_type(__s[*__i]);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __clear(__n);
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ }
+}
+
+template <class _Tp>
+valarray<_Tp>::valarray(const mask_array<value_type>& __ma)
+ : __begin_(nullptr),
+ __end_(nullptr)
+{
+ const size_t __n = __ma.__1d_.size();
+ if (__n)
+ {
+ __begin_ = __end_ = allocator<value_type>().allocate(__n);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#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_;
+ __i != __e; ++__i, ++__end_)
+ ::new ((void*)__end_) value_type(__s[*__i]);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __clear(__n);
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ }
+}
+
+template <class _Tp>
+valarray<_Tp>::valarray(const indirect_array<value_type>& __ia)
+ : __begin_(nullptr),
+ __end_(nullptr)
+{
+ const size_t __n = __ia.__1d_.size();
+ if (__n)
+ {
+ __begin_ = __end_ = allocator<value_type>().allocate(__n);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#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_;
+ __i != __e; ++__i, ++__end_)
+ ::new ((void*)__end_) value_type(__s[*__i]);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __clear(__n);
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ }
+}
+
+template <class _Tp>
+inline
+valarray<_Tp>::~valarray()
+{
+ __clear(size());
+}
+
+template <class _Tp>
+valarray<_Tp>&
+valarray<_Tp>::__assign_range(const value_type* __f, const value_type* __l)
+{
+ size_t __n = __l - __f;
+ if (size() != __n)
+ {
+ __clear(size());
+ __begin_ = allocator<value_type>().allocate(__n);
+ __end_ = __begin_ + __n;
+ _VSTD::uninitialized_copy(__f, __l, __begin_);
+ } else {
+ _VSTD::copy(__f, __l, __begin_);
+ }
+ return *this;
+}
+
+template <class _Tp>
+valarray<_Tp>&
+valarray<_Tp>::operator=(const valarray& __v)
+{
+ if (this != _VSTD::addressof(__v))
+ return __assign_range(__v.__begin_, __v.__end_);
+ return *this;
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Tp>
+inline
+valarray<_Tp>&
+valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT
+{
+ __clear(size());
+ __begin_ = __v.__begin_;
+ __end_ = __v.__end_;
+ __v.__begin_ = nullptr;
+ __v.__end_ = nullptr;
+ return *this;
+}
+
+template <class _Tp>
+inline
+valarray<_Tp>&
+valarray<_Tp>::operator=(initializer_list<value_type> __il)
+{
+ return __assign_range(__il.begin(), __il.end());
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _Tp>
+inline
+valarray<_Tp>&
+valarray<_Tp>::operator=(const value_type& __x)
+{
+ _VSTD::fill(__begin_, __end_, __x);
+ return *this;
+}
+
+template <class _Tp>
+inline
+valarray<_Tp>&
+valarray<_Tp>::operator=(const slice_array<value_type>& __sa)
+{
+ value_type* __t = __begin_;
+ const value_type* __s = __sa.__vp_;
+ for (size_t __n = __sa.__size_; __n; --__n, __s += __sa.__stride_, ++__t)
+ *__t = *__s;
+ return *this;
+}
+
+template <class _Tp>
+inline
+valarray<_Tp>&
+valarray<_Tp>::operator=(const gslice_array<value_type>& __ga)
+{
+ typedef const size_t* _Ip;
+ value_type* __t = __begin_;
+ const value_type* __s = __ga.__vp_;
+ for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_;
+ __i != __e; ++__i, ++__t)
+ *__t = __s[*__i];
+ return *this;
+}
+
+template <class _Tp>
+inline
+valarray<_Tp>&
+valarray<_Tp>::operator=(const mask_array<value_type>& __ma)
+{
+ typedef const size_t* _Ip;
+ value_type* __t = __begin_;
+ const value_type* __s = __ma.__vp_;
+ for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_;
+ __i != __e; ++__i, ++__t)
+ *__t = __s[*__i];
+ return *this;
+}
+
+template <class _Tp>
+inline
+valarray<_Tp>&
+valarray<_Tp>::operator=(const indirect_array<value_type>& __ia)
+{
+ typedef const size_t* _Ip;
+ value_type* __t = __begin_;
+ const value_type* __s = __ia.__vp_;
+ for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_;
+ __i != __e; ++__i, ++__t)
+ *__t = __s[*__i];
+ return *this;
+}
+
+template <class _Tp>
+template <class _ValExpr>
+inline
+valarray<_Tp>&
+valarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v)
+{
+ size_t __n = __v.size();
+ if (size() != __n)
+ resize(__n);
+ value_type* __t = __begin_;
+ for (size_t __i = 0; __i != __n; ++__t, ++__i)
+ *__t = __result_type(__v[__i]);
+ return *this;
+}
+
+template <class _Tp>
+inline
+__val_expr<__slice_expr<const valarray<_Tp>&> >
+valarray<_Tp>::operator[](slice __s) const
+{
+ return __val_expr<__slice_expr<const valarray&> >(__slice_expr<const valarray&>(__s, *this));
+}
+
+template <class _Tp>
+inline
+slice_array<_Tp>
+valarray<_Tp>::operator[](slice __s)
+{
+ return slice_array<value_type>(__s, *this);
+}
+
+template <class _Tp>
+inline
+__val_expr<__indirect_expr<const valarray<_Tp>&> >
+valarray<_Tp>::operator[](const gslice& __gs) const
+{
+ return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__gs.__1d_, *this));
+}
+
+template <class _Tp>
+inline
+gslice_array<_Tp>
+valarray<_Tp>::operator[](const gslice& __gs)
+{
+ return gslice_array<value_type>(__gs, *this);
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Tp>
+inline
+__val_expr<__indirect_expr<const valarray<_Tp>&> >
+valarray<_Tp>::operator[](gslice&& __gs) const
+{
+ return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__gs.__1d_), *this));
+}
+
+template <class _Tp>
+inline
+gslice_array<_Tp>
+valarray<_Tp>::operator[](gslice&& __gs)
+{
+ return gslice_array<value_type>(move(__gs), *this);
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _Tp>
+inline
+__val_expr<__mask_expr<const valarray<_Tp>&> >
+valarray<_Tp>::operator[](const valarray<bool>& __vb) const
+{
+ return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(__vb, *this));
+}
+
+template <class _Tp>
+inline
+mask_array<_Tp>
+valarray<_Tp>::operator[](const valarray<bool>& __vb)
+{
+ return mask_array<value_type>(__vb, *this);
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Tp>
+inline
+__val_expr<__mask_expr<const valarray<_Tp>&> >
+valarray<_Tp>::operator[](valarray<bool>&& __vb) const
+{
+ return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(move(__vb), *this));
+}
+
+template <class _Tp>
+inline
+mask_array<_Tp>
+valarray<_Tp>::operator[](valarray<bool>&& __vb)
+{
+ return mask_array<value_type>(move(__vb), *this);
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _Tp>
+inline
+__val_expr<__indirect_expr<const valarray<_Tp>&> >
+valarray<_Tp>::operator[](const valarray<size_t>& __vs) const
+{
+ return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__vs, *this));
+}
+
+template <class _Tp>
+inline
+indirect_array<_Tp>
+valarray<_Tp>::operator[](const valarray<size_t>& __vs)
+{
+ return indirect_array<value_type>(__vs, *this);
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Tp>
+inline
+__val_expr<__indirect_expr<const valarray<_Tp>&> >
+valarray<_Tp>::operator[](valarray<size_t>&& __vs) const
+{
+ return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__vs), *this));
+}
+
+template <class _Tp>
+inline
+indirect_array<_Tp>
+valarray<_Tp>::operator[](valarray<size_t>&& __vs)
+{
+ return indirect_array<value_type>(move(__vs), *this);
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _Tp>
+valarray<_Tp>
+valarray<_Tp>::operator+() const
+{
+ valarray<value_type> __r;
+ size_t __n = size();
+ if (__n)
+ {
+ __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
+ for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
+ ::new ((void*)__r.__end_) value_type(+*__p);
+ }
+ return __r;
+}
+
+template <class _Tp>
+valarray<_Tp>
+valarray<_Tp>::operator-() const
+{
+ valarray<value_type> __r;
+ size_t __n = size();
+ if (__n)
+ {
+ __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
+ for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
+ ::new ((void*)__r.__end_) value_type(-*__p);
+ }
+ return __r;
+}
+
+template <class _Tp>
+valarray<_Tp>
+valarray<_Tp>::operator~() const
+{
+ valarray<value_type> __r;
+ size_t __n = size();
+ if (__n)
+ {
+ __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
+ for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
+ ::new ((void*)__r.__end_) value_type(~*__p);
+ }
+ return __r;
+}
+
+template <class _Tp>
+valarray<bool>
+valarray<_Tp>::operator!() const
+{
+ valarray<bool> __r;
+ size_t __n = size();
+ if (__n)
+ {
+ __r.__begin_ = __r.__end_ = allocator<bool>().allocate(__n);
+ for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
+ ::new ((void*)__r.__end_) bool(!*__p);
+ }
+ return __r;
+}
+
+template <class _Tp>
+inline
+valarray<_Tp>&
+valarray<_Tp>::operator*=(const value_type& __x)
+{
+ for (value_type* __p = __begin_; __p != __end_; ++__p)
+ *__p *= __x;
+ return *this;
+}
+
+template <class _Tp>
+inline
+valarray<_Tp>&
+valarray<_Tp>::operator/=(const value_type& __x)
+{
+ for (value_type* __p = __begin_; __p != __end_; ++__p)
+ *__p /= __x;
+ return *this;
+}
+
+template <class _Tp>
+inline
+valarray<_Tp>&
+valarray<_Tp>::operator%=(const value_type& __x)
+{
+ for (value_type* __p = __begin_; __p != __end_; ++__p)
+ *__p %= __x;
+ return *this;
+}
+
+template <class _Tp>
+inline
+valarray<_Tp>&
+valarray<_Tp>::operator+=(const value_type& __x)
+{
+ for (value_type* __p = __begin_; __p != __end_; ++__p)
+ *__p += __x;
+ return *this;
+}
+
+template <class _Tp>
+inline
+valarray<_Tp>&
+valarray<_Tp>::operator-=(const value_type& __x)
+{
+ for (value_type* __p = __begin_; __p != __end_; ++__p)
+ *__p -= __x;
+ return *this;
+}
+
+template <class _Tp>
+inline
+valarray<_Tp>&
+valarray<_Tp>::operator^=(const value_type& __x)
+{
+ for (value_type* __p = __begin_; __p != __end_; ++__p)
+ *__p ^= __x;
+ return *this;
+}
+
+template <class _Tp>
+inline
+valarray<_Tp>&
+valarray<_Tp>::operator&=(const value_type& __x)
+{
+ for (value_type* __p = __begin_; __p != __end_; ++__p)
+ *__p &= __x;
+ return *this;
+}
+
+template <class _Tp>
+inline
+valarray<_Tp>&
+valarray<_Tp>::operator|=(const value_type& __x)
+{
+ for (value_type* __p = __begin_; __p != __end_; ++__p)
+ *__p |= __x;
+ return *this;
+}
+
+template <class _Tp>
+inline
+valarray<_Tp>&
+valarray<_Tp>::operator<<=(const value_type& __x)
+{
+ for (value_type* __p = __begin_; __p != __end_; ++__p)
+ *__p <<= __x;
+ return *this;
+}
+
+template <class _Tp>
+inline
+valarray<_Tp>&
+valarray<_Tp>::operator>>=(const value_type& __x)
+{
+ for (value_type* __p = __begin_; __p != __end_; ++__p)
+ *__p >>= __x;
+ return *this;
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ valarray<_Tp>&
+>::type
+valarray<_Tp>::operator*=(const _Expr& __v)
+{
+ size_t __i = 0;
+ for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
+ *__t *= __v[__i];
+ return *this;
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ valarray<_Tp>&
+>::type
+valarray<_Tp>::operator/=(const _Expr& __v)
+{
+ size_t __i = 0;
+ for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
+ *__t /= __v[__i];
+ return *this;
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ valarray<_Tp>&
+>::type
+valarray<_Tp>::operator%=(const _Expr& __v)
+{
+ size_t __i = 0;
+ for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
+ *__t %= __v[__i];
+ return *this;
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ valarray<_Tp>&
+>::type
+valarray<_Tp>::operator+=(const _Expr& __v)
+{
+ size_t __i = 0;
+ for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
+ *__t += __v[__i];
+ return *this;
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ valarray<_Tp>&
+>::type
+valarray<_Tp>::operator-=(const _Expr& __v)
+{
+ size_t __i = 0;
+ for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
+ *__t -= __v[__i];
+ return *this;
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ valarray<_Tp>&
+>::type
+valarray<_Tp>::operator^=(const _Expr& __v)
+{
+ size_t __i = 0;
+ for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
+ *__t ^= __v[__i];
+ return *this;
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ valarray<_Tp>&
+>::type
+valarray<_Tp>::operator|=(const _Expr& __v)
+{
+ size_t __i = 0;
+ for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
+ *__t |= __v[__i];
+ return *this;
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ valarray<_Tp>&
+>::type
+valarray<_Tp>::operator&=(const _Expr& __v)
+{
+ size_t __i = 0;
+ for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
+ *__t &= __v[__i];
+ return *this;
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ valarray<_Tp>&
+>::type
+valarray<_Tp>::operator<<=(const _Expr& __v)
+{
+ size_t __i = 0;
+ for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
+ *__t <<= __v[__i];
+ return *this;
+}
+
+template <class _Tp>
+template <class _Expr>
+inline
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ valarray<_Tp>&
+>::type
+valarray<_Tp>::operator>>=(const _Expr& __v)
+{
+ size_t __i = 0;
+ for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
+ *__t >>= __v[__i];
+ return *this;
+}
+
+template <class _Tp>
+inline
+void
+valarray<_Tp>::swap(valarray& __v) _NOEXCEPT
+{
+ _VSTD::swap(__begin_, __v.__begin_);
+ _VSTD::swap(__end_, __v.__end_);
+}
+
+template <class _Tp>
+inline
+_Tp
+valarray<_Tp>::sum() const
+{
+ if (__begin_ == __end_)
+ return value_type();
+ const value_type* __p = __begin_;
+ _Tp __r = *__p;
+ for (++__p; __p != __end_; ++__p)
+ __r += *__p;
+ return __r;
+}
+
+template <class _Tp>
+inline
+_Tp
+valarray<_Tp>::min() const
+{
+ if (__begin_ == __end_)
+ return value_type();
+ return *_VSTD::min_element(__begin_, __end_);
+}
+
+template <class _Tp>
+inline
+_Tp
+valarray<_Tp>::max() const
+{
+ if (__begin_ == __end_)
+ return value_type();
+ return *_VSTD::max_element(__begin_, __end_);
+}
+
+template <class _Tp>
+valarray<_Tp>
+valarray<_Tp>::shift(int __i) const
+{
+ valarray<value_type> __r;
+ size_t __n = size();
+ if (__n)
+ {
+ __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
+ const value_type* __sb;
+ value_type* __tb;
+ value_type* __te;
+ if (__i >= 0)
+ {
+ __i = _VSTD::min(__i, static_cast<int>(__n));
+ __sb = __begin_ + __i;
+ __tb = __r.__begin_;
+ __te = __r.__begin_ + (__n - __i);
+ }
+ else
+ {
+ __i = _VSTD::min(-__i, static_cast<int>(__n));
+ __sb = __begin_;
+ __tb = __r.__begin_ + __i;
+ __te = __r.__begin_ + __n;
+ }
+ for (; __r.__end_ != __tb; ++__r.__end_)
+ ::new ((void*)__r.__end_) value_type();
+ for (; __r.__end_ != __te; ++__r.__end_, ++__sb)
+ ::new ((void*)__r.__end_) value_type(*__sb);
+ for (__te = __r.__begin_ + __n; __r.__end_ != __te; ++__r.__end_)
+ ::new ((void*)__r.__end_) value_type();
+ }
+ return __r;
+}
+
+template <class _Tp>
+valarray<_Tp>
+valarray<_Tp>::cshift(int __i) const
+{
+ valarray<value_type> __r;
+ size_t __n = size();
+ if (__n)
+ {
+ __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
+ __i %= static_cast<int>(__n);
+ const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i;
+ for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s)
+ ::new ((void*)__r.__end_) value_type(*__s);
+ for (const value_type* __s = __begin_; __s != __m; ++__r.__end_, ++__s)
+ ::new ((void*)__r.__end_) value_type(*__s);
+ }
+ return __r;
+}
+
+template <class _Tp>
+valarray<_Tp>
+valarray<_Tp>::apply(value_type __f(value_type)) const
+{
+ valarray<value_type> __r;
+ size_t __n = size();
+ if (__n)
+ {
+ __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
+ for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
+ ::new ((void*)__r.__end_) value_type(__f(*__p));
+ }
+ return __r;
+}
+
+template <class _Tp>
+valarray<_Tp>
+valarray<_Tp>::apply(value_type __f(const value_type&)) const
+{
+ valarray<value_type> __r;
+ size_t __n = size();
+ if (__n)
+ {
+ __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
+ for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
+ ::new ((void*)__r.__end_) value_type(__f(*__p));
+ }
+ return __r;
+}
+
+template <class _Tp>
+inline
+void valarray<_Tp>::__clear(size_t __capacity)
+{
+ if (__begin_ != nullptr)
+ {
+ while (__end_ != __begin_)
+ (--__end_)->~value_type();
+ allocator<value_type>().deallocate(__begin_, __capacity);
+ __begin_ = __end_ = nullptr;
+ }
+}
+
+template <class _Tp>
+void
+valarray<_Tp>::resize(size_t __n, value_type __x)
+{
+ __clear(size());
+ if (__n)
+ {
+ __begin_ = __end_ = allocator<value_type>().allocate(__n);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#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
+ }
+ catch (...)
+ {
+ __clear(__n);
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ }
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(valarray<_Tp>& __x, valarray<_Tp>& __y) _NOEXCEPT
+{
+ __x.swap(__y);
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+ __val_expr<_BinaryOp<multiplies<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator*(const _Expr1& __x, const _Expr2& __y)
+{
+ typedef typename _Expr1::value_type value_type;
+ typedef _BinaryOp<multiplies<value_type>, _Expr1, _Expr2> _Op;
+ return __val_expr<_Op>(_Op(multiplies<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>,
+ _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator*(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<multiplies<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+ return __val_expr<_Op>(_Op(multiplies<value_type>(),
+ __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>,
+ __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator*(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<multiplies<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(multiplies<value_type>(),
+ __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+ __val_expr<_BinaryOp<divides<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator/(const _Expr1& __x, const _Expr2& __y)
+{
+ typedef typename _Expr1::value_type value_type;
+ typedef _BinaryOp<divides<value_type>, _Expr1, _Expr2> _Op;
+ return __val_expr<_Op>(_Op(divides<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<divides<typename _Expr::value_type>,
+ _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator/(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<divides<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+ return __val_expr<_Op>(_Op(divides<value_type>(),
+ __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<divides<typename _Expr::value_type>,
+ __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator/(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<divides<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(divides<value_type>(),
+ __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+ __val_expr<_BinaryOp<modulus<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator%(const _Expr1& __x, const _Expr2& __y)
+{
+ typedef typename _Expr1::value_type value_type;
+ typedef _BinaryOp<modulus<value_type>, _Expr1, _Expr2> _Op;
+ return __val_expr<_Op>(_Op(modulus<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<modulus<typename _Expr::value_type>,
+ _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator%(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<modulus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+ return __val_expr<_Op>(_Op(modulus<value_type>(),
+ __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<modulus<typename _Expr::value_type>,
+ __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator%(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<modulus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(modulus<value_type>(),
+ __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+ __val_expr<_BinaryOp<plus<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator+(const _Expr1& __x, const _Expr2& __y)
+{
+ typedef typename _Expr1::value_type value_type;
+ typedef _BinaryOp<plus<value_type>, _Expr1, _Expr2> _Op;
+ return __val_expr<_Op>(_Op(plus<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<plus<typename _Expr::value_type>,
+ _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator+(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<plus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+ return __val_expr<_Op>(_Op(plus<value_type>(),
+ __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<plus<typename _Expr::value_type>,
+ __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator+(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<plus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(plus<value_type>(),
+ __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+ __val_expr<_BinaryOp<minus<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator-(const _Expr1& __x, const _Expr2& __y)
+{
+ typedef typename _Expr1::value_type value_type;
+ typedef _BinaryOp<minus<value_type>, _Expr1, _Expr2> _Op;
+ return __val_expr<_Op>(_Op(minus<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<minus<typename _Expr::value_type>,
+ _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator-(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<minus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+ return __val_expr<_Op>(_Op(minus<value_type>(),
+ __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<minus<typename _Expr::value_type>,
+ __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator-(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<minus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(minus<value_type>(),
+ __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+ __val_expr<_BinaryOp<bit_xor<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator^(const _Expr1& __x, const _Expr2& __y)
+{
+ typedef typename _Expr1::value_type value_type;
+ typedef _BinaryOp<bit_xor<value_type>, _Expr1, _Expr2> _Op;
+ return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>,
+ _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator^(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<bit_xor<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+ return __val_expr<_Op>(_Op(bit_xor<value_type>(),
+ __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>,
+ __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator^(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<bit_xor<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(bit_xor<value_type>(),
+ __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+ __val_expr<_BinaryOp<bit_and<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator&(const _Expr1& __x, const _Expr2& __y)
+{
+ typedef typename _Expr1::value_type value_type;
+ typedef _BinaryOp<bit_and<value_type>, _Expr1, _Expr2> _Op;
+ return __val_expr<_Op>(_Op(bit_and<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>,
+ _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator&(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<bit_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+ return __val_expr<_Op>(_Op(bit_and<value_type>(),
+ __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>,
+ __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator&(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<bit_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(bit_and<value_type>(),
+ __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+ __val_expr<_BinaryOp<bit_or<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator|(const _Expr1& __x, const _Expr2& __y)
+{
+ typedef typename _Expr1::value_type value_type;
+ typedef _BinaryOp<bit_or<value_type>, _Expr1, _Expr2> _Op;
+ return __val_expr<_Op>(_Op(bit_or<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>,
+ _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator|(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<bit_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+ return __val_expr<_Op>(_Op(bit_or<value_type>(),
+ __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>,
+ __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator|(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<bit_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(bit_or<value_type>(),
+ __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+ __val_expr<_BinaryOp<__bit_shift_left<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator<<(const _Expr1& __x, const _Expr2& __y)
+{
+ typedef typename _Expr1::value_type value_type;
+ typedef _BinaryOp<__bit_shift_left<value_type>, _Expr1, _Expr2> _Op;
+ return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>,
+ _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator<<(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<__bit_shift_left<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+ return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(),
+ __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>,
+ __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator<<(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<__bit_shift_left<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(),
+ __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+ __val_expr<_BinaryOp<__bit_shift_right<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator>>(const _Expr1& __x, const _Expr2& __y)
+{
+ typedef typename _Expr1::value_type value_type;
+ typedef _BinaryOp<__bit_shift_right<value_type>, _Expr1, _Expr2> _Op;
+ return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>,
+ _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator>>(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<__bit_shift_right<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+ return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(),
+ __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>,
+ __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator>>(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<__bit_shift_right<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(),
+ __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+ __val_expr<_BinaryOp<logical_and<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator&&(const _Expr1& __x, const _Expr2& __y)
+{
+ typedef typename _Expr1::value_type value_type;
+ typedef _BinaryOp<logical_and<value_type>, _Expr1, _Expr2> _Op;
+ return __val_expr<_Op>(_Op(logical_and<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>,
+ _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator&&(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<logical_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+ return __val_expr<_Op>(_Op(logical_and<value_type>(),
+ __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>,
+ __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator&&(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<logical_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(logical_and<value_type>(),
+ __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+ __val_expr<_BinaryOp<logical_or<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator||(const _Expr1& __x, const _Expr2& __y)
+{
+ typedef typename _Expr1::value_type value_type;
+ typedef _BinaryOp<logical_or<value_type>, _Expr1, _Expr2> _Op;
+ return __val_expr<_Op>(_Op(logical_or<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>,
+ _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator||(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<logical_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+ return __val_expr<_Op>(_Op(logical_or<value_type>(),
+ __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>,
+ __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator||(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<logical_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(logical_or<value_type>(),
+ __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+ __val_expr<_BinaryOp<equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator==(const _Expr1& __x, const _Expr2& __y)
+{
+ typedef typename _Expr1::value_type value_type;
+ typedef _BinaryOp<equal_to<value_type>, _Expr1, _Expr2> _Op;
+ return __val_expr<_Op>(_Op(equal_to<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>,
+ _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator==(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+ return __val_expr<_Op>(_Op(equal_to<value_type>(),
+ __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>,
+ __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator==(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(equal_to<value_type>(),
+ __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+ __val_expr<_BinaryOp<not_equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator!=(const _Expr1& __x, const _Expr2& __y)
+{
+ typedef typename _Expr1::value_type value_type;
+ typedef _BinaryOp<not_equal_to<value_type>, _Expr1, _Expr2> _Op;
+ return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>,
+ _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator!=(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<not_equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+ return __val_expr<_Op>(_Op(not_equal_to<value_type>(),
+ __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>,
+ __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator!=(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<not_equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(not_equal_to<value_type>(),
+ __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+ __val_expr<_BinaryOp<less<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator<(const _Expr1& __x, const _Expr2& __y)
+{
+ typedef typename _Expr1::value_type value_type;
+ typedef _BinaryOp<less<value_type>, _Expr1, _Expr2> _Op;
+ return __val_expr<_Op>(_Op(less<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<less<typename _Expr::value_type>,
+ _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator<(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<less<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+ return __val_expr<_Op>(_Op(less<value_type>(),
+ __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<less<typename _Expr::value_type>,
+ __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator<(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<less<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(less<value_type>(),
+ __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+ __val_expr<_BinaryOp<greater<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator>(const _Expr1& __x, const _Expr2& __y)
+{
+ typedef typename _Expr1::value_type value_type;
+ typedef _BinaryOp<greater<value_type>, _Expr1, _Expr2> _Op;
+ return __val_expr<_Op>(_Op(greater<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<greater<typename _Expr::value_type>,
+ _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator>(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<greater<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+ return __val_expr<_Op>(_Op(greater<value_type>(),
+ __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<greater<typename _Expr::value_type>,
+ __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator>(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<greater<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(greater<value_type>(),
+ __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+ __val_expr<_BinaryOp<less_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator<=(const _Expr1& __x, const _Expr2& __y)
+{
+ typedef typename _Expr1::value_type value_type;
+ typedef _BinaryOp<less_equal<value_type>, _Expr1, _Expr2> _Op;
+ return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>,
+ _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator<=(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<less_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+ return __val_expr<_Op>(_Op(less_equal<value_type>(),
+ __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>,
+ __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator<=(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<less_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(less_equal<value_type>(),
+ __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+ __val_expr<_BinaryOp<greater_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator>=(const _Expr1& __x, const _Expr2& __y)
+{
+ typedef typename _Expr1::value_type value_type;
+ typedef _BinaryOp<greater_equal<value_type>, _Expr1, _Expr2> _Op;
+ return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>,
+ _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator>=(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<greater_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+ return __val_expr<_Op>(_Op(greater_equal<value_type>(),
+ __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>,
+ __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator>=(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<greater_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(greater_equal<value_type>(),
+ __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_UnaryOp<__abs_expr<typename _Expr::value_type>, _Expr> >
+>::type
+abs(const _Expr& __x)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _UnaryOp<__abs_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(__abs_expr<value_type>(), __x));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_UnaryOp<__acos_expr<typename _Expr::value_type>, _Expr> >
+>::type
+acos(const _Expr& __x)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _UnaryOp<__acos_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(__acos_expr<value_type>(), __x));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_UnaryOp<__asin_expr<typename _Expr::value_type>, _Expr> >
+>::type
+asin(const _Expr& __x)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _UnaryOp<__asin_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(__asin_expr<value_type>(), __x));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_UnaryOp<__atan_expr<typename _Expr::value_type>, _Expr> >
+>::type
+atan(const _Expr& __x)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _UnaryOp<__atan_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(__atan_expr<value_type>(), __x));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+ __val_expr<_BinaryOp<__atan2_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+atan2(const _Expr1& __x, const _Expr2& __y)
+{
+ typedef typename _Expr1::value_type value_type;
+ typedef _BinaryOp<__atan2_expr<value_type>, _Expr1, _Expr2> _Op;
+ return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>,
+ _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+atan2(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<__atan2_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+ return __val_expr<_Op>(_Op(__atan2_expr<value_type>(),
+ __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>,
+ __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+atan2(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<__atan2_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(__atan2_expr<value_type>(),
+ __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_UnaryOp<__cos_expr<typename _Expr::value_type>, _Expr> >
+>::type
+cos(const _Expr& __x)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _UnaryOp<__cos_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(__cos_expr<value_type>(), __x));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_UnaryOp<__cosh_expr<typename _Expr::value_type>, _Expr> >
+>::type
+cosh(const _Expr& __x)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _UnaryOp<__cosh_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(__cosh_expr<value_type>(), __x));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_UnaryOp<__exp_expr<typename _Expr::value_type>, _Expr> >
+>::type
+exp(const _Expr& __x)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _UnaryOp<__exp_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(__exp_expr<value_type>(), __x));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_UnaryOp<__log_expr<typename _Expr::value_type>, _Expr> >
+>::type
+log(const _Expr& __x)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _UnaryOp<__log_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(__log_expr<value_type>(), __x));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_UnaryOp<__log10_expr<typename _Expr::value_type>, _Expr> >
+>::type
+log10(const _Expr& __x)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _UnaryOp<__log10_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(__log10_expr<value_type>(), __x));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+ __val_expr<_BinaryOp<__pow_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+pow(const _Expr1& __x, const _Expr2& __y)
+{
+ typedef typename _Expr1::value_type value_type;
+ typedef _BinaryOp<__pow_expr<value_type>, _Expr1, _Expr2> _Op;
+ return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>,
+ _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+pow(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<__pow_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+ return __val_expr<_Op>(_Op(__pow_expr<value_type>(),
+ __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>,
+ __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+pow(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _BinaryOp<__pow_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(__pow_expr<value_type>(),
+ __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_UnaryOp<__sin_expr<typename _Expr::value_type>, _Expr> >
+>::type
+sin(const _Expr& __x)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _UnaryOp<__sin_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(__sin_expr<value_type>(), __x));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_UnaryOp<__sinh_expr<typename _Expr::value_type>, _Expr> >
+>::type
+sinh(const _Expr& __x)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _UnaryOp<__sinh_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(__sinh_expr<value_type>(), __x));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_UnaryOp<__sqrt_expr<typename _Expr::value_type>, _Expr> >
+>::type
+sqrt(const _Expr& __x)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _UnaryOp<__sqrt_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(__sqrt_expr<value_type>(), __x));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_UnaryOp<__tan_expr<typename _Expr::value_type>, _Expr> >
+>::type
+tan(const _Expr& __x)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _UnaryOp<__tan_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(__tan_expr<value_type>(), __x));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ __is_val_expr<_Expr>::value,
+ __val_expr<_UnaryOp<__tanh_expr<typename _Expr::value_type>, _Expr> >
+>::type
+tanh(const _Expr& __x)
+{
+ typedef typename _Expr::value_type value_type;
+ typedef _UnaryOp<__tanh_expr<value_type>, _Expr> _Op;
+ return __val_expr<_Op>(_Op(__tanh_expr<value_type>(), __x));
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp*
+begin(valarray<_Tp>& __v)
+{
+ return __v.__begin_;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+const _Tp*
+begin(const valarray<_Tp>& __v)
+{
+ return __v.__begin_;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp*
+end(valarray<_Tp>& __v)
+{
+ return __v.__end_;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+const _Tp*
+end(const valarray<_Tp>& __v)
+{
+ return __v.__end_;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_VALARRAY
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/variant b/contrib/libs/cxxsupp/libcxxmsvc/include/variant
new file mode 100644
index 0000000000..be8e44bf3d
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/variant
@@ -0,0 +1,1789 @@
+// -*- 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
+#define _LIBCPP_VARIANT
+
+/*
+ variant synopsis
+
+namespace std {
+
+ // 20.7.2, class template variant
+ template <class... Types>
+ class variant {
+ public:
+
+ // 20.7.2.1, constructors
+ constexpr variant() noexcept(see below);
+ variant(const variant&); // constexpr in C++20
+ variant(variant&&) noexcept(see below); // constexpr in C++20
+
+ template <class T> constexpr variant(T&&) noexcept(see below);
+
+ template <class T, class... Args>
+ constexpr explicit variant(in_place_type_t<T>, Args&&...);
+
+ template <class T, class U, class... Args>
+ constexpr explicit variant(
+ in_place_type_t<T>, initializer_list<U>, Args&&...);
+
+ template <size_t I, class... Args>
+ constexpr explicit variant(in_place_index_t<I>, Args&&...);
+
+ template <size_t I, class U, class... Args>
+ constexpr explicit variant(
+ in_place_index_t<I>, initializer_list<U>, Args&&...);
+
+ // 20.7.2.2, destructor
+ ~variant();
+
+ // 20.7.2.3, assignment
+ variant& operator=(const variant&); // constexpr in C++20
+ variant& operator=(variant&&) noexcept(see below); // constexpr in C++20
+
+ template <class T> variant& operator=(T&&) noexcept(see below);
+
+ // 20.7.2.4, modifiers
+ template <class T, class... Args>
+ T& emplace(Args&&...);
+
+ template <class T, class U, class... Args>
+ T& emplace(initializer_list<U>, Args&&...);
+
+ template <size_t I, class... Args>
+ variant_alternative_t<I, variant>& emplace(Args&&...);
+
+ template <size_t I, class U, class... Args>
+ variant_alternative_t<I, variant>& emplace(initializer_list<U>, Args&&...);
+
+ // 20.7.2.5, value status
+ constexpr bool valueless_by_exception() const noexcept;
+ constexpr size_t index() const noexcept;
+
+ // 20.7.2.6, swap
+ void swap(variant&) noexcept(see below);
+ };
+
+ // 20.7.3, variant helper classes
+ template <class T> struct variant_size; // undefined
+
+ template <class T>
+ inline constexpr size_t variant_size_v = variant_size<T>::value;
+
+ template <class T> struct variant_size<const T>;
+ template <class T> struct variant_size<volatile T>;
+ template <class T> struct variant_size<const volatile T>;
+
+ template <class... Types>
+ struct variant_size<variant<Types...>>;
+
+ template <size_t I, class T> struct variant_alternative; // undefined
+
+ template <size_t I, class T>
+ using variant_alternative_t = typename variant_alternative<I, T>::type;
+
+ template <size_t I, class T> struct variant_alternative<I, const T>;
+ template <size_t I, class T> struct variant_alternative<I, volatile T>;
+ template <size_t I, class T> struct variant_alternative<I, const volatile T>;
+
+ template <size_t I, class... Types>
+ struct variant_alternative<I, variant<Types...>>;
+
+ inline constexpr size_t variant_npos = -1;
+
+ // 20.7.4, value access
+ template <class T, class... Types>
+ constexpr bool holds_alternative(const variant<Types...>&) noexcept;
+
+ template <size_t I, class... Types>
+ constexpr variant_alternative_t<I, variant<Types...>>&
+ get(variant<Types...>&);
+
+ template <size_t I, class... Types>
+ constexpr variant_alternative_t<I, variant<Types...>>&&
+ get(variant<Types...>&&);
+
+ template <size_t I, class... Types>
+ constexpr variant_alternative_t<I, variant<Types...>> const&
+ get(const variant<Types...>&);
+
+ template <size_t I, class... Types>
+ constexpr variant_alternative_t<I, variant<Types...>> const&&
+ get(const variant<Types...>&&);
+
+ template <class T, class... Types>
+ constexpr T& get(variant<Types...>&);
+
+ template <class T, class... Types>
+ constexpr T&& get(variant<Types...>&&);
+
+ template <class T, class... Types>
+ constexpr const T& get(const variant<Types...>&);
+
+ template <class T, class... Types>
+ constexpr const T&& get(const variant<Types...>&&);
+
+ template <size_t I, class... Types>
+ constexpr add_pointer_t<variant_alternative_t<I, variant<Types...>>>
+ get_if(variant<Types...>*) noexcept;
+
+ template <size_t I, class... Types>
+ constexpr add_pointer_t<const variant_alternative_t<I, variant<Types...>>>
+ get_if(const variant<Types...>*) noexcept;
+
+ template <class T, class... Types>
+ constexpr add_pointer_t<T>
+ get_if(variant<Types...>*) noexcept;
+
+ template <class T, class... Types>
+ constexpr add_pointer_t<const T>
+ get_if(const variant<Types...>*) noexcept;
+
+ // 20.7.5, relational operators
+ template <class... Types>
+ constexpr bool operator==(const variant<Types...>&, const variant<Types...>&);
+
+ template <class... Types>
+ constexpr bool operator!=(const variant<Types...>&, const variant<Types...>&);
+
+ template <class... Types>
+ constexpr bool operator<(const variant<Types...>&, const variant<Types...>&);
+
+ template <class... Types>
+ constexpr bool operator>(const variant<Types...>&, const variant<Types...>&);
+
+ template <class... Types>
+ constexpr bool operator<=(const variant<Types...>&, const variant<Types...>&);
+
+ template <class... Types>
+ constexpr bool operator>=(const variant<Types...>&, const variant<Types...>&);
+
+ // 20.7.6, visitation
+ template <class Visitor, class... Variants>
+ constexpr see below visit(Visitor&&, Variants&&...);
+
+ template <class R, class Visitor, class... Variants>
+ constexpr R visit(Visitor&&, Variants&&...); // since C++20
+
+ // 20.7.7, class monostate
+ struct monostate;
+
+ // 20.7.8, monostate relational operators
+ constexpr bool operator<(monostate, monostate) noexcept;
+ constexpr bool operator>(monostate, monostate) noexcept;
+ constexpr bool operator<=(monostate, monostate) noexcept;
+ constexpr bool operator>=(monostate, monostate) noexcept;
+ constexpr bool operator==(monostate, monostate) noexcept;
+ constexpr bool operator!=(monostate, monostate) noexcept;
+
+ // 20.7.9, specialized algorithms
+ template <class... Types>
+ void swap(variant<Types...>&, variant<Types...>&) noexcept(see below);
+
+ // 20.7.10, class bad_variant_access
+ class bad_variant_access;
+
+ // 20.7.11, hash support
+ template <class T> struct hash;
+ template <class... Types> struct hash<variant<Types...>>;
+ template <> struct hash<monostate>;
+
+} // namespace std
+
+*/
+
+#include <__availability>
+#include <__config>
+#include <__functional/hash.h>
+#include <__functional/operations.h>
+#include <__functional/unary_function.h>
+#include <__tuple>
+#include <__utility/forward.h>
+#include <__variant/monostate.h>
+#include <compare>
+#include <exception>
+#include <initializer_list>
+#include <limits>
+#include <new>
+#include <tuple>
+#include <type_traits>
+#include <utility>
+#include <version>
+
+// TODO: remove these headers
+#include <__functional/binary_function.h>
+#include <__functional/invoke.h>
+#include <__functional/reference_wrapper.h>
+#include <__functional/weak_result_type.h>
+#include <__memory/allocator_arg_t.h>
+#include <__memory/uses_allocator.h>
+#include <typeinfo>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+namespace std { // explicitly not using versioning namespace
+
+class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS bad_variant_access : public exception {
+public:
+ virtual const char* what() const _NOEXCEPT;
+};
+
+} // namespace std
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 14
+
+// 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
+void __throw_bad_variant_access() {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw bad_variant_access();
+#else
+ _VSTD::abort();
+#endif
+}
+
+template <class... _Types>
+class _LIBCPP_TEMPLATE_VIS variant;
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS variant_size;
+
+template <class _Tp>
+inline constexpr size_t variant_size_v = variant_size<_Tp>::value;
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS variant_size<const _Tp> : variant_size<_Tp> {};
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS variant_size<volatile _Tp> : variant_size<_Tp> {};
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS variant_size<const volatile _Tp>
+ : variant_size<_Tp> {};
+
+template <class... _Types>
+struct _LIBCPP_TEMPLATE_VIS variant_size<variant<_Types...>>
+ : integral_constant<size_t, sizeof...(_Types)> {};
+
+template <size_t _Ip, class _Tp>
+struct _LIBCPP_TEMPLATE_VIS variant_alternative;
+
+template <size_t _Ip, class _Tp>
+using variant_alternative_t = typename variant_alternative<_Ip, _Tp>::type;
+
+template <size_t _Ip, class _Tp>
+struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, const _Tp>
+ : add_const<variant_alternative_t<_Ip, _Tp>> {};
+
+template <size_t _Ip, class _Tp>
+struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, volatile _Tp>
+ : add_volatile<variant_alternative_t<_Ip, _Tp>> {};
+
+template <size_t _Ip, class _Tp>
+struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, const volatile _Tp>
+ : add_cv<variant_alternative_t<_Ip, _Tp>> {};
+
+template <size_t _Ip, class... _Types>
+struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, variant<_Types...>> {
+ static_assert(_Ip < sizeof...(_Types), "Index out of bounds in std::variant_alternative<>");
+ using type = __type_pack_element<_Ip, _Types...>;
+};
+
+inline constexpr size_t variant_npos = static_cast<size_t>(-1);
+
+constexpr int __choose_index_type(unsigned int __num_elem) {
+ if (__num_elem < numeric_limits<unsigned char>::max())
+ return 0;
+ if (__num_elem < numeric_limits<unsigned short>::max())
+ return 1;
+ return 2;
+}
+
+template <size_t _NumAlts>
+using __variant_index_t =
+#ifndef _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
+ unsigned int;
+#else
+ std::tuple_element_t<
+ __choose_index_type(_NumAlts),
+ std::tuple<unsigned char, unsigned short, unsigned int>
+ >;
+#endif
+
+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>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr size_t __find_index() {
+ constexpr bool __matches[] = {is_same_v<_Tp, _Types>...};
+ size_t __result = __not_found;
+ for (size_t __i = 0; __i < sizeof...(_Types); ++__i) {
+ if (__matches[__i]) {
+ if (__result != __not_found) {
+ return __ambiguous;
+ }
+ __result = __i;
+ }
+ }
+ return __result;
+}
+
+template <size_t _Index>
+struct __find_unambiguous_index_sfinae_impl
+ : integral_constant<size_t, _Index> {};
+
+template <>
+struct __find_unambiguous_index_sfinae_impl<__not_found> {};
+
+template <>
+struct __find_unambiguous_index_sfinae_impl<__ambiguous> {};
+
+template <class _Tp, class... _Types>
+struct __find_unambiguous_index_sfinae
+ : __find_unambiguous_index_sfinae_impl<__find_index<_Tp, _Types...>()> {};
+
+} // namespace __find_detail
+
+namespace __variant_detail {
+
+struct __valueless_t {};
+
+enum class _Trait { _TriviallyAvailable, _Available, _Unavailable };
+
+template <typename _Tp,
+ template <typename> class _IsTriviallyAvailable,
+ template <typename> class _IsAvailable>
+constexpr _Trait __trait =
+ _IsTriviallyAvailable<_Tp>::value
+ ? _Trait::_TriviallyAvailable
+ : _IsAvailable<_Tp>::value ? _Trait::_Available : _Trait::_Unavailable;
+
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr _Trait __common_trait(initializer_list<_Trait> __traits) {
+ _Trait __result = _Trait::_TriviallyAvailable;
+ for (_Trait __t : __traits) {
+ if (static_cast<int>(__t) > static_cast<int>(__result)) {
+ __result = __t;
+ }
+ }
+ return __result;
+}
+
+template <typename... _Types>
+struct __traits {
+ static constexpr _Trait __copy_constructible_trait =
+ __common_trait({__trait<_Types,
+ is_trivially_copy_constructible,
+ is_copy_constructible>...});
+
+ static constexpr _Trait __move_constructible_trait =
+ __common_trait({__trait<_Types,
+ is_trivially_move_constructible,
+ is_move_constructible>...});
+
+ static constexpr _Trait __copy_assignable_trait = __common_trait(
+ {__copy_constructible_trait,
+ __trait<_Types, is_trivially_copy_assignable, is_copy_assignable>...});
+
+ static constexpr _Trait __move_assignable_trait = __common_trait(
+ {__move_constructible_trait,
+ __trait<_Types, is_trivially_move_assignable, is_move_assignable>...});
+
+ static constexpr _Trait __destructible_trait = __common_trait(
+ {__trait<_Types, is_trivially_destructible, is_destructible>...});
+};
+
+namespace __access {
+
+struct __union {
+ template <class _Vp>
+ inline _LIBCPP_INLINE_VISIBILITY
+ static constexpr auto&& __get_alt(_Vp&& __v, in_place_index_t<0>) {
+ return _VSTD::forward<_Vp>(__v).__head;
+ }
+
+ template <class _Vp, size_t _Ip>
+ inline _LIBCPP_INLINE_VISIBILITY
+ static constexpr auto&& __get_alt(_Vp&& __v, in_place_index_t<_Ip>) {
+ return __get_alt(_VSTD::forward<_Vp>(__v).__tail, in_place_index<_Ip - 1>);
+ }
+};
+
+struct __base {
+ template <size_t _Ip, class _Vp>
+ inline _LIBCPP_INLINE_VISIBILITY
+ static constexpr auto&& __get_alt(_Vp&& __v) {
+ return __union::__get_alt(_VSTD::forward<_Vp>(__v).__data,
+ in_place_index<_Ip>);
+ }
+};
+
+struct __variant {
+ template <size_t _Ip, class _Vp>
+ inline _LIBCPP_INLINE_VISIBILITY
+ static constexpr auto&& __get_alt(_Vp&& __v) {
+ return __base::__get_alt<_Ip>(_VSTD::forward<_Vp>(__v).__impl);
+ }
+};
+
+} // namespace __access
+
+namespace __visitation {
+
+struct __base {
+ template <class _Visitor, class... _Vs>
+ inline _LIBCPP_INLINE_VISIBILITY
+ static constexpr decltype(auto)
+ __visit_alt_at(size_t __index, _Visitor&& __visitor, _Vs&&... __vs) {
+ constexpr auto __fdiagonal =
+ __make_fdiagonal<_Visitor&&,
+ decltype(_VSTD::forward<_Vs>(__vs).__as_base())...>();
+ return __fdiagonal[__index](_VSTD::forward<_Visitor>(__visitor),
+ _VSTD::forward<_Vs>(__vs).__as_base()...);
+ }
+
+ template <class _Visitor, class... _Vs>
+ inline _LIBCPP_INLINE_VISIBILITY
+ static constexpr decltype(auto) __visit_alt(_Visitor&& __visitor,
+ _Vs&&... __vs) {
+ constexpr auto __fmatrix =
+ __make_fmatrix<_Visitor&&,
+ decltype(_VSTD::forward<_Vs>(__vs).__as_base())...>();
+ return __at(__fmatrix, __vs.index()...)(
+ _VSTD::forward<_Visitor>(__visitor),
+ _VSTD::forward<_Vs>(__vs).__as_base()...);
+ }
+
+private:
+ template <class _Tp>
+ inline _LIBCPP_INLINE_VISIBILITY
+ static constexpr const _Tp& __at(const _Tp& __elem) { return __elem; }
+
+ template <class _Tp, size_t _Np, typename... _Indices>
+ inline _LIBCPP_INLINE_VISIBILITY
+ static constexpr auto&& __at(const __farray<_Tp, _Np>& __elems,
+ size_t __index, _Indices... __indices) {
+ return __at(__elems[__index], __indices...);
+ }
+
+ template <class _Fp, class... _Fs>
+ static constexpr void __std_visit_visitor_return_type_check() {
+ static_assert(
+ __all<is_same_v<_Fp, _Fs>...>::value,
+ "`std::visit` requires the visitor to have a single return type.");
+ }
+
+ template <class... _Fs>
+ inline _LIBCPP_INLINE_VISIBILITY
+ static constexpr auto __make_farray(_Fs&&... __fs) {
+ __std_visit_visitor_return_type_check<__uncvref_t<_Fs>...>();
+ using __result = __farray<common_type_t<__uncvref_t<_Fs>...>, sizeof...(_Fs)>;
+ return __result{{_VSTD::forward<_Fs>(__fs)...}};
+ }
+
+ template <size_t... _Is>
+ struct __dispatcher {
+ template <class _Fp, class... _Vs>
+ inline _LIBCPP_INLINE_VISIBILITY
+ static constexpr decltype(auto) __dispatch(_Fp __f, _Vs... __vs) {
+ return _VSTD::__invoke_constexpr(
+ static_cast<_Fp>(__f),
+ __access::__base::__get_alt<_Is>(static_cast<_Vs>(__vs))...);
+ }
+ };
+
+ template <class _Fp, class... _Vs, size_t... _Is>
+ inline _LIBCPP_INLINE_VISIBILITY
+ static constexpr auto __make_dispatch(index_sequence<_Is...>) {
+ return __dispatcher<_Is...>::template __dispatch<_Fp, _Vs...>;
+ }
+
+ template <size_t _Ip, class _Fp, class... _Vs>
+ inline _LIBCPP_INLINE_VISIBILITY
+ static constexpr auto __make_fdiagonal_impl() {
+ return __make_dispatch<_Fp, _Vs...>(
+ index_sequence<((void)__identity<_Vs>{}, _Ip)...>{});
+ }
+
+ template <class _Fp, class... _Vs, size_t... _Is>
+ inline _LIBCPP_INLINE_VISIBILITY
+ static constexpr auto __make_fdiagonal_impl(index_sequence<_Is...>) {
+ return __base::__make_farray(__make_fdiagonal_impl<_Is, _Fp, _Vs...>()...);
+ }
+
+ template <class _Fp, class _Vp, class... _Vs>
+ inline _LIBCPP_INLINE_VISIBILITY
+ static constexpr auto __make_fdiagonal() {
+ constexpr size_t _Np = __uncvref_t<_Vp>::__size();
+ static_assert(__all<(_Np == __uncvref_t<_Vs>::__size())...>::value);
+ return __make_fdiagonal_impl<_Fp, _Vp, _Vs...>(make_index_sequence<_Np>{});
+ }
+
+ template <class _Fp, class... _Vs, size_t... _Is>
+ inline _LIBCPP_INLINE_VISIBILITY
+ static constexpr auto __make_fmatrix_impl(index_sequence<_Is...> __is) {
+ return __make_dispatch<_Fp, _Vs...>(__is);
+ }
+
+ template <class _Fp, class... _Vs, size_t... _Is, size_t... _Js, class... _Ls>
+ inline _LIBCPP_INLINE_VISIBILITY
+ static constexpr auto __make_fmatrix_impl(index_sequence<_Is...>,
+ index_sequence<_Js...>,
+ _Ls... __ls) {
+ return __base::__make_farray(__make_fmatrix_impl<_Fp, _Vs...>(
+ index_sequence<_Is..., _Js>{}, __ls...)...);
+ }
+
+ template <class _Fp, class... _Vs>
+ inline _LIBCPP_INLINE_VISIBILITY
+ static constexpr auto __make_fmatrix() {
+ return __make_fmatrix_impl<_Fp, _Vs...>(
+ index_sequence<>{}, make_index_sequence<__uncvref_t<_Vs>::__size()>{}...);
+ }
+};
+
+struct __variant {
+ template <class _Visitor, class... _Vs>
+ inline _LIBCPP_INLINE_VISIBILITY
+ static constexpr decltype(auto)
+ __visit_alt_at(size_t __index, _Visitor&& __visitor, _Vs&&... __vs) {
+ return __base::__visit_alt_at(__index,
+ _VSTD::forward<_Visitor>(__visitor),
+ _VSTD::forward<_Vs>(__vs).__impl...);
+ }
+
+ template <class _Visitor, class... _Vs>
+ inline _LIBCPP_INLINE_VISIBILITY
+ static constexpr decltype(auto) __visit_alt(_Visitor&& __visitor,
+ _Vs&&... __vs) {
+ return __base::__visit_alt(
+ _VSTD::forward<_Visitor>(__visitor),
+ _VSTD::__as_variant(_VSTD::forward<_Vs>(__vs)).__impl...);
+ }
+
+ template <class _Visitor, class... _Vs>
+ inline _LIBCPP_INLINE_VISIBILITY
+ static constexpr decltype(auto)
+ __visit_value_at(size_t __index, _Visitor&& __visitor, _Vs&&... __vs) {
+ return __visit_alt_at(
+ __index,
+ __make_value_visitor(_VSTD::forward<_Visitor>(__visitor)),
+ _VSTD::forward<_Vs>(__vs)...);
+ }
+
+ template <class _Visitor, class... _Vs>
+ inline _LIBCPP_INLINE_VISIBILITY
+ static constexpr decltype(auto) __visit_value(_Visitor&& __visitor,
+ _Vs&&... __vs) {
+ return __visit_alt(
+ __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
+ static constexpr _Rp __visit_value(_Visitor&& __visitor,
+ _Vs&&... __vs) {
+ return __visit_alt(
+ __make_value_visitor<_Rp>(_VSTD::forward<_Visitor>(__visitor)),
+ _VSTD::forward<_Vs>(__vs)...);
+ }
+#endif
+
+private:
+ template <class _Visitor, class... _Values>
+ static constexpr void __std_visit_exhaustive_visitor_check() {
+ static_assert(is_invocable_v<_Visitor, _Values...>,
+ "`std::visit` requires the visitor to be exhaustive.");
+ }
+
+ template <class _Visitor>
+ struct __value_visitor {
+ template <class... _Alts>
+ inline _LIBCPP_INLINE_VISIBILITY
+ constexpr decltype(auto) operator()(_Alts&&... __alts) const {
+ __std_visit_exhaustive_visitor_check<
+ _Visitor,
+ decltype((_VSTD::forward<_Alts>(__alts).__value))...>();
+ return _VSTD::__invoke_constexpr(_VSTD::forward<_Visitor>(__visitor),
+ _VSTD::forward<_Alts>(__alts).__value...);
+ }
+ _Visitor&& __visitor;
+ };
+
+#if _LIBCPP_STD_VER > 17
+ template <class _Rp, class _Visitor>
+ struct __value_visitor_return_type {
+ template <class... _Alts>
+ inline _LIBCPP_INLINE_VISIBILITY
+ constexpr _Rp operator()(_Alts&&... __alts) const {
+ __std_visit_exhaustive_visitor_check<
+ _Visitor,
+ decltype((_VSTD::forward<_Alts>(__alts).__value))...>();
+ if constexpr (is_void_v<_Rp>) {
+ _VSTD::__invoke_constexpr(_VSTD::forward<_Visitor>(__visitor),
+ _VSTD::forward<_Alts>(__alts).__value...);
+ }
+ else {
+ return _VSTD::__invoke_constexpr(_VSTD::forward<_Visitor>(__visitor),
+ _VSTD::forward<_Alts>(__alts).__value...);
+ }
+ }
+
+ _Visitor&& __visitor;
+ };
+#endif
+
+ template <class _Visitor>
+ inline _LIBCPP_INLINE_VISIBILITY
+ static constexpr auto __make_value_visitor(_Visitor&& __visitor) {
+ return __value_visitor<_Visitor>{_VSTD::forward<_Visitor>(__visitor)};
+ }
+
+#if _LIBCPP_STD_VER > 17
+ template <class _Rp, class _Visitor>
+ inline _LIBCPP_INLINE_VISIBILITY
+ static constexpr auto __make_value_visitor(_Visitor&& __visitor) {
+ return __value_visitor_return_type<_Rp, _Visitor>{_VSTD::forward<_Visitor>(__visitor)};
+ }
+#endif
+};
+
+} // namespace __visitation
+
+template <size_t _Index, class _Tp>
+struct _LIBCPP_TEMPLATE_VIS __alt {
+ using __value_type = _Tp;
+
+ template <class... _Args>
+ inline _LIBCPP_INLINE_VISIBILITY
+ explicit constexpr __alt(in_place_t, _Args&&... __args)
+ : __value(_VSTD::forward<_Args>(__args)...) {}
+
+ __value_type __value;
+};
+
+template <_Trait _DestructibleTrait, size_t _Index, class... _Types>
+union _LIBCPP_TEMPLATE_VIS __union;
+
+template <_Trait _DestructibleTrait, size_t _Index>
+union _LIBCPP_TEMPLATE_VIS __union<_DestructibleTrait, _Index> {};
+
+#define _LIBCPP_VARIANT_UNION(destructible_trait, destructor) \
+ template <size_t _Index, class _Tp, class... _Types> \
+ union _LIBCPP_TEMPLATE_VIS __union<destructible_trait, \
+ _Index, \
+ _Tp, \
+ _Types...> { \
+ public: \
+ inline _LIBCPP_INLINE_VISIBILITY \
+ explicit constexpr __union(__valueless_t) noexcept : __dummy{} {} \
+ \
+ template <class... _Args> \
+ inline _LIBCPP_INLINE_VISIBILITY \
+ explicit constexpr __union(in_place_index_t<0>, _Args&&... __args) \
+ : __head(in_place, _VSTD::forward<_Args>(__args)...) {} \
+ \
+ template <size_t _Ip, class... _Args> \
+ inline _LIBCPP_INLINE_VISIBILITY \
+ explicit constexpr __union(in_place_index_t<_Ip>, _Args&&... __args) \
+ : __tail(in_place_index<_Ip - 1>, _VSTD::forward<_Args>(__args)...) {} \
+ \
+ __union(const __union&) = default; \
+ __union(__union&&) = default; \
+ \
+ destructor \
+ \
+ __union& operator=(const __union&) = default; \
+ __union& operator=(__union&&) = default; \
+ \
+ private: \
+ char __dummy; \
+ __alt<_Index, _Tp> __head; \
+ __union<destructible_trait, _Index + 1, _Types...> __tail; \
+ \
+ friend struct __access::__union; \
+ }
+
+_LIBCPP_VARIANT_UNION(_Trait::_TriviallyAvailable, ~__union() = default;);
+_LIBCPP_VARIANT_UNION(_Trait::_Available, ~__union() {});
+_LIBCPP_VARIANT_UNION(_Trait::_Unavailable, ~__union() = delete;);
+
+#undef _LIBCPP_VARIANT_UNION
+
+template <_Trait _DestructibleTrait, class... _Types>
+class _LIBCPP_TEMPLATE_VIS __base {
+public:
+ using __index_t = __variant_index_t<sizeof...(_Types)>;
+
+ inline _LIBCPP_INLINE_VISIBILITY
+ explicit constexpr __base(__valueless_t tag) noexcept
+ : __data(tag), __index(__variant_npos<__index_t>) {}
+
+ template <size_t _Ip, class... _Args>
+ inline _LIBCPP_INLINE_VISIBILITY
+ explicit constexpr __base(in_place_index_t<_Ip>, _Args&&... __args)
+ :
+ __data(in_place_index<_Ip>, _VSTD::forward<_Args>(__args)...),
+ __index(_Ip) {}
+
+ inline _LIBCPP_INLINE_VISIBILITY
+ constexpr bool valueless_by_exception() const noexcept {
+ return index() == variant_npos;
+ }
+
+ inline _LIBCPP_INLINE_VISIBILITY
+ constexpr size_t index() const noexcept {
+ return __index == __variant_npos<__index_t> ? variant_npos : __index;
+ }
+
+protected:
+ inline _LIBCPP_INLINE_VISIBILITY
+ constexpr auto&& __as_base() & { return *this; }
+
+ inline _LIBCPP_INLINE_VISIBILITY
+ constexpr auto&& __as_base() && { return _VSTD::move(*this); }
+
+ inline _LIBCPP_INLINE_VISIBILITY
+ constexpr auto&& __as_base() const & { return *this; }
+
+ inline _LIBCPP_INLINE_VISIBILITY
+ constexpr auto&& __as_base() const && { return _VSTD::move(*this); }
+
+ inline _LIBCPP_INLINE_VISIBILITY
+ static constexpr size_t __size() { return sizeof...(_Types); }
+
+ __union<_DestructibleTrait, 0, _Types...> __data;
+ __index_t __index;
+
+ friend struct __access::__base;
+ friend struct __visitation::__base;
+};
+
+template <class _Traits, _Trait = _Traits::__destructible_trait>
+class _LIBCPP_TEMPLATE_VIS __dtor;
+
+#define _LIBCPP_VARIANT_DESTRUCTOR(destructible_trait, destructor, destroy) \
+ template <class... _Types> \
+ class _LIBCPP_TEMPLATE_VIS __dtor<__traits<_Types...>, \
+ destructible_trait> \
+ : public __base<destructible_trait, _Types...> { \
+ using __base_type = __base<destructible_trait, _Types...>; \
+ using __index_t = typename __base_type::__index_t; \
+ \
+ public: \
+ using __base_type::__base_type; \
+ using __base_type::operator=; \
+ \
+ __dtor(const __dtor&) = default; \
+ __dtor(__dtor&&) = default; \
+ destructor \
+ __dtor& operator=(const __dtor&) = default; \
+ __dtor& operator=(__dtor&&) = default; \
+ \
+ protected: \
+ inline _LIBCPP_INLINE_VISIBILITY \
+ destroy \
+ }
+
+_LIBCPP_VARIANT_DESTRUCTOR(
+ _Trait::_TriviallyAvailable,
+ ~__dtor() = default;,
+ void __destroy() noexcept { this->__index = __variant_npos<__index_t>; });
+
+_LIBCPP_VARIANT_DESTRUCTOR(
+ _Trait::_Available,
+ ~__dtor() { __destroy(); },
+ void __destroy() noexcept {
+ if (!this->valueless_by_exception()) {
+ __visitation::__base::__visit_alt(
+ [](auto& __alt) noexcept {
+ using __alt_type = __uncvref_t<decltype(__alt)>;
+ __alt.~__alt_type();
+ },
+ *this);
+ }
+ this->__index = __variant_npos<__index_t>;
+ });
+
+_LIBCPP_VARIANT_DESTRUCTOR(
+ _Trait::_Unavailable,
+ ~__dtor() = delete;,
+ void __destroy() noexcept = delete;);
+
+#undef _LIBCPP_VARIANT_DESTRUCTOR
+
+template <class _Traits>
+class _LIBCPP_TEMPLATE_VIS __ctor : public __dtor<_Traits> {
+ using __base_type = __dtor<_Traits>;
+
+public:
+ using __base_type::__base_type;
+ using __base_type::operator=;
+
+protected:
+ template <size_t _Ip, class _Tp, class... _Args>
+ inline _LIBCPP_INLINE_VISIBILITY
+ static _Tp& __construct_alt(__alt<_Ip, _Tp>& __a, _Args&&... __args) {
+ ::new ((void*)_VSTD::addressof(__a))
+ __alt<_Ip, _Tp>(in_place, _VSTD::forward<_Args>(__args)...);
+ return __a.__value;
+ }
+
+ template <class _Rhs>
+ inline _LIBCPP_INLINE_VISIBILITY
+ static void __generic_construct(__ctor& __lhs, _Rhs&& __rhs) {
+ __lhs.__destroy();
+ if (!__rhs.valueless_by_exception()) {
+ __visitation::__base::__visit_alt_at(
+ __rhs.index(),
+ [](auto& __lhs_alt, auto&& __rhs_alt) {
+ __construct_alt(
+ __lhs_alt,
+ _VSTD::forward<decltype(__rhs_alt)>(__rhs_alt).__value);
+ },
+ __lhs, _VSTD::forward<_Rhs>(__rhs));
+ __lhs.__index = __rhs.index();
+ }
+ }
+};
+
+template <class _Traits, _Trait = _Traits::__move_constructible_trait>
+class _LIBCPP_TEMPLATE_VIS __move_constructor;
+
+#define _LIBCPP_VARIANT_MOVE_CONSTRUCTOR(move_constructible_trait, \
+ move_constructor) \
+ template <class... _Types> \
+ class _LIBCPP_TEMPLATE_VIS __move_constructor<__traits<_Types...>, \
+ move_constructible_trait> \
+ : public __ctor<__traits<_Types...>> { \
+ using __base_type = __ctor<__traits<_Types...>>; \
+ \
+ public: \
+ using __base_type::__base_type; \
+ using __base_type::operator=; \
+ \
+ __move_constructor(const __move_constructor&) = default; \
+ move_constructor \
+ ~__move_constructor() = default; \
+ __move_constructor& operator=(const __move_constructor&) = default; \
+ __move_constructor& operator=(__move_constructor&&) = default; \
+ }
+
+_LIBCPP_VARIANT_MOVE_CONSTRUCTOR(
+ _Trait::_TriviallyAvailable,
+ __move_constructor(__move_constructor&& __that) = default;);
+
+_LIBCPP_VARIANT_MOVE_CONSTRUCTOR(
+ _Trait::_Available,
+ __move_constructor(__move_constructor&& __that) noexcept(
+ __all<is_nothrow_move_constructible_v<_Types>...>::value)
+ : __move_constructor(__valueless_t{}) {
+ this->__generic_construct(*this, _VSTD::move(__that));
+ });
+
+_LIBCPP_VARIANT_MOVE_CONSTRUCTOR(
+ _Trait::_Unavailable,
+ __move_constructor(__move_constructor&&) = delete;);
+
+#undef _LIBCPP_VARIANT_MOVE_CONSTRUCTOR
+
+template <class _Traits, _Trait = _Traits::__copy_constructible_trait>
+class _LIBCPP_TEMPLATE_VIS __copy_constructor;
+
+#define _LIBCPP_VARIANT_COPY_CONSTRUCTOR(copy_constructible_trait, \
+ copy_constructor) \
+ template <class... _Types> \
+ class _LIBCPP_TEMPLATE_VIS __copy_constructor<__traits<_Types...>, \
+ copy_constructible_trait> \
+ : public __move_constructor<__traits<_Types...>> { \
+ using __base_type = __move_constructor<__traits<_Types...>>; \
+ \
+ public: \
+ using __base_type::__base_type; \
+ using __base_type::operator=; \
+ \
+ copy_constructor \
+ __copy_constructor(__copy_constructor&&) = default; \
+ ~__copy_constructor() = default; \
+ __copy_constructor& operator=(const __copy_constructor&) = default; \
+ __copy_constructor& operator=(__copy_constructor&&) = default; \
+ }
+
+_LIBCPP_VARIANT_COPY_CONSTRUCTOR(
+ _Trait::_TriviallyAvailable,
+ __copy_constructor(const __copy_constructor& __that) = default;);
+
+_LIBCPP_VARIANT_COPY_CONSTRUCTOR(
+ _Trait::_Available,
+ __copy_constructor(const __copy_constructor& __that)
+ : __copy_constructor(__valueless_t{}) {
+ this->__generic_construct(*this, __that);
+ });
+
+_LIBCPP_VARIANT_COPY_CONSTRUCTOR(
+ _Trait::_Unavailable,
+ __copy_constructor(const __copy_constructor&) = delete;);
+
+#undef _LIBCPP_VARIANT_COPY_CONSTRUCTOR
+
+template <class _Traits>
+class _LIBCPP_TEMPLATE_VIS __assignment : public __copy_constructor<_Traits> {
+ using __base_type = __copy_constructor<_Traits>;
+
+public:
+ using __base_type::__base_type;
+ using __base_type::operator=;
+
+ template <size_t _Ip, class... _Args>
+ inline _LIBCPP_INLINE_VISIBILITY
+ auto& __emplace(_Args&&... __args) {
+ this->__destroy();
+ auto& __res = this->__construct_alt(__access::__base::__get_alt<_Ip>(*this),
+ _VSTD::forward<_Args>(__args)...);
+ this->__index = _Ip;
+ return __res;
+ }
+
+protected:
+ template <size_t _Ip, class _Tp, class _Arg>
+ inline _LIBCPP_INLINE_VISIBILITY
+ void __assign_alt(__alt<_Ip, _Tp>& __a, _Arg&& __arg) {
+ if (this->index() == _Ip) {
+ __a.__value = _VSTD::forward<_Arg>(__arg);
+ } else {
+ struct {
+ void operator()(true_type) const {
+ __this->__emplace<_Ip>(_VSTD::forward<_Arg>(__arg));
+ }
+ void operator()(false_type) const {
+ __this->__emplace<_Ip>(_Tp(_VSTD::forward<_Arg>(__arg)));
+ }
+ __assignment* __this;
+ _Arg&& __arg;
+ } __impl{this, _VSTD::forward<_Arg>(__arg)};
+ __impl(bool_constant<is_nothrow_constructible_v<_Tp, _Arg> ||
+ !is_nothrow_move_constructible_v<_Tp>>{});
+ }
+ }
+
+ template <class _That>
+ inline _LIBCPP_INLINE_VISIBILITY
+ void __generic_assign(_That&& __that) {
+ if (this->valueless_by_exception() && __that.valueless_by_exception()) {
+ // do nothing.
+ } else if (__that.valueless_by_exception()) {
+ this->__destroy();
+ } else {
+ __visitation::__base::__visit_alt_at(
+ __that.index(),
+ [this](auto& __this_alt, auto&& __that_alt) {
+ this->__assign_alt(
+ __this_alt,
+ _VSTD::forward<decltype(__that_alt)>(__that_alt).__value);
+ },
+ *this, _VSTD::forward<_That>(__that));
+ }
+ }
+};
+
+template <class _Traits, _Trait = _Traits::__move_assignable_trait>
+class _LIBCPP_TEMPLATE_VIS __move_assignment;
+
+#define _LIBCPP_VARIANT_MOVE_ASSIGNMENT(move_assignable_trait, \
+ move_assignment) \
+ template <class... _Types> \
+ class _LIBCPP_TEMPLATE_VIS __move_assignment<__traits<_Types...>, \
+ move_assignable_trait> \
+ : public __assignment<__traits<_Types...>> { \
+ using __base_type = __assignment<__traits<_Types...>>; \
+ \
+ public: \
+ using __base_type::__base_type; \
+ using __base_type::operator=; \
+ \
+ __move_assignment(const __move_assignment&) = default; \
+ __move_assignment(__move_assignment&&) = default; \
+ ~__move_assignment() = default; \
+ __move_assignment& operator=(const __move_assignment&) = default; \
+ move_assignment \
+ }
+
+_LIBCPP_VARIANT_MOVE_ASSIGNMENT(
+ _Trait::_TriviallyAvailable,
+ __move_assignment& operator=(__move_assignment&& __that) = default;);
+
+_LIBCPP_VARIANT_MOVE_ASSIGNMENT(
+ _Trait::_Available,
+ __move_assignment& operator=(__move_assignment&& __that) noexcept(
+ __all<(is_nothrow_move_constructible_v<_Types> &&
+ is_nothrow_move_assignable_v<_Types>)...>::value) {
+ this->__generic_assign(_VSTD::move(__that));
+ return *this;
+ });
+
+_LIBCPP_VARIANT_MOVE_ASSIGNMENT(
+ _Trait::_Unavailable,
+ __move_assignment& operator=(__move_assignment&&) = delete;);
+
+#undef _LIBCPP_VARIANT_MOVE_ASSIGNMENT
+
+template <class _Traits, _Trait = _Traits::__copy_assignable_trait>
+class _LIBCPP_TEMPLATE_VIS __copy_assignment;
+
+#define _LIBCPP_VARIANT_COPY_ASSIGNMENT(copy_assignable_trait, \
+ copy_assignment) \
+ template <class... _Types> \
+ class _LIBCPP_TEMPLATE_VIS __copy_assignment<__traits<_Types...>, \
+ copy_assignable_trait> \
+ : public __move_assignment<__traits<_Types...>> { \
+ using __base_type = __move_assignment<__traits<_Types...>>; \
+ \
+ public: \
+ using __base_type::__base_type; \
+ using __base_type::operator=; \
+ \
+ __copy_assignment(const __copy_assignment&) = default; \
+ __copy_assignment(__copy_assignment&&) = default; \
+ ~__copy_assignment() = default; \
+ copy_assignment \
+ __copy_assignment& operator=(__copy_assignment&&) = default; \
+ }
+
+_LIBCPP_VARIANT_COPY_ASSIGNMENT(
+ _Trait::_TriviallyAvailable,
+ __copy_assignment& operator=(const __copy_assignment& __that) = default;);
+
+_LIBCPP_VARIANT_COPY_ASSIGNMENT(
+ _Trait::_Available,
+ __copy_assignment& operator=(const __copy_assignment& __that) {
+ this->__generic_assign(__that);
+ return *this;
+ });
+
+_LIBCPP_VARIANT_COPY_ASSIGNMENT(
+ _Trait::_Unavailable,
+ __copy_assignment& operator=(const __copy_assignment&) = delete;);
+
+#undef _LIBCPP_VARIANT_COPY_ASSIGNMENT
+
+template <class... _Types>
+class _LIBCPP_TEMPLATE_VIS __impl
+ : public __copy_assignment<__traits<_Types...>> {
+ using __base_type = __copy_assignment<__traits<_Types...>>;
+
+public:
+ using __base_type::__base_type;
+ using __base_type::operator=;
+
+ template <size_t _Ip, class _Arg>
+ inline _LIBCPP_INLINE_VISIBILITY
+ void __assign(_Arg&& __arg) {
+ this->__assign_alt(__access::__base::__get_alt<_Ip>(*this),
+ _VSTD::forward<_Arg>(__arg));
+ }
+
+ inline _LIBCPP_INLINE_VISIBILITY
+ void __swap(__impl& __that) {
+ if (this->valueless_by_exception() && __that.valueless_by_exception()) {
+ // do nothing.
+ } else if (this->index() == __that.index()) {
+ __visitation::__base::__visit_alt_at(
+ this->index(),
+ [](auto& __this_alt, auto& __that_alt) {
+ using _VSTD::swap;
+ swap(__this_alt.__value, __that_alt.__value);
+ },
+ *this,
+ __that);
+ } else {
+ __impl* __lhs = this;
+ __impl* __rhs = _VSTD::addressof(__that);
+ if (__lhs->__move_nothrow() && !__rhs->__move_nothrow()) {
+ _VSTD::swap(__lhs, __rhs);
+ }
+ __impl __tmp(_VSTD::move(*__rhs));
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ if constexpr (__all<is_nothrow_move_constructible_v<_Types>...>::value) {
+ this->__generic_construct(*__rhs, _VSTD::move(*__lhs));
+ } else {
+ // EXTENSION: When the move construction of `__lhs` into `__rhs` throws
+ // and `__tmp` is nothrow move constructible then we move `__tmp` back
+ // into `__rhs` and provide the strong exception safety guarantee.
+ try {
+ this->__generic_construct(*__rhs, _VSTD::move(*__lhs));
+ } catch (...) {
+ if (__tmp.__move_nothrow()) {
+ this->__generic_construct(*__rhs, _VSTD::move(__tmp));
+ }
+ throw;
+ }
+ }
+#else
+ // this isn't consolidated with the `if constexpr` branch above due to
+ // `throw` being ill-formed with exceptions disabled even when discarded.
+ this->__generic_construct(*__rhs, _VSTD::move(*__lhs));
+#endif
+ this->__generic_construct(*__lhs, _VSTD::move(__tmp));
+ }
+ }
+
+private:
+ inline _LIBCPP_INLINE_VISIBILITY
+ bool __move_nothrow() const {
+ constexpr bool __results[] = {is_nothrow_move_constructible_v<_Types>...};
+ return this->valueless_by_exception() || __results[this->index()];
+ }
+};
+
+struct __no_narrowing_check {
+ template <class _Dest, class _Source>
+ using _Apply = __identity<_Dest>;
+};
+
+struct __narrowing_check {
+ template <class _Dest>
+ static auto __test_impl(_Dest (&&)[1]) -> __identity<_Dest>;
+ template <class _Dest, class _Source>
+ using _Apply _LIBCPP_NODEBUG = decltype(__test_impl<_Dest>({declval<_Source>()}));
+};
+
+template <class _Dest, class _Source>
+using __check_for_narrowing _LIBCPP_NODEBUG =
+ typename _If<
+#ifdef _LIBCPP_ENABLE_NARROWING_CONVERSIONS_IN_VARIANT
+ false &&
+#endif
+ is_arithmetic<_Dest>::value,
+ __narrowing_check,
+ __no_narrowing_check
+ >::template _Apply<_Dest, _Source>;
+
+template <class _Tp, size_t _Idx>
+struct __overload {
+ template <class _Up>
+ auto operator()(_Tp, _Up&&) const -> __check_for_narrowing<_Tp, _Up>;
+};
+
+template <class _Tp, size_t>
+struct __overload_bool {
+ template <class _Up, class _Ap = __uncvref_t<_Up>>
+ auto operator()(bool, _Up&&) const
+ -> enable_if_t<is_same_v<_Ap, bool>, __identity<_Tp>>;
+};
+
+template <size_t _Idx>
+struct __overload<bool, _Idx> : __overload_bool<bool, _Idx> {};
+template <size_t _Idx>
+struct __overload<bool const, _Idx> : __overload_bool<bool const, _Idx> {};
+template <size_t _Idx>
+struct __overload<bool volatile, _Idx> : __overload_bool<bool volatile, _Idx> {};
+template <size_t _Idx>
+struct __overload<bool const volatile, _Idx> : __overload_bool<bool const volatile, _Idx> {};
+
+template <class ..._Bases>
+struct __all_overloads : _Bases... {
+ void operator()() const;
+ using _Bases::operator()...;
+};
+
+// Change metaprogramming to satisfy MSVC. It doesn't like expression
+// __overload<_Types, _Idx>... when _Types comes from using parameter but
+// _Idx comes from structure template parameter. So I made them both
+// structure template parameters.
+template <class _IdxSeq, class ..._Types>
+struct __make_overloads_imp;
+
+template <size_t ..._Idx, class ..._Types>
+struct __make_overloads_imp<__tuple_indices<_Idx...>, _Types... > {
+ using _Apply _LIBCPP_NODEBUG = __all_overloads<__overload<_Types, _Idx>...>;
+};
+
+template <class ..._Types>
+using _MakeOverloads _LIBCPP_NODEBUG = typename __make_overloads_imp<
+ __make_indices_imp<_Sizeof<_Types...>::value, 0>, _Types...>::_Apply;
+
+template <class _Tp, class... _Types>
+using __best_match_t =
+ typename invoke_result_t<_MakeOverloads<_Types...>, _Tp, _Tp>::type;
+
+} // namespace __variant_detail
+
+template <class... _Types>
+class _LIBCPP_TEMPLATE_VIS variant
+ : private __sfinae_ctor_base<
+ __all<is_copy_constructible_v<_Types>...>::value,
+ __all<is_move_constructible_v<_Types>...>::value>,
+ private __sfinae_assign_base<
+ __all<(is_copy_constructible_v<_Types> &&
+ is_copy_assignable_v<_Types>)...>::value,
+ __all<(is_move_constructible_v<_Types> &&
+ is_move_assignable_v<_Types>)...>::value> {
+ static_assert(0 < sizeof...(_Types),
+ "variant must consist of at least one alternative.");
+
+ static_assert(__all<!is_array_v<_Types>...>::value,
+ "variant can not have an array type as an alternative.");
+
+ static_assert(__all<!is_reference_v<_Types>...>::value,
+ "variant can not have a reference type as an alternative.");
+
+ static_assert(__all<!is_void_v<_Types>...>::value,
+ "variant can not have a void type as an alternative.");
+
+ using __first_type = variant_alternative_t<0, variant>;
+
+public:
+ template <bool _Dummy = true,
+ enable_if_t<__dependent_type<is_default_constructible<__first_type>,
+ _Dummy>::value,
+ int> = 0>
+ inline _LIBCPP_INLINE_VISIBILITY
+ constexpr variant() noexcept(is_nothrow_default_constructible_v<__first_type>)
+ : __impl(in_place_index<0>) {}
+
+ variant(const variant&) = default;
+ variant(variant&&) = default;
+
+ template <
+ class _Arg,
+ enable_if_t<!is_same_v<__uncvref_t<_Arg>, variant>, int> = 0,
+ enable_if_t<!__is_inplace_type<__uncvref_t<_Arg>>::value, int> = 0,
+ enable_if_t<!__is_inplace_index<__uncvref_t<_Arg>>::value, int> = 0,
+ class _Tp = __variant_detail::__best_match_t<_Arg, _Types...>,
+ size_t _Ip =
+ __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value,
+ enable_if_t<is_constructible_v<_Tp, _Arg>, int> = 0>
+ inline _LIBCPP_INLINE_VISIBILITY
+ constexpr variant(_Arg&& __arg) noexcept(
+ is_nothrow_constructible_v<_Tp, _Arg>)
+ : __impl(in_place_index<_Ip>, _VSTD::forward<_Arg>(__arg)) {}
+
+ template <size_t _Ip, class... _Args,
+ class = enable_if_t<(_Ip < sizeof...(_Types)), int>,
+ class _Tp = variant_alternative_t<_Ip, variant<_Types...>>,
+ enable_if_t<is_constructible_v<_Tp, _Args...>, int> = 0>
+ inline _LIBCPP_INLINE_VISIBILITY
+ explicit constexpr variant(
+ in_place_index_t<_Ip>,
+ _Args&&... __args) noexcept(is_nothrow_constructible_v<_Tp, _Args...>)
+ : __impl(in_place_index<_Ip>, _VSTD::forward<_Args>(__args)...) {}
+
+ template <
+ size_t _Ip,
+ class _Up,
+ class... _Args,
+ enable_if_t<(_Ip < sizeof...(_Types)), int> = 0,
+ class _Tp = variant_alternative_t<_Ip, variant<_Types...>>,
+ enable_if_t<is_constructible_v<_Tp, initializer_list<_Up>&, _Args...>,
+ int> = 0>
+ inline _LIBCPP_INLINE_VISIBILITY
+ explicit constexpr variant(
+ in_place_index_t<_Ip>,
+ initializer_list<_Up> __il,
+ _Args&&... __args) noexcept(
+ is_nothrow_constructible_v<_Tp, initializer_list<_Up>&, _Args...>)
+ : __impl(in_place_index<_Ip>, __il, _VSTD::forward<_Args>(__args)...) {}
+
+ template <
+ class _Tp,
+ class... _Args,
+ size_t _Ip =
+ __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value,
+ enable_if_t<is_constructible_v<_Tp, _Args...>, int> = 0>
+ inline _LIBCPP_INLINE_VISIBILITY
+ explicit constexpr variant(in_place_type_t<_Tp>, _Args&&... __args) noexcept(
+ is_nothrow_constructible_v<_Tp, _Args...>)
+ : __impl(in_place_index<_Ip>, _VSTD::forward<_Args>(__args)...) {}
+
+ template <
+ class _Tp,
+ class _Up,
+ class... _Args,
+ size_t _Ip =
+ __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value,
+ enable_if_t<is_constructible_v<_Tp, initializer_list<_Up>&, _Args...>,
+ int> = 0>
+ inline _LIBCPP_INLINE_VISIBILITY
+ explicit constexpr variant(
+ in_place_type_t<_Tp>,
+ initializer_list<_Up> __il,
+ _Args&&... __args) noexcept(
+ is_nothrow_constructible_v<_Tp, initializer_list< _Up>&, _Args...>)
+ : __impl(in_place_index<_Ip>, __il, _VSTD::forward<_Args>(__args)...) {}
+
+ ~variant() = default;
+
+ variant& operator=(const variant&) = default;
+ variant& operator=(variant&&) = default;
+
+ template <
+ class _Arg,
+ enable_if_t<!is_same_v<__uncvref_t<_Arg>, variant>, int> = 0,
+ class _Tp = __variant_detail::__best_match_t<_Arg, _Types...>,
+ size_t _Ip =
+ __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value,
+ enable_if_t<is_assignable_v<_Tp&, _Arg> && is_constructible_v<_Tp, _Arg>,
+ int> = 0>
+ inline _LIBCPP_INLINE_VISIBILITY
+ variant& operator=(_Arg&& __arg) noexcept(
+ is_nothrow_assignable_v<_Tp&, _Arg> &&
+ is_nothrow_constructible_v<_Tp, _Arg>) {
+ __impl.template __assign<_Ip>(_VSTD::forward<_Arg>(__arg));
+ return *this;
+ }
+
+ template <
+ size_t _Ip,
+ class... _Args,
+ enable_if_t<(_Ip < sizeof...(_Types)), int> = 0,
+ class _Tp = variant_alternative_t<_Ip, variant<_Types...>>,
+ enable_if_t<is_constructible_v<_Tp, _Args...>, int> = 0>
+ inline _LIBCPP_INLINE_VISIBILITY
+ _Tp& emplace(_Args&&... __args) {
+ return __impl.template __emplace<_Ip>(_VSTD::forward<_Args>(__args)...);
+ }
+
+ template <
+ size_t _Ip,
+ class _Up,
+ class... _Args,
+ enable_if_t<(_Ip < sizeof...(_Types)), int> = 0,
+ class _Tp = variant_alternative_t<_Ip, variant<_Types...>>,
+ enable_if_t<is_constructible_v<_Tp, initializer_list<_Up>&, _Args...>,
+ int> = 0>
+ inline _LIBCPP_INLINE_VISIBILITY
+ _Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) {
+ return __impl.template __emplace<_Ip>(__il, _VSTD::forward<_Args>(__args)...);
+ }
+
+ template <
+ class _Tp,
+ class... _Args,
+ size_t _Ip =
+ __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value,
+ enable_if_t<is_constructible_v<_Tp, _Args...>, int> = 0>
+ inline _LIBCPP_INLINE_VISIBILITY
+ _Tp& emplace(_Args&&... __args) {
+ return __impl.template __emplace<_Ip>(_VSTD::forward<_Args>(__args)...);
+ }
+
+ template <
+ class _Tp,
+ class _Up,
+ class... _Args,
+ size_t _Ip =
+ __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value,
+ enable_if_t<is_constructible_v<_Tp, initializer_list<_Up>&, _Args...>,
+ int> = 0>
+ inline _LIBCPP_INLINE_VISIBILITY
+ _Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) {
+ return __impl.template __emplace<_Ip>(__il, _VSTD::forward<_Args>(__args)...);
+ }
+
+ inline _LIBCPP_INLINE_VISIBILITY
+ constexpr bool valueless_by_exception() const noexcept {
+ return __impl.valueless_by_exception();
+ }
+
+ inline _LIBCPP_INLINE_VISIBILITY
+ constexpr size_t index() const noexcept { return __impl.index(); }
+
+ template <
+ bool _Dummy = true,
+ enable_if_t<
+ __all<(
+ __dependent_type<is_move_constructible<_Types>, _Dummy>::value &&
+ __dependent_type<is_swappable<_Types>, _Dummy>::value)...>::value,
+ int> = 0>
+ inline _LIBCPP_INLINE_VISIBILITY
+ void swap(variant& __that) noexcept(
+ __all<(is_nothrow_move_constructible_v<_Types> &&
+ is_nothrow_swappable_v<_Types>)...>::value) {
+ __impl.__swap(__that.__impl);
+ }
+
+private:
+ __variant_detail::__impl<_Types...> __impl;
+
+ friend struct __variant_detail::__access::__variant;
+ friend struct __variant_detail::__visitation::__variant;
+};
+
+template <size_t _Ip, class... _Types>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr bool __holds_alternative(const variant<_Types...>& __v) noexcept {
+ return __v.index() == _Ip;
+}
+
+template <class _Tp, class... _Types>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr bool holds_alternative(const variant<_Types...>& __v) noexcept {
+ return __holds_alternative<__find_exactly_one_t<_Tp, _Types...>::value>(__v);
+}
+
+template <size_t _Ip, class _Vp>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
+constexpr auto&& __generic_get(_Vp&& __v) {
+ using __variant_detail::__access::__variant;
+ if (!__holds_alternative<_Ip>(__v)) {
+ __throw_bad_variant_access();
+ }
+ return __variant::__get_alt<_Ip>(_VSTD::forward<_Vp>(__v)).__value;
+}
+
+template <size_t _Ip, class... _Types>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
+constexpr variant_alternative_t<_Ip, variant<_Types...>>& get(
+ variant<_Types...>& __v) {
+ static_assert(_Ip < sizeof...(_Types));
+ static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);
+ return __generic_get<_Ip>(__v);
+}
+
+template <size_t _Ip, class... _Types>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
+constexpr variant_alternative_t<_Ip, variant<_Types...>>&& get(
+ variant<_Types...>&& __v) {
+ static_assert(_Ip < sizeof...(_Types));
+ static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);
+ return __generic_get<_Ip>(_VSTD::move(__v));
+}
+
+template <size_t _Ip, class... _Types>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
+constexpr const variant_alternative_t<_Ip, variant<_Types...>>& get(
+ const variant<_Types...>& __v) {
+ static_assert(_Ip < sizeof...(_Types));
+ static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);
+ return __generic_get<_Ip>(__v);
+}
+
+template <size_t _Ip, class... _Types>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
+constexpr const variant_alternative_t<_Ip, variant<_Types...>>&& get(
+ const variant<_Types...>&& __v) {
+ static_assert(_Ip < sizeof...(_Types));
+ static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);
+ return __generic_get<_Ip>(_VSTD::move(__v));
+}
+
+template <class _Tp, class... _Types>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
+constexpr _Tp& get(variant<_Types...>& __v) {
+ static_assert(!is_void_v<_Tp>);
+ return _VSTD::get<__find_exactly_one_t<_Tp, _Types...>::value>(__v);
+}
+
+template <class _Tp, class... _Types>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
+constexpr _Tp&& get(variant<_Types...>&& __v) {
+ static_assert(!is_void_v<_Tp>);
+ return _VSTD::get<__find_exactly_one_t<_Tp, _Types...>::value>(
+ _VSTD::move(__v));
+}
+
+template <class _Tp, class... _Types>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
+constexpr const _Tp& get(const variant<_Types...>& __v) {
+ static_assert(!is_void_v<_Tp>);
+ return _VSTD::get<__find_exactly_one_t<_Tp, _Types...>::value>(__v);
+}
+
+template <class _Tp, class... _Types>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
+constexpr const _Tp&& get(const variant<_Types...>&& __v) {
+ static_assert(!is_void_v<_Tp>);
+ return _VSTD::get<__find_exactly_one_t<_Tp, _Types...>::value>(
+ _VSTD::move(__v));
+}
+
+template <size_t _Ip, class _Vp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr auto* __generic_get_if(_Vp* __v) noexcept {
+ using __variant_detail::__access::__variant;
+ return __v && __holds_alternative<_Ip>(*__v)
+ ? _VSTD::addressof(__variant::__get_alt<_Ip>(*__v).__value)
+ : nullptr;
+}
+
+template <size_t _Ip, class... _Types>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr add_pointer_t<variant_alternative_t<_Ip, variant<_Types...>>>
+get_if(variant<_Types...>* __v) noexcept {
+ static_assert(_Ip < sizeof...(_Types));
+ static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);
+ return __generic_get_if<_Ip>(__v);
+}
+
+template <size_t _Ip, class... _Types>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr add_pointer_t<const variant_alternative_t<_Ip, variant<_Types...>>>
+get_if(const variant<_Types...>* __v) noexcept {
+ static_assert(_Ip < sizeof...(_Types));
+ static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);
+ return __generic_get_if<_Ip>(__v);
+}
+
+template <class _Tp, class... _Types>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr add_pointer_t<_Tp>
+get_if(variant<_Types...>* __v) noexcept {
+ static_assert(!is_void_v<_Tp>);
+ return _VSTD::get_if<__find_exactly_one_t<_Tp, _Types...>::value>(__v);
+}
+
+template <class _Tp, class... _Types>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr add_pointer_t<const _Tp>
+get_if(const variant<_Types...>* __v) noexcept {
+ static_assert(!is_void_v<_Tp>);
+ return _VSTD::get_if<__find_exactly_one_t<_Tp, _Types...>::value>(__v);
+}
+
+template <class _Operator>
+struct __convert_to_bool {
+ template <class _T1, class _T2>
+ _LIBCPP_INLINE_VISIBILITY constexpr bool operator()(_T1 && __t1, _T2&& __t2) const {
+ static_assert(is_convertible<decltype(_Operator{}(_VSTD::forward<_T1>(__t1), _VSTD::forward<_T2>(__t2))), bool>::value,
+ "the relational operator does not return a type which is implicitly convertible to bool");
+ return _Operator{}(_VSTD::forward<_T1>(__t1), _VSTD::forward<_T2>(__t2));
+ }
+};
+
+template <class... _Types>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr bool operator==(const variant<_Types...>& __lhs,
+ const variant<_Types...>& __rhs) {
+ using __variant_detail::__visitation::__variant;
+ if (__lhs.index() != __rhs.index()) return false;
+ if (__lhs.valueless_by_exception()) return true;
+ return __variant::__visit_value_at(__lhs.index(), __convert_to_bool<equal_to<>>{}, __lhs, __rhs);
+}
+
+template <class... _Types>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr bool operator!=(const variant<_Types...>& __lhs,
+ const variant<_Types...>& __rhs) {
+ using __variant_detail::__visitation::__variant;
+ if (__lhs.index() != __rhs.index()) return true;
+ if (__lhs.valueless_by_exception()) return false;
+ return __variant::__visit_value_at(
+ __lhs.index(), __convert_to_bool<not_equal_to<>>{}, __lhs, __rhs);
+}
+
+template <class... _Types>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr bool operator<(const variant<_Types...>& __lhs,
+ const variant<_Types...>& __rhs) {
+ using __variant_detail::__visitation::__variant;
+ if (__rhs.valueless_by_exception()) return false;
+ if (__lhs.valueless_by_exception()) return true;
+ if (__lhs.index() < __rhs.index()) return true;
+ if (__lhs.index() > __rhs.index()) return false;
+ return __variant::__visit_value_at(__lhs.index(), __convert_to_bool<less<>>{}, __lhs, __rhs);
+}
+
+template <class... _Types>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr bool operator>(const variant<_Types...>& __lhs,
+ const variant<_Types...>& __rhs) {
+ using __variant_detail::__visitation::__variant;
+ if (__lhs.valueless_by_exception()) return false;
+ if (__rhs.valueless_by_exception()) return true;
+ if (__lhs.index() > __rhs.index()) return true;
+ if (__lhs.index() < __rhs.index()) return false;
+ return __variant::__visit_value_at(__lhs.index(), __convert_to_bool<greater<>>{}, __lhs, __rhs);
+}
+
+template <class... _Types>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr bool operator<=(const variant<_Types...>& __lhs,
+ const variant<_Types...>& __rhs) {
+ using __variant_detail::__visitation::__variant;
+ if (__lhs.valueless_by_exception()) return true;
+ if (__rhs.valueless_by_exception()) return false;
+ if (__lhs.index() < __rhs.index()) return true;
+ if (__lhs.index() > __rhs.index()) return false;
+ return __variant::__visit_value_at(
+ __lhs.index(), __convert_to_bool<less_equal<>>{}, __lhs, __rhs);
+}
+
+template <class... _Types>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr bool operator>=(const variant<_Types...>& __lhs,
+ const variant<_Types...>& __rhs) {
+ using __variant_detail::__visitation::__variant;
+ if (__rhs.valueless_by_exception()) return true;
+ if (__lhs.valueless_by_exception()) return false;
+ if (__lhs.index() > __rhs.index()) return true;
+ if (__lhs.index() < __rhs.index()) return false;
+ return __variant::__visit_value_at(
+ __lhs.index(), __convert_to_bool<greater_equal<>>{}, __lhs, __rhs);
+}
+
+template <class... _Vs>
+inline _LIBCPP_INLINE_VISIBILITY
+ _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();
+ }
+}
+
+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) {
+ using __variant_detail::__visitation::__variant;
+ _VSTD::__throw_if_valueless(_VSTD::forward<_Vs>(__vs)...);
+ return __variant::__visit_value(_VSTD::forward<_Visitor>(__visitor),
+ _VSTD::forward<_Vs>(__vs)...);
+}
+
+#if _LIBCPP_STD_VER > 17
+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) {
+ using __variant_detail::__visitation::__variant;
+ _VSTD::__throw_if_valueless(_VSTD::forward<_Vs>(__vs)...);
+ return __variant::__visit_value<_Rp>(_VSTD::forward<_Visitor>(__visitor),
+ _VSTD::forward<_Vs>(__vs)...);
+}
+#endif
+
+template <class... _Types>
+inline _LIBCPP_INLINE_VISIBILITY
+auto swap(variant<_Types...>& __lhs, variant<_Types...>& __rhs)
+ noexcept(noexcept(__lhs.swap(__rhs)))
+ -> decltype( __lhs.swap(__rhs))
+ { return __lhs.swap(__rhs); }
+
+template <class... _Types>
+struct _LIBCPP_TEMPLATE_VIS hash<
+ __enable_hash_helper<variant<_Types...>, remove_const_t<_Types>...>> {
+ using argument_type = variant<_Types...>;
+ using result_type = size_t;
+
+ inline _LIBCPP_INLINE_VISIBILITY
+ result_type operator()(const argument_type& __v) const {
+ using __variant_detail::__visitation::__variant;
+ size_t __res =
+ __v.valueless_by_exception()
+ ? 299792458 // Random value chosen by the universe upon creation
+ : __variant::__visit_alt(
+ [](const auto& __alt) {
+ using __alt_type = __uncvref_t<decltype(__alt)>;
+ using __value_type = remove_const_t<
+ typename __alt_type::__value_type>;
+ return hash<__value_type>{}(__alt.__value);
+ },
+ __v);
+ return __hash_combine(__res, hash<size_t>{}(__v.index()));
+ }
+};
+
+// __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;
+}
+
+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
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_VARIANT
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/vector b/contrib/libs/cxxsupp/libcxxmsvc/include/vector
new file mode 100644
index 0000000000..9810ac710d
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/vector
@@ -0,0 +1,3391 @@
+// -*- 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_VECTOR
+#define _LIBCPP_VECTOR
+
+/*
+ vector synopsis
+
+namespace std
+{
+
+template <class T, class Allocator = allocator<T> >
+class vector
+{
+public:
+ typedef T value_type;
+ typedef Allocator allocator_type;
+ typedef typename allocator_type::reference reference;
+ typedef typename allocator_type::const_reference const_reference;
+ typedef implementation-defined iterator;
+ typedef implementation-defined const_iterator;
+ typedef typename allocator_type::size_type size_type;
+ typedef typename allocator_type::difference_type difference_type;
+ typedef typename allocator_type::pointer pointer;
+ typedef typename allocator_type::const_pointer const_pointer;
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+
+ vector()
+ noexcept(is_nothrow_default_constructible<allocator_type>::value);
+ explicit vector(const allocator_type&);
+ explicit vector(size_type n);
+ explicit vector(size_type n, const allocator_type&); // C++14
+ vector(size_type n, const value_type& value, const allocator_type& = allocator_type());
+ template <class InputIterator>
+ vector(InputIterator first, InputIterator last, const allocator_type& = allocator_type());
+ vector(const vector& x);
+ vector(vector&& x)
+ noexcept(is_nothrow_move_constructible<allocator_type>::value);
+ vector(initializer_list<value_type> il);
+ vector(initializer_list<value_type> il, const allocator_type& a);
+ ~vector();
+ vector& operator=(const vector& x);
+ vector& operator=(vector&& x)
+ noexcept(
+ allocator_type::propagate_on_container_move_assignment::value ||
+ allocator_type::is_always_equal::value); // C++17
+ vector& operator=(initializer_list<value_type> il);
+ template <class InputIterator>
+ void assign(InputIterator first, InputIterator last);
+ void assign(size_type n, const value_type& u);
+ void assign(initializer_list<value_type> il);
+
+ allocator_type get_allocator() const noexcept;
+
+ iterator begin() noexcept;
+ const_iterator begin() const noexcept;
+ iterator end() noexcept;
+ const_iterator end() const noexcept;
+
+ reverse_iterator rbegin() noexcept;
+ const_reverse_iterator rbegin() const noexcept;
+ reverse_iterator rend() noexcept;
+ const_reverse_iterator rend() const noexcept;
+
+ const_iterator cbegin() const noexcept;
+ const_iterator cend() const noexcept;
+ const_reverse_iterator crbegin() const noexcept;
+ const_reverse_iterator crend() const noexcept;
+
+ size_type size() const noexcept;
+ size_type max_size() const noexcept;
+ size_type capacity() const noexcept;
+ bool empty() const noexcept;
+ void reserve(size_type n);
+ void shrink_to_fit() noexcept;
+
+ reference operator[](size_type n);
+ const_reference operator[](size_type n) const;
+ reference at(size_type n);
+ const_reference at(size_type n) const;
+
+ reference front();
+ const_reference front() const;
+ reference back();
+ const_reference back() const;
+
+ value_type* data() noexcept;
+ const value_type* data() const noexcept;
+
+ void push_back(const value_type& x);
+ void push_back(value_type&& x);
+ template <class... Args>
+ reference emplace_back(Args&&... args); // reference in C++17
+ void pop_back();
+
+ template <class... Args> iterator emplace(const_iterator position, Args&&... args);
+ iterator insert(const_iterator position, const value_type& x);
+ iterator insert(const_iterator position, value_type&& x);
+ iterator insert(const_iterator position, size_type n, const value_type& x);
+ template <class InputIterator>
+ iterator insert(const_iterator position, InputIterator first, InputIterator last);
+ iterator insert(const_iterator position, initializer_list<value_type> il);
+
+ iterator erase(const_iterator position);
+ iterator erase(const_iterator first, const_iterator last);
+
+ void clear() noexcept;
+
+ void resize(size_type sz);
+ void resize(size_type sz, const value_type& c);
+
+ void swap(vector&)
+ noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value ||
+ allocator_traits<allocator_type>::is_always_equal::value); // C++17
+
+ bool __invariants() const;
+};
+
+template <class Allocator = allocator<T> >
+class vector<bool, Allocator>
+{
+public:
+ typedef bool value_type;
+ typedef Allocator allocator_type;
+ typedef implementation-defined iterator;
+ typedef implementation-defined const_iterator;
+ typedef typename allocator_type::size_type size_type;
+ typedef typename allocator_type::difference_type difference_type;
+ typedef iterator pointer;
+ typedef const_iterator const_pointer;
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+
+ class reference
+ {
+ public:
+ reference(const reference&) noexcept;
+ operator bool() const noexcept;
+ reference& operator=(bool x) noexcept;
+ reference& operator=(const reference& x) noexcept;
+ iterator operator&() const noexcept;
+ void flip() noexcept;
+ };
+
+ class const_reference
+ {
+ public:
+ const_reference(const reference&) noexcept;
+ operator bool() const noexcept;
+ const_iterator operator&() const noexcept;
+ };
+
+ vector()
+ noexcept(is_nothrow_default_constructible<allocator_type>::value);
+ explicit vector(const allocator_type&);
+ explicit vector(size_type n, const allocator_type& a = allocator_type()); // C++14
+ vector(size_type n, const value_type& value, const allocator_type& = allocator_type());
+ template <class InputIterator>
+ vector(InputIterator first, InputIterator last, const allocator_type& = allocator_type());
+ vector(const vector& x);
+ vector(vector&& x)
+ noexcept(is_nothrow_move_constructible<allocator_type>::value);
+ vector(initializer_list<value_type> il);
+ vector(initializer_list<value_type> il, const allocator_type& a);
+ ~vector();
+ vector& operator=(const vector& x);
+ vector& operator=(vector&& x)
+ noexcept(
+ allocator_type::propagate_on_container_move_assignment::value ||
+ allocator_type::is_always_equal::value); // C++17
+ vector& operator=(initializer_list<value_type> il);
+ template <class InputIterator>
+ void assign(InputIterator first, InputIterator last);
+ void assign(size_type n, const value_type& u);
+ void assign(initializer_list<value_type> il);
+
+ allocator_type get_allocator() const noexcept;
+
+ iterator begin() noexcept;
+ const_iterator begin() const noexcept;
+ iterator end() noexcept;
+ const_iterator end() const noexcept;
+
+ reverse_iterator rbegin() noexcept;
+ const_reverse_iterator rbegin() const noexcept;
+ reverse_iterator rend() noexcept;
+ const_reverse_iterator rend() const noexcept;
+
+ const_iterator cbegin() const noexcept;
+ const_iterator cend() const noexcept;
+ const_reverse_iterator crbegin() const noexcept;
+ const_reverse_iterator crend() const noexcept;
+
+ size_type size() const noexcept;
+ size_type max_size() const noexcept;
+ size_type capacity() const noexcept;
+ bool empty() const noexcept;
+ void reserve(size_type n);
+ void shrink_to_fit() noexcept;
+
+ reference operator[](size_type n);
+ const_reference operator[](size_type n) const;
+ reference at(size_type n);
+ const_reference at(size_type n) const;
+
+ reference front();
+ const_reference front() const;
+ reference back();
+ const_reference back() const;
+
+ void push_back(const value_type& x);
+ template <class... Args> reference emplace_back(Args&&... args); // C++14; reference in C++17
+ void pop_back();
+
+ template <class... Args> iterator emplace(const_iterator position, Args&&... args); // C++14
+ iterator insert(const_iterator position, const value_type& x);
+ iterator insert(const_iterator position, size_type n, const value_type& x);
+ template <class InputIterator>
+ iterator insert(const_iterator position, InputIterator first, InputIterator last);
+ iterator insert(const_iterator position, initializer_list<value_type> il);
+
+ iterator erase(const_iterator position);
+ iterator erase(const_iterator first, const_iterator last);
+
+ void clear() noexcept;
+
+ void resize(size_type sz);
+ void resize(size_type sz, value_type x);
+
+ void swap(vector&)
+ noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value ||
+ allocator_traits<allocator_type>::is_always_equal::value); // C++17
+ void flip() noexcept;
+
+ bool __invariants() const;
+};
+
+template <class InputIterator, class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
+ vector(InputIterator, InputIterator, Allocator = Allocator())
+ -> vector<typename iterator_traits<InputIterator>::value_type, Allocator>; // C++17
+
+template <class Allocator> struct hash<std::vector<bool, Allocator>>;
+
+template <class T, class Allocator> bool operator==(const vector<T,Allocator>& x, const vector<T,Allocator>& y);
+template <class T, class Allocator> bool operator< (const vector<T,Allocator>& x, const vector<T,Allocator>& y);
+template <class T, class Allocator> bool operator!=(const vector<T,Allocator>& x, const vector<T,Allocator>& y);
+template <class T, class Allocator> bool operator> (const vector<T,Allocator>& x, const vector<T,Allocator>& y);
+template <class T, class Allocator> bool operator>=(const vector<T,Allocator>& x, const vector<T,Allocator>& y);
+template <class T, class Allocator> bool operator<=(const vector<T,Allocator>& x, const vector<T,Allocator>& y);
+
+template <class T, class Allocator>
+void swap(vector<T,Allocator>& x, vector<T,Allocator>& y)
+ noexcept(noexcept(x.swap(y)));
+
+template <class T, class Allocator, class U>
+typename vector<T, Allocator>::size_type
+erase(vector<T, Allocator>& c, const U& value); // C++20
+template <class T, class Allocator, class Predicate>
+typename vector<T, Allocator>::size_type
+erase_if(vector<T, Allocator>& c, Predicate pred); // C++20
+
+} // std
+
+*/
+
+#include <__algorithm/copy.h>
+#include <__algorithm/equal.h>
+#include <__algorithm/fill_n.h>
+#include <__algorithm/lexicographical_compare.h>
+#include <__algorithm/remove.h>
+#include <__algorithm/remove_if.h>
+#include <__algorithm/rotate.h>
+#include <__algorithm/unwrap_iter.h>
+#include <__assert>
+#include <__bit_reference>
+#include <__config>
+#include <__debug>
+#include <__functional/hash.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/wrap_iter.h>
+#include <__split_buffer>
+#include <__utility/forward.h>
+#include <climits>
+#include <compare>
+#include <cstdlib>
+#include <cstring>
+#include <initializer_list>
+#include <iosfwd> // for forward declaration of vector
+#include <limits>
+#include <memory>
+#include <stdexcept>
+#include <type_traits>
+#include <version>
+
+// TODO: remove these headers
+#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 <typeinfo>
+#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 _Allocator /* = allocator<_Tp> */>
+class _LIBCPP_TEMPLATE_VIS vector
+{
+private:
+ typedef allocator<_Tp> __default_allocator_type;
+public:
+ typedef vector __self;
+ typedef _Tp value_type;
+ typedef _Allocator allocator_type;
+ typedef allocator_traits<allocator_type> __alloc_traits;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef typename __alloc_traits::size_type size_type;
+ typedef typename __alloc_traits::difference_type difference_type;
+ typedef typename __alloc_traits::pointer pointer;
+ typedef typename __alloc_traits::const_pointer const_pointer;
+#if _YNDX_LIBCPP_MAKE_VECTOR_ITERATOR_POINTERS == 1
+ typedef pointer iterator;
+ typedef const_pointer const_iterator;
+#else
+ typedef __wrap_iter<pointer> iterator;
+ typedef __wrap_iter<const_pointer> const_iterator;
+#endif
+ typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
+ typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
+
+ static_assert((is_same<typename allocator_type::value_type, value_type>::value),
+ "Allocator::value_type must be same type as value_type");
+
+ _LIBCPP_INLINE_VISIBILITY
+ vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
+ {
+ _VSTD::__debug_db_insert_c(this);
+ }
+ _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a)
+#if _LIBCPP_STD_VER <= 14
+ _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
+#else
+ _NOEXCEPT
+#endif
+ : __end_cap_(nullptr, __a)
+ {
+ _VSTD::__debug_db_insert_c(this);
+ }
+ explicit vector(size_type __n);
+#if _LIBCPP_STD_VER > 11
+ explicit vector(size_type __n, const allocator_type& __a);
+#endif
+ vector(size_type __n, const value_type& __x);
+
+ template <class = __enable_if_t<__is_allocator<_Allocator>::value> >
+ vector(size_type __n, const value_type& __x, const allocator_type& __a)
+ : __end_cap_(nullptr, __a)
+ {
+ _VSTD::__debug_db_insert_c(this);
+ if (__n > 0)
+ {
+ __vallocate(__n);
+ __construct_at_end(__n, __x);
+ }
+ }
+
+ template <class _InputIterator>
+ vector(_InputIterator __first,
+ typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value &&
+ is_constructible<
+ value_type,
+ typename iterator_traits<_InputIterator>::reference>::value,
+ _InputIterator>::type __last);
+ template <class _InputIterator>
+ vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
+ typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value &&
+ is_constructible<
+ value_type,
+ typename iterator_traits<_InputIterator>::reference>::value>::type* = 0);
+ template <class _ForwardIterator>
+ vector(_ForwardIterator __first,
+ typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
+ is_constructible<
+ value_type,
+ typename iterator_traits<_ForwardIterator>::reference>::value,
+ _ForwardIterator>::type __last);
+ template <class _ForwardIterator>
+ vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
+ typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
+ is_constructible<
+ value_type,
+ typename iterator_traits<_ForwardIterator>::reference>::value>::type* = 0);
+
+ _LIBCPP_INLINE_VISIBILITY
+ ~vector()
+ {
+ __annotate_delete();
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __get_db()->__erase_c(this);
+#endif
+
+ if (this->__begin_ != nullptr)
+ {
+ __clear();
+ __alloc_traits::deallocate(__alloc(), this->__begin_, capacity());
+ }
+ }
+
+ vector(const vector& __x);
+ vector(const vector& __x, const __identity_t<allocator_type>& __a);
+ _LIBCPP_INLINE_VISIBILITY
+ vector& operator=(const vector& __x);
+
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ vector(initializer_list<value_type> __il);
+
+ _LIBCPP_INLINE_VISIBILITY
+ vector(initializer_list<value_type> __il, const allocator_type& __a);
+
+ _LIBCPP_INLINE_VISIBILITY
+ vector(vector&& __x)
+#if _LIBCPP_STD_VER > 14
+ _NOEXCEPT;
+#else
+ _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ 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));
+
+ _LIBCPP_INLINE_VISIBILITY
+ vector& operator=(initializer_list<value_type> __il)
+ {assign(__il.begin(), __il.end()); return *this;}
+
+#endif // !_LIBCPP_CXX03_LANG
+
+ template <class _InputIterator>
+ typename enable_if
+ <
+ __is_cpp17_input_iterator <_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value &&
+ is_constructible<
+ value_type,
+ typename iterator_traits<_InputIterator>::reference>::value,
+ void
+ >::type
+ assign(_InputIterator __first, _InputIterator __last);
+ template <class _ForwardIterator>
+ typename enable_if
+ <
+ __is_cpp17_forward_iterator<_ForwardIterator>::value &&
+ is_constructible<
+ value_type,
+ typename iterator_traits<_ForwardIterator>::reference>::value,
+ void
+ >::type
+ assign(_ForwardIterator __first, _ForwardIterator __last);
+
+ void assign(size_type __n, const_reference __u);
+
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ void assign(initializer_list<value_type> __il)
+ {assign(__il.begin(), __il.end());}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ allocator_type get_allocator() const _NOEXCEPT
+ {return this->__alloc();}
+
+ _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY
+ reverse_iterator rbegin() _NOEXCEPT
+ {return reverse_iterator(end());}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator rbegin() const _NOEXCEPT
+ {return const_reverse_iterator(end());}
+ _LIBCPP_INLINE_VISIBILITY
+ reverse_iterator rend() _NOEXCEPT
+ {return reverse_iterator(begin());}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator rend() const _NOEXCEPT
+ {return const_reverse_iterator(begin());}
+
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator cbegin() const _NOEXCEPT
+ {return begin();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator cend() const _NOEXCEPT
+ {return end();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator crbegin() const _NOEXCEPT
+ {return rbegin();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator crend() const _NOEXCEPT
+ {return rend();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_type size() const _NOEXCEPT
+ {return static_cast<size_type>(this->__end_ - this->__begin_);}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type capacity() const _NOEXCEPT
+ {return static_cast<size_type>(__end_cap() - this->__begin_);}
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+ bool empty() const _NOEXCEPT
+ {return this->__begin_ == this->__end_;}
+ size_type max_size() const _NOEXCEPT;
+ void reserve(size_type __n);
+ void shrink_to_fit() _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const _NOEXCEPT;
+ reference at(size_type __n);
+ const_reference at(size_type __n) const;
+
+ _LIBCPP_INLINE_VISIBILITY reference front() _NOEXCEPT
+ {
+ _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 on an empty vector");
+ return *this->__begin_;
+ }
+ _LIBCPP_INLINE_VISIBILITY reference back() _NOEXCEPT
+ {
+ _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 on an empty vector");
+ return *(this->__end_ - 1);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ value_type* data() _NOEXCEPT
+ {return _VSTD::__to_address(this->__begin_);}
+ _LIBCPP_INLINE_VISIBILITY
+ const value_type* data() const _NOEXCEPT
+ {return _VSTD::__to_address(this->__begin_);}
+
+#ifdef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ void __emplace_back(const value_type& __x) { push_back(__x); }
+#else
+ template <class _Arg>
+ _LIBCPP_INLINE_VISIBILITY
+ void __emplace_back(_Arg&& __arg) {
+ emplace_back(_VSTD::forward<_Arg>(__arg));
+ }
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
+
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x);
+
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+#if _LIBCPP_STD_VER > 14
+ reference emplace_back(_Args&&... __args);
+#else
+ void emplace_back(_Args&&... __args);
+#endif
+#endif // !_LIBCPP_CXX03_LANG
+
+ _LIBCPP_INLINE_VISIBILITY
+ void pop_back();
+
+ iterator insert(const_iterator __position, const_reference __x);
+
+#ifndef _LIBCPP_CXX03_LANG
+ iterator insert(const_iterator __position, value_type&& __x);
+ template <class... _Args>
+ iterator emplace(const_iterator __position, _Args&&... __args);
+#endif // !_LIBCPP_CXX03_LANG
+
+ iterator insert(const_iterator __position, size_type __n, const_reference __x);
+ template <class _InputIterator>
+ typename enable_if
+ <
+ __is_cpp17_input_iterator <_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value &&
+ is_constructible<
+ value_type,
+ typename iterator_traits<_InputIterator>::reference>::value,
+ iterator
+ >::type
+ insert(const_iterator __position, _InputIterator __first, _InputIterator __last);
+ template <class _ForwardIterator>
+ typename enable_if
+ <
+ __is_cpp17_forward_iterator<_ForwardIterator>::value &&
+ is_constructible<
+ value_type,
+ typename iterator_traits<_ForwardIterator>::reference>::value,
+ iterator
+ >::type
+ insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
+
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const_iterator __position, initializer_list<value_type> __il)
+ {return insert(__position, __il.begin(), __il.end());}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position);
+ iterator erase(const_iterator __first, const_iterator __last);
+
+ _LIBCPP_REINITIALIZES_OBJECT _LIBCPP_INLINE_VISIBILITY
+ void clear() _NOEXCEPT
+ {
+ size_type __old_size = size();
+ __clear();
+ __annotate_shrink(__old_size);
+ __invalidate_all_iterators();
+ }
+
+#if _YNDX_LIBCXX_ENABLE_VECTOR_POD_RESIZE_UNINITIALIZED
+ void resize_uninitialized(size_type __sz);
+#endif
+
+ void resize(size_type __sz);
+ void resize(size_type __sz, const_reference __x);
+
+ void swap(vector&)
+#if _LIBCPP_STD_VER >= 14
+ _NOEXCEPT;
+#else
+ _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
+ __is_nothrow_swappable<allocator_type>::value);
+#endif
+
+ bool __invariants() const;
+
+#if _LIBCPP_DEBUG_LEVEL == 2
+
+ bool __dereferenceable(const const_iterator* __i) const;
+ bool __decrementable(const const_iterator* __i) const;
+ 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
+
+private:
+ pointer __begin_ = nullptr;
+ pointer __end_ = nullptr;
+ __compressed_pair<pointer, allocator_type> __end_cap_ =
+ __compressed_pair<pointer, allocator_type>(nullptr, __default_init_tag());
+
+ _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();
+ _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(pointer __new_last);
+ void __vallocate(size_type __n);
+ void __vdeallocate() _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const;
+ void __construct_at_end(size_type __n);
+ _LIBCPP_INLINE_VISIBILITY
+ void __construct_at_end(size_type __n, const_reference __x);
+ template <class _ForwardIterator>
+ typename enable_if
+ <
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
+ void
+ >::type
+ __construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n);
+ void __append_uninitialized(size_type __n);
+ void __append(size_type __n);
+ void __append(size_type __n, const_reference __x);
+ _LIBCPP_INLINE_VISIBILITY
+ iterator __make_iter(pointer __p) _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator __make_iter(const_pointer __p) const _NOEXCEPT;
+ void __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v);
+ pointer __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p);
+ void __move_range(pointer __from_s, pointer __from_e, pointer __to);
+ void __move_assign(vector& __c, true_type)
+ _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
+ void __move_assign(vector& __c, false_type)
+ _NOEXCEPT_(__alloc_traits::is_always_equal::value);
+ _LIBCPP_INLINE_VISIBILITY
+ void __destruct_at_end(pointer __new_last) _NOEXCEPT
+ {
+ __invalidate_iterators_past(__new_last);
+ size_type __old_size = size();
+ __base_destruct_at_end(__new_last);
+ __annotate_shrink(__old_size);
+ }
+
+// Disable double inline warning.
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( push )
+#pragma warning ( disable : 4141 )
+#endif
+#ifndef _LIBCPP_CXX03_LANG
+ template <class _Up>
+ _LIBCPP_INLINE_VISIBILITY
+ inline void __push_back_slow_path(_Up&& __x);
+
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+ inline void __emplace_back_slow_path(_Args&&... __args);
+#else
+ template <class _Up>
+ _LIBCPP_INLINE_VISIBILITY
+ inline void __push_back_slow_path(_Up& __x);
+#endif
+#ifdef _LIBCPP_COMPILER_MSVC
+#pragma warning ( pop )
+#endif
+
+ // The following functions are no-ops outside of AddressSanitizer mode.
+ // We call annotatations only for the default Allocator because other allocators
+ // may not meet the AddressSanitizer alignment constraints.
+ // See the documentation for __sanitizer_annotate_contiguous_container for more details.
+#ifndef _LIBCPP_HAS_NO_ASAN
+ void __annotate_contiguous_container(const void *__beg, const void *__end,
+ const void *__old_mid,
+ const void *__new_mid) const
+ {
+
+ if (__beg && is_same<allocator_type, __default_allocator_type>::value)
+ __sanitizer_annotate_contiguous_container(__beg, __end, __old_mid, __new_mid);
+ }
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ void __annotate_contiguous_container(const void*, const void*, const void*,
+ const void*) const _NOEXCEPT {}
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ void __annotate_new(size_type __current_size) const _NOEXCEPT {
+ __annotate_contiguous_container(data(), data() + capacity(),
+ data() + capacity(), data() + __current_size);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __annotate_delete() const _NOEXCEPT {
+ __annotate_contiguous_container(data(), data() + capacity(),
+ data() + size(), data() + capacity());
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __annotate_increase(size_type __n) const _NOEXCEPT
+ {
+ __annotate_contiguous_container(data(), data() + capacity(),
+ data() + size(), data() + size() + __n);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __annotate_shrink(size_type __old_size) const _NOEXCEPT
+ {
+ __annotate_contiguous_container(data(), data() + capacity(),
+ data() + __old_size, data() + size());
+ }
+
+ struct _ConstructTransaction {
+ explicit _ConstructTransaction(vector &__v, size_type __n)
+ : __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) {
+#ifndef _LIBCPP_HAS_NO_ASAN
+ __v_.__annotate_increase(__n);
+#endif
+ }
+ ~_ConstructTransaction() {
+ __v_.__end_ = __pos_;
+#ifndef _LIBCPP_HAS_NO_ASAN
+ if (__pos_ != __new_end_) {
+ __v_.__annotate_shrink(__new_end_ - __v_.__begin_);
+ }
+#endif
+ }
+
+ vector &__v_;
+ pointer __pos_;
+ const_pointer const __new_end_;
+
+ private:
+ _ConstructTransaction(_ConstructTransaction const&) = delete;
+ _ConstructTransaction& operator=(_ConstructTransaction const&) = delete;
+ };
+
+ template <class ..._Args>
+ _LIBCPP_INLINE_VISIBILITY
+ void __construct_one_at_end(_Args&& ...__args) {
+ _ConstructTransaction __tx(*this, 1);
+ __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__tx.__pos_),
+ _VSTD::forward<_Args>(__args)...);
+ ++__tx.__pos_;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ allocator_type& __alloc() _NOEXCEPT
+ {return this->__end_cap_.second();}
+ _LIBCPP_INLINE_VISIBILITY
+ const allocator_type& __alloc() const _NOEXCEPT
+ {return this->__end_cap_.second();}
+ _LIBCPP_INLINE_VISIBILITY
+ pointer& __end_cap() _NOEXCEPT
+ {return this->__end_cap_.first();}
+ _LIBCPP_INLINE_VISIBILITY
+ const pointer& __end_cap() const _NOEXCEPT
+ {return this->__end_cap_.first();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __clear() _NOEXCEPT {__base_destruct_at_end(this->__begin_);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __base_destruct_at_end(pointer __new_last) _NOEXCEPT {
+ pointer __soon_to_be_end = this->__end_;
+ while (__new_last != __soon_to_be_end)
+ __alloc_traits::destroy(__alloc(), _VSTD::__to_address(--__soon_to_be_end));
+ this->__end_ = __new_last;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __copy_assign_alloc(const vector& __c)
+ {__copy_assign_alloc(__c, integral_constant<bool,
+ __alloc_traits::propagate_on_container_copy_assignment::value>());}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __move_assign_alloc(vector& __c)
+ _NOEXCEPT_(
+ !__alloc_traits::propagate_on_container_move_assignment::value ||
+ is_nothrow_move_assignable<allocator_type>::value)
+ {__move_assign_alloc(__c, integral_constant<bool,
+ __alloc_traits::propagate_on_container_move_assignment::value>());}
+
+ _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
+ void __throw_length_error() const {
+ _VSTD::__throw_length_error("vector");
+ }
+
+ _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
+ void __throw_out_of_range() const {
+ _VSTD::__throw_out_of_range("vector");
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __copy_assign_alloc(const vector& __c, true_type)
+ {
+ if (__alloc() != __c.__alloc())
+ {
+ __clear();
+ __alloc_traits::deallocate(__alloc(), this->__begin_, capacity());
+ this->__begin_ = this->__end_ = __end_cap() = nullptr;
+ }
+ __alloc() = __c.__alloc();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __copy_assign_alloc(const vector&, false_type)
+ {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __move_assign_alloc(vector& __c, true_type)
+ _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
+ {
+ __alloc() = _VSTD::move(__c.__alloc());
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __move_assign_alloc(vector&, false_type)
+ _NOEXCEPT
+ {}
+};
+
+#if _LIBCPP_STD_VER >= 17
+template<class _InputIterator,
+ class _Alloc = allocator<__iter_value_type<_InputIterator>>,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = enable_if_t<__is_allocator<_Alloc>::value>
+ >
+vector(_InputIterator, _InputIterator)
+ -> vector<__iter_value_type<_InputIterator>, _Alloc>;
+
+template<class _InputIterator,
+ class _Alloc,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = enable_if_t<__is_allocator<_Alloc>::value>
+ >
+vector(_InputIterator, _InputIterator, _Alloc)
+ -> vector<__iter_value_type<_InputIterator>, _Alloc>;
+#endif
+
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v)
+{
+
+ __annotate_delete();
+ _VSTD::__construct_backward_with_exception_guarantees(this->__alloc(), this->__begin_, this->__end_, __v.__begin_);
+ _VSTD::swap(this->__begin_, __v.__begin_);
+ _VSTD::swap(this->__end_, __v.__end_);
+ _VSTD::swap(this->__end_cap(), __v.__end_cap());
+ __v.__first_ = __v.__begin_;
+ __annotate_new(size());
+ __invalidate_all_iterators();
+}
+
+template <class _Tp, class _Allocator>
+typename vector<_Tp, _Allocator>::pointer
+vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p)
+{
+ __annotate_delete();
+ pointer __r = __v.__begin_;
+ _VSTD::__construct_backward_with_exception_guarantees(this->__alloc(), this->__begin_, __p, __v.__begin_);
+ _VSTD::__construct_forward_with_exception_guarantees(this->__alloc(), __p, this->__end_, __v.__end_);
+ _VSTD::swap(this->__begin_, __v.__begin_);
+ _VSTD::swap(this->__end_, __v.__end_);
+ _VSTD::swap(this->__end_cap(), __v.__end_cap());
+ __v.__first_ = __v.__begin_;
+ __annotate_new(size());
+ __invalidate_all_iterators();
+ return __r;
+}
+
+// Allocate space for __n objects
+// throws length_error if __n > max_size()
+// throws (probably bad_alloc) if memory run out
+// Precondition: __begin_ == __end_ == __end_cap() == 0
+// Precondition: __n > 0
+// Postcondition: capacity() == __n
+// Postcondition: size() == 0
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::__vallocate(size_type __n)
+{
+ if (__n > max_size())
+ this->__throw_length_error();
+ this->__begin_ = this->__end_ = __alloc_traits::allocate(this->__alloc(), __n);
+ this->__end_cap() = this->__begin_ + __n;
+ __annotate_new(0);
+}
+
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT
+{
+ if (this->__begin_ != nullptr)
+ {
+ clear();
+ __alloc_traits::deallocate(this->__alloc(), this->__begin_, capacity());
+ this->__begin_ = this->__end_ = this->__end_cap() = nullptr;
+ }
+}
+
+template <class _Tp, class _Allocator>
+typename vector<_Tp, _Allocator>::size_type
+vector<_Tp, _Allocator>::max_size() const _NOEXCEPT
+{
+ return _VSTD::min<size_type>(__alloc_traits::max_size(this->__alloc()),
+ numeric_limits<difference_type>::max());
+}
+
+// Precondition: __new_size > capacity()
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename vector<_Tp, _Allocator>::size_type
+vector<_Tp, _Allocator>::__recommend(size_type __new_size) const
+{
+ const size_type __ms = max_size();
+ if (__new_size > __ms)
+ this->__throw_length_error();
+ const size_type __cap = capacity();
+ if (__cap >= __ms / 2)
+ return __ms;
+ return _VSTD::max<size_type>(2 * __cap, __new_size);
+}
+
+// Default constructs __n objects starting at __end_
+// throws if construction throws
+// Precondition: __n > 0
+// Precondition: size() + __n <= capacity()
+// Postcondition: size() == size() + __n
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::__construct_at_end(size_type __n)
+{
+ _ConstructTransaction __tx(*this, __n);
+ const_pointer __new_end = __tx.__new_end_;
+ for (pointer __pos = __tx.__pos_; __pos != __new_end; __tx.__pos_ = ++__pos) {
+ __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__pos));
+ }
+}
+
+// Copy constructs __n objects starting at __end_ from __x
+// throws if construction throws
+// Precondition: __n > 0
+// Precondition: size() + __n <= capacity()
+// Postcondition: size() == old size() + __n
+// Postcondition: [i] == __x for all i in [size() - __n, __n)
+template <class _Tp, class _Allocator>
+inline
+void
+vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
+{
+ _ConstructTransaction __tx(*this, __n);
+ const_pointer __new_end = __tx.__new_end_;
+ for (pointer __pos = __tx.__pos_; __pos != __new_end; __tx.__pos_ = ++__pos) {
+ __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__pos), __x);
+ }
+}
+
+template <class _Tp, class _Allocator>
+template <class _ForwardIterator>
+typename enable_if
+<
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
+ void
+>::type
+vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n)
+{
+ _ConstructTransaction __tx(*this, __n);
+ _VSTD::__construct_range_forward(this->__alloc(), __first, __last, __tx.__pos_);
+}
+
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::__append_uninitialized(size_type __n)
+{
+ if (static_cast<size_type>(this->__end_cap() - this->__end_) >= __n) {
+ __annotate_increase(__n);
+ this->__end_ += __n;
+ }
+ else
+ {
+ allocator_type& __a = this->__alloc();
+ __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), size(), __a);
+ __v.__uninitialized_at_end(__n);
+ __swap_out_circular_buffer(__v);
+ }
+}
+
+// Default constructs __n objects starting at __end_
+// throws if construction throws
+// Postcondition: size() == size() + __n
+// Exception safety: strong.
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::__append(size_type __n)
+{
+ if (static_cast<size_type>(this->__end_cap() - this->__end_) >= __n)
+ this->__construct_at_end(__n);
+ else
+ {
+ allocator_type& __a = this->__alloc();
+ __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), size(), __a);
+ __v.__construct_at_end(__n);
+ __swap_out_circular_buffer(__v);
+ }
+}
+
+// Default constructs __n objects starting at __end_
+// throws if construction throws
+// Postcondition: size() == size() + __n
+// Exception safety: strong.
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x)
+{
+ if (static_cast<size_type>(this->__end_cap() - this->__end_) >= __n)
+ this->__construct_at_end(__n, __x);
+ else
+ {
+ allocator_type& __a = this->__alloc();
+ __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), size(), __a);
+ __v.__construct_at_end(__n, __x);
+ __swap_out_circular_buffer(__v);
+ }
+}
+
+template <class _Tp, class _Allocator>
+vector<_Tp, _Allocator>::vector(size_type __n)
+{
+ _VSTD::__debug_db_insert_c(this);
+ if (__n > 0)
+ {
+ __vallocate(__n);
+ __construct_at_end(__n);
+ }
+}
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp, class _Allocator>
+vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a)
+ : __end_cap_(nullptr, __a)
+{
+ _VSTD::__debug_db_insert_c(this);
+ if (__n > 0)
+ {
+ __vallocate(__n);
+ __construct_at_end(__n);
+ }
+}
+#endif
+
+template <class _Tp, class _Allocator>
+vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x)
+{
+ _VSTD::__debug_db_insert_c(this);
+ if (__n > 0)
+ {
+ __vallocate(__n);
+ __construct_at_end(__n, __x);
+ }
+}
+
+template <class _Tp, class _Allocator>
+template <class _InputIterator>
+vector<_Tp, _Allocator>::vector(_InputIterator __first,
+ typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value &&
+ is_constructible<
+ value_type,
+ typename iterator_traits<_InputIterator>::reference>::value,
+ _InputIterator>::type __last)
+{
+ _VSTD::__debug_db_insert_c(this);
+ for (; __first != __last; ++__first)
+ __emplace_back(*__first);
+}
+
+template <class _Tp, class _Allocator>
+template <class _InputIterator>
+vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
+ typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value &&
+ is_constructible<
+ value_type,
+ typename iterator_traits<_InputIterator>::reference>::value>::type*)
+ : __end_cap_(nullptr, __a)
+{
+ _VSTD::__debug_db_insert_c(this);
+ for (; __first != __last; ++__first)
+ __emplace_back(*__first);
+}
+
+template <class _Tp, class _Allocator>
+template <class _ForwardIterator>
+vector<_Tp, _Allocator>::vector(_ForwardIterator __first,
+ typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
+ is_constructible<
+ value_type,
+ typename iterator_traits<_ForwardIterator>::reference>::value,
+ _ForwardIterator>::type __last)
+{
+ _VSTD::__debug_db_insert_c(this);
+ size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
+ if (__n > 0)
+ {
+ __vallocate(__n);
+ __construct_at_end(__first, __last, __n);
+ }
+}
+
+template <class _Tp, class _Allocator>
+template <class _ForwardIterator>
+vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
+ typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
+ is_constructible<
+ value_type,
+ typename iterator_traits<_ForwardIterator>::reference>::value>::type*)
+ : __end_cap_(nullptr, __a)
+{
+ _VSTD::__debug_db_insert_c(this);
+ size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
+ if (__n > 0)
+ {
+ __vallocate(__n);
+ __construct_at_end(__first, __last, __n);
+ }
+}
+
+template <class _Tp, class _Allocator>
+vector<_Tp, _Allocator>::vector(const vector& __x)
+ : __end_cap_(nullptr, __alloc_traits::select_on_container_copy_construction(__x.__alloc()))
+{
+ _VSTD::__debug_db_insert_c(this);
+ size_type __n = __x.size();
+ if (__n > 0)
+ {
+ __vallocate(__n);
+ __construct_at_end(__x.__begin_, __x.__end_, __n);
+ }
+}
+
+template <class _Tp, class _Allocator>
+vector<_Tp, _Allocator>::vector(const vector& __x, const __identity_t<allocator_type>& __a)
+ : __end_cap_(nullptr, __a)
+{
+ _VSTD::__debug_db_insert_c(this);
+ size_type __n = __x.size();
+ if (__n > 0)
+ {
+ __vallocate(__n);
+ __construct_at_end(__x.__begin_, __x.__end_, __n);
+ }
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+vector<_Tp, _Allocator>::vector(vector&& __x)
+#if _LIBCPP_STD_VER > 14
+ _NOEXCEPT
+#else
+ _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
+#endif
+ : __end_cap_(nullptr, _VSTD::move(__x.__alloc()))
+{
+ _VSTD::__debug_db_insert_c(this);
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __get_db()->swap(this, _VSTD::addressof(__x));
+#endif
+ this->__begin_ = __x.__begin_;
+ this->__end_ = __x.__end_;
+ this->__end_cap() = __x.__end_cap();
+ __x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr;
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+vector<_Tp, _Allocator>::vector(vector&& __x, const __identity_t<allocator_type>& __a)
+ : __end_cap_(nullptr, __a)
+{
+ _VSTD::__debug_db_insert_c(this);
+ if (__a == __x.__alloc())
+ {
+ this->__begin_ = __x.__begin_;
+ this->__end_ = __x.__end_;
+ this->__end_cap() = __x.__end_cap();
+ __x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr;
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __get_db()->swap(this, _VSTD::addressof(__x));
+#endif
+ }
+ else
+ {
+ typedef move_iterator<iterator> _Ip;
+ assign(_Ip(__x.begin()), _Ip(__x.end()));
+ }
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il)
+{
+ _VSTD::__debug_db_insert_c(this);
+ if (__il.size() > 0)
+ {
+ __vallocate(__il.size());
+ __construct_at_end(__il.begin(), __il.end(), __il.size());
+ }
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)
+ : __end_cap_(nullptr, __a)
+{
+ _VSTD::__debug_db_insert_c(this);
+ if (__il.size() > 0)
+ {
+ __vallocate(__il.size());
+ __construct_at_end(__il.begin(), __il.end(), __il.size());
+ }
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+vector<_Tp, _Allocator>&
+vector<_Tp, _Allocator>::operator=(vector&& __x)
+ _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))
+{
+ __move_assign(__x, integral_constant<bool,
+ __alloc_traits::propagate_on_container_move_assignment::value>());
+ return *this;
+}
+
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type)
+ _NOEXCEPT_(__alloc_traits::is_always_equal::value)
+{
+ if (__alloc() != __c.__alloc())
+ {
+ typedef move_iterator<iterator> _Ip;
+ assign(_Ip(__c.begin()), _Ip(__c.end()));
+ }
+ else
+ __move_assign(__c, true_type());
+}
+
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)
+ _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
+{
+ __vdeallocate();
+ __move_assign_alloc(__c); // this can throw
+ this->__begin_ = __c.__begin_;
+ this->__end_ = __c.__end_;
+ this->__end_cap() = __c.__end_cap();
+ __c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr;
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __get_db()->swap(this, _VSTD::addressof(__c));
+#endif
+}
+
+#endif // !_LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+vector<_Tp, _Allocator>&
+vector<_Tp, _Allocator>::operator=(const vector& __x)
+{
+ if (this != _VSTD::addressof(__x))
+ {
+ __copy_assign_alloc(__x);
+ assign(__x.__begin_, __x.__end_);
+ }
+ return *this;
+}
+
+template <class _Tp, class _Allocator>
+template <class _InputIterator>
+typename enable_if
+<
+ __is_cpp17_input_iterator <_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value &&
+ is_constructible<
+ _Tp,
+ typename iterator_traits<_InputIterator>::reference>::value,
+ void
+>::type
+vector<_Tp, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
+{
+ clear();
+ for (; __first != __last; ++__first)
+ __emplace_back(*__first);
+}
+
+template <class _Tp, class _Allocator>
+template <class _ForwardIterator>
+typename enable_if
+<
+ __is_cpp17_forward_iterator<_ForwardIterator>::value &&
+ is_constructible<
+ _Tp,
+ typename iterator_traits<_ForwardIterator>::reference>::value,
+ void
+>::type
+vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last)
+{
+ size_type __new_size = static_cast<size_type>(_VSTD::distance(__first, __last));
+ if (__new_size <= capacity())
+ {
+ _ForwardIterator __mid = __last;
+ bool __growing = false;
+ if (__new_size > size())
+ {
+ __growing = true;
+ __mid = __first;
+ _VSTD::advance(__mid, size());
+ }
+ pointer __m = _VSTD::copy(__first, __mid, this->__begin_);
+ if (__growing)
+ __construct_at_end(__mid, __last, __new_size - size());
+ else
+ this->__destruct_at_end(__m);
+ }
+ else
+ {
+ __vdeallocate();
+ __vallocate(__recommend(__new_size));
+ __construct_at_end(__first, __last, __new_size);
+ }
+ __invalidate_all_iterators();
+}
+
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u)
+{
+ if (__n <= capacity())
+ {
+ size_type __s = size();
+ _VSTD::fill_n(this->__begin_, _VSTD::min(__n, __s), __u);
+ if (__n > __s)
+ __construct_at_end(__n - __s, __u);
+ else
+ this->__destruct_at_end(this->__begin_ + __n);
+ }
+ else
+ {
+ __vdeallocate();
+ __vallocate(__recommend(static_cast<size_type>(__n)));
+ __construct_at_end(__n, __u);
+ }
+ __invalidate_all_iterators();
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename vector<_Tp, _Allocator>::iterator
+vector<_Tp, _Allocator>::__make_iter(pointer __p) _NOEXCEPT
+{
+#if _LIBCPP_DEBUG_LEVEL == 2
+ return iterator(this, __p);
+#else
+ return iterator(__p);
+#endif
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename vector<_Tp, _Allocator>::const_iterator
+vector<_Tp, _Allocator>::__make_iter(const_pointer __p) const _NOEXCEPT
+{
+#if _LIBCPP_DEBUG_LEVEL == 2
+ return const_iterator(this, __p);
+#else
+ return const_iterator(__p);
+#endif
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename vector<_Tp, _Allocator>::iterator
+vector<_Tp, _Allocator>::begin() _NOEXCEPT
+{
+ return __make_iter(this->__begin_);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename vector<_Tp, _Allocator>::const_iterator
+vector<_Tp, _Allocator>::begin() const _NOEXCEPT
+{
+ return __make_iter(this->__begin_);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename vector<_Tp, _Allocator>::iterator
+vector<_Tp, _Allocator>::end() _NOEXCEPT
+{
+ return __make_iter(this->__end_);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename vector<_Tp, _Allocator>::const_iterator
+vector<_Tp, _Allocator>::end() const _NOEXCEPT
+{
+ return __make_iter(this->__end_);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename vector<_Tp, _Allocator>::reference
+vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT
+{
+ _LIBCPP_ASSERT(__n < size(), "vector[] index out of bounds");
+ return this->__begin_[__n];
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename vector<_Tp, _Allocator>::const_reference
+vector<_Tp, _Allocator>::operator[](size_type __n) const _NOEXCEPT
+{
+ _LIBCPP_ASSERT(__n < size(), "vector[] index out of bounds");
+ return this->__begin_[__n];
+}
+
+template <class _Tp, class _Allocator>
+typename vector<_Tp, _Allocator>::reference
+vector<_Tp, _Allocator>::at(size_type __n)
+{
+ if (__n >= size())
+ this->__throw_out_of_range();
+ return this->__begin_[__n];
+}
+
+template <class _Tp, class _Allocator>
+typename vector<_Tp, _Allocator>::const_reference
+vector<_Tp, _Allocator>::at(size_type __n) const
+{
+ if (__n >= size())
+ this->__throw_out_of_range();
+ return this->__begin_[__n];
+}
+
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::reserve(size_type __n)
+{
+ if (__n > capacity())
+ {
+ if (__n > max_size())
+ this->__throw_length_error();
+ allocator_type& __a = this->__alloc();
+ __split_buffer<value_type, allocator_type&> __v(__n, size(), __a);
+ __swap_out_circular_buffer(__v);
+ }
+}
+
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
+{
+ if (capacity() > size())
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ allocator_type& __a = this->__alloc();
+ __split_buffer<value_type, allocator_type&> __v(size(), size(), __a);
+ __swap_out_circular_buffer(__v);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ }
+}
+
+template <class _Tp, class _Allocator>
+template <class _Up>
+void
+#ifndef _LIBCPP_CXX03_LANG
+vector<_Tp, _Allocator>::__push_back_slow_path(_Up&& __x)
+#else
+vector<_Tp, _Allocator>::__push_back_slow_path(_Up& __x)
+#endif
+{
+ allocator_type& __a = this->__alloc();
+ __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a);
+ // __v.push_back(_VSTD::forward<_Up>(__x));
+ __alloc_traits::construct(__a, _VSTD::__to_address(__v.__end_), _VSTD::forward<_Up>(__x));
+ __v.__end_++;
+ __swap_out_circular_buffer(__v);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+vector<_Tp, _Allocator>::push_back(const_reference __x)
+{
+ if (this->__end_ != this->__end_cap())
+ {
+ __construct_one_at_end(__x);
+ }
+ else
+ __push_back_slow_path(__x);
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+vector<_Tp, _Allocator>::push_back(value_type&& __x)
+{
+ if (this->__end_ < this->__end_cap())
+ {
+ __construct_one_at_end(_VSTD::move(__x));
+ }
+ else
+ __push_back_slow_path(_VSTD::move(__x));
+}
+
+template <class _Tp, class _Allocator>
+template <class... _Args>
+void
+vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args)
+{
+ allocator_type& __a = this->__alloc();
+ __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a);
+// __v.emplace_back(_VSTD::forward<_Args>(__args)...);
+ __alloc_traits::construct(__a, _VSTD::__to_address(__v.__end_), _VSTD::forward<_Args>(__args)...);
+ __v.__end_++;
+ __swap_out_circular_buffer(__v);
+}
+
+template <class _Tp, class _Allocator>
+template <class... _Args>
+inline
+#if _LIBCPP_STD_VER > 14
+typename vector<_Tp, _Allocator>::reference
+#else
+void
+#endif
+vector<_Tp, _Allocator>::emplace_back(_Args&&... __args)
+{
+ if (this->__end_ < this->__end_cap())
+ {
+ __construct_one_at_end(_VSTD::forward<_Args>(__args)...);
+ }
+ else
+ __emplace_back_slow_path(_VSTD::forward<_Args>(__args)...);
+#if _LIBCPP_STD_VER > 14
+ return this->back();
+#endif
+}
+
+#endif // !_LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Allocator>
+inline
+void
+vector<_Tp, _Allocator>::pop_back()
+{
+ _LIBCPP_ASSERT(!empty(), "vector::pop_back called on an empty vector");
+ this->__destruct_at_end(this->__end_ - 1);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename vector<_Tp, _Allocator>::iterator
+vector<_Tp, _Allocator>::erase(const_iterator __position)
+{
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this,
+ "vector::erase(iterator) called with an iterator not referring to this vector");
+ _LIBCPP_ASSERT(__position != end(),
+ "vector::erase(iterator) called with a non-dereferenceable iterator");
+ difference_type __ps = __position - cbegin();
+ pointer __p = this->__begin_ + __ps;
+ this->__destruct_at_end(_VSTD::move(__p + 1, this->__end_, __p));
+ this->__invalidate_iterators_past(__p-1);
+ iterator __r = __make_iter(__p);
+ return __r;
+}
+
+template <class _Tp, class _Allocator>
+typename vector<_Tp, _Allocator>::iterator
+vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last)
+{
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__first)) == this,
+ "vector::erase(iterator, iterator) called with an iterator not referring to this vector");
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__last)) == this,
+ "vector::erase(iterator, iterator) called with an iterator not referring to this vector");
+
+ _LIBCPP_ASSERT(__first <= __last, "vector::erase(first, last) called with invalid range");
+ pointer __p = this->__begin_ + (__first - begin());
+ if (__first != __last) {
+ this->__destruct_at_end(_VSTD::move(__p + (__last - __first), this->__end_, __p));
+ this->__invalidate_iterators_past(__p - 1);
+ }
+ iterator __r = __make_iter(__p);
+ return __r;
+}
+
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointer __to)
+{
+ pointer __old_last = this->__end_;
+ difference_type __n = __old_last - __to;
+ {
+ pointer __i = __from_s + __n;
+ _ConstructTransaction __tx(*this, __from_e - __i);
+ for (pointer __pos = __tx.__pos_; __i < __from_e;
+ ++__i, (void) ++__pos, __tx.__pos_ = __pos) {
+ __alloc_traits::construct(this->__alloc(),
+ _VSTD::__to_address(__pos),
+ _VSTD::move(*__i));
+ }
+ }
+ _VSTD::move_backward(__from_s, __from_s + __n, __old_last);
+}
+
+template <class _Tp, class _Allocator>
+typename vector<_Tp, _Allocator>::iterator
+vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)
+{
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this,
+ "vector::insert(iterator, x) called with an iterator not referring to this vector");
+ pointer __p = this->__begin_ + (__position - begin());
+ if (this->__end_ < this->__end_cap())
+ {
+ if (__p == this->__end_)
+ {
+ __construct_one_at_end(__x);
+ }
+ else
+ {
+ __move_range(__p, this->__end_, __p + 1);
+ const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x);
+ if (__p <= __xr && __xr < this->__end_)
+ ++__xr;
+ *__p = *__xr;
+ }
+ }
+ else
+ {
+ allocator_type& __a = this->__alloc();
+ __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a);
+ __v.push_back(__x);
+ __p = __swap_out_circular_buffer(__v, __p);
+ }
+ return __make_iter(__p);
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Allocator>
+typename vector<_Tp, _Allocator>::iterator
+vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x)
+{
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this,
+ "vector::insert(iterator, x) called with an iterator not referring to this vector");
+ pointer __p = this->__begin_ + (__position - begin());
+ if (this->__end_ < this->__end_cap())
+ {
+ if (__p == this->__end_)
+ {
+ __construct_one_at_end(_VSTD::move(__x));
+ }
+ else
+ {
+ __move_range(__p, this->__end_, __p + 1);
+ *__p = _VSTD::move(__x);
+ }
+ }
+ else
+ {
+ allocator_type& __a = this->__alloc();
+ __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a);
+ __v.push_back(_VSTD::move(__x));
+ __p = __swap_out_circular_buffer(__v, __p);
+ }
+ return __make_iter(__p);
+}
+
+template <class _Tp, class _Allocator>
+template <class... _Args>
+typename vector<_Tp, _Allocator>::iterator
+vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args)
+{
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this,
+ "vector::emplace(iterator, x) called with an iterator not referring to this vector");
+ pointer __p = this->__begin_ + (__position - begin());
+ if (this->__end_ < this->__end_cap())
+ {
+ if (__p == this->__end_)
+ {
+ __construct_one_at_end(_VSTD::forward<_Args>(__args)...);
+ }
+ else
+ {
+ __temp_value<value_type, _Allocator> __tmp(this->__alloc(), _VSTD::forward<_Args>(__args)...);
+ __move_range(__p, this->__end_, __p + 1);
+ *__p = _VSTD::move(__tmp.get());
+ }
+ }
+ else
+ {
+ allocator_type& __a = this->__alloc();
+ __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a);
+ __v.emplace_back(_VSTD::forward<_Args>(__args)...);
+ __p = __swap_out_circular_buffer(__v, __p);
+ }
+ return __make_iter(__p);
+}
+
+#endif // !_LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Allocator>
+typename vector<_Tp, _Allocator>::iterator
+vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x)
+{
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this,
+ "vector::insert(iterator, n, x) called with an iterator not referring to this vector");
+ pointer __p = this->__begin_ + (__position - begin());
+ if (__n > 0)
+ {
+ if (__n <= static_cast<size_type>(this->__end_cap() - this->__end_))
+ {
+ size_type __old_n = __n;
+ pointer __old_last = this->__end_;
+ if (__n > static_cast<size_type>(this->__end_ - __p))
+ {
+ size_type __cx = __n - (this->__end_ - __p);
+ __construct_at_end(__cx, __x);
+ __n -= __cx;
+ }
+ if (__n > 0)
+ {
+ __move_range(__p, __old_last, __p + __old_n);
+ const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x);
+ if (__p <= __xr && __xr < this->__end_)
+ __xr += __old_n;
+ _VSTD::fill_n(__p, __n, *__xr);
+ }
+ }
+ else
+ {
+ allocator_type& __a = this->__alloc();
+ __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, __a);
+ __v.__construct_at_end(__n, __x);
+ __p = __swap_out_circular_buffer(__v, __p);
+ }
+ }
+ return __make_iter(__p);
+}
+
+template <class _Tp, class _Allocator>
+template <class _InputIterator>
+typename enable_if
+<
+ __is_cpp17_input_iterator <_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value &&
+ is_constructible<
+ _Tp,
+ typename iterator_traits<_InputIterator>::reference>::value,
+ typename vector<_Tp, _Allocator>::iterator
+>::type
+vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last)
+{
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this,
+ "vector::insert(iterator, range) called with an iterator not referring to this vector");
+ difference_type __off = __position - begin();
+ pointer __p = this->__begin_ + __off;
+ allocator_type& __a = this->__alloc();
+ pointer __old_last = this->__end_;
+ for (; this->__end_ != this->__end_cap() && __first != __last; ++__first)
+ {
+ __construct_one_at_end(*__first);
+ }
+ __split_buffer<value_type, allocator_type&> __v(__a);
+ if (__first != __last)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#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_;
+ reserve(__recommend(size() + __v.size()));
+ __p = this->__begin_ + __old_p;
+ __old_last = this->__begin_ + __old_size;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ erase(__make_iter(__old_last), end());
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ }
+ __p = _VSTD::rotate(__p, __old_last, this->__end_);
+ insert(__make_iter(__p), _VSTD::make_move_iterator(__v.begin()),
+ _VSTD::make_move_iterator(__v.end()));
+ return begin() + __off;
+}
+
+template <class _Tp, class _Allocator>
+template <class _ForwardIterator>
+typename enable_if
+<
+ __is_cpp17_forward_iterator<_ForwardIterator>::value &&
+ is_constructible<
+ _Tp,
+ typename iterator_traits<_ForwardIterator>::reference>::value,
+ typename vector<_Tp, _Allocator>::iterator
+>::type
+vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last)
+{
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this,
+ "vector::insert(iterator, range) called with an iterator not referring to this vector");
+ pointer __p = this->__begin_ + (__position - begin());
+ difference_type __n = _VSTD::distance(__first, __last);
+ if (__n > 0)
+ {
+ if (__n <= this->__end_cap() - this->__end_)
+ {
+ size_type __old_n = __n;
+ pointer __old_last = this->__end_;
+ _ForwardIterator __m = __last;
+ difference_type __dx = this->__end_ - __p;
+ if (__n > __dx)
+ {
+ __m = __first;
+ difference_type __diff = this->__end_ - __p;
+ _VSTD::advance(__m, __diff);
+ __construct_at_end(__m, __last, __n - __diff);
+ __n = __dx;
+ }
+ if (__n > 0)
+ {
+ __move_range(__p, __old_last, __p + __old_n);
+ _VSTD::copy(__first, __m, __p);
+ }
+ }
+ else
+ {
+ allocator_type& __a = this->__alloc();
+ __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, __a);
+ __v.__construct_at_end(__first, __last);
+ __p = __swap_out_circular_buffer(__v, __p);
+ }
+ }
+ return __make_iter(__p);
+}
+
+#if _YNDX_LIBCXX_ENABLE_VECTOR_POD_RESIZE_UNINITIALIZED
+
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::resize_uninitialized(size_type __sz)
+{
+ size_type __cs = size();
+ if (__cs < __sz)
+ this->__append_uninitialized(__sz - __cs);
+ else if (__cs > __sz) {
+ this->__end_ = this->__begin_ + __sz;
+ __annotate_shrink(__cs);
+ }
+}
+
+#endif
+
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::resize(size_type __sz)
+{
+ size_type __cs = size();
+ if (__cs < __sz)
+ this->__append(__sz - __cs);
+ else if (__cs > __sz)
+ this->__destruct_at_end(this->__begin_ + __sz);
+}
+
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x)
+{
+ size_type __cs = size();
+ if (__cs < __sz)
+ this->__append(__sz - __cs, __x);
+ else if (__cs > __sz)
+ this->__destruct_at_end(this->__begin_ + __sz);
+}
+
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::swap(vector& __x)
+#if _LIBCPP_STD_VER >= 14
+ _NOEXCEPT
+#else
+ _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
+ __is_nothrow_swappable<allocator_type>::value)
+#endif
+{
+ _LIBCPP_ASSERT(__alloc_traits::propagate_on_container_swap::value ||
+ this->__alloc() == __x.__alloc(),
+ "vector::swap: Either propagate_on_container_swap must be true"
+ " or the allocators must compare equal");
+ _VSTD::swap(this->__begin_, __x.__begin_);
+ _VSTD::swap(this->__end_, __x.__end_);
+ _VSTD::swap(this->__end_cap(), __x.__end_cap());
+ _VSTD::__swap_allocator(this->__alloc(), __x.__alloc(),
+ integral_constant<bool,__alloc_traits::propagate_on_container_swap::value>());
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __get_db()->swap(this, _VSTD::addressof(__x));
+#endif
+}
+
+template <class _Tp, class _Allocator>
+bool
+vector<_Tp, _Allocator>::__invariants() const
+{
+ if (this->__begin_ == nullptr)
+ {
+ if (this->__end_ != nullptr || this->__end_cap() != nullptr)
+ return false;
+ }
+ else
+ {
+ if (this->__begin_ > this->__end_)
+ return false;
+ if (this->__begin_ == this->__end_cap())
+ return false;
+ if (this->__end_ > this->__end_cap())
+ return false;
+ }
+ return true;
+}
+
+#if _LIBCPP_DEBUG_LEVEL == 2
+
+template <class _Tp, class _Allocator>
+bool
+vector<_Tp, _Allocator>::__dereferenceable(const const_iterator* __i) const
+{
+ return this->__begin_ <= __i->base() && __i->base() < this->__end_;
+}
+
+template <class _Tp, class _Allocator>
+bool
+vector<_Tp, _Allocator>::__decrementable(const const_iterator* __i) const
+{
+ return this->__begin_ < __i->base() && __i->base() <= this->__end_;
+}
+
+template <class _Tp, class _Allocator>
+bool
+vector<_Tp, _Allocator>::__addable(const const_iterator* __i, ptrdiff_t __n) const
+{
+ const_pointer __p = __i->base() + __n;
+ return this->__begin_ <= __p && __p <= this->__end_;
+}
+
+template <class _Tp, class _Allocator>
+bool
+vector<_Tp, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __n) const
+{
+ const_pointer __p = __i->base() + __n;
+ return this->__begin_ <= __p && __p < this->__end_;
+}
+
+#endif // _LIBCPP_DEBUG_LEVEL == 2
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+vector<_Tp, _Allocator>::__invalidate_all_iterators()
+{
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __get_db()->__invalidate_all(this);
+#endif
+}
+
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+vector<_Tp, _Allocator>::__invalidate_iterators_past(pointer __new_last) {
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __c_node* __c = __get_db()->__find_c_and_lock(this);
+ for (__i_node** __p = __c->end_; __p != __c->beg_; ) {
+ --__p;
+ const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_);
+ if (__i->base() > __new_last) {
+ (*__p)->__c_ = nullptr;
+ if (--__c->end_ != __p)
+ _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
+ }
+ }
+ __get_db()->unlock();
+#else
+ ((void)__new_last);
+#endif
+}
+
+#if _YNDX_LIBCXX_ENABLE_VECTOR_BOOL_COMPRESSION == 1
+// vector<bool>
+
+template <class _Allocator> class vector<bool, _Allocator>;
+
+template <class _Allocator> struct hash<vector<bool, _Allocator> >;
+
+template <class _Allocator>
+struct __has_storage_type<vector<bool, _Allocator> >
+{
+ static const bool value = true;
+};
+
+template <class _Allocator>
+class _LIBCPP_TEMPLATE_VIS vector<bool, _Allocator>
+{
+public:
+ typedef vector __self;
+ typedef bool value_type;
+ typedef _Allocator allocator_type;
+ typedef allocator_traits<allocator_type> __alloc_traits;
+ typedef typename __alloc_traits::size_type size_type;
+ typedef typename __alloc_traits::difference_type difference_type;
+ typedef size_type __storage_type;
+ typedef __bit_iterator<vector, false> pointer;
+ typedef __bit_iterator<vector, true> const_pointer;
+ typedef pointer iterator;
+ typedef const_pointer const_iterator;
+ typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
+ typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
+
+private:
+ typedef typename __rebind_alloc_helper<__alloc_traits, __storage_type>::type __storage_allocator;
+ typedef allocator_traits<__storage_allocator> __storage_traits;
+ typedef typename __storage_traits::pointer __storage_pointer;
+ typedef typename __storage_traits::const_pointer __const_storage_pointer;
+
+ __storage_pointer __begin_;
+ size_type __size_;
+ __compressed_pair<size_type, __storage_allocator> __cap_alloc_;
+public:
+ typedef __bit_reference<vector> reference;
+ typedef __bit_const_reference<vector> const_reference;
+private:
+ _LIBCPP_INLINE_VISIBILITY
+ size_type& __cap() _NOEXCEPT
+ {return __cap_alloc_.first();}
+ _LIBCPP_INLINE_VISIBILITY
+ const size_type& __cap() const _NOEXCEPT
+ {return __cap_alloc_.first();}
+ _LIBCPP_INLINE_VISIBILITY
+ __storage_allocator& __alloc() _NOEXCEPT
+ {return __cap_alloc_.second();}
+ _LIBCPP_INLINE_VISIBILITY
+ const __storage_allocator& __alloc() const _NOEXCEPT
+ {return __cap_alloc_.second();}
+
+ static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);
+
+ _LIBCPP_INLINE_VISIBILITY
+ static size_type __internal_cap_to_external(size_type __n) _NOEXCEPT
+ {return __n * __bits_per_word;}
+ _LIBCPP_INLINE_VISIBILITY
+ static size_type __external_cap_to_internal(size_type __n) _NOEXCEPT
+ {return (__n - 1) / __bits_per_word + 1;}
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
+
+ _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a)
+#if _LIBCPP_STD_VER <= 14
+ _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value);
+#else
+ _NOEXCEPT;
+#endif
+ ~vector();
+ explicit vector(size_type __n);
+#if _LIBCPP_STD_VER > 11
+ explicit vector(size_type __n, const allocator_type& __a);
+#endif
+ vector(size_type __n, const value_type& __v);
+ vector(size_type __n, const value_type& __v, const allocator_type& __a);
+ template <class _InputIterator>
+ vector(_InputIterator __first, _InputIterator __last,
+ typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value>::type* = 0);
+ template <class _InputIterator>
+ vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
+ typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value>::type* = 0);
+ template <class _ForwardIterator>
+ vector(_ForwardIterator __first, _ForwardIterator __last,
+ typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0);
+ template <class _ForwardIterator>
+ vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
+ typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0);
+
+ vector(const vector& __v);
+ vector(const vector& __v, const allocator_type& __a);
+ vector& operator=(const vector& __v);
+
+#ifndef _LIBCPP_CXX03_LANG
+ vector(initializer_list<value_type> __il);
+ vector(initializer_list<value_type> __il, const allocator_type& __a);
+
+ _LIBCPP_INLINE_VISIBILITY
+ vector(vector&& __v)
+#if _LIBCPP_STD_VER > 14
+ _NOEXCEPT;
+#else
+ _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
+#endif
+ 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));
+
+ _LIBCPP_INLINE_VISIBILITY
+ vector& operator=(initializer_list<value_type> __il)
+ {assign(__il.begin(), __il.end()); return *this;}
+
+#endif // !_LIBCPP_CXX03_LANG
+
+ template <class _InputIterator>
+ typename enable_if
+ <
+ __is_cpp17_input_iterator<_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value,
+ void
+ >::type
+ assign(_InputIterator __first, _InputIterator __last);
+ template <class _ForwardIterator>
+ typename enable_if
+ <
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
+ void
+ >::type
+ assign(_ForwardIterator __first, _ForwardIterator __last);
+
+ void assign(size_type __n, const value_type& __x);
+
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ void assign(initializer_list<value_type> __il)
+ {assign(__il.begin(), __il.end());}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY allocator_type get_allocator() const _NOEXCEPT
+ {return allocator_type(this->__alloc());}
+
+ size_type max_size() const _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ size_type capacity() const _NOEXCEPT
+ {return __internal_cap_to_external(__cap());}
+ _LIBCPP_INLINE_VISIBILITY
+ size_type size() const _NOEXCEPT
+ {return __size_;}
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+ bool empty() const _NOEXCEPT
+ {return __size_ == 0;}
+ void reserve(size_type __n);
+ void shrink_to_fit() _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY
+ iterator begin() _NOEXCEPT
+ {return __make_iter(0);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator begin() const _NOEXCEPT
+ {return __make_iter(0);}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator end() _NOEXCEPT
+ {return __make_iter(__size_);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator end() const _NOEXCEPT
+ {return __make_iter(__size_);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ reverse_iterator rbegin() _NOEXCEPT
+ {return reverse_iterator(end());}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator rbegin() const _NOEXCEPT
+ {return const_reverse_iterator(end());}
+ _LIBCPP_INLINE_VISIBILITY
+ reverse_iterator rend() _NOEXCEPT
+ {return reverse_iterator(begin());}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator rend() const _NOEXCEPT
+ {return const_reverse_iterator(begin());}
+
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator cbegin() const _NOEXCEPT
+ {return __make_iter(0);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator cend() const _NOEXCEPT
+ {return __make_iter(__size_);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator crbegin() const _NOEXCEPT
+ {return rbegin();}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator crend() const _NOEXCEPT
+ {return rend();}
+
+ _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) {return __make_ref(__n);}
+ _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const {return __make_ref(__n);}
+ reference at(size_type __n);
+ const_reference at(size_type __n) const;
+
+ _LIBCPP_INLINE_VISIBILITY reference front() {return __make_ref(0);}
+ _LIBCPP_INLINE_VISIBILITY const_reference front() const {return __make_ref(0);}
+ _LIBCPP_INLINE_VISIBILITY reference back() {return __make_ref(__size_ - 1);}
+ _LIBCPP_INLINE_VISIBILITY const_reference back() const {return __make_ref(__size_ - 1);}
+
+ void push_back(const value_type& __x);
+#if _LIBCPP_STD_VER > 11
+ template <class... _Args>
+#if _LIBCPP_STD_VER > 14
+ _LIBCPP_INLINE_VISIBILITY reference emplace_back(_Args&&... __args)
+#else
+ _LIBCPP_INLINE_VISIBILITY void emplace_back(_Args&&... __args)
+#endif
+ {
+ push_back ( value_type ( _VSTD::forward<_Args>(__args)... ));
+#if _LIBCPP_STD_VER > 14
+ return this->back();
+#endif
+ }
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY void pop_back() {--__size_;}
+
+#if _LIBCPP_STD_VER > 11
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY iterator emplace(const_iterator position, _Args&&... __args)
+ { return insert ( position, value_type ( _VSTD::forward<_Args>(__args)... )); }
+#endif
+
+ iterator insert(const_iterator __position, const value_type& __x);
+ iterator insert(const_iterator __position, size_type __n, const value_type& __x);
+ iterator insert(const_iterator __position, size_type __n, const_reference __x);
+ template <class _InputIterator>
+ typename enable_if
+ <
+ __is_cpp17_input_iterator <_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value,
+ iterator
+ >::type
+ insert(const_iterator __position, _InputIterator __first, _InputIterator __last);
+ template <class _ForwardIterator>
+ typename enable_if
+ <
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
+ iterator
+ >::type
+ insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
+
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ iterator insert(const_iterator __position, initializer_list<value_type> __il)
+ {return insert(__position, __il.begin(), __il.end());}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position);
+ iterator erase(const_iterator __first, const_iterator __last);
+
+ _LIBCPP_REINITIALIZES_OBJECT _LIBCPP_INLINE_VISIBILITY
+ void clear() _NOEXCEPT {__size_ = 0;}
+
+ void swap(vector&)
+#if _LIBCPP_STD_VER >= 14
+ _NOEXCEPT;
+#else
+ _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
+ __is_nothrow_swappable<allocator_type>::value);
+#endif
+ static void swap(reference __x, reference __y) _NOEXCEPT { _VSTD::swap(__x, __y); }
+
+ void resize(size_type __sz, value_type __x = false);
+ void flip() _NOEXCEPT;
+
+ bool __invariants() const;
+
+private:
+ _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
+ void __throw_length_error() const {
+ _VSTD::__throw_length_error("vector");
+ }
+
+ _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
+ void __throw_out_of_range() const {
+ _VSTD::__throw_out_of_range("vector");
+ }
+
+ _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();
+ void __vallocate(size_type __n);
+ void __vdeallocate() _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ static size_type __align_it(size_type __new_size) _NOEXCEPT
+ {return __new_size + (__bits_per_word-1) & ~((size_type)__bits_per_word-1);}
+ _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const;
+ _LIBCPP_INLINE_VISIBILITY void __construct_at_end(size_type __n, bool __x);
+ template <class _ForwardIterator>
+ typename enable_if
+ <
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
+ void
+ >::type
+ __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
+ void __append(size_type __n, const_reference __x);
+ _LIBCPP_INLINE_VISIBILITY
+ reference __make_ref(size_type __pos) _NOEXCEPT
+ {return reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);}
+ _LIBCPP_INLINE_VISIBILITY
+ const_reference __make_ref(size_type __pos) const _NOEXCEPT
+ {return const_reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator __make_iter(size_type __pos) _NOEXCEPT
+ {return iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));}
+ _LIBCPP_INLINE_VISIBILITY
+ const_iterator __make_iter(size_type __pos) const _NOEXCEPT
+ {return const_iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));}
+ _LIBCPP_INLINE_VISIBILITY
+ iterator __const_iterator_cast(const_iterator __p) _NOEXCEPT
+ {return begin() + (__p - cbegin());}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __copy_assign_alloc(const vector& __v)
+ {__copy_assign_alloc(__v, integral_constant<bool,
+ __storage_traits::propagate_on_container_copy_assignment::value>());}
+ _LIBCPP_INLINE_VISIBILITY
+ void __copy_assign_alloc(const vector& __c, true_type)
+ {
+ if (__alloc() != __c.__alloc())
+ __vdeallocate();
+ __alloc() = __c.__alloc();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __copy_assign_alloc(const vector&, false_type)
+ {}
+
+ void __move_assign(vector& __c, false_type);
+ void __move_assign(vector& __c, true_type)
+ _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
+ _LIBCPP_INLINE_VISIBILITY
+ void __move_assign_alloc(vector& __c)
+ _NOEXCEPT_(
+ !__storage_traits::propagate_on_container_move_assignment::value ||
+ is_nothrow_move_assignable<allocator_type>::value)
+ {__move_assign_alloc(__c, integral_constant<bool,
+ __storage_traits::propagate_on_container_move_assignment::value>());}
+ _LIBCPP_INLINE_VISIBILITY
+ void __move_assign_alloc(vector& __c, true_type)
+ _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
+ {
+ __alloc() = _VSTD::move(__c.__alloc());
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __move_assign_alloc(vector&, false_type)
+ _NOEXCEPT
+ {}
+
+ size_t __hash_code() const _NOEXCEPT;
+
+ friend class __bit_reference<vector>;
+ friend class __bit_const_reference<vector>;
+ friend class __bit_iterator<vector, false>;
+ friend class __bit_iterator<vector, true>;
+ friend struct __bit_array<vector>;
+ friend struct _LIBCPP_TEMPLATE_VIS hash<vector>;
+};
+
+template <class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+vector<bool, _Allocator>::__invalidate_all_iterators()
+{
+}
+
+// Allocate space for __n objects
+// throws length_error if __n > max_size()
+// throws (probably bad_alloc) if memory run out
+// Precondition: __begin_ == __end_ == __cap() == 0
+// Precondition: __n > 0
+// Postcondition: capacity() == __n
+// Postcondition: size() == 0
+template <class _Allocator>
+void
+vector<bool, _Allocator>::__vallocate(size_type __n)
+{
+ if (__n > max_size())
+ this->__throw_length_error();
+ __n = __external_cap_to_internal(__n);
+ this->__begin_ = __storage_traits::allocate(this->__alloc(), __n);
+ this->__size_ = 0;
+ this->__cap() = __n;
+}
+
+template <class _Allocator>
+void
+vector<bool, _Allocator>::__vdeallocate() _NOEXCEPT
+{
+ if (this->__begin_ != nullptr)
+ {
+ __storage_traits::deallocate(this->__alloc(), this->__begin_, __cap());
+ __invalidate_all_iterators();
+ this->__begin_ = nullptr;
+ this->__size_ = this->__cap() = 0;
+ }
+}
+
+template <class _Allocator>
+typename vector<bool, _Allocator>::size_type
+vector<bool, _Allocator>::max_size() const _NOEXCEPT
+{
+ size_type __amax = __storage_traits::max_size(__alloc());
+ size_type __nmax = numeric_limits<size_type>::max() / 2; // end() >= begin(), always
+ if (__nmax / __bits_per_word <= __amax)
+ return __nmax;
+ return __internal_cap_to_external(__amax);
+}
+
+// Precondition: __new_size > capacity()
+template <class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename vector<bool, _Allocator>::size_type
+vector<bool, _Allocator>::__recommend(size_type __new_size) const
+{
+ const size_type __ms = max_size();
+ if (__new_size > __ms)
+ this->__throw_length_error();
+ const size_type __cap = capacity();
+ if (__cap >= __ms / 2)
+ return __ms;
+ return _VSTD::max(2 * __cap, __align_it(__new_size));
+}
+
+// Default constructs __n objects starting at __end_
+// Precondition: __n > 0
+// Precondition: size() + __n <= capacity()
+// Postcondition: size() == size() + __n
+template <class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x)
+{
+ size_type __old_size = this->__size_;
+ this->__size_ += __n;
+ if (__old_size == 0 || ((__old_size - 1) / __bits_per_word) != ((this->__size_ - 1) / __bits_per_word))
+ {
+ if (this->__size_ <= __bits_per_word)
+ this->__begin_[0] = __storage_type(0);
+ else
+ this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0);
+ }
+ _VSTD::fill_n(__make_iter(__old_size), __n, __x);
+}
+
+template <class _Allocator>
+template <class _ForwardIterator>
+typename enable_if
+<
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
+ void
+>::type
+vector<bool, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)
+{
+ size_type __old_size = this->__size_;
+ this->__size_ += _VSTD::distance(__first, __last);
+ if (__old_size == 0 || ((__old_size - 1) / __bits_per_word) != ((this->__size_ - 1) / __bits_per_word))
+ {
+ if (this->__size_ <= __bits_per_word)
+ this->__begin_[0] = __storage_type(0);
+ else
+ this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0);
+ }
+ _VSTD::copy(__first, __last, __make_iter(__old_size));
+}
+
+template <class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+vector<bool, _Allocator>::vector()
+ _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
+ : __begin_(nullptr),
+ __size_(0),
+ __cap_alloc_(0, __default_init_tag())
+{
+}
+
+template <class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+vector<bool, _Allocator>::vector(const allocator_type& __a)
+#if _LIBCPP_STD_VER <= 14
+ _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
+#else
+ _NOEXCEPT
+#endif
+ : __begin_(nullptr),
+ __size_(0),
+ __cap_alloc_(0, static_cast<__storage_allocator>(__a))
+{
+}
+
+template <class _Allocator>
+vector<bool, _Allocator>::vector(size_type __n)
+ : __begin_(nullptr),
+ __size_(0),
+ __cap_alloc_(0, __default_init_tag())
+{
+ if (__n > 0)
+ {
+ __vallocate(__n);
+ __construct_at_end(__n, false);
+ }
+}
+
+#if _LIBCPP_STD_VER > 11
+template <class _Allocator>
+vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a)
+ : __begin_(nullptr),
+ __size_(0),
+ __cap_alloc_(0, static_cast<__storage_allocator>(__a))
+{
+ if (__n > 0)
+ {
+ __vallocate(__n);
+ __construct_at_end(__n, false);
+ }
+}
+#endif
+
+template <class _Allocator>
+vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)
+ : __begin_(nullptr),
+ __size_(0),
+ __cap_alloc_(0, __default_init_tag())
+{
+ if (__n > 0)
+ {
+ __vallocate(__n);
+ __construct_at_end(__n, __x);
+ }
+}
+
+template <class _Allocator>
+vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a)
+ : __begin_(nullptr),
+ __size_(0),
+ __cap_alloc_(0, static_cast<__storage_allocator>(__a))
+{
+ if (__n > 0)
+ {
+ __vallocate(__n);
+ __construct_at_end(__n, __x);
+ }
+}
+
+template <class _Allocator>
+template <class _InputIterator>
+vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
+ typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value>::type*)
+ : __begin_(nullptr),
+ __size_(0),
+ __cap_alloc_(0, __default_init_tag())
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ for (; __first != __last; ++__first)
+ push_back(*__first);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ if (__begin_ != nullptr)
+ __storage_traits::deallocate(__alloc(), __begin_, __cap());
+ __invalidate_all_iterators();
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+}
+
+template <class _Allocator>
+template <class _InputIterator>
+vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
+ typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value>::type*)
+ : __begin_(nullptr),
+ __size_(0),
+ __cap_alloc_(0, static_cast<__storage_allocator>(__a))
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ for (; __first != __last; ++__first)
+ push_back(*__first);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ if (__begin_ != nullptr)
+ __storage_traits::deallocate(__alloc(), __begin_, __cap());
+ __invalidate_all_iterators();
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+}
+
+template <class _Allocator>
+template <class _ForwardIterator>
+vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last,
+ typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type*)
+ : __begin_(nullptr),
+ __size_(0),
+ __cap_alloc_(0, __default_init_tag())
+{
+ size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
+ if (__n > 0)
+ {
+ __vallocate(__n);
+ __construct_at_end(__first, __last);
+ }
+}
+
+template <class _Allocator>
+template <class _ForwardIterator>
+vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
+ typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type*)
+ : __begin_(nullptr),
+ __size_(0),
+ __cap_alloc_(0, static_cast<__storage_allocator>(__a))
+{
+ size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
+ if (__n > 0)
+ {
+ __vallocate(__n);
+ __construct_at_end(__first, __last);
+ }
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Allocator>
+vector<bool, _Allocator>::vector(initializer_list<value_type> __il)
+ : __begin_(nullptr),
+ __size_(0),
+ __cap_alloc_(0, __default_init_tag())
+{
+ size_type __n = static_cast<size_type>(__il.size());
+ if (__n > 0)
+ {
+ __vallocate(__n);
+ __construct_at_end(__il.begin(), __il.end());
+ }
+}
+
+template <class _Allocator>
+vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)
+ : __begin_(nullptr),
+ __size_(0),
+ __cap_alloc_(0, static_cast<__storage_allocator>(__a))
+{
+ size_type __n = static_cast<size_type>(__il.size());
+ if (__n > 0)
+ {
+ __vallocate(__n);
+ __construct_at_end(__il.begin(), __il.end());
+ }
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _Allocator>
+vector<bool, _Allocator>::~vector()
+{
+ if (__begin_ != nullptr)
+ __storage_traits::deallocate(__alloc(), __begin_, __cap());
+ __invalidate_all_iterators();
+}
+
+template <class _Allocator>
+vector<bool, _Allocator>::vector(const vector& __v)
+ : __begin_(nullptr),
+ __size_(0),
+ __cap_alloc_(0, __storage_traits::select_on_container_copy_construction(__v.__alloc()))
+{
+ if (__v.size() > 0)
+ {
+ __vallocate(__v.size());
+ __construct_at_end(__v.begin(), __v.end());
+ }
+}
+
+template <class _Allocator>
+vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a)
+ : __begin_(nullptr),
+ __size_(0),
+ __cap_alloc_(0, __a)
+{
+ if (__v.size() > 0)
+ {
+ __vallocate(__v.size());
+ __construct_at_end(__v.begin(), __v.end());
+ }
+}
+
+template <class _Allocator>
+vector<bool, _Allocator>&
+vector<bool, _Allocator>::operator=(const vector& __v)
+{
+ if (this != _VSTD::addressof(__v))
+ {
+ __copy_assign_alloc(__v);
+ if (__v.__size_)
+ {
+ if (__v.__size_ > capacity())
+ {
+ __vdeallocate();
+ __vallocate(__v.__size_);
+ }
+ _VSTD::copy(__v.__begin_, __v.__begin_ + __external_cap_to_internal(__v.__size_), __begin_);
+ }
+ __size_ = __v.__size_;
+ }
+ return *this;
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>::vector(vector&& __v)
+#if _LIBCPP_STD_VER > 14
+ _NOEXCEPT
+#else
+ _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
+#endif
+ : __begin_(__v.__begin_),
+ __size_(__v.__size_),
+ __cap_alloc_(_VSTD::move(__v.__cap_alloc_)) {
+ __v.__begin_ = nullptr;
+ __v.__size_ = 0;
+ __v.__cap() = 0;
+}
+
+template <class _Allocator>
+vector<bool, _Allocator>::vector(vector&& __v, const __identity_t<allocator_type>& __a)
+ : __begin_(nullptr),
+ __size_(0),
+ __cap_alloc_(0, __a)
+{
+ if (__a == allocator_type(__v.__alloc()))
+ {
+ this->__begin_ = __v.__begin_;
+ this->__size_ = __v.__size_;
+ this->__cap() = __v.__cap();
+ __v.__begin_ = nullptr;
+ __v.__cap() = __v.__size_ = 0;
+ }
+ else if (__v.size() > 0)
+ {
+ __vallocate(__v.size());
+ __construct_at_end(__v.begin(), __v.end());
+ }
+}
+
+template <class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+vector<bool, _Allocator>&
+vector<bool, _Allocator>::operator=(vector&& __v)
+ _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))
+{
+ __move_assign(__v, integral_constant<bool,
+ __storage_traits::propagate_on_container_move_assignment::value>());
+ return *this;
+}
+
+template <class _Allocator>
+void
+vector<bool, _Allocator>::__move_assign(vector& __c, false_type)
+{
+ if (__alloc() != __c.__alloc())
+ assign(__c.begin(), __c.end());
+ else
+ __move_assign(__c, true_type());
+}
+
+template <class _Allocator>
+void
+vector<bool, _Allocator>::__move_assign(vector& __c, true_type)
+ _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
+{
+ __vdeallocate();
+ __move_assign_alloc(__c);
+ this->__begin_ = __c.__begin_;
+ this->__size_ = __c.__size_;
+ this->__cap() = __c.__cap();
+ __c.__begin_ = nullptr;
+ __c.__cap() = __c.__size_ = 0;
+}
+
+#endif // !_LIBCPP_CXX03_LANG
+
+template <class _Allocator>
+void
+vector<bool, _Allocator>::assign(size_type __n, const value_type& __x)
+{
+ __size_ = 0;
+ if (__n > 0)
+ {
+ size_type __c = capacity();
+ if (__n <= __c)
+ __size_ = __n;
+ else
+ {
+ vector __v(get_allocator());
+ __v.reserve(__recommend(__n));
+ __v.__size_ = __n;
+ swap(__v);
+ }
+ _VSTD::fill_n(begin(), __n, __x);
+ }
+ __invalidate_all_iterators();
+}
+
+template <class _Allocator>
+template <class _InputIterator>
+typename enable_if
+<
+ __is_cpp17_input_iterator<_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value,
+ void
+>::type
+vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
+{
+ clear();
+ for (; __first != __last; ++__first)
+ push_back(*__first);
+}
+
+template <class _Allocator>
+template <class _ForwardIterator>
+typename enable_if
+<
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
+ void
+>::type
+vector<bool, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last)
+{
+ clear();
+ difference_type __ns = _VSTD::distance(__first, __last);
+ _LIBCPP_ASSERT(__ns >= 0, "invalid range specified");
+ const size_t __n = static_cast<size_type>(__ns);
+ if (__n)
+ {
+ if (__n > capacity())
+ {
+ __vdeallocate();
+ __vallocate(__n);
+ }
+ __construct_at_end(__first, __last);
+ }
+}
+
+template <class _Allocator>
+void
+vector<bool, _Allocator>::reserve(size_type __n)
+{
+ if (__n > capacity())
+ {
+ if (__n > max_size())
+ this->__throw_length_error();
+ vector __v(this->get_allocator());
+ __v.__vallocate(__n);
+ __v.__construct_at_end(this->begin(), this->end());
+ swap(__v);
+ __invalidate_all_iterators();
+ }
+}
+
+template <class _Allocator>
+void
+vector<bool, _Allocator>::shrink_to_fit() _NOEXCEPT
+{
+ if (__external_cap_to_internal(size()) > __cap())
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ vector(*this, allocator_type(__alloc())).swap(*this);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ }
+}
+
+template <class _Allocator>
+typename vector<bool, _Allocator>::reference
+vector<bool, _Allocator>::at(size_type __n)
+{
+ if (__n >= size())
+ this->__throw_out_of_range();
+ return (*this)[__n];
+}
+
+template <class _Allocator>
+typename vector<bool, _Allocator>::const_reference
+vector<bool, _Allocator>::at(size_type __n) const
+{
+ if (__n >= size())
+ this->__throw_out_of_range();
+ return (*this)[__n];
+}
+
+template <class _Allocator>
+void
+vector<bool, _Allocator>::push_back(const value_type& __x)
+{
+ if (this->__size_ == this->capacity())
+ reserve(__recommend(this->__size_ + 1));
+ ++this->__size_;
+ back() = __x;
+}
+
+template <class _Allocator>
+typename vector<bool, _Allocator>::iterator
+vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __x)
+{
+ iterator __r;
+ if (size() < capacity())
+ {
+ const_iterator __old_end = end();
+ ++__size_;
+ _VSTD::copy_backward(__position, __old_end, end());
+ __r = __const_iterator_cast(__position);
+ }
+ else
+ {
+ vector __v(get_allocator());
+ __v.reserve(__recommend(__size_ + 1));
+ __v.__size_ = __size_ + 1;
+ __r = _VSTD::copy(cbegin(), __position, __v.begin());
+ _VSTD::copy_backward(__position, cend(), __v.end());
+ swap(__v);
+ }
+ *__r = __x;
+ return __r;
+}
+
+template <class _Allocator>
+typename vector<bool, _Allocator>::iterator
+vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const value_type& __x)
+{
+ iterator __r;
+ size_type __c = capacity();
+ if (__n <= __c && size() <= __c - __n)
+ {
+ const_iterator __old_end = end();
+ __size_ += __n;
+ _VSTD::copy_backward(__position, __old_end, end());
+ __r = __const_iterator_cast(__position);
+ }
+ else
+ {
+ vector __v(get_allocator());
+ __v.reserve(__recommend(__size_ + __n));
+ __v.__size_ = __size_ + __n;
+ __r = _VSTD::copy(cbegin(), __position, __v.begin());
+ _VSTD::copy_backward(__position, cend(), __v.end());
+ swap(__v);
+ }
+ _VSTD::fill_n(__r, __n, __x);
+ return __r;
+}
+
+template <class _Allocator>
+template <class _InputIterator>
+typename enable_if
+<
+ __is_cpp17_input_iterator <_InputIterator>::value &&
+ !__is_cpp17_forward_iterator<_InputIterator>::value,
+ typename vector<bool, _Allocator>::iterator
+>::type
+vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last)
+{
+ difference_type __off = __position - begin();
+ iterator __p = __const_iterator_cast(__position);
+ iterator __old_end = end();
+ for (; size() != capacity() && __first != __last; ++__first)
+ {
+ ++this->__size_;
+ back() = *__first;
+ }
+ vector __v(get_allocator());
+ if (__first != __last)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#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();
+ reserve(__recommend(size() + __v.size()));
+ __p = begin() + __old_p;
+ __old_end = begin() + __old_size;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ erase(__old_end, end());
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ }
+ __p = _VSTD::rotate(__p, __old_end, end());
+ insert(__p, __v.begin(), __v.end());
+ return begin() + __off;
+}
+
+template <class _Allocator>
+template <class _ForwardIterator>
+typename enable_if
+<
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
+ typename vector<bool, _Allocator>::iterator
+>::type
+vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last)
+{
+ const difference_type __n_signed = _VSTD::distance(__first, __last);
+ _LIBCPP_ASSERT(__n_signed >= 0, "invalid range specified");
+ const size_type __n = static_cast<size_type>(__n_signed);
+ iterator __r;
+ size_type __c = capacity();
+ if (__n <= __c && size() <= __c - __n)
+ {
+ const_iterator __old_end = end();
+ __size_ += __n;
+ _VSTD::copy_backward(__position, __old_end, end());
+ __r = __const_iterator_cast(__position);
+ }
+ else
+ {
+ vector __v(get_allocator());
+ __v.reserve(__recommend(__size_ + __n));
+ __v.__size_ = __size_ + __n;
+ __r = _VSTD::copy(cbegin(), __position, __v.begin());
+ _VSTD::copy_backward(__position, cend(), __v.end());
+ swap(__v);
+ }
+ _VSTD::copy(__first, __last, __r);
+ return __r;
+}
+
+template <class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename vector<bool, _Allocator>::iterator
+vector<bool, _Allocator>::erase(const_iterator __position)
+{
+ iterator __r = __const_iterator_cast(__position);
+ _VSTD::copy(__position + 1, this->cend(), __r);
+ --__size_;
+ return __r;
+}
+
+template <class _Allocator>
+typename vector<bool, _Allocator>::iterator
+vector<bool, _Allocator>::erase(const_iterator __first, const_iterator __last)
+{
+ iterator __r = __const_iterator_cast(__first);
+ difference_type __d = __last - __first;
+ _VSTD::copy(__last, this->cend(), __r);
+ __size_ -= __d;
+ return __r;
+}
+
+template <class _Allocator>
+void
+vector<bool, _Allocator>::swap(vector& __x)
+#if _LIBCPP_STD_VER >= 14
+ _NOEXCEPT
+#else
+ _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
+ __is_nothrow_swappable<allocator_type>::value)
+#endif
+{
+ _VSTD::swap(this->__begin_, __x.__begin_);
+ _VSTD::swap(this->__size_, __x.__size_);
+ _VSTD::swap(this->__cap(), __x.__cap());
+ _VSTD::__swap_allocator(this->__alloc(), __x.__alloc(),
+ integral_constant<bool, __alloc_traits::propagate_on_container_swap::value>());
+}
+
+template <class _Allocator>
+void
+vector<bool, _Allocator>::resize(size_type __sz, value_type __x)
+{
+ size_type __cs = size();
+ if (__cs < __sz)
+ {
+ iterator __r;
+ size_type __c = capacity();
+ size_type __n = __sz - __cs;
+ if (__n <= __c && __cs <= __c - __n)
+ {
+ __r = end();
+ __size_ += __n;
+ }
+ else
+ {
+ vector __v(get_allocator());
+ __v.reserve(__recommend(__size_ + __n));
+ __v.__size_ = __size_ + __n;
+ __r = _VSTD::copy(cbegin(), cend(), __v.begin());
+ swap(__v);
+ }
+ _VSTD::fill_n(__r, __n, __x);
+ }
+ else
+ __size_ = __sz;
+}
+
+template <class _Allocator>
+void
+vector<bool, _Allocator>::flip() _NOEXCEPT
+{
+ // do middle whole words
+ size_type __n = __size_;
+ __storage_pointer __p = __begin_;
+ for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
+ *__p = ~*__p;
+ // do last partial word
+ if (__n > 0)
+ {
+ __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
+ __storage_type __b = *__p & __m;
+ *__p &= ~__m;
+ *__p |= ~__b & __m;
+ }
+}
+
+template <class _Allocator>
+bool
+vector<bool, _Allocator>::__invariants() const
+{
+ if (this->__begin_ == nullptr)
+ {
+ if (this->__size_ != 0 || this->__cap() != 0)
+ return false;
+ }
+ else
+ {
+ if (this->__cap() == 0)
+ return false;
+ if (this->__size_ > this->capacity())
+ return false;
+ }
+ return true;
+}
+
+template <class _Allocator>
+size_t
+vector<bool, _Allocator>::__hash_code() const _NOEXCEPT
+{
+ size_t __h = 0;
+ // do middle whole words
+ size_type __n = __size_;
+ __storage_pointer __p = __begin_;
+ for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
+ __h ^= *__p;
+ // do last partial word
+ if (__n > 0)
+ {
+ const __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
+ __h ^= *__p & __m;
+ }
+ return __h;
+}
+
+template <class _Allocator>
+struct _LIBCPP_TEMPLATE_VIS hash<vector<bool, _Allocator> >
+ : public unary_function<vector<bool, _Allocator>, size_t>
+{
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(const vector<bool, _Allocator>& __vec) const _NOEXCEPT
+ {return __vec.__hash_code();}
+};
+#else // _YNDX_LIBCXX_ENABLE_VECTOR_BOOL_COMPRESSION
+// Hash function implementation for uncompressed std::vector<bool> which returns the same result.
+template <class _Allocator>
+struct _LIBCPP_TEMPLATE_VIS hash<vector<bool, _Allocator> >
+ : public unary_function<vector<bool, _Allocator>, size_t>
+{
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(const vector<bool, _Allocator>& __vec) const _NOEXCEPT
+ {
+ size_t __h = 0;
+ size_t __idx = 0;
+ size_t __n = __vec.size();
+ constexpr size_t __bits_per_word = sizeof(typename allocator_traits<_Allocator>::size_type) * CHAR_BIT;
+ static_assert(sizeof(typename allocator_traits<_Allocator>::size_type) <= sizeof(size_t), "size_type constraint violated");
+ for (;__idx + __bits_per_word <= __n;) {
+ for (size_t __bit = 0; __bit < __bits_per_word; __bit++, __idx++) {
+ __h ^= static_cast<size_t>(__vec[__idx]) << __bit;
+ }
+ }
+ for (size_t __bit = 0; __idx < __n; __bit++, __idx++) {
+ __h ^= static_cast<size_t>(__vec[__idx]) << __bit;
+ }
+ return __h;
+ }
+};
+#endif // _YNDX_LIBCXX_ENABLE_VECTOR_BOOL_COMPRESSION
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
+{
+ const typename vector<_Tp, _Allocator>::size_type __sz = __x.size();
+ return __sz == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
+{
+ return !(__x == __y);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
+{
+ return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
+{
+ return __y < __x;
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
+{
+ return !(__x < __y);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
+{
+ return !(__y < __x);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y)
+ _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+ __x.swap(__y);
+}
+
+#if _LIBCPP_STD_VER > 17
+template <class _Tp, class _Allocator, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type
+erase(vector<_Tp, _Allocator>& __c, const _Up& __v) {
+ auto __old_size = __c.size();
+ __c.erase(_VSTD::remove(__c.begin(), __c.end(), __v), __c.end());
+ return __old_size - __c.size();
+}
+
+template <class _Tp, class _Allocator, class _Predicate>
+inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type
+erase_if(vector<_Tp, _Allocator>& __c, _Predicate __pred) {
+ auto __old_size = __c.size();
+ __c.erase(_VSTD::remove_if(__c.begin(), __c.end(), __pred), __c.end());
+ return __old_size - __c.size();
+}
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_VECTOR
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/version b/contrib/libs/cxxsupp/libcxxmsvc/include/version
new file mode 100644
index 0000000000..25d112af18
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/version
@@ -0,0 +1,416 @@
+// -*- 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_VERSIONH
+#define _LIBCPP_VERSIONH
+
+/*
+ version synopsis
+
+Macro name Value Headers
+__cpp_lib_adaptor_iterator_pair_constructor 202106L <queue> <stack>
+__cpp_lib_addressof_constexpr 201603L <memory>
+__cpp_lib_allocate_at_least 202106L <memory>
+__cpp_lib_allocator_traits_is_always_equal 201411L <deque> <forward_list> <list>
+ <map> <memory> <scoped_allocator>
+ <set> <string> <unordered_map>
+ <unordered_set> <vector>
+__cpp_lib_any 201606L <any>
+__cpp_lib_apply 201603L <tuple>
+__cpp_lib_array_constexpr 201811L <array> <iterator>
+ 201603L // C++17
+__cpp_lib_as_const 201510L <utility>
+__cpp_lib_associative_heterogeneous_erasure 202110L <map> <set> <unordered_map>
+ <unordered_set>
+__cpp_lib_assume_aligned 201811L <memory>
+__cpp_lib_atomic_flag_test 201907L <atomic>
+__cpp_lib_atomic_float 201711L <atomic>
+__cpp_lib_atomic_is_always_lock_free 201603L <atomic>
+__cpp_lib_atomic_lock_free_type_aliases 201907L <atomic>
+__cpp_lib_atomic_ref 201806L <atomic>
+__cpp_lib_atomic_shared_ptr 201711L <atomic>
+__cpp_lib_atomic_value_initialization 201911L <atomic> <memory>
+__cpp_lib_atomic_wait 201907L <atomic>
+__cpp_lib_barrier 201907L <barrier>
+__cpp_lib_bind_back 202202L <functional>
+__cpp_lib_bind_front 201907L <functional>
+__cpp_lib_bit_cast 201806L <bit>
+__cpp_lib_bitops 201907L <bit>
+__cpp_lib_bool_constant 201505L <type_traits>
+__cpp_lib_bounded_array_traits 201902L <type_traits>
+__cpp_lib_boyer_moore_searcher 201603L <functional>
+__cpp_lib_byte 201603L <cstddef>
+__cpp_lib_byteswap 202110L <bit>
+__cpp_lib_char8_t 201907L <atomic> <filesystem> <istream>
+ <limits> <locale> <ostream>
+ <string> <string_view>
+__cpp_lib_chrono 201611L <chrono>
+__cpp_lib_chrono_udls 201304L <chrono>
+__cpp_lib_clamp 201603L <algorithm>
+__cpp_lib_complex_udls 201309L <complex>
+__cpp_lib_concepts 202002L <concepts>
+__cpp_lib_constexpr_algorithms 201806L <algorithm>
+__cpp_lib_constexpr_cmath 202202L <cmath> <cstdlib>
+__cpp_lib_constexpr_complex 201711L <complex>
+__cpp_lib_constexpr_dynamic_alloc 201907L <memory>
+__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 201811L <string>
+__cpp_lib_constexpr_string_view 201811L <string_view>
+__cpp_lib_constexpr_tuple 201811L <tuple>
+__cpp_lib_constexpr_typeinfo 202106L <typeinfo>
+__cpp_lib_constexpr_utility 201811L <utility>
+__cpp_lib_constexpr_vector 201907L <vector>
+__cpp_lib_coroutine 201902L <coroutine>
+__cpp_lib_destroying_delete 201806L <new>
+__cpp_lib_enable_shared_from_this 201603L <memory>
+__cpp_lib_endian 201907L <bit>
+__cpp_lib_erase_if 202002L <deque> <forward_list> <list>
+ <map> <set> <string>
+ <unordered_map> <unordered_set> <vector>
+__cpp_lib_exchange_function 201304L <utility>
+__cpp_lib_execution 201902L <execution>
+ 201603L // C++17
+__cpp_lib_filesystem 201703L <filesystem>
+__cpp_lib_format 202106L <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>
+__cpp_lib_hardware_interference_size 201703L <new>
+__cpp_lib_has_unique_object_representations 201606L <type_traits>
+__cpp_lib_hypot 201603L <cmath>
+__cpp_lib_incomplete_container_elements 201505L <forward_list> <list> <vector>
+__cpp_lib_int_pow2 202002L <bit>
+__cpp_lib_integer_comparison_functions 202002L <utility>
+__cpp_lib_integer_sequence 201304L <utility>
+__cpp_lib_integral_constant_callable 201304L <type_traits>
+__cpp_lib_interpolate 201902L <cmath> <numeric>
+__cpp_lib_invoke 201411L <functional>
+__cpp_lib_invoke_r 202106L <functional>
+__cpp_lib_is_aggregate 201703L <type_traits>
+__cpp_lib_is_constant_evaluated 201811L <type_traits>
+__cpp_lib_is_final 201402L <type_traits>
+__cpp_lib_is_invocable 201703L <type_traits>
+__cpp_lib_is_layout_compatible 201907L <type_traits>
+__cpp_lib_is_nothrow_convertible 201806L <type_traits>
+__cpp_lib_is_null_pointer 201309L <type_traits>
+__cpp_lib_is_pointer_interconvertible 201907L <type_traits>
+__cpp_lib_is_scoped_enum 202011L <type_traits>
+__cpp_lib_is_swappable 201603L <type_traits>
+__cpp_lib_jthread 201911L <stop_token> <thread>
+__cpp_lib_latch 201907L <latch>
+__cpp_lib_launder 201606L <new>
+__cpp_lib_list_remove_return_type 201806L <forward_list> <list>
+__cpp_lib_logical_traits 201510L <type_traits>
+__cpp_lib_make_from_tuple 201606L <tuple>
+__cpp_lib_make_reverse_iterator 201402L <iterator>
+__cpp_lib_make_unique 201304L <memory>
+__cpp_lib_map_try_emplace 201411L <map>
+__cpp_lib_math_constants 201907L <numbers>
+__cpp_lib_math_special_functions 201603L <cmath>
+__cpp_lib_memory_resource 201603L <memory_resource>
+__cpp_lib_monadic_optional 202110L <optional>
+__cpp_lib_move_only_function 202110L <functional>
+__cpp_lib_node_extract 201606L <map> <set> <unordered_map>
+ <unordered_set>
+__cpp_lib_nonmember_container_access 201411L <array> <deque> <forward_list>
+ <iterator> <list> <map>
+ <regex> <set> <string>
+ <unordered_map> <unordered_set> <vector>
+__cpp_lib_not_fn 201603L <functional>
+__cpp_lib_null_iterators 201304L <iterator>
+__cpp_lib_optional 201606L <optional>
+__cpp_lib_out_ptr 202106L <memory>
+__cpp_lib_parallel_algorithm 201603L <algorithm> <numeric>
+__cpp_lib_polymorphic_allocator 201902L <memory_resource>
+__cpp_lib_quoted_string_io 201304L <iomanip>
+__cpp_lib_ranges 201811L <algorithm> <functional> <iterator>
+ <memory> <ranges>
+__cpp_lib_ranges_chunk 202202L <ranges>
+__cpp_lib_ranges_chunk_by 202202L <ranges>
+__cpp_lib_ranges_iota 202202L <numeric>
+__cpp_lib_ranges_join_with 202202L <ranges>
+__cpp_lib_ranges_slide 202202L <ranges>
+__cpp_lib_ranges_starts_ends_with 202106L <algorithm>
+__cpp_lib_ranges_to_container 202202L <deque> <forward_list> <list>
+ <map> <priority_queue> <queue>
+ <set> <stack> <string>
+ <unordered_map> <unordered_set> <vector>
+__cpp_lib_ranges_zip 202110L <ranges> <tuple> <utility>
+__cpp_lib_raw_memory_algorithms 201606L <memory>
+__cpp_lib_reference_from_temporary 202202L <type_traits>
+__cpp_lib_remove_cvref 201711L <type_traits>
+__cpp_lib_result_of_sfinae 201210L <functional> <type_traits>
+__cpp_lib_robust_nonmodifying_seq_ops 201304L <algorithm>
+__cpp_lib_sample 201603L <algorithm>
+__cpp_lib_scoped_lock 201703L <mutex>
+__cpp_lib_semaphore 201907L <semaphore>
+__cpp_lib_shared_mutex 201505L <shared_mutex>
+__cpp_lib_shared_ptr_arrays 201611L <memory>
+__cpp_lib_shared_ptr_weak_type 201606L <memory>
+__cpp_lib_shared_timed_mutex 201402L <shared_mutex>
+__cpp_lib_shift 201806L <algorithm>
+__cpp_lib_smart_ptr_for_overwrite 202002L <memory>
+__cpp_lib_source_location 201907L <source_location>
+__cpp_lib_span 202002L <span>
+__cpp_lib_spanstream 202106L <spanstream>
+__cpp_lib_ssize 201902L <iterator>
+__cpp_lib_stacktrace 202011L <stacktrace>
+__cpp_lib_starts_ends_with 201711L <string> <string_view>
+__cpp_lib_stdatomic_h 202011L <stdatomic.h>
+__cpp_lib_string_contains 202011L <string> <string_view>
+__cpp_lib_string_resize_and_overwrite 202110L <string>
+__cpp_lib_string_udls 201304L <string>
+__cpp_lib_string_view 201803L <string> <string_view>
+ 201606L // C++17
+__cpp_lib_syncbuf 201803L <syncstream>
+__cpp_lib_three_way_comparison 201907L <compare>
+__cpp_lib_to_address 201711L <memory>
+__cpp_lib_to_array 201907L <array>
+__cpp_lib_to_chars 201611L <charconv>
+__cpp_lib_to_underlying 202102L <utility>
+__cpp_lib_transformation_trait_aliases 201304L <type_traits>
+__cpp_lib_transparent_operators 201510L <functional> <memory>
+ 201210L // C++14
+__cpp_lib_tuple_element_t 201402L <tuple>
+__cpp_lib_tuples_by_type 201304L <tuple> <utility>
+__cpp_lib_type_identity 201806L <type_traits>
+__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_unreachable 202202L <utility>
+__cpp_lib_unwrap_ref 201811L <functional>
+__cpp_lib_variant 202102L <variant>
+__cpp_lib_void_t 201411L <type_traits>
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# 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
+# define __cpp_lib_exchange_function 201304L
+# define __cpp_lib_generic_associative_lookup 201304L
+# define __cpp_lib_integer_sequence 201304L
+# define __cpp_lib_integral_constant_callable 201304L
+# define __cpp_lib_is_final 201402L
+# define __cpp_lib_is_null_pointer 201309L
+# define __cpp_lib_make_reverse_iterator 201402L
+# define __cpp_lib_make_unique 201304L
+# define __cpp_lib_null_iterators 201304L
+# define __cpp_lib_quoted_string_io 201304L
+# define __cpp_lib_result_of_sfinae 201210L
+# define __cpp_lib_robust_nonmodifying_seq_ops 201304L
+# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_shared_timed_mutex)
+# define __cpp_lib_shared_timed_mutex 201402L
+# endif
+# define __cpp_lib_string_udls 201304L
+# define __cpp_lib_transformation_trait_aliases 201304L
+# define __cpp_lib_transparent_operators 201210L
+# define __cpp_lib_tuple_element_t 201402L
+# define __cpp_lib_tuples_by_type 201304L
+#endif
+
+#if _LIBCPP_STD_VER > 14
+# define __cpp_lib_addressof_constexpr 201603L
+# define __cpp_lib_allocator_traits_is_always_equal 201411L
+# define __cpp_lib_any 201606L
+# define __cpp_lib_apply 201603L
+# if defined(_MSC_VER) && _MSC_VER >= 1926
+# define __cpp_lib_array_constexpr 201803L
+# else
+# define __cpp_lib_array_constexpr 201603L
+# endif
+# define __cpp_lib_as_const 201510L
+# define __cpp_lib_atomic_is_always_lock_free 201603L
+# define __cpp_lib_bool_constant 201505L
+// # define __cpp_lib_boyer_moore_searcher 201603L
+# define __cpp_lib_byte 201603L
+# define __cpp_lib_chrono 201611L
+# define __cpp_lib_clamp 201603L
+# define __cpp_lib_enable_shared_from_this 201603L
+// # define __cpp_lib_execution 201603L
+# if !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_filesystem)
+# define __cpp_lib_filesystem 201703L
+# endif
+# define __cpp_lib_gcd_lcm 201606L
+// # define __cpp_lib_hardware_interference_size 201703L
+# define __cpp_lib_has_unique_object_representations 201606L
+# define __cpp_lib_hypot 201603L
+# define __cpp_lib_incomplete_container_elements 201505L
+# define __cpp_lib_invoke 201411L
+# define __cpp_lib_is_aggregate 201703L
+# define __cpp_lib_is_invocable 201703L
+# define __cpp_lib_is_swappable 201603L
+# define __cpp_lib_launder 201606L
+# define __cpp_lib_logical_traits 201510L
+# define __cpp_lib_make_from_tuple 201606L
+# define __cpp_lib_map_try_emplace 201411L
+// # define __cpp_lib_math_special_functions 201603L
+// # define __cpp_lib_memory_resource 201603L
+# define __cpp_lib_node_extract 201606L
+# define __cpp_lib_nonmember_container_access 201411L
+# define __cpp_lib_not_fn 201603L
+# define __cpp_lib_optional 201606L
+// # define __cpp_lib_parallel_algorithm 201603L
+# define __cpp_lib_raw_memory_algorithms 201606L
+# define __cpp_lib_sample 201603L
+# define __cpp_lib_scoped_lock 201703L
+# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_shared_mutex)
+# define __cpp_lib_shared_mutex 201505L
+# endif
+# define __cpp_lib_shared_ptr_arrays 201611L
+# define __cpp_lib_shared_ptr_weak_type 201606L
+# if defined(_MSC_VER) && _MSC_VER >= 1926
+# define __cpp_lib_string_view 201803L
+# else
+# define __cpp_lib_string_view 201606L
+# endif
+// # define __cpp_lib_to_chars 201611L
+# undef __cpp_lib_transparent_operators
+# define __cpp_lib_transparent_operators 201510L
+# 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 202102L
+# define __cpp_lib_void_t 201411L
+#endif
+
+#if _LIBCPP_STD_VER > 17
+# undef __cpp_lib_array_constexpr
+# define __cpp_lib_array_constexpr 201811L
+// # define __cpp_lib_assume_aligned 201811L
+# define __cpp_lib_atomic_flag_test 201907L
+// # define __cpp_lib_atomic_float 201711L
+# define __cpp_lib_atomic_lock_free_type_aliases 201907L
+// # define __cpp_lib_atomic_ref 201806L
+// # define __cpp_lib_atomic_shared_ptr 201711L
+# define __cpp_lib_atomic_value_initialization 201911L
+# if !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait)
+# define __cpp_lib_atomic_wait 201907L
+# endif
+# 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_bit_cast 201806L
+// # define __cpp_lib_bitops 201907L
+# define __cpp_lib_bounded_array_traits 201902L
+# if !defined(_LIBCPP_HAS_NO_CHAR8_T)
+# define __cpp_lib_char8_t 201907L
+# endif
+# 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_numeric 201911L
+# 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
+# if _LIBCPP_STD_VER > 17 && defined(__cpp_impl_destroying_delete) && __cpp_impl_destroying_delete >= 201806L
+# define __cpp_lib_destroying_delete 201806L
+# endif
+# define __cpp_lib_endian 201907L
+# 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 202106L
+# endif
+# define __cpp_lib_generic_unordered_lookup 201811L
+# define __cpp_lib_int_pow2 202002L
+# if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+# define __cpp_lib_integer_comparison_functions 202002L
+# endif
+# define __cpp_lib_interpolate 201902L
+# define __cpp_lib_is_constant_evaluated 201811L
+// # define __cpp_lib_is_layout_compatible 201907L
+# define __cpp_lib_is_nothrow_convertible 201806L
+// # define __cpp_lib_is_pointer_interconvertible 201907L
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+// # define __cpp_lib_jthread 201911L
+# endif
+# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_latch)
+# define __cpp_lib_latch 201907L
+# endif
+# define __cpp_lib_list_remove_return_type 201806L
+# if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+# define __cpp_lib_math_constants 201907L
+# endif
+// # define __cpp_lib_polymorphic_allocator 201902L
+// # define __cpp_lib_ranges 201811L
+# define __cpp_lib_remove_cvref 201711L
+# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_semaphore)
+# define __cpp_lib_semaphore 201907L
+# endif
+# define __cpp_lib_shift 201806L
+// # define __cpp_lib_smart_ptr_for_overwrite 202002L
+// # define __cpp_lib_source_location 201907L
+# define __cpp_lib_span 202002L
+# define __cpp_lib_ssize 201902L
+# define __cpp_lib_starts_ends_with 201711L
+# undef __cpp_lib_string_view
+# define __cpp_lib_string_view 201803L
+// # define __cpp_lib_syncbuf 201803L
+// # define __cpp_lib_three_way_comparison 201907L
+# define __cpp_lib_to_address 201711L
+# define __cpp_lib_to_array 201907L
+# define __cpp_lib_type_identity 201806L
+# define __cpp_lib_unwrap_ref 201811L
+#endif
+
+#if _LIBCPP_STD_VER > 20
+# define __cpp_lib_adaptor_iterator_pair_constructor 202106L
+// # define __cpp_lib_allocate_at_least 202106L
+// # define __cpp_lib_associative_heterogeneous_erasure 202110L
+// # define __cpp_lib_bind_back 202202L
+# define __cpp_lib_byteswap 202110L
+// # define __cpp_lib_constexpr_cmath 202202L
+// # define __cpp_lib_constexpr_typeinfo 202106L
+// # define __cpp_lib_invoke_r 202106L
+# define __cpp_lib_is_scoped_enum 202011L
+# define __cpp_lib_monadic_optional 202110L
+// # define __cpp_lib_move_only_function 202110L
+// # define __cpp_lib_out_ptr 202106L
+// # define __cpp_lib_ranges_chunk 202202L
+// # define __cpp_lib_ranges_chunk_by 202202L
+// # define __cpp_lib_ranges_iota 202202L
+// # define __cpp_lib_ranges_join_with 202202L
+// # define __cpp_lib_ranges_slide 202202L
+// # define __cpp_lib_ranges_starts_ends_with 202106L
+// # define __cpp_lib_ranges_to_container 202202L
+// # define __cpp_lib_ranges_zip 202110L
+// # define __cpp_lib_reference_from_temporary 202202L
+// # define __cpp_lib_spanstream 202106L
+// # define __cpp_lib_stacktrace 202011L
+// # define __cpp_lib_stdatomic_h 202011L
+# define __cpp_lib_string_contains 202011L
+# define __cpp_lib_string_resize_and_overwrite 202110L
+# define __cpp_lib_to_underlying 202102L
+# define __cpp_lib_unreachable 202202L
+#endif
+
+// clang-format on
+
+#endif // _LIBCPP_VERSIONH
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/wchar.h b/contrib/libs/cxxsupp/libcxxmsvc/include/wchar.h
new file mode 100644
index 0000000000..fd22a2715f
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/wchar.h
@@ -0,0 +1,194 @@
+// -*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#if defined(__need_wint_t) || defined(__need_mbstate_t)
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#include Y_UCRT_INCLUDE_NEXT(wchar.h)
+#else
+#include_next <wchar.h>
+#endif
+
+#elif !defined(_LIBCPP_WCHAR_H)
+#define _LIBCPP_WCHAR_H
+
+/*
+ wchar.h synopsis
+
+Macros:
+
+ NULL
+ WCHAR_MAX
+ WCHAR_MIN
+ WEOF
+
+Types:
+
+ mbstate_t
+ size_t
+ tm
+ wint_t
+
+int fwprintf(FILE* restrict stream, const wchar_t* restrict format, ...);
+int fwscanf(FILE* restrict stream, const wchar_t* restrict format, ...);
+int swprintf(wchar_t* restrict s, size_t n, const wchar_t* restrict format, ...);
+int swscanf(const wchar_t* restrict s, const wchar_t* restrict format, ...);
+int vfwprintf(FILE* restrict stream, const wchar_t* restrict format, va_list arg);
+int vfwscanf(FILE* restrict stream, const wchar_t* restrict format, va_list arg); // C99
+int vswprintf(wchar_t* restrict s, size_t n, const wchar_t* restrict format, va_list arg);
+int vswscanf(const wchar_t* restrict s, const wchar_t* restrict format, va_list arg); // C99
+int vwprintf(const wchar_t* restrict format, va_list arg);
+int vwscanf(const wchar_t* restrict format, va_list arg); // C99
+int wprintf(const wchar_t* restrict format, ...);
+int wscanf(const wchar_t* restrict format, ...);
+wint_t fgetwc(FILE* stream);
+wchar_t* fgetws(wchar_t* restrict s, int n, FILE* restrict stream);
+wint_t fputwc(wchar_t c, FILE* stream);
+int fputws(const wchar_t* restrict s, FILE* restrict stream);
+int fwide(FILE* stream, int mode);
+wint_t getwc(FILE* stream);
+wint_t getwchar();
+wint_t putwc(wchar_t c, FILE* stream);
+wint_t putwchar(wchar_t c);
+wint_t ungetwc(wint_t c, FILE* stream);
+double wcstod(const wchar_t* restrict nptr, wchar_t** restrict endptr);
+float wcstof(const wchar_t* restrict nptr, wchar_t** restrict endptr); // C99
+long double wcstold(const wchar_t* restrict nptr, wchar_t** restrict endptr); // C99
+long wcstol(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
+long long wcstoll(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); // C99
+unsigned long wcstoul(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
+unsigned long long wcstoull(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); // C99
+wchar_t* wcscpy(wchar_t* restrict s1, const wchar_t* restrict s2);
+wchar_t* wcsncpy(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
+wchar_t* wcscat(wchar_t* restrict s1, const wchar_t* restrict s2);
+wchar_t* wcsncat(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
+int wcscmp(const wchar_t* s1, const wchar_t* s2);
+int wcscoll(const wchar_t* s1, const wchar_t* s2);
+int wcsncmp(const wchar_t* s1, const wchar_t* s2, size_t n);
+size_t wcsxfrm(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
+const wchar_t* wcschr(const wchar_t* s, wchar_t c);
+ wchar_t* wcschr( wchar_t* s, wchar_t c);
+size_t wcscspn(const wchar_t* s1, const wchar_t* s2);
+size_t wcslen(const wchar_t* s);
+const wchar_t* wcspbrk(const wchar_t* s1, const wchar_t* s2);
+ wchar_t* wcspbrk( wchar_t* s1, const wchar_t* s2);
+const wchar_t* wcsrchr(const wchar_t* s, wchar_t c);
+ wchar_t* wcsrchr( wchar_t* s, wchar_t c);
+size_t wcsspn(const wchar_t* s1, const wchar_t* s2);
+const wchar_t* wcsstr(const wchar_t* s1, const wchar_t* s2);
+ wchar_t* wcsstr( wchar_t* s1, const wchar_t* s2);
+wchar_t* wcstok(wchar_t* restrict s1, const wchar_t* restrict s2, wchar_t** restrict ptr);
+const wchar_t* wmemchr(const wchar_t* s, wchar_t c, size_t n);
+ wchar_t* wmemchr( wchar_t* s, wchar_t c, size_t n);
+int wmemcmp(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
+wchar_t* wmemcpy(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
+wchar_t* wmemmove(wchar_t* s1, const wchar_t* s2, size_t n);
+wchar_t* wmemset(wchar_t* s, wchar_t c, size_t n);
+size_t wcsftime(wchar_t* restrict s, size_t maxsize, const wchar_t* restrict format,
+ const tm* restrict timeptr);
+wint_t btowc(int c);
+int wctob(wint_t c);
+int mbsinit(const mbstate_t* ps);
+size_t mbrlen(const char* restrict s, size_t n, mbstate_t* restrict ps);
+size_t mbrtowc(wchar_t* restrict pwc, const char* restrict s, size_t n, mbstate_t* restrict ps);
+size_t wcrtomb(char* restrict s, wchar_t wc, mbstate_t* restrict ps);
+size_t mbsrtowcs(wchar_t* restrict dst, const char** restrict src, size_t len,
+ mbstate_t* restrict ps);
+size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
+ mbstate_t* restrict ps);
+
+*/
+
+#include <__config>
+#include <stddef.h>
+
+#if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
+# error "The <wchar.h> header is not supported since libc++ has been configured with LIBCXX_ENABLE_WIDE_CHARACTERS disabled"
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifdef __cplusplus
+#define __CORRECT_ISO_CPP_WCHAR_H_PROTO
+#endif
+
+#ifdef _LIBCPP_COMPILER_MSVC
+#include Y_UCRT_INCLUDE_NEXT(wchar.h)
+#else
+#include_next <wchar.h>
+#endif
+
+// Determine whether we have const-correct overloads for wcschr and friends.
+#if defined(_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_)
+# define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1
+#elif defined(__GLIBC_PREREQ)
+# if __GLIBC_PREREQ(2, 10)
+# define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1
+# endif
+#elif defined(_LIBCPP_MSVCRT)
+# if defined(_CRT_CONST_CORRECT_OVERLOADS)
+# define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1
+# endif
+#endif
+
+#if defined(__cplusplus) && !defined(_LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD)
+extern "C++" {
+inline _LIBCPP_INLINE_VISIBILITY
+wchar_t* __libcpp_wcschr(const wchar_t* __s, wchar_t __c) {return (wchar_t*)wcschr(__s, __c);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+const wchar_t* wcschr(const wchar_t* __s, wchar_t __c) {return __libcpp_wcschr(__s, __c);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+ wchar_t* wcschr( wchar_t* __s, wchar_t __c) {return __libcpp_wcschr(__s, __c);}
+
+inline _LIBCPP_INLINE_VISIBILITY
+wchar_t* __libcpp_wcspbrk(const wchar_t* __s1, const wchar_t* __s2) {return (wchar_t*)wcspbrk(__s1, __s2);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+const wchar_t* wcspbrk(const wchar_t* __s1, const wchar_t* __s2) {return __libcpp_wcspbrk(__s1, __s2);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+ wchar_t* wcspbrk( wchar_t* __s1, const wchar_t* __s2) {return __libcpp_wcspbrk(__s1, __s2);}
+
+inline _LIBCPP_INLINE_VISIBILITY
+wchar_t* __libcpp_wcsrchr(const wchar_t* __s, wchar_t __c) {return (wchar_t*)wcsrchr(__s, __c);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+const wchar_t* wcsrchr(const wchar_t* __s, wchar_t __c) {return __libcpp_wcsrchr(__s, __c);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+ wchar_t* wcsrchr( wchar_t* __s, wchar_t __c) {return __libcpp_wcsrchr(__s, __c);}
+
+inline _LIBCPP_INLINE_VISIBILITY
+wchar_t* __libcpp_wcsstr(const wchar_t* __s1, const wchar_t* __s2) {return (wchar_t*)wcsstr(__s1, __s2);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+const wchar_t* wcsstr(const wchar_t* __s1, const wchar_t* __s2) {return __libcpp_wcsstr(__s1, __s2);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+ wchar_t* wcsstr( wchar_t* __s1, const wchar_t* __s2) {return __libcpp_wcsstr(__s1, __s2);}
+
+inline _LIBCPP_INLINE_VISIBILITY
+wchar_t* __libcpp_wmemchr(const wchar_t* __s, wchar_t __c, size_t __n) {return (wchar_t*)wmemchr(__s, __c, __n);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+const wchar_t* wmemchr(const wchar_t* __s, wchar_t __c, size_t __n) {return __libcpp_wmemchr(__s, __c, __n);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+ wchar_t* wmemchr( wchar_t* __s, wchar_t __c, size_t __n) {return __libcpp_wmemchr(__s, __c, __n);}
+}
+#endif
+
+#if defined(__cplusplus) && (defined(_LIBCPP_MSVCRT_LIKE) || defined(__MVS__))
+extern "C" {
+size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src,
+ size_t nmc, size_t len, mbstate_t *__restrict ps);
+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 || __MVS__)
+
+#endif // _LIBCPP_WCHAR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/wctype.h b/contrib/libs/cxxsupp/libcxxmsvc/include/wctype.h
new file mode 100644
index 0000000000..98d64739e5
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/include/wctype.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_WCTYPE_H
+#define _LIBCPP_WCTYPE_H
+
+/*
+ wctype.h synopsis
+
+Macros:
+
+ WEOF
+
+Types:
+
+ wint_t
+ wctrans_t
+ wctype_t
+
+int iswalnum(wint_t wc);
+int iswalpha(wint_t wc);
+int iswblank(wint_t wc); // C99
+int iswcntrl(wint_t wc);
+int iswdigit(wint_t wc);
+int iswgraph(wint_t wc);
+int iswlower(wint_t wc);
+int iswprint(wint_t wc);
+int iswpunct(wint_t wc);
+int iswspace(wint_t wc);
+int iswupper(wint_t wc);
+int iswxdigit(wint_t wc);
+int iswctype(wint_t wc, wctype_t desc);
+wctype_t wctype(const char* property);
+wint_t towlower(wint_t wc);
+wint_t towupper(wint_t wc);
+wint_t towctrans(wint_t wc, wctrans_t desc);
+wctrans_t wctrans(const char* property);
+
+*/
+
+#include <__config>
+
+#if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
+# error "The <wctype.h> header is not supported since libc++ has been configured with LIBCXX_ENABLE_WIDE_CHARACTERS disabled"
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifdef _LIBCPP_COMPILER_MSVC
+# include Y_UCRT_INCLUDE_NEXT(wctype.h)
+# define _LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H
+#else
+// TODO:
+// In the future, we should unconditionally include_next <wctype.h> here and instead
+// have a mode under which the library does not need libc++'s <wctype.h> or <cwctype>
+// at all (i.e. a mode without wchar_t). As it stands, we need to do that to completely
+// bypass the using declarations in <cwctype> when we did not include <wctype.h>.
+// Otherwise, a using declaration like `using ::wint_t` in <cwctype> will refer to
+// nothing (with using_if_exists), and if we include another header that defines one
+// of these declarations (e.g. <wchar.h>), the second `using ::wint_t` with using_if_exists
+// will fail because it does not refer to the same declaration.
+#if __has_include_next(<wctype.h>)
+# include_next <wctype.h>
+# define _LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H
+#endif
+#endif
+
+#ifdef __cplusplus
+
+#undef iswalnum
+#undef iswalpha
+#undef iswblank
+#undef iswcntrl
+#undef iswdigit
+#undef iswgraph
+#undef iswlower
+#undef iswprint
+#undef iswpunct
+#undef iswspace
+#undef iswupper
+#undef iswxdigit
+#undef iswctype
+#undef wctype
+#undef towlower
+#undef towupper
+#undef towctrans
+#undef wctrans
+
+#endif // __cplusplus
+
+#endif // _LIBCPP_WCTYPE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/algorithm.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/algorithm.cpp
new file mode 100644
index 0000000000..decc8419fa
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/algorithm.cpp
@@ -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
+//
+//===----------------------------------------------------------------------===//
+
+#include <algorithm>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template void __sort<__less<char>&, char*>(char*, char*, __less<char>&);
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);
+#endif
+template void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&);
+template void __sort<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&);
+template void __sort<__less<short>&, short*>(short*, short*, __less<short>&);
+template void __sort<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&);
+template void __sort<__less<int>&, int*>(int*, int*, __less<int>&);
+template void __sort<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&);
+template void __sort<__less<long>&, long*>(long*, long*, __less<long>&);
+template void __sort<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&);
+template void __sort<__less<long long>&, long long*>(long long*, long long*, __less<long long>&);
+template void __sort<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&);
+template void __sort<__less<float>&, float*>(float*, float*, __less<float>&);
+template void __sort<__less<double>&, double*>(double*, double*, __less<double>&);
+template void __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&);
+
+template bool __insertion_sort_incomplete<__less<char>&, char*>(char*, char*, __less<char>&);
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template bool __insertion_sort_incomplete<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);
+#endif
+template bool __insertion_sort_incomplete<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&);
+template bool __insertion_sort_incomplete<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&);
+template bool __insertion_sort_incomplete<__less<short>&, short*>(short*, short*, __less<short>&);
+template bool __insertion_sort_incomplete<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&);
+template bool __insertion_sort_incomplete<__less<int>&, int*>(int*, int*, __less<int>&);
+template bool __insertion_sort_incomplete<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&);
+template bool __insertion_sort_incomplete<__less<long>&, long*>(long*, long*, __less<long>&);
+template bool __insertion_sort_incomplete<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&);
+template bool __insertion_sort_incomplete<__less<long long>&, long long*>(long long*, long long*, __less<long long>&);
+template bool __insertion_sort_incomplete<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&);
+template bool __insertion_sort_incomplete<__less<float>&, float*>(float*, float*, __less<float>&);
+template bool __insertion_sort_incomplete<__less<double>&, double*>(double*, double*, __less<double>&);
+template bool __insertion_sort_incomplete<__less<long double>&, long double*>(long double*, long double*, __less<long double>&);
+
+template unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&);
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/any.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/any.cpp
new file mode 100644
index 0000000000..9a101b44a7
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/any.cpp
@@ -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
+//
+//===----------------------------------------------------------------------===//
+
+#include <any>
+
+namespace std {
+const char* bad_any_cast::what() const noexcept {
+ return "bad any cast";
+}
+}
+
+
+#include <experimental/__config>
+
+// Preserve std::experimental::any_bad_cast for ABI compatibility
+// Even though it no longer exists in a header file
+_LIBCPP_BEGIN_NAMESPACE_LFTS
+
+class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : public bad_cast
+{
+public:
+ virtual const char* what() const noexcept;
+};
+
+const char* bad_any_cast::what() const noexcept {
+ return "bad any cast";
+}
+
+_LIBCPP_END_NAMESPACE_LFTS
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/assert.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/assert.cpp
new file mode 100644
index 0000000000..21a3863cd0
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/assert.cpp
@@ -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
+//
+//===----------------------------------------------------------------------===//
+
+#include <__assert>
+#include <__config>
+#include <cstdio>
+#include <cstdlib>
+#include <string>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+std::string __libcpp_debug_info::what() const {
+ string msg = __file_;
+ msg += ":" + std::to_string(__line_) + ": _LIBCPP_ASSERT '";
+ msg += __pred_;
+ msg += "' failed. ";
+ msg += __msg_;
+ return msg;
+}
+
+_LIBCPP_NORETURN void __libcpp_abort_debug_function(__libcpp_debug_info const& info) {
+ std::fprintf(stderr, "%s\n", info.what().c_str());
+ std::abort();
+}
+
+_LIBCPP_CONSTINIT __libcpp_debug_function_type __libcpp_debug_function = __libcpp_abort_debug_function;
+
+bool __libcpp_set_debug_function(__libcpp_debug_function_type __func) {
+ __libcpp_debug_function = __func;
+ return true;
+}
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/atomic.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/atomic.cpp
new file mode 100644
index 0000000000..5968aafb53
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/atomic.cpp
@@ -0,0 +1,194 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <__config>
+#ifndef _LIBCPP_HAS_NO_THREADS
+
+#include <atomic>
+#include <climits>
+#include <functional>
+#include <thread>
+
+#ifdef __linux__
+
+#include <unistd.h>
+#include <linux/futex.h>
+#include <sys/syscall.h>
+
+// libc++ uses SYS_futex as a universal syscall name. However, on 32 bit architectures
+// with a 64 bit time_t, we need to specify SYS_futex_time64.
+#if !defined(SYS_futex) && defined(SYS_futex_time64)
+# define SYS_futex SYS_futex_time64
+#endif
+
+#else // <- Add other operating systems here
+
+// Baseline needs no new headers
+
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifdef __linux__
+
+static void __libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr,
+ __cxx_contention_t __val)
+{
+ static constexpr timespec __timeout = { 2, 0 };
+ syscall(SYS_futex, __ptr, FUTEX_WAIT_PRIVATE, __val, &__timeout, 0, 0);
+}
+
+static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr,
+ bool __notify_one)
+{
+ syscall(SYS_futex, __ptr, FUTEX_WAKE_PRIVATE, __notify_one ? 1 : INT_MAX, 0, 0, 0);
+}
+
+#elif defined(__APPLE__) && defined(_LIBCPP_USE_ULOCK)
+
+extern "C" int __ulock_wait(uint32_t operation, void *addr, uint64_t value,
+ uint32_t timeout); /* timeout is specified in microseconds */
+extern "C" int __ulock_wake(uint32_t operation, void *addr, uint64_t wake_value);
+
+#define UL_COMPARE_AND_WAIT 1
+#define ULF_WAKE_ALL 0x00000100
+
+static void __libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr,
+ __cxx_contention_t __val)
+{
+ __ulock_wait(UL_COMPARE_AND_WAIT,
+ const_cast<__cxx_atomic_contention_t*>(__ptr), __val, 0);
+}
+
+static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr,
+ bool __notify_one)
+{
+ __ulock_wake(UL_COMPARE_AND_WAIT | (__notify_one ? 0 : ULF_WAKE_ALL),
+ const_cast<__cxx_atomic_contention_t*>(__ptr), 0);
+}
+
+#else // <- Add other operating systems here
+
+// Baseline is just a timed backoff
+
+static void __libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr,
+ __cxx_contention_t __val)
+{
+ __libcpp_thread_poll_with_backoff([=]() -> bool {
+ return !__cxx_nonatomic_compare_equal(__cxx_atomic_load(__ptr, memory_order_relaxed), __val);
+ }, __libcpp_timed_backoff_policy());
+}
+
+static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile*, bool) { }
+
+#endif // __linux__
+
+static constexpr size_t __libcpp_contention_table_size = (1 << 8); /* < there's no magic in this number */
+
+struct alignas(64) /* aim to avoid false sharing */ __libcpp_contention_table_entry
+{
+ __cxx_atomic_contention_t __contention_state;
+ __cxx_atomic_contention_t __platform_state;
+ inline constexpr __libcpp_contention_table_entry() :
+ __contention_state(0), __platform_state(0) { }
+};
+
+static __libcpp_contention_table_entry __libcpp_contention_table[ __libcpp_contention_table_size ];
+
+static hash<void const volatile*> __libcpp_contention_hasher;
+
+static __libcpp_contention_table_entry* __libcpp_contention_state(void const volatile * p)
+{
+ return &__libcpp_contention_table[__libcpp_contention_hasher(p) & (__libcpp_contention_table_size - 1)];
+}
+
+/* Given an atomic to track contention and an atomic to actually wait on, which may be
+ the same atomic, we try to detect contention to avoid spuriously calling the platform. */
+
+static void __libcpp_contention_notify(__cxx_atomic_contention_t volatile* __contention_state,
+ __cxx_atomic_contention_t const volatile* __platform_state,
+ bool __notify_one)
+{
+ if(0 != __cxx_atomic_load(__contention_state, memory_order_seq_cst))
+ // We only call 'wake' if we consumed a contention bit here.
+ __libcpp_platform_wake_by_address(__platform_state, __notify_one);
+}
+static __cxx_contention_t __libcpp_contention_monitor_for_wait(__cxx_atomic_contention_t volatile* __contention_state,
+ __cxx_atomic_contention_t const volatile* __platform_state)
+{
+ // We will monitor this value.
+ return __cxx_atomic_load(__platform_state, memory_order_acquire);
+}
+static void __libcpp_contention_wait(__cxx_atomic_contention_t volatile* __contention_state,
+ __cxx_atomic_contention_t const volatile* __platform_state,
+ __cxx_contention_t __old_value)
+{
+ __cxx_atomic_fetch_add(__contention_state, __cxx_contention_t(1), memory_order_seq_cst);
+ // We sleep as long as the monitored value hasn't changed.
+ __libcpp_platform_wait_on_address(__platform_state, __old_value);
+ __cxx_atomic_fetch_sub(__contention_state, __cxx_contention_t(1), memory_order_release);
+}
+
+/* When the incoming atomic is the wrong size for the platform wait size, need to
+ launder the value sequence through an atomic from our table. */
+
+static void __libcpp_atomic_notify(void const volatile* __location)
+{
+ auto const __entry = __libcpp_contention_state(__location);
+ // The value sequence laundering happens on the next line below.
+ __cxx_atomic_fetch_add(&__entry->__platform_state, __cxx_contention_t(1), memory_order_release);
+ __libcpp_contention_notify(&__entry->__contention_state,
+ &__entry->__platform_state,
+ false /* when laundering, we can't handle notify_one */);
+}
+_LIBCPP_EXPORTED_FROM_ABI
+void __cxx_atomic_notify_one(void const volatile* __location)
+ { __libcpp_atomic_notify(__location); }
+_LIBCPP_EXPORTED_FROM_ABI
+void __cxx_atomic_notify_all(void const volatile* __location)
+ { __libcpp_atomic_notify(__location); }
+_LIBCPP_EXPORTED_FROM_ABI
+__cxx_contention_t __libcpp_atomic_monitor(void const volatile* __location)
+{
+ auto const __entry = __libcpp_contention_state(__location);
+ return __libcpp_contention_monitor_for_wait(&__entry->__contention_state, &__entry->__platform_state);
+}
+_LIBCPP_EXPORTED_FROM_ABI
+void __libcpp_atomic_wait(void const volatile* __location, __cxx_contention_t __old_value)
+{
+ auto const __entry = __libcpp_contention_state(__location);
+ __libcpp_contention_wait(&__entry->__contention_state, &__entry->__platform_state, __old_value);
+}
+
+/* When the incoming atomic happens to be the platform wait size, we still need to use the
+ table for the contention detection, but we can use the atomic directly for the wait. */
+
+_LIBCPP_EXPORTED_FROM_ABI
+void __cxx_atomic_notify_one(__cxx_atomic_contention_t const volatile* __location)
+{
+ __libcpp_contention_notify(&__libcpp_contention_state(__location)->__contention_state, __location, true);
+}
+_LIBCPP_EXPORTED_FROM_ABI
+void __cxx_atomic_notify_all(__cxx_atomic_contention_t const volatile* __location)
+{
+ __libcpp_contention_notify(&__libcpp_contention_state(__location)->__contention_state, __location, false);
+}
+_LIBCPP_EXPORTED_FROM_ABI
+__cxx_contention_t __libcpp_atomic_monitor(__cxx_atomic_contention_t const volatile* __location)
+{
+ return __libcpp_contention_monitor_for_wait(&__libcpp_contention_state(__location)->__contention_state, __location);
+}
+_LIBCPP_EXPORTED_FROM_ABI
+void __libcpp_atomic_wait(__cxx_atomic_contention_t const volatile* __location, __cxx_contention_t __old_value)
+{
+ __libcpp_contention_wait(&__libcpp_contention_state(__location)->__contention_state, __location, __old_value);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif //_LIBCPP_HAS_NO_THREADS
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/barrier.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/barrier.cpp
new file mode 100644
index 0000000000..54890b2d79
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/barrier.cpp
@@ -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
+//
+//===----------------------------------------------------------------------===//
+
+#include <__config>
+
+#ifndef _LIBCPP_HAS_NO_THREADS
+
+#include <barrier>
+#include <thread>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_TREE_BARRIER)
+
+class __barrier_algorithm_base {
+public:
+ struct alignas(64) /* naturally-align the heap state */ __state_t
+ {
+ struct {
+ __atomic_base<__barrier_phase_t> __phase{0};
+ } __tickets[64];
+ };
+
+ ptrdiff_t& __expected;
+ unique_ptr<__state_t[]> __state;
+
+ _LIBCPP_HIDDEN
+ __barrier_algorithm_base(ptrdiff_t& __expected)
+ : __expected(__expected)
+ {
+ size_t const __count = (__expected + 1) >> 1;
+ __state = unique_ptr<__state_t[]>(new __state_t[__count]);
+ }
+ _LIBCPP_HIDDEN
+ bool __arrive(__barrier_phase_t __old_phase)
+ {
+ __barrier_phase_t const __half_step = __old_phase + 1,
+ __full_step = __old_phase + 2;
+ size_t __current_expected = __expected,
+ __current = hash<thread::id>()(this_thread::get_id()) % ((__expected + 1) >> 1);
+ for(int __round = 0;; ++__round) {
+ if(__current_expected <= 1)
+ return true;
+ size_t const __end_node = ((__current_expected + 1) >> 1),
+ __last_node = __end_node - 1;
+ for(;;++__current) {
+ if(__current == __end_node)
+ __current = 0;
+ __barrier_phase_t expect = __old_phase;
+ if(__current == __last_node && (__current_expected & 1))
+ {
+ if(__state[__current].__tickets[__round].__phase.compare_exchange_strong(expect, __full_step, memory_order_acq_rel))
+ break; // I'm 1 in 1, go to next __round
+ }
+ else if(__state[__current].__tickets[__round].__phase.compare_exchange_strong(expect, __half_step, memory_order_acq_rel))
+ {
+ return false; // I'm 1 in 2, done with arrival
+ }
+ else if(expect == __half_step)
+ {
+ if(__state[__current].__tickets[__round].__phase.compare_exchange_strong(expect, __full_step, memory_order_acq_rel))
+ break; // I'm 2 in 2, go to next __round
+ }
+ }
+ __current_expected = __last_node + 1;
+ __current >>= 1;
+ }
+ }
+};
+
+_LIBCPP_EXPORTED_FROM_ABI
+__barrier_algorithm_base * __construct_barrier_algorithm_base(ptrdiff_t& __expected)
+{
+ return new __barrier_algorithm_base(__expected);
+}
+_LIBCPP_EXPORTED_FROM_ABI
+bool __arrive_barrier_algorithm_base(__barrier_algorithm_base* __barrier,
+ __barrier_phase_t __old_phase)
+{
+ return __barrier->__arrive(__old_phase);
+}
+_LIBCPP_EXPORTED_FROM_ABI
+void __destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier)
+{
+ delete __barrier;
+}
+
+#endif //!defined(_LIBCPP_HAS_NO_TREE_BARRIER)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif //_LIBCPP_HAS_NO_THREADS
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/bind.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/bind.cpp
new file mode 100644
index 0000000000..0e217e5fc5
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/bind.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <functional>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace placeholders
+{
+
+const __ph<1> _1{};
+const __ph<2> _2{};
+const __ph<3> _3{};
+const __ph<4> _4{};
+const __ph<5> _5{};
+const __ph<6> _6{};
+const __ph<7> _7{};
+const __ph<8> _8{};
+const __ph<9> _9{};
+const __ph<10> _10{};
+
+} // placeholders
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/charconv.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/charconv.cpp
new file mode 100644
index 0000000000..9537b42de7
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/charconv.cpp
@@ -0,0 +1,196 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <charconv>
+#include <string.h>
+
+#include "include/ryu/digit_table.h"
+#include "include/to_chars_floating_point.h"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace __itoa
+{
+
+template <typename T>
+inline _LIBCPP_INLINE_VISIBILITY char*
+append1(char* buffer, T i) noexcept
+{
+ *buffer = '0' + static_cast<char>(i);
+ return buffer + 1;
+}
+
+template <typename T>
+inline _LIBCPP_INLINE_VISIBILITY char*
+append2(char* buffer, T i) noexcept
+{
+ memcpy(buffer, &__DIGIT_TABLE[(i)*2], 2);
+ return buffer + 2;
+}
+
+template <typename T>
+inline _LIBCPP_INLINE_VISIBILITY char*
+append3(char* buffer, T i) noexcept
+{
+ return append2(append1(buffer, (i) / 100), (i) % 100);
+}
+
+template <typename T>
+inline _LIBCPP_INLINE_VISIBILITY char*
+append4(char* buffer, T i) noexcept
+{
+ return append2(append2(buffer, (i) / 100), (i) % 100);
+}
+
+template <typename T>
+inline _LIBCPP_INLINE_VISIBILITY char*
+append2_no_zeros(char* buffer, T v) noexcept
+{
+ if (v < 10)
+ return append1(buffer, v);
+ else
+ return append2(buffer, v);
+}
+
+template <typename T>
+inline _LIBCPP_INLINE_VISIBILITY char*
+append4_no_zeros(char* buffer, T v) noexcept
+{
+ if (v < 100)
+ return append2_no_zeros(buffer, v);
+ else if (v < 1000)
+ return append3(buffer, v);
+ else
+ return append4(buffer, v);
+}
+
+template <typename T>
+inline _LIBCPP_INLINE_VISIBILITY char*
+append8_no_zeros(char* buffer, T v) noexcept
+{
+ if (v < 10000)
+ {
+ buffer = append4_no_zeros(buffer, v);
+ }
+ else
+ {
+ buffer = append4_no_zeros(buffer, v / 10000);
+ buffer = append4(buffer, v % 10000);
+ }
+ return buffer;
+}
+
+char*
+__u32toa(uint32_t value, char* buffer) noexcept
+{
+ if (value < 100000000)
+ {
+ buffer = append8_no_zeros(buffer, value);
+ }
+ else
+ {
+ // value = aabbbbcccc in decimal
+ const uint32_t a = value / 100000000; // 1 to 42
+ value %= 100000000;
+
+ buffer = append2_no_zeros(buffer, a);
+ buffer = append4(buffer, value / 10000);
+ buffer = append4(buffer, value % 10000);
+ }
+
+ return buffer;
+}
+
+char*
+__u64toa(uint64_t value, char* buffer) noexcept
+{
+ if (value < 100000000)
+ {
+ uint32_t v = static_cast<uint32_t>(value);
+ buffer = append8_no_zeros(buffer, v);
+ }
+ else if (value < 10000000000000000)
+ {
+ const uint32_t v0 = static_cast<uint32_t>(value / 100000000);
+ const uint32_t v1 = static_cast<uint32_t>(value % 100000000);
+
+ buffer = append8_no_zeros(buffer, v0);
+ buffer = append4(buffer, v1 / 10000);
+ buffer = append4(buffer, v1 % 10000);
+ }
+ else
+ {
+ const uint32_t a =
+ static_cast<uint32_t>(value / 10000000000000000); // 1 to 1844
+ value %= 10000000000000000;
+
+ buffer = append4_no_zeros(buffer, a);
+
+ const uint32_t v0 = static_cast<uint32_t>(value / 100000000);
+ const uint32_t v1 = static_cast<uint32_t>(value % 100000000);
+ buffer = append4(buffer, v0 / 10000);
+ buffer = append4(buffer, v0 % 10000);
+ buffer = append4(buffer, v1 / 10000);
+ buffer = append4(buffer, v1 % 10000);
+ }
+
+ return buffer;
+}
+
+} // namespace __itoa
+
+// The original version of floating-point to_chars was written by Microsoft and
+// contributed with the following license.
+
+// Copyright (c) Microsoft Corporation.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+// This implementation is dedicated to the memory of Mary and Thavatchai.
+
+to_chars_result to_chars(char* __first, char* __last, float __value) {
+ return _Floating_to_chars<_Floating_to_chars_overload::_Plain>(__first, __last, __value, chars_format{}, 0);
+}
+
+to_chars_result to_chars(char* __first, char* __last, double __value) {
+ return _Floating_to_chars<_Floating_to_chars_overload::_Plain>(__first, __last, __value, chars_format{}, 0);
+}
+
+to_chars_result to_chars(char* __first, char* __last, long double __value) {
+ return _Floating_to_chars<_Floating_to_chars_overload::_Plain>(__first, __last, static_cast<double>(__value),
+ chars_format{}, 0);
+}
+
+to_chars_result to_chars(char* __first, char* __last, float __value, chars_format __fmt) {
+ return _Floating_to_chars<_Floating_to_chars_overload::_Format_only>(__first, __last, __value, __fmt, 0);
+}
+
+to_chars_result to_chars(char* __first, char* __last, double __value, chars_format __fmt) {
+ return _Floating_to_chars<_Floating_to_chars_overload::_Format_only>(__first, __last, __value, __fmt, 0);
+}
+
+to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt) {
+ return _Floating_to_chars<_Floating_to_chars_overload::_Format_only>(__first, __last, static_cast<double>(__value),
+ __fmt, 0);
+}
+
+to_chars_result to_chars(char* __first, char* __last, float __value, chars_format __fmt, int __precision) {
+ return _Floating_to_chars<_Floating_to_chars_overload::_Format_precision>(__first, __last, __value, __fmt,
+ __precision);
+}
+
+to_chars_result to_chars(char* __first, char* __last, double __value, chars_format __fmt, int __precision) {
+ return _Floating_to_chars<_Floating_to_chars_overload::_Format_precision>(__first, __last, __value, __fmt,
+ __precision);
+}
+
+to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt, int __precision) {
+ return _Floating_to_chars<_Floating_to_chars_overload::_Format_precision>(
+ __first, __last, static_cast<double>(__value), __fmt, __precision);
+}
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/chrono.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/chrono.cpp
new file mode 100644
index 0000000000..0af89d6a52
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/chrono.cpp
@@ -0,0 +1,309 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#if defined(__MVS__)
+// As part of monotonic clock support on z/OS we need macro _LARGE_TIME_API
+// to be defined before any system header to include definition of struct timespec64.
+#define _LARGE_TIME_API
+#endif
+
+#include <cerrno> // errno
+#include <chrono>
+#include <system_error> // __throw_system_error
+
+#if defined(__MVS__)
+#include <__support/ibm/gettod_zos.h> // gettimeofdayMonotonic
+#endif
+
+#include <time.h> // clock_gettime and CLOCK_{MONOTONIC,REALTIME,MONOTONIC_RAW}
+#include "include/apple_availability.h"
+
+#if __has_include(<unistd.h>)
+# include <unistd.h>
+#endif
+
+#if __has_include(<sys/time.h>)
+# include <sys/time.h> // for gettimeofday and timeval
+#endif
+
+#if !defined(__APPLE__) && defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0
+# define _LIBCPP_USE_CLOCK_GETTIME
+#endif
+
+#if defined(_LIBCPP_WIN32API)
+# define WIN32_LEAN_AND_MEAN
+# define VC_EXTRA_LEAN
+# include <windows.h>
+# if _WIN32_WINNT >= _WIN32_WINNT_WIN8
+# include <winapifamily.h>
+# endif
+#endif // defined(_LIBCPP_WIN32API)
+
+#if defined(__Fuchsia__)
+# include <zircon/syscalls.h>
+#endif
+
+#if __has_include(<mach/mach_time.h>)
+# include <mach/mach_time.h>
+#endif
+
+#if defined(__ELF__) && defined(_LIBCPP_LINK_RT_LIB)
+# pragma comment(lib, "rt")
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace chrono
+{
+
+//
+// system_clock
+//
+
+#if defined(_LIBCPP_WIN32API)
+
+#if _WIN32_WINNT < _WIN32_WINNT_WIN8
+
+namespace {
+
+typedef void(WINAPI *GetSystemTimeAsFileTimePtr)(LPFILETIME);
+
+class GetSystemTimeInit {
+public:
+ GetSystemTimeInit() {
+ fp = (GetSystemTimeAsFileTimePtr)GetProcAddress(
+ GetModuleHandleW(L"kernel32.dll"), "GetSystemTimePreciseAsFileTime");
+ if (fp == nullptr)
+ fp = GetSystemTimeAsFileTime;
+ }
+ GetSystemTimeAsFileTimePtr fp;
+};
+
+// Pretend we're inside a system header so the compiler doesn't flag the use of the init_priority
+// attribute with a value that's reserved for the implementation (we're the implementation).
+#include "chrono_system_time_init.h"
+} // namespace
+
+#endif
+
+static system_clock::time_point __libcpp_system_clock_now() {
+ // FILETIME is in 100ns units
+ using filetime_duration =
+ _VSTD::chrono::duration<__int64,
+ _VSTD::ratio_multiply<_VSTD::ratio<100, 1>,
+ nanoseconds::period>>;
+
+ // The Windows epoch is Jan 1 1601, the Unix epoch Jan 1 1970.
+ static _LIBCPP_CONSTEXPR const seconds nt_to_unix_epoch{11644473600};
+
+ FILETIME ft;
+#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8 && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)) || \
+ (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
+ GetSystemTimePreciseAsFileTime(&ft);
+#elif !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+ GetSystemTimeAsFileTime(&ft);
+#else
+ GetSystemTimeAsFileTimeFunc.fp(&ft);
+#endif
+
+ filetime_duration d{(static_cast<__int64>(ft.dwHighDateTime) << 32) |
+ static_cast<__int64>(ft.dwLowDateTime)};
+ return system_clock::time_point(duration_cast<system_clock::duration>(d - nt_to_unix_epoch));
+}
+
+#elif defined(CLOCK_REALTIME) && defined(_LIBCPP_USE_CLOCK_GETTIME)
+
+static system_clock::time_point __libcpp_system_clock_now() {
+ struct timespec tp;
+ if (0 != clock_gettime(CLOCK_REALTIME, &tp))
+ __throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed");
+ return system_clock::time_point(seconds(tp.tv_sec) + microseconds(tp.tv_nsec / 1000));
+}
+
+#else
+
+static system_clock::time_point __libcpp_system_clock_now() {
+ timeval tv;
+ gettimeofday(&tv, 0);
+ return system_clock::time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
+}
+
+#endif
+
+const bool system_clock::is_steady;
+
+system_clock::time_point
+system_clock::now() noexcept
+{
+ return __libcpp_system_clock_now();
+}
+
+time_t
+system_clock::to_time_t(const time_point& t) noexcept
+{
+ return time_t(duration_cast<seconds>(t.time_since_epoch()).count());
+}
+
+system_clock::time_point
+system_clock::from_time_t(time_t t) noexcept
+{
+ return system_clock::time_point(seconds(t));
+}
+
+//
+// steady_clock
+//
+// Warning: If this is not truly steady, then it is non-conforming. It is
+// better for it to not exist and have the rest of libc++ use system_clock
+// instead.
+//
+
+#ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK
+
+#if defined(__APPLE__)
+
+// TODO(ldionne):
+// This old implementation of steady_clock is retained until Chrome drops supports
+// for macOS < 10.12. The issue is that they link libc++ statically into their
+// application, which means that libc++ must support being built for such deployment
+// targets. See https://llvm.org/D74489 for details.
+#if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101200) || \
+ (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 100000) || \
+ (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 100000) || \
+ (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 30000)
+# define _LIBCPP_USE_OLD_MACH_ABSOLUTE_TIME
+#endif
+
+#if defined(_LIBCPP_USE_OLD_MACH_ABSOLUTE_TIME)
+
+// mach_absolute_time() * MachInfo.numer / MachInfo.denom is the number of
+// nanoseconds since the computer booted up. MachInfo.numer and MachInfo.denom
+// are run time constants supplied by the OS. This clock has no relationship
+// to the Gregorian calendar. It's main use is as a high resolution timer.
+
+// MachInfo.numer / MachInfo.denom is often 1 on the latest equipment. Specialize
+// for that case as an optimization.
+
+static steady_clock::rep steady_simplified() {
+ return static_cast<steady_clock::rep>(mach_absolute_time());
+}
+static double compute_steady_factor() {
+ mach_timebase_info_data_t MachInfo;
+ mach_timebase_info(&MachInfo);
+ return static_cast<double>(MachInfo.numer) / MachInfo.denom;
+}
+
+static steady_clock::rep steady_full() {
+ static const double factor = compute_steady_factor();
+ return static_cast<steady_clock::rep>(mach_absolute_time() * factor);
+}
+
+typedef steady_clock::rep (*FP)();
+
+static FP init_steady_clock() {
+ mach_timebase_info_data_t MachInfo;
+ mach_timebase_info(&MachInfo);
+ if (MachInfo.numer == MachInfo.denom)
+ return &steady_simplified;
+ return &steady_full;
+}
+
+static steady_clock::time_point __libcpp_steady_clock_now() {
+ static FP fp = init_steady_clock();
+ return steady_clock::time_point(steady_clock::duration(fp()));
+}
+
+#else // vvvvv default behavior for Apple platforms vvvvv
+
+// On Apple platforms, only CLOCK_UPTIME_RAW, CLOCK_MONOTONIC_RAW or
+// mach_absolute_time are able to time functions in the nanosecond range.
+// Furthermore, only CLOCK_MONOTONIC_RAW is truly monotonic, because it
+// also counts cycles when the system is asleep. Thus, it is the only
+// acceptable implementation of steady_clock.
+static steady_clock::time_point __libcpp_steady_clock_now() {
+ struct timespec tp;
+ if (0 != clock_gettime(CLOCK_MONOTONIC_RAW, &tp))
+ __throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC_RAW) failed");
+ return steady_clock::time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));
+}
+
+#endif
+
+#elif defined(_LIBCPP_WIN32API)
+
+// https://msdn.microsoft.com/en-us/library/windows/desktop/ms644905(v=vs.85).aspx says:
+// If the function fails, the return value is zero. <snip>
+// On systems that run Windows XP or later, the function will always succeed
+// and will thus never return zero.
+
+static LARGE_INTEGER
+__QueryPerformanceFrequency()
+{
+ LARGE_INTEGER val;
+ (void) QueryPerformanceFrequency(&val);
+ return val;
+}
+
+static steady_clock::time_point __libcpp_steady_clock_now() {
+ static const LARGE_INTEGER freq = __QueryPerformanceFrequency();
+
+ LARGE_INTEGER counter;
+ (void) QueryPerformanceCounter(&counter);
+ auto seconds = counter.QuadPart / freq.QuadPart;
+ auto fractions = counter.QuadPart % freq.QuadPart;
+ auto dur = seconds * nano::den + fractions * nano::den / freq.QuadPart;
+ return steady_clock::time_point(steady_clock::duration(dur));
+}
+
+#elif defined(__MVS__)
+
+static steady_clock::time_point __libcpp_steady_clock_now() {
+ struct timespec64 ts;
+ if (0 != gettimeofdayMonotonic(&ts))
+ __throw_system_error(errno, "failed to obtain time of day");
+
+ return steady_clock::time_point(seconds(ts.tv_sec) + nanoseconds(ts.tv_nsec));
+}
+
+# elif defined(__Fuchsia__)
+
+static steady_clock::time_point __libcpp_steady_clock_now() noexcept {
+ // Implicitly link against the vDSO system call ABI without
+ // requiring the final link to specify -lzircon explicitly when
+ // statically linking libc++.
+# pragma comment(lib, "zircon")
+
+ return steady_clock::time_point(nanoseconds(_zx_clock_get_monotonic()));
+}
+
+# elif defined(CLOCK_MONOTONIC)
+
+static steady_clock::time_point __libcpp_steady_clock_now() {
+ struct timespec tp;
+ if (0 != clock_gettime(CLOCK_MONOTONIC, &tp))
+ __throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC) failed");
+ return steady_clock::time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));
+}
+
+# else
+# error "Monotonic clock not implemented on this platform"
+# endif
+
+const bool steady_clock::is_steady;
+
+steady_clock::time_point
+steady_clock::now() noexcept
+{
+ return __libcpp_steady_clock_now();
+}
+
+#endif // !_LIBCPP_HAS_NO_MONOTONIC_CLOCK
+
+}
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/chrono_system_time_init.h b/contrib/libs/cxxsupp/libcxxmsvc/src/chrono_system_time_init.h
new file mode 100644
index 0000000000..b1bdc691b3
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/chrono_system_time_init.h
@@ -0,0 +1,2 @@
+#pragma GCC system_header
+GetSystemTimeInit GetSystemTimeAsFileTimeFunc _LIBCPP_INIT_PRIORITY_MAX;
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/condition_variable.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/condition_variable.cpp
new file mode 100644
index 0000000000..b17c4cf645
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/condition_variable.cpp
@@ -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
+//
+//===----------------------------------------------------------------------===//
+
+#include <__config>
+
+#ifndef _LIBCPP_HAS_NO_THREADS
+
+#include <condition_variable>
+#include <thread>
+#include <system_error>
+
+#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
+# pragma comment(lib, "pthread")
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// ~condition_variable is defined elsewhere.
+
+void
+condition_variable::notify_one() noexcept
+{
+ __libcpp_condvar_signal(&__cv_);
+}
+
+void
+condition_variable::notify_all() noexcept
+{
+ __libcpp_condvar_broadcast(&__cv_);
+}
+
+void
+condition_variable::wait(unique_lock<mutex>& lk) noexcept
+{
+ if (!lk.owns_lock())
+ __throw_system_error(EPERM,
+ "condition_variable::wait: mutex not locked");
+ int ec = __libcpp_condvar_wait(&__cv_, lk.mutex()->native_handle());
+ if (ec)
+ __throw_system_error(ec, "condition_variable wait failed");
+}
+
+void
+condition_variable::__do_timed_wait(unique_lock<mutex>& lk,
+ chrono::time_point<chrono::system_clock, chrono::nanoseconds> tp) noexcept
+{
+ using namespace chrono;
+ if (!lk.owns_lock())
+ __throw_system_error(EPERM,
+ "condition_variable::timed wait: mutex not locked");
+ nanoseconds d = tp.time_since_epoch();
+ if (d > nanoseconds(0x59682F000000E941))
+ d = nanoseconds(0x59682F000000E941);
+ __libcpp_timespec_t ts;
+ seconds s = duration_cast<seconds>(d);
+ typedef decltype(ts.tv_sec) ts_sec;
+ _LIBCPP_CONSTEXPR ts_sec ts_sec_max = numeric_limits<ts_sec>::max();
+ if (s.count() < ts_sec_max)
+ {
+ ts.tv_sec = static_cast<ts_sec>(s.count());
+ ts.tv_nsec = static_cast<decltype(ts.tv_nsec)>((d - s).count());
+ }
+ else
+ {
+ ts.tv_sec = ts_sec_max;
+ ts.tv_nsec = giga::num - 1;
+ }
+ int ec = __libcpp_condvar_timedwait(&__cv_, lk.mutex()->native_handle(), &ts);
+ if (ec != 0 && ec != ETIMEDOUT)
+ __throw_system_error(ec, "condition_variable timed_wait failed");
+}
+
+void
+notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk)
+{
+ auto& tl_ptr = __thread_local_data();
+ // If this thread was not created using std::thread then it will not have
+ // previously allocated.
+ if (tl_ptr.get() == nullptr) {
+ tl_ptr.set_pointer(new __thread_struct);
+ }
+ __thread_local_data()->notify_all_at_thread_exit(&cond, lk.release());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // !_LIBCPP_HAS_NO_THREADS
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/condition_variable_destructor.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/condition_variable_destructor.cpp
new file mode 100644
index 0000000000..c217a09394
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/condition_variable_destructor.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// Define ~condition_variable.
+//
+// On some platforms ~condition_variable has been made trivial and the
+// definition is only provided for ABI compatibility.
+
+#include <__config>
+#include <__threading_support>
+
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+# if _LIBCPP_ABI_VERSION == 1 || !defined(_LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION)
+# define NEEDS_CONDVAR_DESTRUCTOR
+# endif
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifdef NEEDS_CONDVAR_DESTRUCTOR
+
+class _LIBCPP_TYPE_VIS condition_variable
+{
+ __libcpp_condvar_t __cv_ = _LIBCPP_CONDVAR_INITIALIZER;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr condition_variable() noexcept = default;
+
+ ~condition_variable();
+
+ condition_variable(const condition_variable&) = delete;
+ condition_variable& operator=(const condition_variable&) = delete;
+};
+
+condition_variable::~condition_variable()
+{
+ __libcpp_condvar_destroy(&__cv_);
+}
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/debug.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/debug.cpp
new file mode 100644
index 0000000000..8f1d328f0e
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/debug.cpp
@@ -0,0 +1,559 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <__assert>
+#include <__config>
+#include <__debug>
+#include <__hash_table>
+#include <algorithm>
+#include <cstdio>
+#include <functional>
+#include <string>
+
+#ifndef _LIBCPP_HAS_NO_THREADS
+# include <mutex>
+# if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
+# pragma comment(lib, "pthread")
+# endif
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+_LIBCPP_FUNC_VIS
+__libcpp_db*
+__get_db()
+{
+ static _LIBCPP_NO_DESTROY __libcpp_db db;
+ return &db;
+}
+
+_LIBCPP_FUNC_VIS
+const __libcpp_db*
+__get_const_db()
+{
+ return __get_db();
+}
+
+namespace
+{
+
+#ifndef _LIBCPP_HAS_NO_THREADS
+typedef mutex mutex_type;
+typedef lock_guard<mutex_type> WLock;
+typedef lock_guard<mutex_type> RLock;
+
+mutex_type&
+mut()
+{
+ static _LIBCPP_NO_DESTROY mutex_type m;
+ return m;
+}
+#endif // !_LIBCPP_HAS_NO_THREADS
+
+} // unnamed namespace
+
+__i_node::~__i_node()
+{
+ if (__next_)
+ {
+ __next_->~__i_node();
+ free(__next_);
+ }
+}
+
+__c_node::~__c_node()
+{
+ free(beg_);
+ if (__next_)
+ {
+ __next_->~__c_node();
+ free(__next_);
+ }
+}
+
+__libcpp_db::__libcpp_db()
+ : __cbeg_(nullptr),
+ __cend_(nullptr),
+ __csz_(0),
+ __ibeg_(nullptr),
+ __iend_(nullptr),
+ __isz_(0)
+{
+}
+
+__libcpp_db::~__libcpp_db()
+{
+ if (__cbeg_)
+ {
+ for (__c_node** p = __cbeg_; p != __cend_; ++p)
+ {
+ if (*p != nullptr)
+ {
+ (*p)->~__c_node();
+ free(*p);
+ }
+ }
+ free(__cbeg_);
+ }
+ if (__ibeg_)
+ {
+ for (__i_node** p = __ibeg_; p != __iend_; ++p)
+ {
+ if (*p != nullptr)
+ {
+ (*p)->~__i_node();
+ free(*p);
+ }
+ }
+ free(__ibeg_);
+ }
+}
+
+void*
+__libcpp_db::__find_c_from_i(void* __i) const
+{
+#ifndef _LIBCPP_HAS_NO_THREADS
+ RLock _(mut());
+#endif
+ __i_node* i = __find_iterator(__i);
+ _LIBCPP_ASSERT(i != nullptr, "iterator not found in debug database.");
+ return i->__c_ != nullptr ? i->__c_->__c_ : nullptr;
+}
+
+void
+__libcpp_db::__insert_ic(void* __i, const void* __c)
+{
+#ifndef _LIBCPP_HAS_NO_THREADS
+ WLock _(mut());
+#endif
+ if (__cbeg_ == __cend_)
+ return;
+ size_t hc = hash<const void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
+ __c_node* c = __cbeg_[hc];
+ if (c == nullptr)
+ return;
+ while (c->__c_ != __c)
+ {
+ c = c->__next_;
+ if (c == nullptr)
+ return;
+ }
+ __i_node* i = __insert_iterator(__i);
+ c->__add(i);
+ i->__c_ = c;
+}
+
+void
+__libcpp_db::__insert_c(void* __c, __libcpp_db::_InsertConstruct *__fn)
+{
+#ifndef _LIBCPP_HAS_NO_THREADS
+ WLock _(mut());
+#endif
+ if (__csz_ + 1 > static_cast<size_t>(__cend_ - __cbeg_))
+ {
+ size_t nc = __next_prime(2*static_cast<size_t>(__cend_ - __cbeg_) + 1);
+ __c_node** cbeg = static_cast<__c_node**>(calloc(nc, sizeof(__c_node*)));
+ if (cbeg == nullptr)
+ __throw_bad_alloc();
+
+ for (__c_node** p = __cbeg_; p != __cend_; ++p)
+ {
+ __c_node* q = *p;
+ while (q != nullptr)
+ {
+ size_t h = hash<void*>()(q->__c_) % nc;
+ __c_node* r = q->__next_;
+ q->__next_ = cbeg[h];
+ cbeg[h] = q;
+ q = r;
+ }
+ }
+ free(__cbeg_);
+ __cbeg_ = cbeg;
+ __cend_ = __cbeg_ + nc;
+ }
+ size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
+ __c_node* p = __cbeg_[hc];
+ void *buf = malloc(sizeof(__c_node));
+ if (buf == nullptr)
+ __throw_bad_alloc();
+ __cbeg_[hc] = __fn(buf, __c, p);
+
+ ++__csz_;
+}
+
+void
+__libcpp_db::__erase_i(void* __i)
+{
+#ifndef _LIBCPP_HAS_NO_THREADS
+ WLock _(mut());
+#endif
+ if (__ibeg_ != __iend_)
+ {
+ size_t hi = hash<void*>()(__i) % static_cast<size_t>(__iend_ - __ibeg_);
+ __i_node* p = __ibeg_[hi];
+ if (p != nullptr)
+ {
+ __i_node* q = nullptr;
+ while (p->__i_ != __i)
+ {
+ q = p;
+ p = p->__next_;
+ if (p == nullptr)
+ return;
+ }
+ if (q == nullptr)
+ __ibeg_[hi] = p->__next_;
+ else
+ q->__next_ = p->__next_;
+ __c_node* c = p->__c_;
+ --__isz_;
+ if (c != nullptr)
+ c->__remove(p);
+ free(p);
+ }
+ }
+}
+
+void
+__libcpp_db::__invalidate_all(void* __c)
+{
+#ifndef _LIBCPP_HAS_NO_THREADS
+ WLock _(mut());
+#endif
+ if (__cend_ != __cbeg_)
+ {
+ size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
+ __c_node* p = __cbeg_[hc];
+ if (p == nullptr)
+ return;
+ while (p->__c_ != __c)
+ {
+ p = p->__next_;
+ if (p == nullptr)
+ return;
+ }
+ while (p->end_ != p->beg_)
+ {
+ --p->end_;
+ (*p->end_)->__c_ = nullptr;
+ }
+ }
+}
+
+__c_node*
+__libcpp_db::__find_c_and_lock(void* __c) const
+{
+#ifndef _LIBCPP_HAS_NO_THREADS
+ mut().lock();
+#endif
+ if (__cend_ == __cbeg_)
+ {
+#ifndef _LIBCPP_HAS_NO_THREADS
+ mut().unlock();
+#endif
+ return nullptr;
+ }
+ size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
+ __c_node* p = __cbeg_[hc];
+ if (p == nullptr)
+ {
+#ifndef _LIBCPP_HAS_NO_THREADS
+ mut().unlock();
+#endif
+ return nullptr;
+ }
+ while (p->__c_ != __c)
+ {
+ p = p->__next_;
+ if (p == nullptr)
+ {
+#ifndef _LIBCPP_HAS_NO_THREADS
+ mut().unlock();
+#endif
+ return nullptr;
+ }
+ }
+ return p;
+}
+
+__c_node*
+__libcpp_db::__find_c(void* __c) const
+{
+ size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
+ __c_node* p = __cbeg_[hc];
+ _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __find_c A");
+ while (p->__c_ != __c)
+ {
+ p = p->__next_;
+ _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __find_c B");
+ }
+ return p;
+}
+
+void
+__libcpp_db::unlock() const
+{
+#ifndef _LIBCPP_HAS_NO_THREADS
+ mut().unlock();
+#endif
+}
+
+void
+__libcpp_db::__erase_c(void* __c)
+{
+#ifndef _LIBCPP_HAS_NO_THREADS
+ WLock _(mut());
+#endif
+ if (__cend_ != __cbeg_)
+ {
+ size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
+ __c_node* p = __cbeg_[hc];
+ if (p == nullptr)
+ return;
+ __c_node* q = nullptr;
+ _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __erase_c A");
+ while (p->__c_ != __c)
+ {
+ q = p;
+ p = p->__next_;
+ if (p == nullptr)
+ return;
+ _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __erase_c B");
+ }
+ if (q == nullptr)
+ __cbeg_[hc] = p->__next_;
+ else
+ q->__next_ = p->__next_;
+ while (p->end_ != p->beg_)
+ {
+ --p->end_;
+ (*p->end_)->__c_ = nullptr;
+ }
+ free(p->beg_);
+ free(p);
+ --__csz_;
+ }
+}
+
+void
+__libcpp_db::__iterator_copy(void* __i, const void* __i0)
+{
+#ifndef _LIBCPP_HAS_NO_THREADS
+ WLock _(mut());
+#endif
+ __i_node* i = __find_iterator(__i);
+ __i_node* i0 = __find_iterator(__i0);
+ __c_node* c0 = i0 != nullptr ? i0->__c_ : nullptr;
+ if (i == nullptr && i0 != nullptr)
+ i = __insert_iterator(__i);
+ __c_node* c = i != nullptr ? i->__c_ : nullptr;
+ if (c != c0)
+ {
+ if (c != nullptr)
+ c->__remove(i);
+ if (i != nullptr)
+ {
+ i->__c_ = nullptr;
+ if (c0 != nullptr)
+ {
+ i->__c_ = c0;
+ i->__c_->__add(i);
+ }
+ }
+ }
+}
+
+bool
+__libcpp_db::__dereferenceable(const void* __i) const
+{
+#ifndef _LIBCPP_HAS_NO_THREADS
+ RLock _(mut());
+#endif
+ __i_node* i = __find_iterator(__i);
+ return i != nullptr && i->__c_ != nullptr && i->__c_->__dereferenceable(__i);
+}
+
+bool
+__libcpp_db::__decrementable(const void* __i) const
+{
+#ifndef _LIBCPP_HAS_NO_THREADS
+ RLock _(mut());
+#endif
+ __i_node* i = __find_iterator(__i);
+ return i != nullptr && i->__c_ != nullptr && i->__c_->__decrementable(__i);
+}
+
+bool
+__libcpp_db::__addable(const void* __i, ptrdiff_t __n) const
+{
+#ifndef _LIBCPP_HAS_NO_THREADS
+ RLock _(mut());
+#endif
+ __i_node* i = __find_iterator(__i);
+ return i != nullptr && i->__c_ != nullptr && i->__c_->__addable(__i, __n);
+}
+
+bool
+__libcpp_db::__subscriptable(const void* __i, ptrdiff_t __n) const
+{
+#ifndef _LIBCPP_HAS_NO_THREADS
+ RLock _(mut());
+#endif
+ __i_node* i = __find_iterator(__i);
+ return i != nullptr && i->__c_ != nullptr && i->__c_->__subscriptable(__i, __n);
+}
+
+bool
+__libcpp_db::__less_than_comparable(const void* __i, const void* __j) const
+{
+#ifndef _LIBCPP_HAS_NO_THREADS
+ RLock _(mut());
+#endif
+ __i_node* i = __find_iterator(__i);
+ __i_node* j = __find_iterator(__j);
+ __c_node* ci = i != nullptr ? i->__c_ : nullptr;
+ __c_node* cj = j != nullptr ? j->__c_ : nullptr;
+ return ci == cj;
+}
+
+void
+__libcpp_db::swap(void* c1, void* c2)
+{
+#ifndef _LIBCPP_HAS_NO_THREADS
+ WLock _(mut());
+#endif
+ size_t hc = hash<void*>()(c1) % static_cast<size_t>(__cend_ - __cbeg_);
+ __c_node* p1 = __cbeg_[hc];
+ _LIBCPP_ASSERT(p1 != nullptr, "debug mode internal logic error swap A");
+ while (p1->__c_ != c1)
+ {
+ p1 = p1->__next_;
+ _LIBCPP_ASSERT(p1 != nullptr, "debug mode internal logic error swap B");
+ }
+ hc = hash<void*>()(c2) % static_cast<size_t>(__cend_ - __cbeg_);
+ __c_node* p2 = __cbeg_[hc];
+ _LIBCPP_ASSERT(p2 != nullptr, "debug mode internal logic error swap C");
+ while (p2->__c_ != c2)
+ {
+ p2 = p2->__next_;
+ _LIBCPP_ASSERT(p2 != nullptr, "debug mode internal logic error swap D");
+ }
+ std::swap(p1->beg_, p2->beg_);
+ std::swap(p1->end_, p2->end_);
+ std::swap(p1->cap_, p2->cap_);
+ for (__i_node** p = p1->beg_; p != p1->end_; ++p)
+ (*p)->__c_ = p1;
+ for (__i_node** p = p2->beg_; p != p2->end_; ++p)
+ (*p)->__c_ = p2;
+}
+
+void
+__libcpp_db::__insert_i(void* __i)
+{
+#ifndef _LIBCPP_HAS_NO_THREADS
+ WLock _(mut());
+#endif
+ __insert_iterator(__i);
+}
+
+void
+__c_node::__add(__i_node* i)
+{
+ if (end_ == cap_)
+ {
+ size_t nc = 2*static_cast<size_t>(cap_ - beg_);
+ if (nc == 0)
+ nc = 1;
+ __i_node** beg =
+ static_cast<__i_node**>(malloc(nc * sizeof(__i_node*)));
+ if (beg == nullptr)
+ __throw_bad_alloc();
+
+ if (nc > 1)
+ memcpy(beg, beg_, nc/2*sizeof(__i_node*));
+ free(beg_);
+ beg_ = beg;
+ end_ = beg_ + nc/2;
+ cap_ = beg_ + nc;
+ }
+ *end_++ = i;
+}
+
+// private api
+
+_LIBCPP_HIDDEN
+__i_node*
+__libcpp_db::__insert_iterator(void* __i)
+{
+ if (__isz_ + 1 > static_cast<size_t>(__iend_ - __ibeg_))
+ {
+ size_t nc = __next_prime(2*static_cast<size_t>(__iend_ - __ibeg_) + 1);
+ __i_node** ibeg = static_cast<__i_node**>(calloc(nc, sizeof(__i_node*)));
+ if (ibeg == nullptr)
+ __throw_bad_alloc();
+
+ for (__i_node** p = __ibeg_; p != __iend_; ++p)
+ {
+ __i_node* q = *p;
+ while (q != nullptr)
+ {
+ size_t h = hash<void*>()(q->__i_) % nc;
+ __i_node* r = q->__next_;
+ q->__next_ = ibeg[h];
+ ibeg[h] = q;
+ q = r;
+ }
+ }
+ free(__ibeg_);
+ __ibeg_ = ibeg;
+ __iend_ = __ibeg_ + nc;
+ }
+ size_t hi = hash<void*>()(__i) % static_cast<size_t>(__iend_ - __ibeg_);
+ __i_node* p = __ibeg_[hi];
+ __i_node* r = __ibeg_[hi] =
+ static_cast<__i_node*>(malloc(sizeof(__i_node)));
+ if (r == nullptr)
+ __throw_bad_alloc();
+
+ ::new(r) __i_node(__i, p, nullptr);
+ ++__isz_;
+ return r;
+}
+
+_LIBCPP_HIDDEN
+__i_node*
+__libcpp_db::__find_iterator(const void* __i) const
+{
+ __i_node* r = nullptr;
+ if (__ibeg_ != __iend_)
+ {
+ size_t h = hash<const void*>()(__i) % static_cast<size_t>(__iend_ - __ibeg_);
+ for (__i_node* nd = __ibeg_[h]; nd != nullptr; nd = nd->__next_)
+ {
+ if (nd->__i_ == __i)
+ {
+ r = nd;
+ break;
+ }
+ }
+ }
+ return r;
+}
+
+_LIBCPP_HIDDEN
+void
+__c_node::__remove(__i_node* p)
+{
+ __i_node** r = find(beg_, end_, p);
+ _LIBCPP_ASSERT(r != end_, "debug mode internal logic error __c_node::__remove");
+ if (--end_ != r)
+ memmove(r, r+1, static_cast<size_t>(end_ - r)*sizeof(__i_node*));
+}
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/exception.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/exception.cpp
new file mode 100644
index 0000000000..915ab3fb64
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/exception.cpp
@@ -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
+//
+//===----------------------------------------------------------------------===//
+
+#include <exception>
+#include <new>
+#include <typeinfo>
+
+#if defined(LIBCXX_BUILDING_LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI)
+ #include <cxxabi.h>
+ using namespace __cxxabiv1;
+ #define HAVE_DEPENDENT_EH_ABI 1
+#endif
+
+#if defined(_LIBCPP_ABI_MICROSOFT)
+#include "support/runtime/exception_msvc.ipp"
+#include "support/runtime/exception_pointer_msvc.ipp"
+#elif defined(_LIBCPPABI_VERSION)
+#include "support/runtime/exception_libcxxabi.ipp"
+#include "support/runtime/exception_pointer_cxxabi.ipp"
+#elif defined(LIBCXX_BUILDING_LIBCXXRT)
+#include "support/runtime/exception_libcxxrt.ipp"
+#include "support/runtime/exception_pointer_cxxabi.ipp"
+#elif defined(__GLIBCXX__)
+#include "support/runtime/exception_glibcxx.ipp"
+#include "support/runtime/exception_pointer_glibcxx.ipp"
+#else
+#include "support/runtime/exception_fallback.ipp"
+#include "support/runtime/exception_pointer_unimplemented.ipp"
+#endif
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/filesystem/directory_iterator.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/filesystem/directory_iterator.cpp
new file mode 100644
index 0000000000..8b91929df8
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/filesystem/directory_iterator.cpp
@@ -0,0 +1,332 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <__assert>
+#include <__config>
+#include <errno.h>
+#include <filesystem>
+#include <stack>
+
+#include "filesystem_common.h"
+
+_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
+
+using detail::ErrorHandler;
+
+#if defined(_LIBCPP_WIN32API)
+class __dir_stream {
+public:
+ __dir_stream() = delete;
+ __dir_stream& operator=(const __dir_stream&) = delete;
+
+ __dir_stream(__dir_stream&& __ds) noexcept : __stream_(__ds.__stream_),
+ __root_(move(__ds.__root_)),
+ __entry_(move(__ds.__entry_)) {
+ __ds.__stream_ = INVALID_HANDLE_VALUE;
+ }
+
+ __dir_stream(const path& root, directory_options opts, error_code& ec)
+ : __stream_(INVALID_HANDLE_VALUE), __root_(root) {
+ if (root.native().empty()) {
+ ec = make_error_code(errc::no_such_file_or_directory);
+ return;
+ }
+ __stream_ = ::FindFirstFileW((root / "*").c_str(), &__data_);
+ if (__stream_ == INVALID_HANDLE_VALUE) {
+ ec = detail::make_windows_error(GetLastError());
+ const bool ignore_permission_denied =
+ bool(opts & directory_options::skip_permission_denied);
+ if (ignore_permission_denied &&
+ ec.value() == static_cast<int>(errc::permission_denied))
+ ec.clear();
+ return;
+ }
+ if (!assign())
+ advance(ec);
+ }
+
+ ~__dir_stream() noexcept {
+ if (__stream_ == INVALID_HANDLE_VALUE)
+ return;
+ close();
+ }
+
+ bool good() const noexcept { return __stream_ != INVALID_HANDLE_VALUE; }
+
+ bool advance(error_code& ec) {
+ while (::FindNextFileW(__stream_, &__data_)) {
+ if (assign())
+ return true;
+ }
+ close();
+ return false;
+ }
+
+ bool assign() {
+ if (!wcscmp(__data_.cFileName, L".") || !wcscmp(__data_.cFileName, L".."))
+ return false;
+ // FIXME: Cache more of this
+ //directory_entry::__cached_data cdata;
+ //cdata.__type_ = get_file_type(__data_);
+ //cdata.__size_ = get_file_size(__data_);
+ //cdata.__write_time_ = get_write_time(__data_);
+ __entry_.__assign_iter_entry(
+ __root_ / __data_.cFileName,
+ directory_entry::__create_iter_result(detail::get_file_type(__data_)));
+ return true;
+ }
+
+private:
+ error_code close() noexcept {
+ error_code ec;
+ if (!::FindClose(__stream_))
+ ec = detail::make_windows_error(GetLastError());
+ __stream_ = INVALID_HANDLE_VALUE;
+ return ec;
+ }
+
+ HANDLE __stream_{INVALID_HANDLE_VALUE};
+ WIN32_FIND_DATAW __data_;
+
+public:
+ path __root_;
+ directory_entry __entry_;
+};
+#else
+class __dir_stream {
+public:
+ __dir_stream() = delete;
+ __dir_stream& operator=(const __dir_stream&) = delete;
+
+ __dir_stream(__dir_stream&& other) noexcept : __stream_(other.__stream_),
+ __root_(move(other.__root_)),
+ __entry_(move(other.__entry_)) {
+ other.__stream_ = nullptr;
+ }
+
+ __dir_stream(const path& root, directory_options opts, error_code& ec)
+ : __stream_(nullptr), __root_(root) {
+ if ((__stream_ = ::opendir(root.c_str())) == nullptr) {
+ ec = detail::capture_errno();
+ const bool allow_eacces =
+ bool(opts & directory_options::skip_permission_denied);
+ if (allow_eacces && ec.value() == EACCES)
+ ec.clear();
+ return;
+ }
+ advance(ec);
+ }
+
+ ~__dir_stream() noexcept {
+ if (__stream_)
+ close();
+ }
+
+ bool good() const noexcept { return __stream_ != nullptr; }
+
+ bool advance(error_code& ec) {
+ while (true) {
+ auto str_type_pair = detail::posix_readdir(__stream_, ec);
+ auto& str = str_type_pair.first;
+ if (str == "." || str == "..") {
+ continue;
+ } else if (ec || str.empty()) {
+ close();
+ return false;
+ } else {
+ __entry_.__assign_iter_entry(
+ __root_ / str,
+ directory_entry::__create_iter_result(str_type_pair.second));
+ return true;
+ }
+ }
+ }
+
+private:
+ error_code close() noexcept {
+ error_code m_ec;
+ if (::closedir(__stream_) == -1)
+ m_ec = detail::capture_errno();
+ __stream_ = nullptr;
+ return m_ec;
+ }
+
+ DIR* __stream_{nullptr};
+
+public:
+ path __root_;
+ directory_entry __entry_;
+};
+#endif
+
+// directory_iterator
+
+directory_iterator::directory_iterator(const path& p, error_code* ec,
+ directory_options opts) {
+ ErrorHandler<void> err("directory_iterator::directory_iterator(...)", ec, &p);
+
+ error_code m_ec;
+ __imp_ = make_shared<__dir_stream>(p, opts, m_ec);
+ if (ec)
+ *ec = m_ec;
+ if (!__imp_->good()) {
+ __imp_.reset();
+ if (m_ec)
+ err.report(m_ec);
+ }
+}
+
+directory_iterator& directory_iterator::__increment(error_code* ec) {
+ _LIBCPP_ASSERT(__imp_, "Attempting to increment an invalid iterator");
+ ErrorHandler<void> err("directory_iterator::operator++()", ec);
+
+ error_code m_ec;
+ if (!__imp_->advance(m_ec)) {
+ path root = move(__imp_->__root_);
+ __imp_.reset();
+ if (m_ec)
+ err.report(m_ec, "at root " PATH_CSTR_FMT, root.c_str());
+ }
+ return *this;
+}
+
+directory_entry const& directory_iterator::__dereference() const {
+ _LIBCPP_ASSERT(__imp_, "Attempting to dereference an invalid iterator");
+ return __imp_->__entry_;
+}
+
+// recursive_directory_iterator
+
+struct recursive_directory_iterator::__shared_imp {
+ stack<__dir_stream> __stack_;
+ directory_options __options_;
+};
+
+recursive_directory_iterator::recursive_directory_iterator(
+ const path& p, directory_options opt, error_code* ec)
+ : __imp_(nullptr), __rec_(true) {
+ ErrorHandler<void> err("recursive_directory_iterator", ec, &p);
+
+ error_code m_ec;
+ __dir_stream new_s(p, opt, m_ec);
+ if (m_ec)
+ err.report(m_ec);
+ if (m_ec || !new_s.good())
+ return;
+
+ __imp_ = make_shared<__shared_imp>();
+ __imp_->__options_ = opt;
+ __imp_->__stack_.push(move(new_s));
+}
+
+void recursive_directory_iterator::__pop(error_code* ec) {
+ _LIBCPP_ASSERT(__imp_, "Popping the end iterator");
+ if (ec)
+ ec->clear();
+ __imp_->__stack_.pop();
+ if (__imp_->__stack_.size() == 0)
+ __imp_.reset();
+ else
+ __advance(ec);
+}
+
+directory_options recursive_directory_iterator::options() const {
+ return __imp_->__options_;
+}
+
+int recursive_directory_iterator::depth() const {
+ return __imp_->__stack_.size() - 1;
+}
+
+const directory_entry& recursive_directory_iterator::__dereference() const {
+ return __imp_->__stack_.top().__entry_;
+}
+
+recursive_directory_iterator&
+recursive_directory_iterator::__increment(error_code* ec) {
+ if (ec)
+ ec->clear();
+ if (recursion_pending()) {
+ if (__try_recursion(ec) || (ec && *ec))
+ return *this;
+ }
+ __rec_ = true;
+ __advance(ec);
+ return *this;
+}
+
+void recursive_directory_iterator::__advance(error_code* ec) {
+ ErrorHandler<void> err("recursive_directory_iterator::operator++()", ec);
+
+ const directory_iterator end_it;
+ auto& stack = __imp_->__stack_;
+ error_code m_ec;
+ while (stack.size() > 0) {
+ if (stack.top().advance(m_ec))
+ return;
+ if (m_ec)
+ break;
+ stack.pop();
+ }
+
+ if (m_ec) {
+ path root = move(stack.top().__root_);
+ __imp_.reset();
+ err.report(m_ec, "at root " PATH_CSTR_FMT, root.c_str());
+ } else {
+ __imp_.reset();
+ }
+}
+
+bool recursive_directory_iterator::__try_recursion(error_code* ec) {
+ ErrorHandler<void> err("recursive_directory_iterator::operator++()", ec);
+
+ bool rec_sym = bool(options() & directory_options::follow_directory_symlink);
+
+ auto& curr_it = __imp_->__stack_.top();
+
+ bool skip_rec = false;
+ error_code m_ec;
+ if (!rec_sym) {
+ file_status st(curr_it.__entry_.__get_sym_ft(&m_ec));
+ if (m_ec && status_known(st))
+ m_ec.clear();
+ if (m_ec || is_symlink(st) || !is_directory(st))
+ skip_rec = true;
+ } else {
+ file_status st(curr_it.__entry_.__get_ft(&m_ec));
+ if (m_ec && status_known(st))
+ m_ec.clear();
+ if (m_ec || !is_directory(st))
+ skip_rec = true;
+ }
+
+ if (!skip_rec) {
+ __dir_stream new_it(curr_it.__entry_.path(), __imp_->__options_, m_ec);
+ if (new_it.good()) {
+ __imp_->__stack_.push(move(new_it));
+ return true;
+ }
+ }
+ if (m_ec) {
+ const bool allow_eacess =
+ bool(__imp_->__options_ & directory_options::skip_permission_denied);
+ if (m_ec.value() == EACCES && allow_eacess) {
+ if (ec)
+ ec->clear();
+ } else {
+ path at_ent = move(curr_it.__entry_.__p_);
+ __imp_.reset();
+ err.report(m_ec, "attempting recursion into " PATH_CSTR_FMT,
+ at_ent.c_str());
+ }
+ }
+ return false;
+}
+
+_LIBCPP_END_NAMESPACE_FILESYSTEM
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/filesystem/filesystem_common.h b/contrib/libs/cxxsupp/libcxxmsvc/src/filesystem/filesystem_common.h
new file mode 100644
index 0000000000..f6ba686b41
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/filesystem/filesystem_common.h
@@ -0,0 +1,624 @@
+//===----------------------------------------------------------------------===////
+//
+// 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 FILESYSTEM_COMMON_H
+#define FILESYSTEM_COMMON_H
+
+#include <__assert>
+#include <__config>
+#include <array>
+#include <chrono>
+#include <climits>
+#include <cstdarg>
+#include <ctime>
+#include <filesystem>
+#include <ratio>
+#include <system_error>
+#include <utility>
+
+#if defined(_LIBCPP_WIN32API)
+# define WIN32_LEAN_AND_MEAN
+# define NOMINMAX
+# include <windows.h>
+#endif
+
+#if !defined(_LIBCPP_WIN32API)
+# include <dirent.h> // for DIR & friends
+# include <fcntl.h> /* values for fchmodat */
+# include <sys/stat.h>
+# include <sys/statvfs.h>
+# include <sys/time.h> // for ::utimes as used in __last_write_time
+# include <unistd.h>
+#endif
+
+#include "../include/apple_availability.h"
+
+#if !defined(__APPLE__)
+// We can use the presence of UTIME_OMIT to detect platforms that provide
+// utimensat.
+#if defined(UTIME_OMIT)
+#define _LIBCPP_USE_UTIMENSAT
+#endif
+#endif
+
+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-function"
+#endif
+
+#if defined(_LIBCPP_WIN32API)
+#define PS(x) (L##x)
+#define PATH_CSTR_FMT "\"%ls\""
+#else
+#define PS(x) (x)
+#define PATH_CSTR_FMT "\"%s\""
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
+
+namespace detail {
+
+#if defined(_LIBCPP_WIN32API)
+// Non anonymous, to allow access from two translation units.
+errc __win_err_to_errc(int err);
+#endif
+
+namespace {
+
+static _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 0) string
+format_string_impl(const char* msg, va_list ap) {
+ array<char, 256> buf;
+
+ va_list apcopy;
+ va_copy(apcopy, ap);
+ int ret = ::vsnprintf(buf.data(), buf.size(), msg, apcopy);
+ va_end(apcopy);
+
+ string result;
+ if (static_cast<size_t>(ret) < buf.size()) {
+ result.assign(buf.data(), static_cast<size_t>(ret));
+ } else {
+ // we did not provide a long enough buffer on our first attempt. The
+ // return value is the number of bytes (excluding the null byte) that are
+ // needed for formatting.
+ size_t size_with_null = static_cast<size_t>(ret) + 1;
+ result.__resize_default_init(size_with_null - 1);
+ ret = ::vsnprintf(&result[0], size_with_null, msg, ap);
+ _LIBCPP_ASSERT(static_cast<size_t>(ret) == (size_with_null - 1), "TODO");
+ }
+ return result;
+}
+
+static _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) string
+format_string(const char* msg, ...) {
+ string ret;
+ va_list ap;
+ va_start(ap, msg);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ ret = format_string_impl(msg, ap);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ } catch (...) {
+ va_end(ap);
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ va_end(ap);
+ return ret;
+}
+
+error_code capture_errno() {
+ _LIBCPP_ASSERT(errno, "Expected errno to be non-zero");
+ return error_code(errno, generic_category());
+}
+
+#if defined(_LIBCPP_WIN32API)
+error_code make_windows_error(int err) {
+ return make_error_code(__win_err_to_errc(err));
+}
+#endif
+
+template <class T>
+T error_value();
+template <>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 void error_value<void>() {}
+template <>
+bool error_value<bool>() {
+ return false;
+}
+#if __SIZEOF_SIZE_T__ != __SIZEOF_LONG_LONG__
+template <>
+size_t error_value<size_t>() {
+ return size_t(-1);
+}
+#endif
+
+#if defined(_MSC_VER) && !defined(__clang__) && defined(_M_IX86)
+// FIXME thegeorg@ MSVC on i686 somehow depends on this function presence.
+// Further investigation is needed in order to understand the logic behind this.
+template <>
+unsigned int error_value<unsigned int>() {
+ return unsigned int(-1);
+}
+#endif
+
+template <>
+uintmax_t error_value<uintmax_t>() {
+ return uintmax_t(-1);
+}
+template <>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 file_time_type error_value<file_time_type>() {
+ return file_time_type::min();
+}
+template <>
+path error_value<path>() {
+ return {};
+}
+
+template <class T>
+struct ErrorHandler {
+ const char* func_name_;
+ error_code* ec_ = nullptr;
+ const path* p1_ = nullptr;
+ const path* p2_ = nullptr;
+
+ ErrorHandler(const char* fname, error_code* ec, const path* p1 = nullptr,
+ const path* p2 = nullptr)
+ : func_name_(fname), ec_(ec), p1_(p1), p2_(p2) {
+ if (ec_)
+ ec_->clear();
+ }
+
+ T report(const error_code& ec) const {
+ if (ec_) {
+ *ec_ = ec;
+ return error_value<T>();
+ }
+ string what = string("in ") + func_name_;
+ switch (bool(p1_) + bool(p2_)) {
+ case 0:
+ __throw_filesystem_error(what, ec);
+ case 1:
+ __throw_filesystem_error(what, *p1_, ec);
+ case 2:
+ __throw_filesystem_error(what, *p1_, *p2_, ec);
+ }
+ __libcpp_unreachable();
+ }
+
+ _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 0)
+ void report_impl(const error_code& ec, const char* msg, va_list ap) const {
+ if (ec_) {
+ *ec_ = ec;
+ return;
+ }
+ string what =
+ string("in ") + func_name_ + ": " + format_string_impl(msg, ap);
+ switch (bool(p1_) + bool(p2_)) {
+ case 0:
+ __throw_filesystem_error(what, ec);
+ case 1:
+ __throw_filesystem_error(what, *p1_, ec);
+ case 2:
+ __throw_filesystem_error(what, *p1_, *p2_, ec);
+ }
+ __libcpp_unreachable();
+ }
+
+ _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4)
+ T report(const error_code& ec, const char* msg, ...) const {
+ va_list ap;
+ va_start(ap, msg);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ report_impl(ec, msg, ap);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ } catch (...) {
+ va_end(ap);
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ va_end(ap);
+ return error_value<T>();
+ }
+
+ T report(errc const& err) const {
+ return report(make_error_code(err));
+ }
+
+ _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4)
+ T report(errc const& err, const char* msg, ...) const {
+ va_list ap;
+ va_start(ap, msg);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ report_impl(make_error_code(err), msg, ap);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ } catch (...) {
+ va_end(ap);
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ va_end(ap);
+ return error_value<T>();
+ }
+
+private:
+ ErrorHandler(ErrorHandler const&) = delete;
+ ErrorHandler& operator=(ErrorHandler const&) = delete;
+};
+
+using chrono::duration;
+using chrono::duration_cast;
+
+#if defined(_LIBCPP_WIN32API)
+// Various C runtime versions (UCRT, or the legacy msvcrt.dll used by
+// some mingw toolchains) provide different stat function implementations,
+// with a number of limitations with respect to what we want from the
+// stat function. Instead provide our own (in the anonymous detail namespace
+// in posix_compat.h) which does exactly what we want, along with our own
+// stat structure and flag macros.
+
+struct TimeSpec {
+ int64_t tv_sec;
+ int64_t tv_nsec;
+};
+struct StatT {
+ unsigned st_mode;
+ TimeSpec st_atim;
+ TimeSpec st_mtim;
+ uint64_t st_dev; // FILE_ID_INFO::VolumeSerialNumber
+ struct FileIdStruct {
+ unsigned char id[16]; // FILE_ID_INFO::FileId
+ bool operator==(const FileIdStruct &other) const {
+ for (int i = 0; i < 16; i++)
+ if (id[i] != other.id[i])
+ return false;
+ return true;
+ }
+ } st_ino;
+ uint32_t st_nlink;
+ uintmax_t st_size;
+};
+
+#else
+using TimeSpec = struct timespec;
+using TimeVal = struct timeval;
+using StatT = struct stat;
+#endif
+
+template <class FileTimeT, class TimeT,
+ bool IsFloat = is_floating_point<typename FileTimeT::rep>::value>
+struct time_util_base {
+ using rep = typename FileTimeT::rep;
+ using fs_duration = typename FileTimeT::duration;
+ using fs_seconds = duration<rep>;
+ using fs_nanoseconds = duration<rep, nano>;
+ using fs_microseconds = duration<rep, micro>;
+
+ static constexpr rep max_seconds =
+ duration_cast<fs_seconds>(FileTimeT::duration::max()).count();
+
+ static constexpr rep max_nsec =
+ duration_cast<fs_nanoseconds>(FileTimeT::duration::max() -
+ fs_seconds(max_seconds))
+ .count();
+
+ static constexpr rep min_seconds =
+ duration_cast<fs_seconds>(FileTimeT::duration::min()).count();
+
+ static constexpr rep min_nsec_timespec =
+ duration_cast<fs_nanoseconds>(
+ (FileTimeT::duration::min() - fs_seconds(min_seconds)) +
+ fs_seconds(1))
+ .count();
+
+private:
+ static _LIBCPP_CONSTEXPR_AFTER_CXX11 fs_duration get_min_nsecs() {
+ return duration_cast<fs_duration>(
+ fs_nanoseconds(min_nsec_timespec) -
+ duration_cast<fs_nanoseconds>(fs_seconds(1)));
+ }
+ // Static assert that these values properly round trip.
+ static_assert(fs_seconds(min_seconds) + get_min_nsecs() ==
+ FileTimeT::duration::min(),
+ "value doesn't roundtrip");
+
+ static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool check_range() {
+ // This kinda sucks, but it's what happens when we don't have __int128_t.
+ if (sizeof(TimeT) == sizeof(rep)) {
+ typedef duration<long long, ratio<3600 * 24 * 365> > Years;
+ return duration_cast<Years>(fs_seconds(max_seconds)) > Years(250) &&
+ duration_cast<Years>(fs_seconds(min_seconds)) < Years(-250);
+ }
+ return max_seconds >= numeric_limits<TimeT>::max() &&
+ min_seconds <= numeric_limits<TimeT>::min();
+ }
+ static_assert(check_range(), "the representable range is unacceptable small");
+};
+
+template <class FileTimeT, class TimeT>
+struct time_util_base<FileTimeT, TimeT, true> {
+ using rep = typename FileTimeT::rep;
+ using fs_duration = typename FileTimeT::duration;
+ using fs_seconds = duration<rep>;
+ using fs_nanoseconds = duration<rep, nano>;
+ using fs_microseconds = duration<rep, micro>;
+
+ static const rep max_seconds;
+ static const rep max_nsec;
+ static const rep min_seconds;
+ static const rep min_nsec_timespec;
+};
+
+template <class FileTimeT, class TimeT>
+const typename FileTimeT::rep
+ time_util_base<FileTimeT, TimeT, true>::max_seconds =
+ duration_cast<fs_seconds>(FileTimeT::duration::max()).count();
+
+template <class FileTimeT, class TimeT>
+const typename FileTimeT::rep time_util_base<FileTimeT, TimeT, true>::max_nsec =
+ duration_cast<fs_nanoseconds>(FileTimeT::duration::max() -
+ fs_seconds(max_seconds))
+ .count();
+
+template <class FileTimeT, class TimeT>
+const typename FileTimeT::rep
+ time_util_base<FileTimeT, TimeT, true>::min_seconds =
+ duration_cast<fs_seconds>(FileTimeT::duration::min()).count();
+
+template <class FileTimeT, class TimeT>
+const typename FileTimeT::rep
+ time_util_base<FileTimeT, TimeT, true>::min_nsec_timespec =
+ duration_cast<fs_nanoseconds>((FileTimeT::duration::min() -
+ fs_seconds(min_seconds)) +
+ fs_seconds(1))
+ .count();
+
+template <class FileTimeT, class TimeT, class TimeSpecT>
+struct time_util : time_util_base<FileTimeT, TimeT> {
+ using Base = time_util_base<FileTimeT, TimeT>;
+ using Base::max_nsec;
+ using Base::max_seconds;
+ using Base::min_nsec_timespec;
+ using Base::min_seconds;
+
+ using typename Base::fs_duration;
+ using typename Base::fs_microseconds;
+ using typename Base::fs_nanoseconds;
+ using typename Base::fs_seconds;
+
+public:
+ template <class CType, class ChronoType>
+ static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool checked_set(CType* out,
+ ChronoType time) {
+ using Lim = numeric_limits<CType>;
+ if (time > Lim::max() || time < Lim::min())
+ return false;
+ *out = static_cast<CType>(time);
+ return true;
+ }
+
+ static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool is_representable(TimeSpecT tm) {
+ if (tm.tv_sec >= 0) {
+ return tm.tv_sec < max_seconds ||
+ (tm.tv_sec == max_seconds && tm.tv_nsec <= max_nsec);
+ } else if (tm.tv_sec == (min_seconds - 1)) {
+ return tm.tv_nsec >= min_nsec_timespec;
+ } else {
+ return tm.tv_sec >= min_seconds;
+ }
+ }
+
+ static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool is_representable(FileTimeT tm) {
+ auto secs = duration_cast<fs_seconds>(tm.time_since_epoch());
+ auto nsecs = duration_cast<fs_nanoseconds>(tm.time_since_epoch() - secs);
+ if (nsecs.count() < 0) {
+ secs = secs + fs_seconds(1);
+ nsecs = nsecs + fs_seconds(1);
+ }
+ using TLim = numeric_limits<TimeT>;
+ if (secs.count() >= 0)
+ return secs.count() <= TLim::max();
+ return secs.count() >= TLim::min();
+ }
+
+ static _LIBCPP_CONSTEXPR_AFTER_CXX11 FileTimeT
+ convert_from_timespec(TimeSpecT tm) {
+ if (tm.tv_sec >= 0 || tm.tv_nsec == 0) {
+ return FileTimeT(fs_seconds(tm.tv_sec) +
+ duration_cast<fs_duration>(fs_nanoseconds(tm.tv_nsec)));
+ } else { // tm.tv_sec < 0
+ auto adj_subsec = duration_cast<fs_duration>(fs_seconds(1) -
+ fs_nanoseconds(tm.tv_nsec));
+ auto Dur = fs_seconds(tm.tv_sec + 1) - adj_subsec;
+ return FileTimeT(Dur);
+ }
+ }
+
+ template <class SubSecT>
+ static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool
+ set_times_checked(TimeT* sec_out, SubSecT* subsec_out, FileTimeT tp) {
+ auto dur = tp.time_since_epoch();
+ auto sec_dur = duration_cast<fs_seconds>(dur);
+ auto subsec_dur = duration_cast<fs_nanoseconds>(dur - sec_dur);
+ // The tv_nsec and tv_usec fields must not be negative so adjust accordingly
+ if (subsec_dur.count() < 0) {
+ if (sec_dur.count() > min_seconds) {
+ sec_dur = sec_dur - fs_seconds(1);
+ subsec_dur = subsec_dur + fs_seconds(1);
+ } else {
+ subsec_dur = fs_nanoseconds::zero();
+ }
+ }
+ return checked_set(sec_out, sec_dur.count()) &&
+ checked_set(subsec_out, subsec_dur.count());
+ }
+ static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool convert_to_timespec(TimeSpecT& dest,
+ FileTimeT tp) {
+ if (!is_representable(tp))
+ return false;
+ return set_times_checked(&dest.tv_sec, &dest.tv_nsec, tp);
+ }
+};
+
+#if defined(_LIBCPP_WIN32API)
+using fs_time = time_util<file_time_type, int64_t, TimeSpec>;
+#else
+using fs_time = time_util<file_time_type, time_t, TimeSpec>;
+#endif
+
+#if defined(__APPLE__)
+inline TimeSpec extract_mtime(StatT const& st) { return st.st_mtimespec; }
+inline TimeSpec extract_atime(StatT const& st) { return st.st_atimespec; }
+#elif defined(__MVS__)
+inline TimeSpec extract_mtime(StatT const& st) {
+ TimeSpec TS = {st.st_mtime, 0};
+ return TS;
+}
+inline TimeSpec extract_atime(StatT const& st) {
+ TimeSpec TS = {st.st_atime, 0};
+ return TS;
+}
+#elif defined(_AIX)
+inline TimeSpec extract_mtime(StatT const& st) {
+ TimeSpec TS = {st.st_mtime, st.st_mtime_n};
+ return TS;
+}
+inline TimeSpec extract_atime(StatT const& st) {
+ TimeSpec TS = {st.st_atime, st.st_atime_n};
+ return TS;
+}
+#else
+inline TimeSpec extract_mtime(StatT const& st) { return st.st_mtim; }
+inline TimeSpec extract_atime(StatT const& st) { return st.st_atim; }
+#endif
+
+#if !defined(_LIBCPP_WIN32API)
+inline TimeVal make_timeval(TimeSpec const& ts) {
+ using namespace chrono;
+ auto Convert = [](long nsec) {
+ using int_type = decltype(std::declval<TimeVal>().tv_usec);
+ auto dur = duration_cast<microseconds>(nanoseconds(nsec)).count();
+ return static_cast<int_type>(dur);
+ };
+ TimeVal TV = {};
+ TV.tv_sec = ts.tv_sec;
+ TV.tv_usec = Convert(ts.tv_nsec);
+ return TV;
+}
+
+inline bool posix_utimes(const path& p, std::array<TimeSpec, 2> const& TS,
+ error_code& ec) {
+ TimeVal ConvertedTS[2] = {make_timeval(TS[0]), make_timeval(TS[1])};
+ if (::utimes(p.c_str(), ConvertedTS) == -1) {
+ ec = capture_errno();
+ return true;
+ }
+ return false;
+}
+
+#if defined(_LIBCPP_USE_UTIMENSAT)
+bool posix_utimensat(const path& p, std::array<TimeSpec, 2> const& TS,
+ error_code& ec) {
+ if (::utimensat(AT_FDCWD, p.c_str(), TS.data(), 0) == -1) {
+ ec = capture_errno();
+ return true;
+ }
+ return false;
+}
+#endif
+
+bool set_file_times(const path& p, std::array<TimeSpec, 2> const& TS,
+ error_code& ec) {
+#if !defined(_LIBCPP_USE_UTIMENSAT)
+ return posix_utimes(p, TS, ec);
+#else
+ return posix_utimensat(p, TS, ec);
+#endif
+}
+
+#if defined(DT_BLK)
+template <class DirEntT, class = decltype(DirEntT::d_type)>
+static file_type get_file_type(DirEntT* ent, int) {
+ switch (ent->d_type) {
+ case DT_BLK:
+ return file_type::block;
+ case DT_CHR:
+ return file_type::character;
+ case DT_DIR:
+ return file_type::directory;
+ case DT_FIFO:
+ return file_type::fifo;
+ case DT_LNK:
+ return file_type::symlink;
+ case DT_REG:
+ return file_type::regular;
+ case DT_SOCK:
+ return file_type::socket;
+ // Unlike in lstat, hitting "unknown" here simply means that the underlying
+ // filesystem doesn't support d_type. Report is as 'none' so we correctly
+ // set the cache to empty.
+ case DT_UNKNOWN:
+ break;
+ }
+ return file_type::none;
+}
+#endif // defined(DT_BLK)
+
+template <class DirEntT>
+static file_type get_file_type(DirEntT*, long) {
+ return file_type::none;
+}
+
+static pair<string_view, file_type> posix_readdir(DIR* dir_stream,
+ error_code& ec) {
+ struct dirent* dir_entry_ptr = nullptr;
+ errno = 0; // zero errno in order to detect errors
+ ec.clear();
+ if ((dir_entry_ptr = ::readdir(dir_stream)) == nullptr) {
+ if (errno)
+ ec = capture_errno();
+ return {};
+ } else {
+ return {dir_entry_ptr->d_name, get_file_type(dir_entry_ptr, 0)};
+ }
+}
+
+#else // _LIBCPP_WIN32API
+
+static file_type get_file_type(const WIN32_FIND_DATAW& data) {
+ if (data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT &&
+ data.dwReserved0 == IO_REPARSE_TAG_SYMLINK)
+ return file_type::symlink;
+ if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ return file_type::directory;
+ return file_type::regular;
+}
+static uintmax_t get_file_size(const WIN32_FIND_DATAW& data) {
+ return (static_cast<uint64_t>(data.nFileSizeHigh) << 32) + data.nFileSizeLow;
+}
+static file_time_type get_write_time(const WIN32_FIND_DATAW& data) {
+ ULARGE_INTEGER tmp;
+ const FILETIME& time = data.ftLastWriteTime;
+ tmp.u.LowPart = time.dwLowDateTime;
+ tmp.u.HighPart = time.dwHighDateTime;
+ return file_time_type(file_time_type::duration(tmp.QuadPart));
+}
+
+#endif // !_LIBCPP_WIN32API
+
+} // namespace
+} // end namespace detail
+
+_LIBCPP_END_NAMESPACE_FILESYSTEM
+
+#endif // FILESYSTEM_COMMON_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/filesystem/operations.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/filesystem/operations.cpp
new file mode 100644
index 0000000000..9e0abc83b1
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/filesystem/operations.cpp
@@ -0,0 +1,2104 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <__assert>
+#include <__utility/unreachable.h>
+#include <array>
+#include <climits>
+#include <cstdlib>
+#include <filesystem>
+#include <iterator>
+#include <string_view>
+#include <type_traits>
+#include <vector>
+
+#include "filesystem_common.h"
+
+#include "posix_compat.h"
+
+#if defined(_LIBCPP_WIN32API)
+# define WIN32_LEAN_AND_MEAN
+# define NOMINMAX
+# include <windows.h>
+#else
+# include <dirent.h>
+# include <sys/stat.h>
+# include <sys/statvfs.h>
+# include <unistd.h>
+#endif
+#include <time.h>
+#include <fcntl.h> /* values for fchmodat */
+
+#if __has_include(<sys/sendfile.h>)
+# include <sys/sendfile.h>
+# define _LIBCPP_FILESYSTEM_USE_SENDFILE
+#elif defined(__APPLE__) || __has_include(<copyfile.h>)
+# include <copyfile.h>
+# define _LIBCPP_FILESYSTEM_USE_COPYFILE
+#else
+# include <fstream>
+# define _LIBCPP_FILESYSTEM_USE_FSTREAM
+#endif
+
+#if !defined(CLOCK_REALTIME) && !defined(_LIBCPP_WIN32API)
+# include <sys/time.h> // for gettimeofday and timeval
+#endif
+
+#if defined(__ELF__) && defined(_LIBCPP_LINK_RT_LIB)
+# pragma comment(lib, "rt")
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
+
+namespace {
+
+bool isSeparator(path::value_type C) {
+ if (C == '/')
+ return true;
+#if defined(_LIBCPP_WIN32API)
+ if (C == '\\')
+ return true;
+#endif
+ return false;
+}
+
+bool isDriveLetter(path::value_type C) {
+ return (C >= 'a' && C <= 'z') || (C >= 'A' && C <= 'Z');
+}
+
+namespace parser {
+
+using string_view_t = path::__string_view;
+using string_view_pair = pair<string_view_t, string_view_t>;
+using PosPtr = path::value_type const*;
+
+struct PathParser {
+ enum ParserState : unsigned char {
+ // Zero is a special sentinel value used by default constructed iterators.
+ PS_BeforeBegin = path::iterator::_BeforeBegin,
+ PS_InRootName = path::iterator::_InRootName,
+ PS_InRootDir = path::iterator::_InRootDir,
+ PS_InFilenames = path::iterator::_InFilenames,
+ PS_InTrailingSep = path::iterator::_InTrailingSep,
+ PS_AtEnd = path::iterator::_AtEnd
+ };
+
+ const string_view_t Path;
+ string_view_t RawEntry;
+ ParserState State;
+
+private:
+ PathParser(string_view_t P, ParserState State) noexcept : Path(P),
+ State(State) {}
+
+public:
+ PathParser(string_view_t P, string_view_t E, unsigned char S)
+ : Path(P), RawEntry(E), State(static_cast<ParserState>(S)) {
+ // S cannot be '0' or PS_BeforeBegin.
+ }
+
+ static PathParser CreateBegin(string_view_t P) noexcept {
+ PathParser PP(P, PS_BeforeBegin);
+ PP.increment();
+ return PP;
+ }
+
+ static PathParser CreateEnd(string_view_t P) noexcept {
+ PathParser PP(P, PS_AtEnd);
+ return PP;
+ }
+
+ PosPtr peek() const noexcept {
+ auto TkEnd = getNextTokenStartPos();
+ auto End = getAfterBack();
+ return TkEnd == End ? nullptr : TkEnd;
+ }
+
+ void increment() noexcept {
+ const PosPtr End = getAfterBack();
+ const PosPtr Start = getNextTokenStartPos();
+ if (Start == End)
+ return makeState(PS_AtEnd);
+
+ switch (State) {
+ case PS_BeforeBegin: {
+ PosPtr TkEnd = consumeRootName(Start, End);
+ if (TkEnd)
+ return makeState(PS_InRootName, Start, TkEnd);
+ }
+ _LIBCPP_FALLTHROUGH();
+ case PS_InRootName: {
+ PosPtr TkEnd = consumeAllSeparators(Start, End);
+ if (TkEnd)
+ return makeState(PS_InRootDir, Start, TkEnd);
+ else
+ return makeState(PS_InFilenames, Start, consumeName(Start, End));
+ }
+ case PS_InRootDir:
+ return makeState(PS_InFilenames, Start, consumeName(Start, End));
+
+ case PS_InFilenames: {
+ PosPtr SepEnd = consumeAllSeparators(Start, End);
+ if (SepEnd != End) {
+ PosPtr TkEnd = consumeName(SepEnd, End);
+ if (TkEnd)
+ return makeState(PS_InFilenames, SepEnd, TkEnd);
+ }
+ return makeState(PS_InTrailingSep, Start, SepEnd);
+ }
+
+ case PS_InTrailingSep:
+ return makeState(PS_AtEnd);
+
+ case PS_AtEnd:
+ __libcpp_unreachable();
+ }
+ }
+
+ void decrement() noexcept {
+ const PosPtr REnd = getBeforeFront();
+ const PosPtr RStart = getCurrentTokenStartPos() - 1;
+ if (RStart == REnd) // we're decrementing the begin
+ return makeState(PS_BeforeBegin);
+
+ switch (State) {
+ case PS_AtEnd: {
+ // Try to consume a trailing separator or root directory first.
+ if (PosPtr SepEnd = consumeAllSeparators(RStart, REnd)) {
+ if (SepEnd == REnd)
+ return makeState(PS_InRootDir, Path.data(), RStart + 1);
+ PosPtr TkStart = consumeRootName(SepEnd, REnd);
+ if (TkStart == REnd)
+ return makeState(PS_InRootDir, RStart, RStart + 1);
+ return makeState(PS_InTrailingSep, SepEnd + 1, RStart + 1);
+ } else {
+ PosPtr TkStart = consumeRootName(RStart, REnd);
+ if (TkStart == REnd)
+ return makeState(PS_InRootName, TkStart + 1, RStart + 1);
+ TkStart = consumeName(RStart, REnd);
+ return makeState(PS_InFilenames, TkStart + 1, RStart + 1);
+ }
+ }
+ case PS_InTrailingSep:
+ return makeState(PS_InFilenames, consumeName(RStart, REnd) + 1,
+ RStart + 1);
+ case PS_InFilenames: {
+ PosPtr SepEnd = consumeAllSeparators(RStart, REnd);
+ if (SepEnd == REnd)
+ return makeState(PS_InRootDir, Path.data(), RStart + 1);
+ PosPtr TkStart = consumeRootName(SepEnd ? SepEnd : RStart, REnd);
+ if (TkStart == REnd) {
+ if (SepEnd)
+ return makeState(PS_InRootDir, SepEnd + 1, RStart + 1);
+ return makeState(PS_InRootName, TkStart + 1, RStart + 1);
+ }
+ TkStart = consumeName(SepEnd, REnd);
+ return makeState(PS_InFilenames, TkStart + 1, SepEnd + 1);
+ }
+ case PS_InRootDir:
+ return makeState(PS_InRootName, Path.data(), RStart + 1);
+ case PS_InRootName:
+ case PS_BeforeBegin:
+ __libcpp_unreachable();
+ }
+ }
+
+ /// \brief Return a view with the "preferred representation" of the current
+ /// element. For example trailing separators are represented as a '.'
+ string_view_t operator*() const noexcept {
+ switch (State) {
+ case PS_BeforeBegin:
+ case PS_AtEnd:
+ return PS("");
+ case PS_InRootDir:
+ if (RawEntry[0] == '\\')
+ return PS("\\");
+ else
+ return PS("/");
+ case PS_InTrailingSep:
+ return PS("");
+ case PS_InRootName:
+ case PS_InFilenames:
+ return RawEntry;
+ }
+ __libcpp_unreachable();
+ }
+
+ explicit operator bool() const noexcept {
+ return State != PS_BeforeBegin && State != PS_AtEnd;
+ }
+
+ PathParser& operator++() noexcept {
+ increment();
+ return *this;
+ }
+
+ PathParser& operator--() noexcept {
+ decrement();
+ return *this;
+ }
+
+ bool atEnd() const noexcept {
+ return State == PS_AtEnd;
+ }
+
+ bool inRootDir() const noexcept {
+ return State == PS_InRootDir;
+ }
+
+ bool inRootName() const noexcept {
+ return State == PS_InRootName;
+ }
+
+ bool inRootPath() const noexcept {
+ return inRootName() || inRootDir();
+ }
+
+private:
+ void makeState(ParserState NewState, PosPtr Start, PosPtr End) noexcept {
+ State = NewState;
+ RawEntry = string_view_t(Start, End - Start);
+ }
+ void makeState(ParserState NewState) noexcept {
+ State = NewState;
+ RawEntry = {};
+ }
+
+ PosPtr getAfterBack() const noexcept { return Path.data() + Path.size(); }
+
+ PosPtr getBeforeFront() const noexcept { return Path.data() - 1; }
+
+ /// \brief Return a pointer to the first character after the currently
+ /// lexed element.
+ PosPtr getNextTokenStartPos() const noexcept {
+ switch (State) {
+ case PS_BeforeBegin:
+ return Path.data();
+ case PS_InRootName:
+ case PS_InRootDir:
+ case PS_InFilenames:
+ return &RawEntry.back() + 1;
+ case PS_InTrailingSep:
+ case PS_AtEnd:
+ return getAfterBack();
+ }
+ __libcpp_unreachable();
+ }
+
+ /// \brief Return a pointer to the first character in the currently lexed
+ /// element.
+ PosPtr getCurrentTokenStartPos() const noexcept {
+ switch (State) {
+ case PS_BeforeBegin:
+ case PS_InRootName:
+ return &Path.front();
+ case PS_InRootDir:
+ case PS_InFilenames:
+ case PS_InTrailingSep:
+ return &RawEntry.front();
+ case PS_AtEnd:
+ return &Path.back() + 1;
+ }
+ __libcpp_unreachable();
+ }
+
+ // Consume all consecutive separators.
+ PosPtr consumeAllSeparators(PosPtr P, PosPtr End) const noexcept {
+ if (P == nullptr || P == End || !isSeparator(*P))
+ return nullptr;
+ const int Inc = P < End ? 1 : -1;
+ P += Inc;
+ while (P != End && isSeparator(*P))
+ P += Inc;
+ return P;
+ }
+
+ // Consume exactly N separators, or return nullptr.
+ PosPtr consumeNSeparators(PosPtr P, PosPtr End, int N) const noexcept {
+ PosPtr Ret = consumeAllSeparators(P, End);
+ if (Ret == nullptr)
+ return nullptr;
+ if (P < End) {
+ if (Ret == P + N)
+ return Ret;
+ } else {
+ if (Ret == P - N)
+ return Ret;
+ }
+ return nullptr;
+ }
+
+ PosPtr consumeName(PosPtr P, PosPtr End) const noexcept {
+ PosPtr Start = P;
+ if (P == nullptr || P == End || isSeparator(*P))
+ return nullptr;
+ const int Inc = P < End ? 1 : -1;
+ P += Inc;
+ while (P != End && !isSeparator(*P))
+ P += Inc;
+ if (P == End && Inc < 0) {
+ // Iterating backwards and consumed all the rest of the input.
+ // Check if the start of the string would have been considered
+ // a root name.
+ PosPtr RootEnd = consumeRootName(End + 1, Start);
+ if (RootEnd)
+ return RootEnd - 1;
+ }
+ return P;
+ }
+
+ PosPtr consumeDriveLetter(PosPtr P, PosPtr End) const noexcept {
+ if (P == End)
+ return nullptr;
+ if (P < End) {
+ if (P + 1 == End || !isDriveLetter(P[0]) || P[1] != ':')
+ return nullptr;
+ return P + 2;
+ } else {
+ if (P - 1 == End || !isDriveLetter(P[-1]) || P[0] != ':')
+ return nullptr;
+ return P - 2;
+ }
+ }
+
+ PosPtr consumeNetworkRoot(PosPtr P, PosPtr End) const noexcept {
+ if (P == End)
+ return nullptr;
+ if (P < End)
+ return consumeName(consumeNSeparators(P, End, 2), End);
+ else
+ return consumeNSeparators(consumeName(P, End), End, 2);
+ }
+
+#if defined(_LIBCPP_WIN32API)
+ PosPtr consumeRootName(PosPtr P, PosPtr End) const noexcept {
+ if (PosPtr Ret = consumeDriveLetter(P, End))
+ return Ret;
+ if (PosPtr Ret = consumeNetworkRoot(P, End))
+ return Ret;
+ return nullptr;
+ }
+#else
+ PosPtr consumeRootName(PosPtr /*P*/, PosPtr /*End*/) const noexcept {
+ return nullptr;
+ }
+#endif
+};
+
+string_view_pair separate_filename(string_view_t const& s) {
+ if (s == PS(".") || s == PS("..") || s.empty())
+ return string_view_pair{s, PS("")};
+ auto pos = s.find_last_of('.');
+ if (pos == string_view_t::npos || pos == 0)
+ return string_view_pair{s, string_view_t{}};
+ return string_view_pair{s.substr(0, pos), s.substr(pos)};
+}
+
+string_view_t createView(PosPtr S, PosPtr E) noexcept {
+ return {S, static_cast<size_t>(E - S) + 1};
+}
+
+} // namespace parser
+} // namespace
+
+// POSIX HELPERS
+
+#if defined(_LIBCPP_WIN32API)
+namespace detail {
+
+errc __win_err_to_errc(int err) {
+ constexpr struct {
+ DWORD win;
+ errc errc;
+ } win_error_mapping[] = {
+ {ERROR_ACCESS_DENIED, errc::permission_denied},
+ {ERROR_ALREADY_EXISTS, errc::file_exists},
+ {ERROR_BAD_NETPATH, errc::no_such_file_or_directory},
+ {ERROR_BAD_PATHNAME, errc::no_such_file_or_directory},
+ {ERROR_BAD_UNIT, errc::no_such_device},
+ {ERROR_BROKEN_PIPE, errc::broken_pipe},
+ {ERROR_BUFFER_OVERFLOW, errc::filename_too_long},
+ {ERROR_BUSY, errc::device_or_resource_busy},
+ {ERROR_BUSY_DRIVE, errc::device_or_resource_busy},
+ {ERROR_CANNOT_MAKE, errc::permission_denied},
+ {ERROR_CANTOPEN, errc::io_error},
+ {ERROR_CANTREAD, errc::io_error},
+ {ERROR_CANTWRITE, errc::io_error},
+ {ERROR_CURRENT_DIRECTORY, errc::permission_denied},
+ {ERROR_DEV_NOT_EXIST, errc::no_such_device},
+ {ERROR_DEVICE_IN_USE, errc::device_or_resource_busy},
+ {ERROR_DIR_NOT_EMPTY, errc::directory_not_empty},
+ {ERROR_DIRECTORY, errc::invalid_argument},
+ {ERROR_DISK_FULL, errc::no_space_on_device},
+ {ERROR_FILE_EXISTS, errc::file_exists},
+ {ERROR_FILE_NOT_FOUND, errc::no_such_file_or_directory},
+ {ERROR_HANDLE_DISK_FULL, errc::no_space_on_device},
+ {ERROR_INVALID_ACCESS, errc::permission_denied},
+ {ERROR_INVALID_DRIVE, errc::no_such_device},
+ {ERROR_INVALID_FUNCTION, errc::function_not_supported},
+ {ERROR_INVALID_HANDLE, errc::invalid_argument},
+ {ERROR_INVALID_NAME, errc::no_such_file_or_directory},
+ {ERROR_INVALID_PARAMETER, errc::invalid_argument},
+ {ERROR_LOCK_VIOLATION, errc::no_lock_available},
+ {ERROR_LOCKED, errc::no_lock_available},
+ {ERROR_NEGATIVE_SEEK, errc::invalid_argument},
+ {ERROR_NOACCESS, errc::permission_denied},
+ {ERROR_NOT_ENOUGH_MEMORY, errc::not_enough_memory},
+ {ERROR_NOT_READY, errc::resource_unavailable_try_again},
+ {ERROR_NOT_SAME_DEVICE, errc::cross_device_link},
+ {ERROR_NOT_SUPPORTED, errc::not_supported},
+ {ERROR_OPEN_FAILED, errc::io_error},
+ {ERROR_OPEN_FILES, errc::device_or_resource_busy},
+ {ERROR_OPERATION_ABORTED, errc::operation_canceled},
+ {ERROR_OUTOFMEMORY, errc::not_enough_memory},
+ {ERROR_PATH_NOT_FOUND, errc::no_such_file_or_directory},
+ {ERROR_READ_FAULT, errc::io_error},
+ {ERROR_REPARSE_TAG_INVALID, errc::invalid_argument},
+ {ERROR_RETRY, errc::resource_unavailable_try_again},
+ {ERROR_SEEK, errc::io_error},
+ {ERROR_SHARING_VIOLATION, errc::permission_denied},
+ {ERROR_TOO_MANY_OPEN_FILES, errc::too_many_files_open},
+ {ERROR_WRITE_FAULT, errc::io_error},
+ {ERROR_WRITE_PROTECT, errc::permission_denied},
+ };
+
+ for (const auto &pair : win_error_mapping)
+ if (pair.win == static_cast<DWORD>(err))
+ return pair.errc;
+ return errc::invalid_argument;
+}
+
+} // namespace detail
+#endif
+
+namespace detail {
+namespace {
+
+using value_type = path::value_type;
+using string_type = path::string_type;
+
+struct FileDescriptor {
+ const path& name;
+ int fd = -1;
+ StatT m_stat;
+ file_status m_status;
+
+ template <class... Args>
+ static FileDescriptor create(const path* p, error_code& ec, Args... args) {
+ ec.clear();
+ int fd;
+ if ((fd = detail::open(p->c_str(), args...)) == -1) {
+ ec = capture_errno();
+ return FileDescriptor{p};
+ }
+ return FileDescriptor(p, fd);
+ }
+
+ template <class... Args>
+ static FileDescriptor create_with_status(const path* p, error_code& ec,
+ Args... args) {
+ FileDescriptor fd = create(p, ec, args...);
+ if (!ec)
+ fd.refresh_status(ec);
+
+ return fd;
+ }
+
+ file_status get_status() const { return m_status; }
+ StatT const& get_stat() const { return m_stat; }
+
+ bool status_known() const { return _VSTD_FS::status_known(m_status); }
+
+ file_status refresh_status(error_code& ec);
+
+ void close() noexcept {
+ if (fd != -1)
+ detail::close(fd);
+ fd = -1;
+ }
+
+ FileDescriptor(FileDescriptor&& other)
+ : name(other.name), fd(other.fd), m_stat(other.m_stat),
+ m_status(other.m_status) {
+ other.fd = -1;
+ other.m_status = file_status{};
+ }
+
+ ~FileDescriptor() { close(); }
+
+ FileDescriptor(FileDescriptor const&) = delete;
+ FileDescriptor& operator=(FileDescriptor const&) = delete;
+
+private:
+ explicit FileDescriptor(const path* p, int fd = -1) : name(*p), fd(fd) {}
+};
+
+perms posix_get_perms(const StatT& st) noexcept {
+ return static_cast<perms>(st.st_mode) & perms::mask;
+}
+
+file_status create_file_status(error_code& m_ec, path const& p,
+ const StatT& path_stat, error_code* ec) {
+ if (ec)
+ *ec = m_ec;
+ if (m_ec && (m_ec.value() == ENOENT || m_ec.value() == ENOTDIR)) {
+ return file_status(file_type::not_found);
+ } else if (m_ec) {
+ ErrorHandler<void> err("posix_stat", ec, &p);
+ err.report(m_ec, "failed to determine attributes for the specified path");
+ return file_status(file_type::none);
+ }
+ // else
+
+ file_status fs_tmp;
+ auto const mode = path_stat.st_mode;
+ if (S_ISLNK(mode))
+ fs_tmp.type(file_type::symlink);
+ else if (S_ISREG(mode))
+ fs_tmp.type(file_type::regular);
+ else if (S_ISDIR(mode))
+ fs_tmp.type(file_type::directory);
+ else if (S_ISBLK(mode))
+ fs_tmp.type(file_type::block);
+ else if (S_ISCHR(mode))
+ fs_tmp.type(file_type::character);
+ else if (S_ISFIFO(mode))
+ fs_tmp.type(file_type::fifo);
+ else if (S_ISSOCK(mode))
+ fs_tmp.type(file_type::socket);
+ else
+ fs_tmp.type(file_type::unknown);
+
+ fs_tmp.permissions(detail::posix_get_perms(path_stat));
+ return fs_tmp;
+}
+
+file_status posix_stat(path const& p, StatT& path_stat, error_code* ec) {
+ error_code m_ec;
+ if (detail::stat(p.c_str(), &path_stat) == -1)
+ m_ec = detail::capture_errno();
+ return create_file_status(m_ec, p, path_stat, ec);
+}
+
+file_status posix_stat(path const& p, error_code* ec) {
+ StatT path_stat;
+ return posix_stat(p, path_stat, ec);
+}
+
+file_status posix_lstat(path const& p, StatT& path_stat, error_code* ec) {
+ error_code m_ec;
+ if (detail::lstat(p.c_str(), &path_stat) == -1)
+ m_ec = detail::capture_errno();
+ return create_file_status(m_ec, p, path_stat, ec);
+}
+
+file_status posix_lstat(path const& p, error_code* ec) {
+ StatT path_stat;
+ return posix_lstat(p, path_stat, ec);
+}
+
+// http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html
+bool posix_ftruncate(const FileDescriptor& fd, off_t to_size, error_code& ec) {
+ if (detail::ftruncate(fd.fd, to_size) == -1) {
+ ec = capture_errno();
+ return true;
+ }
+ ec.clear();
+ return false;
+}
+
+bool posix_fchmod(const FileDescriptor& fd, const StatT& st, error_code& ec) {
+ if (detail::fchmod(fd.fd, st.st_mode) == -1) {
+ ec = capture_errno();
+ return true;
+ }
+ ec.clear();
+ return false;
+}
+
+bool stat_equivalent(const StatT& st1, const StatT& st2) {
+ return (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino);
+}
+
+file_status FileDescriptor::refresh_status(error_code& ec) {
+ // FD must be open and good.
+ m_status = file_status{};
+ m_stat = {};
+ error_code m_ec;
+ if (detail::fstat(fd, &m_stat) == -1)
+ m_ec = capture_errno();
+ m_status = create_file_status(m_ec, name, m_stat, &ec);
+ return m_status;
+}
+} // namespace
+} // end namespace detail
+
+using detail::capture_errno;
+using detail::ErrorHandler;
+using detail::StatT;
+using detail::TimeSpec;
+using parser::createView;
+using parser::PathParser;
+using parser::string_view_t;
+
+const bool _FilesystemClock::is_steady;
+
+_FilesystemClock::time_point _FilesystemClock::now() noexcept {
+ typedef chrono::duration<rep> __secs;
+#if defined(_LIBCPP_WIN32API)
+ typedef chrono::duration<rep, nano> __nsecs;
+ FILETIME time;
+ GetSystemTimeAsFileTime(&time);
+ TimeSpec tp = detail::filetime_to_timespec(time);
+ return time_point(__secs(tp.tv_sec) +
+ chrono::duration_cast<duration>(__nsecs(tp.tv_nsec)));
+#elif defined(CLOCK_REALTIME)
+ typedef chrono::duration<rep, nano> __nsecs;
+ struct timespec tp;
+ if (0 != clock_gettime(CLOCK_REALTIME, &tp))
+ __throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed");
+ return time_point(__secs(tp.tv_sec) +
+ chrono::duration_cast<duration>(__nsecs(tp.tv_nsec)));
+#else
+ typedef chrono::duration<rep, micro> __microsecs;
+ timeval tv;
+ gettimeofday(&tv, 0);
+ return time_point(__secs(tv.tv_sec) + __microsecs(tv.tv_usec));
+#endif // CLOCK_REALTIME
+}
+
+filesystem_error::~filesystem_error() {}
+
+void filesystem_error::__create_what(int __num_paths) {
+ const char* derived_what = system_error::what();
+ __storage_->__what_ = [&]() -> string {
+ switch (__num_paths) {
+ case 0:
+ return detail::format_string("filesystem error: %s", derived_what);
+ case 1:
+ return detail::format_string("filesystem error: %s [" PATH_CSTR_FMT "]",
+ derived_what, path1().c_str());
+ case 2:
+ return detail::format_string("filesystem error: %s [" PATH_CSTR_FMT "] [" PATH_CSTR_FMT "]",
+ derived_what, path1().c_str(), path2().c_str());
+ }
+ __libcpp_unreachable();
+ }();
+}
+
+static path __do_absolute(const path& p, path* cwd, error_code* ec) {
+ if (ec)
+ ec->clear();
+ if (p.is_absolute())
+ return p;
+ *cwd = __current_path(ec);
+ if (ec && *ec)
+ return {};
+ return (*cwd) / p;
+}
+
+path __absolute(const path& p, error_code* ec) {
+ path cwd;
+ return __do_absolute(p, &cwd, ec);
+}
+
+path __canonical(path const& orig_p, error_code* ec) {
+ path cwd;
+ ErrorHandler<path> err("canonical", ec, &orig_p, &cwd);
+
+ path p = __do_absolute(orig_p, &cwd, ec);
+#if (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112) || defined(_LIBCPP_WIN32API)
+ std::unique_ptr<path::value_type, decltype(&::free)>
+ hold(detail::realpath(p.c_str(), nullptr), &::free);
+ if (hold.get() == nullptr)
+ return err.report(capture_errno());
+ return {hold.get()};
+#else
+ #if defined(__MVS__) && !defined(PATH_MAX)
+ path::value_type buff[ _XOPEN_PATH_MAX + 1 ];
+ #else
+ path::value_type buff[PATH_MAX + 1];
+ #endif
+ path::value_type* ret;
+ if ((ret = detail::realpath(p.c_str(), buff)) == nullptr)
+ return err.report(capture_errno());
+ return {ret};
+#endif
+}
+
+void __copy(const path& from, const path& to, copy_options options,
+ error_code* ec) {
+ ErrorHandler<void> err("copy", ec, &from, &to);
+
+ const bool sym_status = bool(
+ options & (copy_options::create_symlinks | copy_options::skip_symlinks));
+
+ const bool sym_status2 = bool(options & copy_options::copy_symlinks);
+
+ error_code m_ec1;
+ StatT f_st = {};
+ const file_status f = sym_status || sym_status2
+ ? detail::posix_lstat(from, f_st, &m_ec1)
+ : detail::posix_stat(from, f_st, &m_ec1);
+ if (m_ec1)
+ return err.report(m_ec1);
+
+ StatT t_st = {};
+ const file_status t = sym_status ? detail::posix_lstat(to, t_st, &m_ec1)
+ : detail::posix_stat(to, t_st, &m_ec1);
+
+ if (not status_known(t))
+ return err.report(m_ec1);
+
+ if (!exists(f) || is_other(f) || is_other(t) ||
+ (is_directory(f) && is_regular_file(t)) ||
+ detail::stat_equivalent(f_st, t_st)) {
+ return err.report(errc::function_not_supported);
+ }
+
+ if (ec)
+ ec->clear();
+
+ if (is_symlink(f)) {
+ if (bool(copy_options::skip_symlinks & options)) {
+ // do nothing
+ } else if (not exists(t)) {
+ __copy_symlink(from, to, ec);
+ } else {
+ return err.report(errc::file_exists);
+ }
+ return;
+ } else if (is_regular_file(f)) {
+ if (bool(copy_options::directories_only & options)) {
+ // do nothing
+ } else if (bool(copy_options::create_symlinks & options)) {
+ __create_symlink(from, to, ec);
+ } else if (bool(copy_options::create_hard_links & options)) {
+ __create_hard_link(from, to, ec);
+ } else if (is_directory(t)) {
+ __copy_file(from, to / from.filename(), options, ec);
+ } else {
+ __copy_file(from, to, options, ec);
+ }
+ return;
+ } else if (is_directory(f) && bool(copy_options::create_symlinks & options)) {
+ return err.report(errc::is_a_directory);
+ } else if (is_directory(f) && (bool(copy_options::recursive & options) ||
+ copy_options::none == options)) {
+
+ if (!exists(t)) {
+ // create directory to with attributes from 'from'.
+ __create_directory(to, from, ec);
+ if (ec && *ec) {
+ return;
+ }
+ }
+ directory_iterator it =
+ ec ? directory_iterator(from, *ec) : directory_iterator(from);
+ if (ec && *ec) {
+ return;
+ }
+ error_code m_ec2;
+ for (; it != directory_iterator(); it.increment(m_ec2)) {
+ if (m_ec2) {
+ return err.report(m_ec2);
+ }
+ __copy(it->path(), to / it->path().filename(),
+ options | copy_options::__in_recursive_copy, ec);
+ if (ec && *ec) {
+ return;
+ }
+ }
+ }
+}
+
+namespace detail {
+namespace {
+
+#if defined(_LIBCPP_FILESYSTEM_USE_SENDFILE)
+ bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_code& ec) {
+ size_t count = read_fd.get_stat().st_size;
+ do {
+ ssize_t res;
+ if ((res = ::sendfile(write_fd.fd, read_fd.fd, nullptr, count)) == -1) {
+ ec = capture_errno();
+ return false;
+ }
+ count -= res;
+ } while (count > 0);
+
+ ec.clear();
+
+ return true;
+ }
+#elif defined(_LIBCPP_FILESYSTEM_USE_COPYFILE)
+ bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_code& ec) {
+ struct CopyFileState {
+ copyfile_state_t state;
+ CopyFileState() { state = copyfile_state_alloc(); }
+ ~CopyFileState() { copyfile_state_free(state); }
+
+ private:
+ CopyFileState(CopyFileState const&) = delete;
+ CopyFileState& operator=(CopyFileState const&) = delete;
+ };
+
+ CopyFileState cfs;
+ if (fcopyfile(read_fd.fd, write_fd.fd, cfs.state, COPYFILE_DATA) < 0) {
+ ec = capture_errno();
+ return false;
+ }
+
+ ec.clear();
+ return true;
+ }
+#elif defined(_LIBCPP_FILESYSTEM_USE_FSTREAM)
+ bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_code& ec) {
+ ifstream in;
+ in.__open(read_fd.fd, ios::binary);
+ if (!in.is_open()) {
+ // This assumes that __open didn't reset the error code.
+ ec = capture_errno();
+ return false;
+ }
+ read_fd.fd = -1;
+ ofstream out;
+ out.__open(write_fd.fd, ios::binary);
+ if (!out.is_open()) {
+ ec = capture_errno();
+ return false;
+ }
+ write_fd.fd = -1;
+
+ if (in.good() && out.good()) {
+ using InIt = istreambuf_iterator<char>;
+ using OutIt = ostreambuf_iterator<char>;
+ InIt bin(in);
+ InIt ein;
+ OutIt bout(out);
+ copy(bin, ein, bout);
+ }
+ if (out.fail() || in.fail()) {
+ ec = make_error_code(errc::io_error);
+ return false;
+ }
+
+ ec.clear();
+ return true;
+ }
+#else
+# error "Unknown implementation for copy_file_impl"
+#endif // copy_file_impl implementation
+
+} // end anonymous namespace
+} // end namespace detail
+
+bool __copy_file(const path& from, const path& to, copy_options options,
+ error_code* ec) {
+ using detail::FileDescriptor;
+ ErrorHandler<bool> err("copy_file", ec, &to, &from);
+
+ error_code m_ec;
+ FileDescriptor from_fd = FileDescriptor::create_with_status(
+ &from, m_ec, O_RDONLY | O_NONBLOCK | O_BINARY);
+ if (m_ec)
+ return err.report(m_ec);
+
+ auto from_st = from_fd.get_status();
+ StatT const& from_stat = from_fd.get_stat();
+ if (!is_regular_file(from_st)) {
+ if (not m_ec)
+ m_ec = make_error_code(errc::not_supported);
+ return err.report(m_ec);
+ }
+
+ const bool skip_existing = bool(copy_options::skip_existing & options);
+ const bool update_existing = bool(copy_options::update_existing & options);
+ const bool overwrite_existing =
+ bool(copy_options::overwrite_existing & options);
+
+ StatT to_stat_path;
+ file_status to_st = detail::posix_stat(to, to_stat_path, &m_ec);
+ if (!status_known(to_st))
+ return err.report(m_ec);
+
+ const bool to_exists = exists(to_st);
+ if (to_exists && !is_regular_file(to_st))
+ return err.report(errc::not_supported);
+
+ if (to_exists && detail::stat_equivalent(from_stat, to_stat_path))
+ return err.report(errc::file_exists);
+
+ if (to_exists && skip_existing)
+ return false;
+
+ bool ShouldCopy = [&]() {
+ if (to_exists && update_existing) {
+ auto from_time = detail::extract_mtime(from_stat);
+ auto to_time = detail::extract_mtime(to_stat_path);
+ if (from_time.tv_sec < to_time.tv_sec)
+ return false;
+ if (from_time.tv_sec == to_time.tv_sec &&
+ from_time.tv_nsec <= to_time.tv_nsec)
+ return false;
+ return true;
+ }
+ if (!to_exists || overwrite_existing)
+ return true;
+ return err.report(errc::file_exists);
+ }();
+ if (!ShouldCopy)
+ return false;
+
+ // Don't truncate right away. We may not be opening the file we originally
+ // looked at; we'll check this later.
+ int to_open_flags = O_WRONLY | O_BINARY;
+ if (!to_exists)
+ to_open_flags |= O_CREAT;
+ FileDescriptor to_fd = FileDescriptor::create_with_status(
+ &to, m_ec, to_open_flags, from_stat.st_mode);
+ if (m_ec)
+ return err.report(m_ec);
+
+ if (to_exists) {
+ // Check that the file we initially stat'ed is equivalent to the one
+ // we opened.
+ // FIXME: report this better.
+ if (!detail::stat_equivalent(to_stat_path, to_fd.get_stat()))
+ return err.report(errc::bad_file_descriptor);
+
+ // Set the permissions and truncate the file we opened.
+ if (detail::posix_fchmod(to_fd, from_stat, m_ec))
+ return err.report(m_ec);
+ if (detail::posix_ftruncate(to_fd, 0, m_ec))
+ return err.report(m_ec);
+ }
+
+ if (!copy_file_impl(from_fd, to_fd, m_ec)) {
+ // FIXME: Remove the dest file if we failed, and it didn't exist previously.
+ return err.report(m_ec);
+ }
+
+ return true;
+}
+
+void __copy_symlink(const path& existing_symlink, const path& new_symlink,
+ error_code* ec) {
+ const path real_path(__read_symlink(existing_symlink, ec));
+ if (ec && *ec) {
+ return;
+ }
+#if defined(_LIBCPP_WIN32API)
+ error_code local_ec;
+ if (is_directory(real_path, local_ec))
+ __create_directory_symlink(real_path, new_symlink, ec);
+ else
+#endif
+ __create_symlink(real_path, new_symlink, ec);
+}
+
+bool __create_directories(const path& p, error_code* ec) {
+ ErrorHandler<bool> err("create_directories", ec, &p);
+
+ error_code m_ec;
+ auto const st = detail::posix_stat(p, &m_ec);
+ if (!status_known(st))
+ return err.report(m_ec);
+ else if (is_directory(st))
+ return false;
+ else if (exists(st))
+ return err.report(errc::file_exists);
+
+ const path parent = p.parent_path();
+ if (!parent.empty()) {
+ const file_status parent_st = status(parent, m_ec);
+ if (not status_known(parent_st))
+ return err.report(m_ec);
+ if (not exists(parent_st)) {
+ if (parent == p)
+ return err.report(errc::invalid_argument);
+ __create_directories(parent, ec);
+ if (ec && *ec) {
+ return false;
+ }
+ } else if (not is_directory(parent_st))
+ return err.report(errc::not_a_directory);
+ }
+ bool ret = __create_directory(p, &m_ec);
+ if (m_ec)
+ return err.report(m_ec);
+ return ret;
+}
+
+bool __create_directory(const path& p, error_code* ec) {
+ ErrorHandler<bool> err("create_directory", ec, &p);
+
+ if (detail::mkdir(p.c_str(), static_cast<int>(perms::all)) == 0)
+ return true;
+
+ if (errno != EEXIST)
+ return err.report(capture_errno());
+ error_code mec = capture_errno();
+ error_code ignored_ec;
+ const file_status st = status(p, ignored_ec);
+ if (!is_directory(st))
+ return err.report(mec);
+ return false;
+}
+
+bool __create_directory(path const& p, path const& attributes, error_code* ec) {
+ ErrorHandler<bool> err("create_directory", ec, &p, &attributes);
+
+ StatT attr_stat;
+ error_code mec;
+ file_status st = detail::posix_stat(attributes, attr_stat, &mec);
+ if (!status_known(st))
+ return err.report(mec);
+ if (!is_directory(st))
+ return err.report(errc::not_a_directory,
+ "the specified attribute path is invalid");
+
+ if (detail::mkdir(p.c_str(), attr_stat.st_mode) == 0)
+ return true;
+
+ if (errno != EEXIST)
+ return err.report(capture_errno());
+
+ mec = capture_errno();
+ error_code ignored_ec;
+ st = status(p, ignored_ec);
+ if (!is_directory(st))
+ return err.report(mec);
+ return false;
+}
+
+void __create_directory_symlink(path const& from, path const& to,
+ error_code* ec) {
+ ErrorHandler<void> err("create_directory_symlink", ec, &from, &to);
+ if (detail::symlink_dir(from.c_str(), to.c_str()) == -1)
+ return err.report(capture_errno());
+}
+
+void __create_hard_link(const path& from, const path& to, error_code* ec) {
+ ErrorHandler<void> err("create_hard_link", ec, &from, &to);
+ if (detail::link(from.c_str(), to.c_str()) == -1)
+ return err.report(capture_errno());
+}
+
+void __create_symlink(path const& from, path const& to, error_code* ec) {
+ ErrorHandler<void> err("create_symlink", ec, &from, &to);
+ if (detail::symlink_file(from.c_str(), to.c_str()) == -1)
+ return err.report(capture_errno());
+}
+
+path __current_path(error_code* ec) {
+ ErrorHandler<path> err("current_path", ec);
+
+#if defined(_LIBCPP_WIN32API) || defined(__GLIBC__) || defined(__APPLE__)
+ // Common extension outside of POSIX getcwd() spec, without needing to
+ // preallocate a buffer. Also supported by a number of other POSIX libcs.
+ int size = 0;
+ path::value_type* ptr = nullptr;
+ typedef decltype(&::free) Deleter;
+ Deleter deleter = &::free;
+#else
+ auto size = ::pathconf(".", _PC_PATH_MAX);
+ _LIBCPP_ASSERT(size >= 0, "pathconf returned a 0 as max size");
+
+ auto buff = unique_ptr<path::value_type[]>(new path::value_type[size + 1]);
+ path::value_type* ptr = buff.get();
+
+ // Preallocated buffer, don't free the buffer in the second unique_ptr
+ // below.
+ struct Deleter { void operator()(void*) const {} };
+ Deleter deleter;
+#endif
+
+ unique_ptr<path::value_type, Deleter> hold(detail::getcwd(ptr, size),
+ deleter);
+ if (hold.get() == nullptr)
+ return err.report(capture_errno(), "call to getcwd failed");
+
+ return {hold.get()};
+}
+
+void __current_path(const path& p, error_code* ec) {
+ ErrorHandler<void> err("current_path", ec, &p);
+ if (detail::chdir(p.c_str()) == -1)
+ err.report(capture_errno());
+}
+
+bool __equivalent(const path& p1, const path& p2, error_code* ec) {
+ ErrorHandler<bool> err("equivalent", ec, &p1, &p2);
+
+ error_code ec1, ec2;
+ StatT st1 = {}, st2 = {};
+ auto s1 = detail::posix_stat(p1.native(), st1, &ec1);
+ if (!exists(s1))
+ return err.report(errc::not_supported);
+ auto s2 = detail::posix_stat(p2.native(), st2, &ec2);
+ if (!exists(s2))
+ return err.report(errc::not_supported);
+
+ return detail::stat_equivalent(st1, st2);
+}
+
+uintmax_t __file_size(const path& p, error_code* ec) {
+ ErrorHandler<uintmax_t> err("file_size", ec, &p);
+
+ error_code m_ec;
+ StatT st;
+ file_status fst = detail::posix_stat(p, st, &m_ec);
+ if (!exists(fst) || !is_regular_file(fst)) {
+ errc error_kind =
+ is_directory(fst) ? errc::is_a_directory : errc::not_supported;
+ if (!m_ec)
+ m_ec = make_error_code(error_kind);
+ return err.report(m_ec);
+ }
+ // is_regular_file(p) == true
+ return static_cast<uintmax_t>(st.st_size);
+}
+
+uintmax_t __hard_link_count(const path& p, error_code* ec) {
+ ErrorHandler<uintmax_t> err("hard_link_count", ec, &p);
+
+ error_code m_ec;
+ StatT st;
+ detail::posix_stat(p, st, &m_ec);
+ if (m_ec)
+ return err.report(m_ec);
+ return static_cast<uintmax_t>(st.st_nlink);
+}
+
+bool __fs_is_empty(const path& p, error_code* ec) {
+ ErrorHandler<bool> err("is_empty", ec, &p);
+
+ error_code m_ec;
+ StatT pst;
+ auto st = detail::posix_stat(p, pst, &m_ec);
+ if (m_ec)
+ return err.report(m_ec);
+ else if (!is_directory(st) && !is_regular_file(st))
+ return err.report(errc::not_supported);
+ else if (is_directory(st)) {
+ auto it = ec ? directory_iterator(p, *ec) : directory_iterator(p);
+ if (ec && *ec)
+ return false;
+ return it == directory_iterator{};
+ } else if (is_regular_file(st))
+ return static_cast<uintmax_t>(pst.st_size) == 0;
+
+ __libcpp_unreachable();
+}
+
+static file_time_type __extract_last_write_time(const path& p, const StatT& st,
+ error_code* ec) {
+ using detail::fs_time;
+ ErrorHandler<file_time_type> err("last_write_time", ec, &p);
+
+ auto ts = detail::extract_mtime(st);
+ if (!fs_time::is_representable(ts))
+ return err.report(errc::value_too_large);
+
+ return fs_time::convert_from_timespec(ts);
+}
+
+file_time_type __last_write_time(const path& p, error_code* ec) {
+ using namespace chrono;
+ ErrorHandler<file_time_type> err("last_write_time", ec, &p);
+
+ error_code m_ec;
+ StatT st;
+ detail::posix_stat(p, st, &m_ec);
+ if (m_ec)
+ return err.report(m_ec);
+ return __extract_last_write_time(p, st, ec);
+}
+
+void __last_write_time(const path& p, file_time_type new_time, error_code* ec) {
+ using detail::fs_time;
+ ErrorHandler<void> err("last_write_time", ec, &p);
+
+#if defined(_LIBCPP_WIN32API)
+ TimeSpec ts;
+ if (!fs_time::convert_to_timespec(ts, new_time))
+ return err.report(errc::value_too_large);
+ detail::WinHandle h(p.c_str(), FILE_WRITE_ATTRIBUTES, 0);
+ if (!h)
+ return err.report(detail::make_windows_error(GetLastError()));
+ FILETIME last_write = timespec_to_filetime(ts);
+ if (!SetFileTime(h, nullptr, nullptr, &last_write))
+ return err.report(detail::make_windows_error(GetLastError()));
+#else
+ error_code m_ec;
+ array<TimeSpec, 2> tbuf;
+#if !defined(_LIBCPP_USE_UTIMENSAT)
+ // This implementation has a race condition between determining the
+ // last access time and attempting to set it to the same value using
+ // ::utimes
+ StatT st;
+ file_status fst = detail::posix_stat(p, st, &m_ec);
+ if (m_ec)
+ return err.report(m_ec);
+ tbuf[0] = detail::extract_atime(st);
+#else
+ tbuf[0].tv_sec = 0;
+ tbuf[0].tv_nsec = UTIME_OMIT;
+#endif
+ if (!fs_time::convert_to_timespec(tbuf[1], new_time))
+ return err.report(errc::value_too_large);
+
+ detail::set_file_times(p, tbuf, m_ec);
+ if (m_ec)
+ return err.report(m_ec);
+#endif
+}
+
+void __permissions(const path& p, perms prms, perm_options opts,
+ error_code* ec) {
+ ErrorHandler<void> err("permissions", ec, &p);
+
+ auto has_opt = [&](perm_options o) { return bool(o & opts); };
+ const bool resolve_symlinks = !has_opt(perm_options::nofollow);
+ const bool add_perms = has_opt(perm_options::add);
+ const bool remove_perms = has_opt(perm_options::remove);
+ _LIBCPP_ASSERT(
+ (add_perms + remove_perms + has_opt(perm_options::replace)) == 1,
+ "One and only one of the perm_options constants replace, add, or remove "
+ "is present in opts");
+
+ bool set_sym_perms = false;
+ prms &= perms::mask;
+ if (!resolve_symlinks || (add_perms || remove_perms)) {
+ error_code m_ec;
+ file_status st = resolve_symlinks ? detail::posix_stat(p, &m_ec)
+ : detail::posix_lstat(p, &m_ec);
+ set_sym_perms = is_symlink(st);
+ if (m_ec)
+ return err.report(m_ec);
+ _LIBCPP_ASSERT(st.permissions() != perms::unknown,
+ "Permissions unexpectedly unknown");
+ if (add_perms)
+ prms |= st.permissions();
+ else if (remove_perms)
+ prms = st.permissions() & ~prms;
+ }
+ const auto real_perms = static_cast<detail::ModeT>(prms & perms::mask);
+
+#if defined(AT_SYMLINK_NOFOLLOW) && defined(AT_FDCWD)
+ const int flags = set_sym_perms ? AT_SYMLINK_NOFOLLOW : 0;
+ if (detail::fchmodat(AT_FDCWD, p.c_str(), real_perms, flags) == -1) {
+ return err.report(capture_errno());
+ }
+#else
+ if (set_sym_perms)
+ return err.report(errc::operation_not_supported);
+ if (::chmod(p.c_str(), real_perms) == -1) {
+ return err.report(capture_errno());
+ }
+#endif
+}
+
+path __read_symlink(const path& p, error_code* ec) {
+ ErrorHandler<path> err("read_symlink", ec, &p);
+
+#if defined(PATH_MAX) || defined(MAX_SYMLINK_SIZE)
+ struct NullDeleter { void operator()(void*) const {} };
+#ifdef MAX_SYMLINK_SIZE
+ const size_t size = MAX_SYMLINK_SIZE + 1;
+#else
+ const size_t size = PATH_MAX + 1;
+#endif
+ path::value_type stack_buff[size];
+ auto buff = std::unique_ptr<path::value_type[], NullDeleter>(stack_buff);
+#else
+ StatT sb;
+ if (detail::lstat(p.c_str(), &sb) == -1) {
+ return err.report(capture_errno());
+ }
+ const size_t size = sb.st_size + 1;
+ auto buff = unique_ptr<path::value_type[]>(new path::value_type[size]);
+#endif
+ detail::SSizeT ret;
+ if ((ret = detail::readlink(p.c_str(), buff.get(), size)) == -1)
+ return err.report(capture_errno());
+ _LIBCPP_ASSERT(ret > 0, "TODO");
+ if (static_cast<size_t>(ret) >= size)
+ return err.report(errc::value_too_large);
+ buff[ret] = 0;
+ return {buff.get()};
+}
+
+bool __remove(const path& p, error_code* ec) {
+ ErrorHandler<bool> err("remove", ec, &p);
+ if (detail::remove(p.c_str()) == -1) {
+ if (errno != ENOENT)
+ err.report(capture_errno());
+ return false;
+ }
+ return true;
+}
+
+// We currently have two implementations of `__remove_all`. The first one is general and
+// used on platforms where we don't have access to the `openat()` family of POSIX functions.
+// That implementation uses `directory_iterator`, however it is vulnerable to some race
+// conditions, see https://reviews.llvm.org/D118134 for details.
+//
+// The second implementation is used on platforms where `openat()` & friends are available,
+// and it threads file descriptors through recursive calls to avoid such race conditions.
+#if defined(_LIBCPP_WIN32API)
+# define REMOVE_ALL_USE_DIRECTORY_ITERATOR
+#endif
+
+#if defined(REMOVE_ALL_USE_DIRECTORY_ITERATOR)
+
+namespace {
+
+uintmax_t remove_all_impl(path const& p, error_code& ec) {
+ const auto npos = static_cast<uintmax_t>(-1);
+ const file_status st = __symlink_status(p, &ec);
+ if (ec)
+ return npos;
+ uintmax_t count = 1;
+ if (is_directory(st)) {
+ for (directory_iterator it(p, ec); !ec && it != directory_iterator();
+ it.increment(ec)) {
+ auto other_count = remove_all_impl(it->path(), ec);
+ if (ec)
+ return npos;
+ count += other_count;
+ }
+ if (ec)
+ return npos;
+ }
+ if (!__remove(p, &ec))
+ return npos;
+ return count;
+}
+
+} // end namespace
+
+uintmax_t __remove_all(const path& p, error_code* ec) {
+ ErrorHandler<uintmax_t> err("remove_all", ec, &p);
+
+ error_code mec;
+ auto count = remove_all_impl(p, mec);
+ if (mec) {
+ if (mec == errc::no_such_file_or_directory)
+ return 0;
+ return err.report(mec);
+ }
+ return count;
+}
+
+#else // !REMOVE_ALL_USE_DIRECTORY_ITERATOR
+
+namespace {
+
+template <class Cleanup>
+struct scope_exit {
+ explicit scope_exit(Cleanup const& cleanup)
+ : cleanup_(cleanup)
+ { }
+
+ ~scope_exit() { cleanup_(); }
+
+private:
+ Cleanup cleanup_;
+};
+
+uintmax_t remove_all_impl(int parent_directory, const path& p, error_code& ec) {
+ // First, try to open the path as a directory.
+ const int options = O_CLOEXEC | O_RDONLY | O_DIRECTORY | O_NOFOLLOW;
+ int fd = ::openat(parent_directory, p.c_str(), options);
+ if (fd != -1) {
+ // If that worked, iterate over the contents of the directory and
+ // remove everything in it, recursively.
+ scope_exit close_fd([=] { ::close(fd); });
+ DIR* stream = ::fdopendir(fd);
+ if (stream == nullptr) {
+ ec = detail::capture_errno();
+ return 0;
+ }
+ scope_exit close_stream([=] { ::closedir(stream); });
+
+ uintmax_t count = 0;
+ while (true) {
+ auto [str, type] = detail::posix_readdir(stream, ec);
+ static_assert(std::is_same_v<decltype(str), std::string_view>);
+ if (str == "." || str == "..") {
+ continue;
+ } else if (ec || str.empty()) {
+ break; // we're done iterating through the directory
+ } else {
+ count += remove_all_impl(fd, str, ec);
+ }
+ }
+
+ // Then, remove the now-empty directory itself.
+ if (::unlinkat(parent_directory, p.c_str(), AT_REMOVEDIR) == -1) {
+ ec = detail::capture_errno();
+ return count;
+ }
+
+ return count + 1; // the contents of the directory + the directory itself
+ }
+
+ ec = detail::capture_errno();
+
+ // If we failed to open `p` because it didn't exist, it's not an
+ // error -- it might have moved or have been deleted already.
+ if (ec == errc::no_such_file_or_directory) {
+ ec.clear();
+ return 0;
+ }
+
+ // If opening `p` failed because it wasn't a directory, remove it as
+ // a normal file instead. Note that `openat()` can return either ENOTDIR
+ // or ELOOP depending on the exact reason of the failure.
+ if (ec == errc::not_a_directory || ec == errc::too_many_symbolic_link_levels) {
+ ec.clear();
+ if (::unlinkat(parent_directory, p.c_str(), /* flags = */0) == -1) {
+ ec = detail::capture_errno();
+ return 0;
+ }
+ return 1;
+ }
+
+ // Otherwise, it's a real error -- we don't remove anything.
+ return 0;
+}
+
+} // end namespace
+
+uintmax_t __remove_all(const path& p, error_code* ec) {
+ ErrorHandler<uintmax_t> err("remove_all", ec, &p);
+ error_code mec;
+ uintmax_t count = remove_all_impl(AT_FDCWD, p, mec);
+ if (mec)
+ return err.report(mec);
+ return count;
+}
+
+#endif // REMOVE_ALL_USE_DIRECTORY_ITERATOR
+
+void __rename(const path& from, const path& to, error_code* ec) {
+ ErrorHandler<void> err("rename", ec, &from, &to);
+ if (detail::rename(from.c_str(), to.c_str()) == -1)
+ err.report(capture_errno());
+}
+
+void __resize_file(const path& p, uintmax_t size, error_code* ec) {
+ ErrorHandler<void> err("resize_file", ec, &p);
+ if (detail::truncate(p.c_str(), static_cast< ::off_t>(size)) == -1)
+ return err.report(capture_errno());
+}
+
+space_info __space(const path& p, error_code* ec) {
+ ErrorHandler<void> err("space", ec, &p);
+ space_info si;
+ detail::StatVFS m_svfs = {};
+ if (detail::statvfs(p.c_str(), &m_svfs) == -1) {
+ err.report(capture_errno());
+ si.capacity = si.free = si.available = static_cast<uintmax_t>(-1);
+ return si;
+ }
+ // Multiply with overflow checking.
+ auto do_mult = [&](uintmax_t& out, uintmax_t other) {
+ out = other * m_svfs.f_frsize;
+ if (other == 0 || out / other != m_svfs.f_frsize)
+ out = static_cast<uintmax_t>(-1);
+ };
+ do_mult(si.capacity, m_svfs.f_blocks);
+ do_mult(si.free, m_svfs.f_bfree);
+ do_mult(si.available, m_svfs.f_bavail);
+ return si;
+}
+
+file_status __status(const path& p, error_code* ec) {
+ return detail::posix_stat(p, ec);
+}
+
+file_status __symlink_status(const path& p, error_code* ec) {
+ return detail::posix_lstat(p, ec);
+}
+
+path __temp_directory_path(error_code* ec) {
+ ErrorHandler<path> err("temp_directory_path", ec);
+
+#if defined(_LIBCPP_WIN32API)
+ wchar_t buf[MAX_PATH];
+ DWORD retval = GetTempPathW(MAX_PATH, buf);
+ if (!retval)
+ return err.report(detail::make_windows_error(GetLastError()));
+ if (retval > MAX_PATH)
+ return err.report(errc::filename_too_long);
+ // GetTempPathW returns a path with a trailing slash, which we
+ // shouldn't include for consistency.
+ if (buf[retval-1] == L'\\')
+ buf[retval-1] = L'\0';
+ path p(buf);
+#else
+ const char* env_paths[] = {"TMPDIR", "TMP", "TEMP", "TEMPDIR"};
+ const char* ret = nullptr;
+
+ for (auto& ep : env_paths)
+ if ((ret = getenv(ep)))
+ break;
+ if (ret == nullptr)
+ ret = "/tmp";
+
+ path p(ret);
+#endif
+ error_code m_ec;
+ file_status st = detail::posix_stat(p, &m_ec);
+ if (!status_known(st))
+ return err.report(m_ec, "cannot access path " PATH_CSTR_FMT, p.c_str());
+
+ if (!exists(st) || !is_directory(st))
+ return err.report(errc::not_a_directory,
+ "path " PATH_CSTR_FMT " is not a directory", p.c_str());
+
+ return p;
+}
+
+path __weakly_canonical(const path& p, error_code* ec) {
+ ErrorHandler<path> err("weakly_canonical", ec, &p);
+
+ if (p.empty())
+ return __canonical("", ec);
+
+ path result;
+ path tmp;
+ tmp.__reserve(p.native().size());
+ auto PP = PathParser::CreateEnd(p.native());
+ --PP;
+ vector<string_view_t> DNEParts;
+
+ while (PP.State != PathParser::PS_BeforeBegin) {
+ tmp.assign(createView(p.native().data(), &PP.RawEntry.back()));
+ error_code m_ec;
+ file_status st = __status(tmp, &m_ec);
+ if (!status_known(st)) {
+ return err.report(m_ec);
+ } else if (exists(st)) {
+ result = __canonical(tmp, ec);
+ break;
+ }
+ DNEParts.push_back(*PP);
+ --PP;
+ }
+ if (PP.State == PathParser::PS_BeforeBegin)
+ result = __canonical("", ec);
+ if (ec)
+ ec->clear();
+ if (DNEParts.empty())
+ return result;
+ for (auto It = DNEParts.rbegin(); It != DNEParts.rend(); ++It)
+ result /= *It;
+ return result.lexically_normal();
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// path definitions
+///////////////////////////////////////////////////////////////////////////////
+
+constexpr path::value_type path::preferred_separator;
+
+path& path::replace_extension(path const& replacement) {
+ path p = extension();
+ if (not p.empty()) {
+ __pn_.erase(__pn_.size() - p.native().size());
+ }
+ if (!replacement.empty()) {
+ if (replacement.native()[0] != '.') {
+ __pn_ += PS(".");
+ }
+ __pn_.append(replacement.__pn_);
+ }
+ return *this;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// path.decompose
+
+string_view_t path::__root_name() const {
+ auto PP = PathParser::CreateBegin(__pn_);
+ if (PP.State == PathParser::PS_InRootName)
+ return *PP;
+ return {};
+}
+
+string_view_t path::__root_directory() const {
+ auto PP = PathParser::CreateBegin(__pn_);
+ if (PP.State == PathParser::PS_InRootName)
+ ++PP;
+ if (PP.State == PathParser::PS_InRootDir)
+ return *PP;
+ return {};
+}
+
+string_view_t path::__root_path_raw() const {
+ auto PP = PathParser::CreateBegin(__pn_);
+ if (PP.State == PathParser::PS_InRootName) {
+ auto NextCh = PP.peek();
+ if (NextCh && isSeparator(*NextCh)) {
+ ++PP;
+ return createView(__pn_.data(), &PP.RawEntry.back());
+ }
+ return PP.RawEntry;
+ }
+ if (PP.State == PathParser::PS_InRootDir)
+ return *PP;
+ return {};
+}
+
+static bool ConsumeRootName(PathParser *PP) {
+ static_assert(PathParser::PS_BeforeBegin == 1 &&
+ PathParser::PS_InRootName == 2,
+ "Values for enums are incorrect");
+ while (PP->State <= PathParser::PS_InRootName)
+ ++(*PP);
+ return PP->State == PathParser::PS_AtEnd;
+}
+
+static bool ConsumeRootDir(PathParser* PP) {
+ static_assert(PathParser::PS_BeforeBegin == 1 &&
+ PathParser::PS_InRootName == 2 &&
+ PathParser::PS_InRootDir == 3, "Values for enums are incorrect");
+ while (PP->State <= PathParser::PS_InRootDir)
+ ++(*PP);
+ return PP->State == PathParser::PS_AtEnd;
+}
+
+string_view_t path::__relative_path() const {
+ auto PP = PathParser::CreateBegin(__pn_);
+ if (ConsumeRootDir(&PP))
+ return {};
+ return createView(PP.RawEntry.data(), &__pn_.back());
+}
+
+string_view_t path::__parent_path() const {
+ if (empty())
+ return {};
+ // Determine if we have a root path but not a relative path. In that case
+ // return *this.
+ {
+ auto PP = PathParser::CreateBegin(__pn_);
+ if (ConsumeRootDir(&PP))
+ return __pn_;
+ }
+ // Otherwise remove a single element from the end of the path, and return
+ // a string representing that path
+ {
+ auto PP = PathParser::CreateEnd(__pn_);
+ --PP;
+ if (PP.RawEntry.data() == __pn_.data())
+ return {};
+ --PP;
+ return createView(__pn_.data(), &PP.RawEntry.back());
+ }
+}
+
+string_view_t path::__filename() const {
+ if (empty())
+ return {};
+ {
+ PathParser PP = PathParser::CreateBegin(__pn_);
+ if (ConsumeRootDir(&PP))
+ return {};
+ }
+ return *(--PathParser::CreateEnd(__pn_));
+}
+
+string_view_t path::__stem() const {
+ return parser::separate_filename(__filename()).first;
+}
+
+string_view_t path::__extension() const {
+ return parser::separate_filename(__filename()).second;
+}
+
+////////////////////////////////////////////////////////////////////////////
+// path.gen
+
+enum PathPartKind : unsigned char {
+ PK_None,
+ PK_RootSep,
+ PK_Filename,
+ PK_Dot,
+ PK_DotDot,
+ PK_TrailingSep
+};
+
+static PathPartKind ClassifyPathPart(string_view_t Part) {
+ if (Part.empty())
+ return PK_TrailingSep;
+ if (Part == PS("."))
+ return PK_Dot;
+ if (Part == PS(".."))
+ return PK_DotDot;
+ if (Part == PS("/"))
+ return PK_RootSep;
+#if defined(_LIBCPP_WIN32API)
+ if (Part == PS("\\"))
+ return PK_RootSep;
+#endif
+ return PK_Filename;
+}
+
+path path::lexically_normal() const {
+ if (__pn_.empty())
+ return *this;
+
+ using PartKindPair = pair<string_view_t, PathPartKind>;
+ vector<PartKindPair> Parts;
+ // Guess as to how many elements the path has to avoid reallocating.
+ Parts.reserve(32);
+
+ // Track the total size of the parts as we collect them. This allows the
+ // resulting path to reserve the correct amount of memory.
+ size_t NewPathSize = 0;
+ auto AddPart = [&](PathPartKind K, string_view_t P) {
+ NewPathSize += P.size();
+ Parts.emplace_back(P, K);
+ };
+ auto LastPartKind = [&]() {
+ if (Parts.empty())
+ return PK_None;
+ return Parts.back().second;
+ };
+
+ bool MaybeNeedTrailingSep = false;
+ // Build a stack containing the remaining elements of the path, popping off
+ // elements which occur before a '..' entry.
+ for (auto PP = PathParser::CreateBegin(__pn_); PP; ++PP) {
+ auto Part = *PP;
+ PathPartKind Kind = ClassifyPathPart(Part);
+ switch (Kind) {
+ case PK_Filename:
+ case PK_RootSep: {
+ // Add all non-dot and non-dot-dot elements to the stack of elements.
+ AddPart(Kind, Part);
+ MaybeNeedTrailingSep = false;
+ break;
+ }
+ case PK_DotDot: {
+ // Only push a ".." element if there are no elements preceding the "..",
+ // or if the preceding element is itself "..".
+ auto LastKind = LastPartKind();
+ if (LastKind == PK_Filename) {
+ NewPathSize -= Parts.back().first.size();
+ Parts.pop_back();
+ } else if (LastKind != PK_RootSep)
+ AddPart(PK_DotDot, PS(".."));
+ MaybeNeedTrailingSep = LastKind == PK_Filename;
+ break;
+ }
+ case PK_Dot:
+ case PK_TrailingSep: {
+ MaybeNeedTrailingSep = true;
+ break;
+ }
+ case PK_None:
+ __libcpp_unreachable();
+ }
+ }
+ // [fs.path.generic]p6.8: If the path is empty, add a dot.
+ if (Parts.empty())
+ return PS(".");
+
+ // [fs.path.generic]p6.7: If the last filename is dot-dot, remove any
+ // trailing directory-separator.
+ bool NeedTrailingSep = MaybeNeedTrailingSep && LastPartKind() == PK_Filename;
+
+ path Result;
+ Result.__pn_.reserve(Parts.size() + NewPathSize + NeedTrailingSep);
+ for (auto& PK : Parts)
+ Result /= PK.first;
+
+ if (NeedTrailingSep)
+ Result /= PS("");
+
+ Result.make_preferred();
+ return Result;
+}
+
+static int DetermineLexicalElementCount(PathParser PP) {
+ int Count = 0;
+ for (; PP; ++PP) {
+ auto Elem = *PP;
+ if (Elem == PS(".."))
+ --Count;
+ else if (Elem != PS(".") && Elem != PS(""))
+ ++Count;
+ }
+ return Count;
+}
+
+path path::lexically_relative(const path& base) const {
+ { // perform root-name/root-directory mismatch checks
+ auto PP = PathParser::CreateBegin(__pn_);
+ auto PPBase = PathParser::CreateBegin(base.__pn_);
+ auto CheckIterMismatchAtBase = [&]() {
+ return PP.State != PPBase.State &&
+ (PP.inRootPath() || PPBase.inRootPath());
+ };
+ if (PP.inRootName() && PPBase.inRootName()) {
+ if (*PP != *PPBase)
+ return {};
+ } else if (CheckIterMismatchAtBase())
+ return {};
+
+ if (PP.inRootPath())
+ ++PP;
+ if (PPBase.inRootPath())
+ ++PPBase;
+ if (CheckIterMismatchAtBase())
+ return {};
+ }
+
+ // Find the first mismatching element
+ auto PP = PathParser::CreateBegin(__pn_);
+ auto PPBase = PathParser::CreateBegin(base.__pn_);
+ while (PP && PPBase && PP.State == PPBase.State && *PP == *PPBase) {
+ ++PP;
+ ++PPBase;
+ }
+
+ // If there is no mismatch, return ".".
+ if (!PP && !PPBase)
+ return ".";
+
+ // Otherwise, determine the number of elements, 'n', which are not dot or
+ // dot-dot minus the number of dot-dot elements.
+ int ElemCount = DetermineLexicalElementCount(PPBase);
+ if (ElemCount < 0)
+ return {};
+
+ // if n == 0 and (a == end() || a->empty()), returns path("."); otherwise
+ if (ElemCount == 0 && (PP.atEnd() || *PP == PS("")))
+ return PS(".");
+
+ // return a path constructed with 'n' dot-dot elements, followed by the the
+ // elements of '*this' after the mismatch.
+ path Result;
+ // FIXME: Reserve enough room in Result that it won't have to re-allocate.
+ while (ElemCount--)
+ Result /= PS("..");
+ for (; PP; ++PP)
+ Result /= *PP;
+ return Result;
+}
+
+////////////////////////////////////////////////////////////////////////////
+// path.comparisons
+static int CompareRootName(PathParser *LHS, PathParser *RHS) {
+ if (!LHS->inRootName() && !RHS->inRootName())
+ return 0;
+
+ auto GetRootName = [](PathParser *Parser) -> string_view_t {
+ return Parser->inRootName() ? **Parser : PS("");
+ };
+ int res = GetRootName(LHS).compare(GetRootName(RHS));
+ ConsumeRootName(LHS);
+ ConsumeRootName(RHS);
+ return res;
+}
+
+static int CompareRootDir(PathParser *LHS, PathParser *RHS) {
+ if (!LHS->inRootDir() && RHS->inRootDir())
+ return -1;
+ else if (LHS->inRootDir() && !RHS->inRootDir())
+ return 1;
+ else {
+ ConsumeRootDir(LHS);
+ ConsumeRootDir(RHS);
+ return 0;
+ }
+}
+
+static int CompareRelative(PathParser *LHSPtr, PathParser *RHSPtr) {
+ auto &LHS = *LHSPtr;
+ auto &RHS = *RHSPtr;
+
+ int res;
+ while (LHS && RHS) {
+ if ((res = (*LHS).compare(*RHS)) != 0)
+ return res;
+ ++LHS;
+ ++RHS;
+ }
+ return 0;
+}
+
+static int CompareEndState(PathParser *LHS, PathParser *RHS) {
+ if (LHS->atEnd() && !RHS->atEnd())
+ return -1;
+ else if (!LHS->atEnd() && RHS->atEnd())
+ return 1;
+ return 0;
+}
+
+int path::__compare(string_view_t __s) const {
+ auto LHS = PathParser::CreateBegin(__pn_);
+ auto RHS = PathParser::CreateBegin(__s);
+ int res;
+
+ if ((res = CompareRootName(&LHS, &RHS)) != 0)
+ return res;
+
+ if ((res = CompareRootDir(&LHS, &RHS)) != 0)
+ return res;
+
+ if ((res = CompareRelative(&LHS, &RHS)) != 0)
+ return res;
+
+ return CompareEndState(&LHS, &RHS);
+}
+
+////////////////////////////////////////////////////////////////////////////
+// path.nonmembers
+size_t hash_value(const path& __p) noexcept {
+ auto PP = PathParser::CreateBegin(__p.native());
+ size_t hash_value = 0;
+ hash<string_view_t> hasher;
+ while (PP) {
+ hash_value = __hash_combine(hash_value, hasher(*PP));
+ ++PP;
+ }
+ return hash_value;
+}
+
+////////////////////////////////////////////////////////////////////////////
+// path.itr
+path::iterator path::begin() const {
+ auto PP = PathParser::CreateBegin(__pn_);
+ iterator it;
+ it.__path_ptr_ = this;
+ it.__state_ = static_cast<path::iterator::_ParserState>(PP.State);
+ it.__entry_ = PP.RawEntry;
+ it.__stashed_elem_.__assign_view(*PP);
+ return it;
+}
+
+path::iterator path::end() const {
+ iterator it{};
+ it.__state_ = path::iterator::_AtEnd;
+ it.__path_ptr_ = this;
+ return it;
+}
+
+path::iterator& path::iterator::__increment() {
+ PathParser PP(__path_ptr_->native(), __entry_, __state_);
+ ++PP;
+ __state_ = static_cast<_ParserState>(PP.State);
+ __entry_ = PP.RawEntry;
+ __stashed_elem_.__assign_view(*PP);
+ return *this;
+}
+
+path::iterator& path::iterator::__decrement() {
+ PathParser PP(__path_ptr_->native(), __entry_, __state_);
+ --PP;
+ __state_ = static_cast<_ParserState>(PP.State);
+ __entry_ = PP.RawEntry;
+ __stashed_elem_.__assign_view(*PP);
+ return *this;
+}
+
+#if defined(_LIBCPP_WIN32API)
+////////////////////////////////////////////////////////////////////////////
+// Windows path conversions
+size_t __wide_to_char(const wstring &str, char *out, size_t outlen) {
+ if (str.empty())
+ return 0;
+ ErrorHandler<size_t> err("__wide_to_char", nullptr);
+ UINT codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP;
+ BOOL used_default = FALSE;
+ int ret = WideCharToMultiByte(codepage, 0, str.data(), str.size(), out,
+ outlen, nullptr, &used_default);
+ if (ret <= 0 || used_default)
+ return err.report(errc::illegal_byte_sequence);
+ return ret;
+}
+
+size_t __char_to_wide(const string &str, wchar_t *out, size_t outlen) {
+ if (str.empty())
+ return 0;
+ ErrorHandler<size_t> err("__char_to_wide", nullptr);
+ UINT codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP;
+ int ret = MultiByteToWideChar(codepage, MB_ERR_INVALID_CHARS, str.data(),
+ str.size(), out, outlen);
+ if (ret <= 0)
+ return err.report(errc::illegal_byte_sequence);
+ return ret;
+}
+#endif
+
+
+///////////////////////////////////////////////////////////////////////////////
+// directory entry definitions
+///////////////////////////////////////////////////////////////////////////////
+
+error_code directory_entry::__do_refresh() noexcept {
+ __data_.__reset();
+ error_code failure_ec;
+
+ StatT full_st;
+ file_status st = detail::posix_lstat(__p_, full_st, &failure_ec);
+ if (!status_known(st)) {
+ __data_.__reset();
+ return failure_ec;
+ }
+
+ if (!_VSTD_FS::exists(st) || !_VSTD_FS::is_symlink(st)) {
+ __data_.__cache_type_ = directory_entry::_RefreshNonSymlink;
+ __data_.__type_ = st.type();
+ __data_.__non_sym_perms_ = st.permissions();
+ } else { // we have a symlink
+ __data_.__sym_perms_ = st.permissions();
+ // Get the information about the linked entity.
+ // Ignore errors from stat, since we don't want errors regarding symlink
+ // resolution to be reported to the user.
+ error_code ignored_ec;
+ st = detail::posix_stat(__p_, full_st, &ignored_ec);
+
+ __data_.__type_ = st.type();
+ __data_.__non_sym_perms_ = st.permissions();
+
+ // If we failed to resolve the link, then only partially populate the
+ // cache.
+ if (!status_known(st)) {
+ __data_.__cache_type_ = directory_entry::_RefreshSymlinkUnresolved;
+ return error_code{};
+ }
+ // Otherwise, we resolved the link, potentially as not existing.
+ // That's OK.
+ __data_.__cache_type_ = directory_entry::_RefreshSymlink;
+ }
+
+ if (_VSTD_FS::is_regular_file(st))
+ __data_.__size_ = static_cast<uintmax_t>(full_st.st_size);
+
+ if (_VSTD_FS::exists(st)) {
+ __data_.__nlink_ = static_cast<uintmax_t>(full_st.st_nlink);
+
+ // Attempt to extract the mtime, and fail if it's not representable using
+ // file_time_type. For now we ignore the error, as we'll report it when
+ // the value is actually used.
+ error_code ignored_ec;
+ __data_.__write_time_ =
+ __extract_last_write_time(__p_, full_st, &ignored_ec);
+ }
+
+ return failure_ec;
+}
+
+_LIBCPP_END_NAMESPACE_FILESYSTEM
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/filesystem/posix_compat.h b/contrib/libs/cxxsupp/libcxxmsvc/src/filesystem/posix_compat.h
new file mode 100644
index 0000000000..36116ec5a3
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/filesystem/posix_compat.h
@@ -0,0 +1,522 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+//
+// POSIX-like portability helper functions.
+//
+// These generally behave like the proper posix functions, with these
+// exceptions:
+// On Windows, they take paths in wchar_t* form, instead of char* form.
+// The symlink() function is split into two frontends, symlink_file()
+// and symlink_dir().
+//
+// These are provided within an anonymous namespace within the detail
+// namespace - callers need to include this header and call them as
+// detail::function(), regardless of platform.
+//
+
+#ifndef POSIX_COMPAT_H
+#define POSIX_COMPAT_H
+
+#include <__assert>
+#include <filesystem>
+
+#include "filesystem_common.h"
+
+#if defined(_LIBCPP_WIN32API)
+# define WIN32_LEAN_AND_MEAN
+# define NOMINMAX
+# include <windows.h>
+# include <io.h>
+# include <winioctl.h>
+#else
+# include <unistd.h>
+# include <sys/stat.h>
+# include <sys/statvfs.h>
+#endif
+#include <time.h>
+
+#if defined(_LIBCPP_WIN32API)
+// This struct isn't defined in the normal Windows SDK, but only in the
+// Windows Driver Kit.
+struct LIBCPP_REPARSE_DATA_BUFFER {
+ unsigned long ReparseTag;
+ unsigned short ReparseDataLength;
+ unsigned short Reserved;
+ union {
+ struct {
+ unsigned short SubstituteNameOffset;
+ unsigned short SubstituteNameLength;
+ unsigned short PrintNameOffset;
+ unsigned short PrintNameLength;
+ unsigned long Flags;
+ wchar_t PathBuffer[1];
+ } SymbolicLinkReparseBuffer;
+ struct {
+ unsigned short SubstituteNameOffset;
+ unsigned short SubstituteNameLength;
+ unsigned short PrintNameOffset;
+ unsigned short PrintNameLength;
+ wchar_t PathBuffer[1];
+ } MountPointReparseBuffer;
+ struct {
+ unsigned char DataBuffer[1];
+ } GenericReparseBuffer;
+ };
+};
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
+
+namespace detail {
+namespace {
+
+#if defined(_LIBCPP_WIN32API)
+
+// Various C runtime header sets provide more or less of these. As we
+// provide our own implementation, undef all potential defines from the
+// C runtime headers and provide a complete set of macros of our own.
+
+#undef _S_IFMT
+#undef _S_IFDIR
+#undef _S_IFCHR
+#undef _S_IFIFO
+#undef _S_IFREG
+#undef _S_IFBLK
+#undef _S_IFLNK
+#undef _S_IFSOCK
+
+#define _S_IFMT 0xF000
+#define _S_IFDIR 0x4000
+#define _S_IFCHR 0x2000
+#define _S_IFIFO 0x1000
+#define _S_IFREG 0x8000
+#define _S_IFBLK 0x6000
+#define _S_IFLNK 0xA000
+#define _S_IFSOCK 0xC000
+
+#undef S_ISDIR
+#undef S_ISFIFO
+#undef S_ISCHR
+#undef S_ISREG
+#undef S_ISLNK
+#undef S_ISBLK
+#undef S_ISSOCK
+
+#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
+#define S_ISCHR(m) (((m) & _S_IFMT) == _S_IFCHR)
+#define S_ISFIFO(m) (((m) & _S_IFMT) == _S_IFIFO)
+#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
+#define S_ISBLK(m) (((m) & _S_IFMT) == _S_IFBLK)
+#define S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK)
+#define S_ISSOCK(m) (((m) & _S_IFMT) == _S_IFSOCK)
+
+#define O_NONBLOCK 0
+
+
+// There were 369 years and 89 leap days from the Windows epoch
+// (1601) to the Unix epoch (1970).
+#define FILE_TIME_OFFSET_SECS (uint64_t(369 * 365 + 89) * (24 * 60 * 60))
+
+TimeSpec filetime_to_timespec(LARGE_INTEGER li) {
+ TimeSpec ret;
+ ret.tv_sec = li.QuadPart / 10000000 - FILE_TIME_OFFSET_SECS;
+ ret.tv_nsec = (li.QuadPart % 10000000) * 100;
+ return ret;
+}
+
+TimeSpec filetime_to_timespec(FILETIME ft) {
+ LARGE_INTEGER li;
+ li.LowPart = ft.dwLowDateTime;
+ li.HighPart = ft.dwHighDateTime;
+ return filetime_to_timespec(li);
+}
+
+FILETIME timespec_to_filetime(TimeSpec ts) {
+ LARGE_INTEGER li;
+ li.QuadPart =
+ ts.tv_nsec / 100 + (ts.tv_sec + FILE_TIME_OFFSET_SECS) * 10000000;
+ FILETIME ft;
+ ft.dwLowDateTime = li.LowPart;
+ ft.dwHighDateTime = li.HighPart;
+ return ft;
+}
+
+int set_errno(int e = GetLastError()) {
+ errno = static_cast<int>(__win_err_to_errc(e));
+ return -1;
+}
+
+class WinHandle {
+public:
+ WinHandle(const wchar_t *p, DWORD access, DWORD flags) {
+ h = CreateFileW(
+ p, access, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | flags, nullptr);
+ }
+ ~WinHandle() {
+ if (h != INVALID_HANDLE_VALUE)
+ CloseHandle(h);
+ }
+ operator HANDLE() const { return h; }
+ operator bool() const { return h != INVALID_HANDLE_VALUE; }
+
+private:
+ HANDLE h;
+};
+
+int stat_handle(HANDLE h, StatT *buf) {
+ FILE_BASIC_INFO basic;
+ if (!GetFileInformationByHandleEx(h, FileBasicInfo, &basic, sizeof(basic)))
+ return set_errno();
+ memset(buf, 0, sizeof(*buf));
+ buf->st_mtim = filetime_to_timespec(basic.LastWriteTime);
+ buf->st_atim = filetime_to_timespec(basic.LastAccessTime);
+ buf->st_mode = 0555; // Read-only
+ if (!(basic.FileAttributes & FILE_ATTRIBUTE_READONLY))
+ buf->st_mode |= 0222; // Write
+ if (basic.FileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
+ buf->st_mode |= _S_IFDIR;
+ } else {
+ buf->st_mode |= _S_IFREG;
+ }
+ if (basic.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
+ FILE_ATTRIBUTE_TAG_INFO tag;
+ if (!GetFileInformationByHandleEx(h, FileAttributeTagInfo, &tag,
+ sizeof(tag)))
+ return set_errno();
+ if (tag.ReparseTag == IO_REPARSE_TAG_SYMLINK)
+ buf->st_mode = (buf->st_mode & ~_S_IFMT) | _S_IFLNK;
+ }
+ FILE_STANDARD_INFO standard;
+ if (!GetFileInformationByHandleEx(h, FileStandardInfo, &standard,
+ sizeof(standard)))
+ return set_errno();
+ buf->st_nlink = standard.NumberOfLinks;
+ buf->st_size = standard.EndOfFile.QuadPart;
+ BY_HANDLE_FILE_INFORMATION info;
+ if (!GetFileInformationByHandle(h, &info))
+ return set_errno();
+ buf->st_dev = info.dwVolumeSerialNumber;
+ memcpy(&buf->st_ino.id[0], &info.nFileIndexHigh, 4);
+ memcpy(&buf->st_ino.id[4], &info.nFileIndexLow, 4);
+ return 0;
+}
+
+int stat_file(const wchar_t *path, StatT *buf, DWORD flags) {
+ WinHandle h(path, FILE_READ_ATTRIBUTES, flags);
+ if (!h)
+ return set_errno();
+ int ret = stat_handle(h, buf);
+ return ret;
+}
+
+int stat(const wchar_t *path, StatT *buf) { return stat_file(path, buf, 0); }
+
+int lstat(const wchar_t *path, StatT *buf) {
+ return stat_file(path, buf, FILE_FLAG_OPEN_REPARSE_POINT);
+}
+
+int fstat(int fd, StatT *buf) {
+ HANDLE h = reinterpret_cast<HANDLE>(_get_osfhandle(fd));
+ return stat_handle(h, buf);
+}
+
+int mkdir(const wchar_t *path, int permissions) {
+ (void)permissions;
+ return _wmkdir(path);
+}
+
+int symlink_file_dir(const wchar_t *oldname, const wchar_t *newname,
+ bool is_dir) {
+ path dest(oldname);
+ dest.make_preferred();
+ oldname = dest.c_str();
+ DWORD flags = is_dir ? SYMBOLIC_LINK_FLAG_DIRECTORY : 0;
+ if (CreateSymbolicLinkW(newname, oldname,
+ flags | SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE))
+ return 0;
+ int e = GetLastError();
+ if (e != ERROR_INVALID_PARAMETER)
+ return set_errno(e);
+ if (CreateSymbolicLinkW(newname, oldname, flags))
+ return 0;
+ return set_errno();
+}
+
+int symlink_file(const wchar_t *oldname, const wchar_t *newname) {
+ return symlink_file_dir(oldname, newname, false);
+}
+
+int symlink_dir(const wchar_t *oldname, const wchar_t *newname) {
+ return symlink_file_dir(oldname, newname, true);
+}
+
+int link(const wchar_t *oldname, const wchar_t *newname) {
+ if (CreateHardLinkW(newname, oldname, nullptr))
+ return 0;
+ return set_errno();
+}
+
+int remove(const wchar_t *path) {
+ detail::WinHandle h(path, DELETE, FILE_FLAG_OPEN_REPARSE_POINT);
+ if (!h)
+ return set_errno();
+ FILE_DISPOSITION_INFO info;
+ info.DeleteFile = TRUE;
+ if (!SetFileInformationByHandle(h, FileDispositionInfo, &info, sizeof(info)))
+ return set_errno();
+ return 0;
+}
+
+int truncate_handle(HANDLE h, off_t length) {
+ LARGE_INTEGER size_param;
+ size_param.QuadPart = length;
+ if (!SetFilePointerEx(h, size_param, 0, FILE_BEGIN))
+ return set_errno();
+ if (!SetEndOfFile(h))
+ return set_errno();
+ return 0;
+}
+
+int ftruncate(int fd, off_t length) {
+ HANDLE h = reinterpret_cast<HANDLE>(_get_osfhandle(fd));
+ return truncate_handle(h, length);
+}
+
+int truncate(const wchar_t *path, off_t length) {
+ detail::WinHandle h(path, GENERIC_WRITE, 0);
+ if (!h)
+ return set_errno();
+ return truncate_handle(h, length);
+}
+
+int rename(const wchar_t *from, const wchar_t *to) {
+ if (!(MoveFileExW(from, to,
+ MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING |
+ MOVEFILE_WRITE_THROUGH)))
+ return set_errno();
+ return 0;
+}
+
+template <class... Args> int open(const wchar_t *filename, Args... args) {
+ return _wopen(filename, args...);
+}
+int close(int fd) { return _close(fd); }
+int chdir(const wchar_t *path) { return _wchdir(path); }
+
+struct StatVFS {
+ uint64_t f_frsize;
+ uint64_t f_blocks;
+ uint64_t f_bfree;
+ uint64_t f_bavail;
+};
+
+int statvfs(const wchar_t *p, StatVFS *buf) {
+ path dir = p;
+ while (true) {
+ error_code local_ec;
+ const file_status st = status(dir, local_ec);
+ if (!exists(st) || is_directory(st))
+ break;
+ path parent = dir.parent_path();
+ if (parent == dir) {
+ errno = ENOENT;
+ return -1;
+ }
+ dir = parent;
+ }
+ ULARGE_INTEGER free_bytes_available_to_caller, total_number_of_bytes,
+ total_number_of_free_bytes;
+ if (!GetDiskFreeSpaceExW(dir.c_str(), &free_bytes_available_to_caller,
+ &total_number_of_bytes, &total_number_of_free_bytes))
+ return set_errno();
+ buf->f_frsize = 1;
+ buf->f_blocks = total_number_of_bytes.QuadPart;
+ buf->f_bfree = total_number_of_free_bytes.QuadPart;
+ buf->f_bavail = free_bytes_available_to_caller.QuadPart;
+ return 0;
+}
+
+wchar_t *getcwd(wchar_t *buff, size_t size) { return _wgetcwd(buff, size); }
+
+wchar_t *realpath(const wchar_t *path, wchar_t *resolved_name) {
+ // Only expected to be used with us allocating the buffer.
+ _LIBCPP_ASSERT(resolved_name == nullptr,
+ "Windows realpath() assumes a null resolved_name");
+
+ WinHandle h(path, FILE_READ_ATTRIBUTES, 0);
+ if (!h) {
+ set_errno();
+ return nullptr;
+ }
+ size_t buff_size = MAX_PATH + 10;
+ std::unique_ptr<wchar_t, decltype(&::free)> buff(
+ static_cast<wchar_t *>(malloc(buff_size * sizeof(wchar_t))), &::free);
+ DWORD retval = GetFinalPathNameByHandleW(
+ h, buff.get(), buff_size, FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
+ if (retval > buff_size) {
+ buff_size = retval;
+ buff.reset(static_cast<wchar_t *>(malloc(buff_size * sizeof(wchar_t))));
+ retval = GetFinalPathNameByHandleW(h, buff.get(), buff_size,
+ FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
+ }
+ if (!retval) {
+ set_errno();
+ return nullptr;
+ }
+ wchar_t *ptr = buff.get();
+ if (!wcsncmp(ptr, L"\\\\?\\", 4)) {
+ if (ptr[5] == ':') { // \\?\X: -> X:
+ memmove(&ptr[0], &ptr[4], (wcslen(&ptr[4]) + 1) * sizeof(wchar_t));
+ } else if (!wcsncmp(&ptr[4], L"UNC\\", 4)) { // \\?\UNC\server -> \\server
+ wcscpy(&ptr[0], L"\\\\");
+ memmove(&ptr[2], &ptr[8], (wcslen(&ptr[8]) + 1) * sizeof(wchar_t));
+ }
+ }
+ return buff.release();
+}
+
+#define AT_FDCWD -1
+#define AT_SYMLINK_NOFOLLOW 1
+using ModeT = int;
+
+int fchmod_handle(HANDLE h, int perms) {
+ FILE_BASIC_INFO basic;
+ if (!GetFileInformationByHandleEx(h, FileBasicInfo, &basic, sizeof(basic)))
+ return set_errno();
+ DWORD orig_attributes = basic.FileAttributes;
+ basic.FileAttributes &= ~FILE_ATTRIBUTE_READONLY;
+ if ((perms & 0222) == 0)
+ basic.FileAttributes |= FILE_ATTRIBUTE_READONLY;
+ if (basic.FileAttributes != orig_attributes &&
+ !SetFileInformationByHandle(h, FileBasicInfo, &basic, sizeof(basic)))
+ return set_errno();
+ return 0;
+}
+
+int fchmodat(int fd, const wchar_t *path, int perms, int flag) {
+ DWORD attributes = GetFileAttributesW(path);
+ if (attributes == INVALID_FILE_ATTRIBUTES)
+ return set_errno();
+ if (attributes & FILE_ATTRIBUTE_REPARSE_POINT &&
+ !(flag & AT_SYMLINK_NOFOLLOW)) {
+ // If the file is a symlink, and we are supposed to operate on the target
+ // of the symlink, we need to open a handle to it, without the
+ // FILE_FLAG_OPEN_REPARSE_POINT flag, to open the destination of the
+ // symlink, and operate on it via the handle.
+ detail::WinHandle h(path, FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES, 0);
+ if (!h)
+ return set_errno();
+ return fchmod_handle(h, perms);
+ } else {
+ // For a non-symlink, or if operating on the symlink itself instead of
+ // its target, we can use SetFileAttributesW, saving a few calls.
+ DWORD orig_attributes = attributes;
+ attributes &= ~FILE_ATTRIBUTE_READONLY;
+ if ((perms & 0222) == 0)
+ attributes |= FILE_ATTRIBUTE_READONLY;
+ if (attributes != orig_attributes && !SetFileAttributesW(path, attributes))
+ return set_errno();
+ }
+ return 0;
+}
+
+int fchmod(int fd, int perms) {
+ HANDLE h = reinterpret_cast<HANDLE>(_get_osfhandle(fd));
+ return fchmod_handle(h, perms);
+}
+
+#define MAX_SYMLINK_SIZE MAXIMUM_REPARSE_DATA_BUFFER_SIZE
+using SSizeT = ::int64_t;
+
+SSizeT readlink(const wchar_t *path, wchar_t *ret_buf, size_t bufsize) {
+ uint8_t buf[MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
+ detail::WinHandle h(path, FILE_READ_ATTRIBUTES, FILE_FLAG_OPEN_REPARSE_POINT);
+ if (!h)
+ return set_errno();
+ DWORD out;
+ if (!DeviceIoControl(h, FSCTL_GET_REPARSE_POINT, nullptr, 0, buf, sizeof(buf),
+ &out, 0))
+ return set_errno();
+ const auto *reparse = reinterpret_cast<LIBCPP_REPARSE_DATA_BUFFER *>(buf);
+ size_t path_buf_offset = offsetof(LIBCPP_REPARSE_DATA_BUFFER,
+ SymbolicLinkReparseBuffer.PathBuffer[0]);
+ if (out < path_buf_offset) {
+ errno = EINVAL;
+ return -1;
+ }
+ if (reparse->ReparseTag != IO_REPARSE_TAG_SYMLINK) {
+ errno = EINVAL;
+ return -1;
+ }
+ const auto &symlink = reparse->SymbolicLinkReparseBuffer;
+ unsigned short name_offset, name_length;
+ if (symlink.PrintNameLength == 0) {
+ name_offset = symlink.SubstituteNameOffset;
+ name_length = symlink.SubstituteNameLength;
+ } else {
+ name_offset = symlink.PrintNameOffset;
+ name_length = symlink.PrintNameLength;
+ }
+ // name_offset/length are expressed in bytes, not in wchar_t
+ if (path_buf_offset + name_offset + name_length > out) {
+ errno = EINVAL;
+ return -1;
+ }
+ if (name_length / sizeof(wchar_t) > bufsize) {
+ errno = ENOMEM;
+ return -1;
+ }
+ memcpy(ret_buf, &symlink.PathBuffer[name_offset / sizeof(wchar_t)],
+ name_length);
+ return name_length / sizeof(wchar_t);
+}
+
+#else
+int symlink_file(const char *oldname, const char *newname) {
+ return ::symlink(oldname, newname);
+}
+int symlink_dir(const char *oldname, const char *newname) {
+ return ::symlink(oldname, newname);
+}
+using ::chdir;
+using ::close;
+using ::fchmod;
+#if defined(AT_SYMLINK_NOFOLLOW) && defined(AT_FDCWD)
+using ::fchmodat;
+#endif
+using ::fstat;
+using ::ftruncate;
+using ::getcwd;
+using ::link;
+using ::lstat;
+using ::mkdir;
+using ::open;
+using ::readlink;
+using ::realpath;
+using ::remove;
+using ::rename;
+using ::stat;
+using ::statvfs;
+using ::truncate;
+
+#define O_BINARY 0
+
+using StatVFS = struct statvfs;
+using ModeT = ::mode_t;
+using SSizeT = ::ssize_t;
+
+#endif
+
+} // namespace
+} // end namespace detail
+
+_LIBCPP_END_NAMESPACE_FILESYSTEM
+
+#endif // POSIX_COMPAT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/format.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/format.cpp
new file mode 100644
index 0000000000..cdbcbf8b05
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/format.cpp
@@ -0,0 +1,15 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <format>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+format_error::~format_error() noexcept = default;
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/functional.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/functional.cpp
new file mode 100644
index 0000000000..ca1079cdd8
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/functional.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <functional>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
+bad_function_call::~bad_function_call() noexcept
+{
+}
+#endif
+
+#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
+const char*
+bad_function_call::what() const noexcept
+{
+ return "std::bad_function_call";
+}
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/future.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/future.cpp
new file mode 100644
index 0000000000..cdaa938275
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/future.cpp
@@ -0,0 +1,269 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <__config>
+
+#ifndef _LIBCPP_HAS_NO_THREADS
+
+#include <future>
+#include <string>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+class _LIBCPP_HIDDEN __future_error_category
+ : public __do_message
+{
+public:
+ virtual const char* name() const noexcept;
+ virtual string message(int ev) const;
+};
+
+const char*
+__future_error_category::name() const noexcept
+{
+ return "future";
+}
+
+_LIBCPP_DIAGNOSTIC_PUSH
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wswitch")
+_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wswitch")
+
+string
+__future_error_category::message(int ev) const
+{
+ switch (static_cast<future_errc>(ev))
+ {
+ case future_errc(0): // For backwards compatibility with C++11 (LWG 2056)
+ case future_errc::broken_promise:
+ return string("The associated promise has been destructed prior "
+ "to the associated state becoming ready.");
+ case future_errc::future_already_retrieved:
+ return string("The future has already been retrieved from "
+ "the promise or packaged_task.");
+ case future_errc::promise_already_satisfied:
+ return string("The state of the promise has already been set.");
+ case future_errc::no_state:
+ return string("Operation not permitted on an object without "
+ "an associated state.");
+ }
+ return string("unspecified future_errc value\n");
+}
+
+_LIBCPP_DIAGNOSTIC_POP
+
+const error_category&
+future_category() noexcept
+{
+ static __future_error_category __f;
+ return __f;
+}
+
+future_error::future_error(error_code __ec)
+ : logic_error(__ec.message()),
+ __ec_(__ec)
+{
+}
+
+future_error::~future_error() noexcept
+{
+}
+
+void
+__assoc_sub_state::__on_zero_shared() noexcept
+{
+ delete this;
+}
+
+void
+__assoc_sub_state::set_value()
+{
+ unique_lock<mutex> __lk(__mut_);
+ if (__has_value())
+ __throw_future_error(future_errc::promise_already_satisfied);
+ __state_ |= __constructed | ready;
+ __cv_.notify_all();
+}
+
+void
+__assoc_sub_state::set_value_at_thread_exit()
+{
+ unique_lock<mutex> __lk(__mut_);
+ if (__has_value())
+ __throw_future_error(future_errc::promise_already_satisfied);
+ __state_ |= __constructed;
+ __thread_local_data()->__make_ready_at_thread_exit(this);
+}
+
+void
+__assoc_sub_state::set_exception(exception_ptr __p)
+{
+ unique_lock<mutex> __lk(__mut_);
+ if (__has_value())
+ __throw_future_error(future_errc::promise_already_satisfied);
+ __exception_ = __p;
+ __state_ |= ready;
+ __cv_.notify_all();
+}
+
+void
+__assoc_sub_state::set_exception_at_thread_exit(exception_ptr __p)
+{
+ unique_lock<mutex> __lk(__mut_);
+ if (__has_value())
+ __throw_future_error(future_errc::promise_already_satisfied);
+ __exception_ = __p;
+ __thread_local_data()->__make_ready_at_thread_exit(this);
+}
+
+void
+__assoc_sub_state::__make_ready()
+{
+ unique_lock<mutex> __lk(__mut_);
+ __state_ |= ready;
+ __cv_.notify_all();
+}
+
+void
+__assoc_sub_state::copy()
+{
+ unique_lock<mutex> __lk(__mut_);
+ __sub_wait(__lk);
+ if (__exception_ != nullptr)
+ rethrow_exception(__exception_);
+}
+
+void
+__assoc_sub_state::wait()
+{
+ unique_lock<mutex> __lk(__mut_);
+ __sub_wait(__lk);
+}
+
+void
+__assoc_sub_state::__sub_wait(unique_lock<mutex>& __lk)
+{
+ if (!__is_ready())
+ {
+ if (__state_ & static_cast<unsigned>(deferred))
+ {
+ __state_ &= ~static_cast<unsigned>(deferred);
+ __lk.unlock();
+ __execute();
+ }
+ else
+ while (!__is_ready())
+ __cv_.wait(__lk);
+ }
+}
+
+void
+__assoc_sub_state::__execute()
+{
+ __throw_future_error(future_errc::no_state);
+}
+
+future<void>::future(__assoc_sub_state* __state)
+ : __state_(__state)
+{
+ __state_->__attach_future();
+}
+
+future<void>::~future()
+{
+ if (__state_)
+ __state_->__release_shared();
+}
+
+void
+future<void>::get()
+{
+ unique_ptr<__shared_count, __release_shared_count> __(__state_);
+ __assoc_sub_state* __s = __state_;
+ __state_ = nullptr;
+ __s->copy();
+}
+
+promise<void>::promise()
+ : __state_(new __assoc_sub_state)
+{
+}
+
+promise<void>::~promise()
+{
+ if (__state_)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ if (!__state_->__has_value() && __state_->use_count() > 1)
+ __state_->set_exception(make_exception_ptr(
+ future_error(make_error_code(future_errc::broken_promise))
+ ));
+#endif // _LIBCPP_NO_EXCEPTIONS
+ __state_->__release_shared();
+ }
+}
+
+future<void>
+promise<void>::get_future()
+{
+ if (__state_ == nullptr)
+ __throw_future_error(future_errc::no_state);
+ return future<void>(__state_);
+}
+
+void
+promise<void>::set_value()
+{
+ if (__state_ == nullptr)
+ __throw_future_error(future_errc::no_state);
+ __state_->set_value();
+}
+
+void
+promise<void>::set_exception(exception_ptr __p)
+{
+ if (__state_ == nullptr)
+ __throw_future_error(future_errc::no_state);
+ __state_->set_exception(__p);
+}
+
+void
+promise<void>::set_value_at_thread_exit()
+{
+ if (__state_ == nullptr)
+ __throw_future_error(future_errc::no_state);
+ __state_->set_value_at_thread_exit();
+}
+
+void
+promise<void>::set_exception_at_thread_exit(exception_ptr __p)
+{
+ if (__state_ == nullptr)
+ __throw_future_error(future_errc::no_state);
+ __state_->set_exception_at_thread_exit(__p);
+}
+
+shared_future<void>::~shared_future()
+{
+ if (__state_)
+ __state_->__release_shared();
+}
+
+shared_future<void>&
+shared_future<void>::operator=(const shared_future& __rhs)
+{
+ if (__rhs.__state_)
+ __rhs.__state_->__add_shared();
+ if (__state_)
+ __state_->__release_shared();
+ __state_ = __rhs.__state_;
+ return *this;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // !_LIBCPP_HAS_NO_THREADS
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/hash.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/hash.cpp
new file mode 100644
index 0000000000..96cbd38f4d
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/hash.cpp
@@ -0,0 +1,559 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <__hash_table>
+#include <algorithm>
+#include <stdexcept>
+#include <type_traits>
+
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wtautological-constant-out-of-range-compare")
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace {
+
+// handle all next_prime(i) for i in [1, 210), special case 0
+const unsigned small_primes[] =
+{
+ 0,
+ 2,
+ 3,
+ 5,
+ 7,
+ 11,
+ 13,
+ 17,
+ 19,
+ 23,
+ 29,
+ 31,
+ 37,
+ 41,
+ 43,
+ 47,
+ 53,
+ 59,
+ 61,
+ 67,
+ 71,
+ 73,
+ 79,
+ 83,
+ 89,
+ 97,
+ 101,
+ 103,
+ 107,
+ 109,
+ 113,
+ 127,
+ 131,
+ 137,
+ 139,
+ 149,
+ 151,
+ 157,
+ 163,
+ 167,
+ 173,
+ 179,
+ 181,
+ 191,
+ 193,
+ 197,
+ 199,
+ 211
+};
+
+// potential primes = 210*k + indices[i], k >= 1
+// these numbers are not divisible by 2, 3, 5 or 7
+// (or any integer 2 <= j <= 10 for that matter).
+const unsigned indices[] =
+{
+ 1,
+ 11,
+ 13,
+ 17,
+ 19,
+ 23,
+ 29,
+ 31,
+ 37,
+ 41,
+ 43,
+ 47,
+ 53,
+ 59,
+ 61,
+ 67,
+ 71,
+ 73,
+ 79,
+ 83,
+ 89,
+ 97,
+ 101,
+ 103,
+ 107,
+ 109,
+ 113,
+ 121,
+ 127,
+ 131,
+ 137,
+ 139,
+ 143,
+ 149,
+ 151,
+ 157,
+ 163,
+ 167,
+ 169,
+ 173,
+ 179,
+ 181,
+ 187,
+ 191,
+ 193,
+ 197,
+ 199,
+ 209
+};
+
+}
+
+// Returns: If n == 0, returns 0. Else returns the lowest prime number that
+// is greater than or equal to n.
+//
+// The algorithm creates a list of small primes, plus an open-ended list of
+// potential primes. All prime numbers are potential prime numbers. However
+// some potential prime numbers are not prime. In an ideal world, all potential
+// prime numbers would be prime. Candidate prime numbers are chosen as the next
+// highest potential prime. Then this number is tested for prime by dividing it
+// by all potential prime numbers less than the sqrt of the candidate.
+//
+// This implementation defines potential primes as those numbers not divisible
+// by 2, 3, 5, and 7. Other (common) implementations define potential primes
+// as those not divisible by 2. A few other implementations define potential
+// primes as those not divisible by 2 or 3. By raising the number of small
+// primes which the potential prime is not divisible by, the set of potential
+// primes more closely approximates the set of prime numbers. And thus there
+// are fewer potential primes to search, and fewer potential primes to divide
+// against.
+
+template <size_t _Sz = sizeof(size_t)>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<_Sz == 4, void>::type
+__check_for_overflow(size_t N)
+{
+ if (N > 0xFFFFFFFB)
+ __throw_overflow_error("__next_prime overflow");
+}
+
+template <size_t _Sz = sizeof(size_t)>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<_Sz == 8, void>::type
+__check_for_overflow(size_t N)
+{
+ if (N > 0xFFFFFFFFFFFFFFC5ull)
+ __throw_overflow_error("__next_prime overflow");
+}
+
+size_t
+__next_prime(size_t n)
+{
+ const size_t L = 210;
+ const size_t N = sizeof(small_primes) / sizeof(small_primes[0]);
+ // If n is small enough, search in small_primes
+ if (n <= small_primes[N-1])
+ return *std::lower_bound(small_primes, small_primes + N, n);
+ // Else n > largest small_primes
+ // Check for overflow
+ __check_for_overflow(n);
+ // Start searching list of potential primes: L * k0 + indices[in]
+ const size_t M = sizeof(indices) / sizeof(indices[0]);
+ // Select first potential prime >= n
+ // Known a-priori n >= L
+ size_t k0 = n / L;
+ size_t in = static_cast<size_t>(std::lower_bound(indices, indices + M, n - k0 * L)
+ - indices);
+ n = L * k0 + indices[in];
+ while (true)
+ {
+ // Divide n by all primes or potential primes (i) until:
+ // 1. The division is even, so try next potential prime.
+ // 2. The i > sqrt(n), in which case n is prime.
+ // It is known a-priori that n is not divisible by 2, 3, 5 or 7,
+ // so don't test those (j == 5 -> divide by 11 first). And the
+ // potential primes start with 211, so don't test against the last
+ // small prime.
+ for (size_t j = 5; j < N - 1; ++j)
+ {
+ const std::size_t p = small_primes[j];
+ const std::size_t q = n / p;
+ if (q < p)
+ return n;
+ if (n == q * p)
+ goto next;
+ }
+ // n wasn't divisible by small primes, try potential primes
+ {
+ size_t i = 211;
+ while (true)
+ {
+ std::size_t q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 10;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 2;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 4;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 2;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 4;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 6;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 2;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 6;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 4;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 2;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 4;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 6;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 6;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 2;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 6;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 4;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 2;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 6;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 4;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 6;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 8;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 4;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 2;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 4;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 2;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 4;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 8;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 6;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 4;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 6;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 2;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 4;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 6;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 2;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 6;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 6;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 4;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 2;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 4;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 6;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 2;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 6;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 4;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 2;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 4;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 2;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 10;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ // This will loop i to the next "plane" of potential primes
+ i += 2;
+ }
+ }
+next:
+ // n is not prime. Increment n to next potential prime.
+ if (++in == M)
+ {
+ ++k0;
+ in = 0;
+ }
+ n = L * k0 + indices[in];
+ }
+}
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/include/apple_availability.h b/contrib/libs/cxxsupp/libcxxmsvc/src/include/apple_availability.h
new file mode 100644
index 0000000000..504700ebd0
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/include/apple_availability.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_SRC_INCLUDE_APPLE_AVAILABILITY_H
+#define _LIBCPP_SRC_INCLUDE_APPLE_AVAILABILITY_H
+
+#if defined(__APPLE__)
+
+#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
+#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101300
+#define _LIBCPP_USE_UTIMENSAT
+#endif
+#elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)
+#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 110000
+#define _LIBCPP_USE_UTIMENSAT
+#endif
+#elif defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__)
+#if __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 110000
+#define _LIBCPP_USE_UTIMENSAT
+#endif
+#elif defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__)
+#if __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 40000
+#define _LIBCPP_USE_UTIMENSAT
+#endif
+#endif // __ENVIRONMENT_.*_VERSION_MIN_REQUIRED__
+
+#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
+#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101500
+#define _LIBCPP_USE_ULOCK
+#endif
+#elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)
+#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130000
+#define _LIBCPP_USE_ULOCK
+#endif
+#elif defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__)
+#if __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 130000
+#define _LIBCPP_USE_ULOCK
+#endif
+#elif defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__)
+#if __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 60000
+#define _LIBCPP_USE_ULOCK
+#endif
+#endif // __ENVIRONMENT_.*_VERSION_MIN_REQUIRED__
+
+#endif // __APPLE__
+
+#endif // _LIBCPP_SRC_INCLUDE_APPLE_AVAILABILITY_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/include/atomic_support.h b/contrib/libs/cxxsupp/libcxxmsvc/src/include/atomic_support.h
new file mode 100644
index 0000000000..3e73f2ce27
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/include/atomic_support.h
@@ -0,0 +1,176 @@
+//===----------------------------------------------------------------------===////
+//
+// 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 ATOMIC_SUPPORT_H
+#define ATOMIC_SUPPORT_H
+
+#include <__config>
+#include <memory> // for __libcpp_relaxed_load
+
+#if defined(__clang__) && __has_builtin(__atomic_load_n) \
+ && __has_builtin(__atomic_store_n) \
+ && __has_builtin(__atomic_add_fetch) \
+ && __has_builtin(__atomic_exchange_n) \
+ && __has_builtin(__atomic_compare_exchange_n) \
+ && defined(__ATOMIC_RELAXED) \
+ && defined(__ATOMIC_CONSUME) \
+ && defined(__ATOMIC_ACQUIRE) \
+ && defined(__ATOMIC_RELEASE) \
+ && defined(__ATOMIC_ACQ_REL) \
+ && defined(__ATOMIC_SEQ_CST)
+# define _LIBCPP_HAS_ATOMIC_BUILTINS
+#elif defined(_LIBCPP_COMPILER_GCC)
+# define _LIBCPP_HAS_ATOMIC_BUILTINS
+#endif
+
+#if !defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && !defined(_LIBCPP_HAS_NO_THREADS)
+# if defined(_LIBCPP_WARNING)
+ _LIBCPP_WARNING("Building libc++ without __atomic builtins is unsupported")
+# else
+# warning Building libc++ without __atomic builtins is unsupported
+# endif
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace {
+
+#if defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && !defined(_LIBCPP_HAS_NO_THREADS)
+
+enum __libcpp_atomic_order {
+ _AO_Relaxed = __ATOMIC_RELAXED,
+ _AO_Consume = __ATOMIC_CONSUME,
+ _AO_Acquire = __ATOMIC_ACQUIRE,
+ _AO_Release = __ATOMIC_RELEASE,
+ _AO_Acq_Rel = __ATOMIC_ACQ_REL,
+ _AO_Seq = __ATOMIC_SEQ_CST
+};
+
+template <class _ValueType, class _FromType>
+inline _LIBCPP_INLINE_VISIBILITY
+void __libcpp_atomic_store(_ValueType* __dest, _FromType __val,
+ int __order = _AO_Seq)
+{
+ __atomic_store_n(__dest, __val, __order);
+}
+
+template <class _ValueType, class _FromType>
+inline _LIBCPP_INLINE_VISIBILITY
+void __libcpp_relaxed_store(_ValueType* __dest, _FromType __val)
+{
+ __atomic_store_n(__dest, __val, _AO_Relaxed);
+}
+
+template <class _ValueType>
+inline _LIBCPP_INLINE_VISIBILITY
+_ValueType __libcpp_atomic_load(_ValueType const* __val,
+ int __order = _AO_Seq)
+{
+ return __atomic_load_n(__val, __order);
+}
+
+template <class _ValueType, class _AddType>
+inline _LIBCPP_INLINE_VISIBILITY
+_ValueType __libcpp_atomic_add(_ValueType* __val, _AddType __a,
+ int __order = _AO_Seq)
+{
+ return __atomic_add_fetch(__val, __a, __order);
+}
+
+template <class _ValueType>
+inline _LIBCPP_INLINE_VISIBILITY
+_ValueType __libcpp_atomic_exchange(_ValueType* __target,
+ _ValueType __value, int __order = _AO_Seq)
+{
+ return __atomic_exchange_n(__target, __value, __order);
+}
+
+template <class _ValueType>
+inline _LIBCPP_INLINE_VISIBILITY
+bool __libcpp_atomic_compare_exchange(_ValueType* __val,
+ _ValueType* __expected, _ValueType __after,
+ int __success_order = _AO_Seq,
+ int __fail_order = _AO_Seq)
+{
+ return __atomic_compare_exchange_n(__val, __expected, __after, true,
+ __success_order, __fail_order);
+}
+
+#else // _LIBCPP_HAS_NO_THREADS
+
+enum __libcpp_atomic_order {
+ _AO_Relaxed,
+ _AO_Consume,
+ _AO_Acquire,
+ _AO_Release,
+ _AO_Acq_Rel,
+ _AO_Seq
+};
+
+template <class _ValueType, class _FromType>
+inline _LIBCPP_INLINE_VISIBILITY
+void __libcpp_atomic_store(_ValueType* __dest, _FromType __val,
+ int = 0)
+{
+ *__dest = __val;
+}
+
+template <class _ValueType, class _FromType>
+inline _LIBCPP_INLINE_VISIBILITY
+void __libcpp_relaxed_store(_ValueType* __dest, _FromType __val)
+{
+ *__dest = __val;
+}
+
+template <class _ValueType>
+inline _LIBCPP_INLINE_VISIBILITY
+_ValueType __libcpp_atomic_load(_ValueType const* __val,
+ int = 0)
+{
+ return *__val;
+}
+
+template <class _ValueType, class _AddType>
+inline _LIBCPP_INLINE_VISIBILITY
+_ValueType __libcpp_atomic_add(_ValueType* __val, _AddType __a,
+ int = 0)
+{
+ return *__val += __a;
+}
+
+template <class _ValueType>
+inline _LIBCPP_INLINE_VISIBILITY
+_ValueType __libcpp_atomic_exchange(_ValueType* __target,
+ _ValueType __value, int = _AO_Seq)
+{
+ _ValueType old = *__target;
+ *__target = __value;
+ return old;
+}
+
+template <class _ValueType>
+inline _LIBCPP_INLINE_VISIBILITY
+bool __libcpp_atomic_compare_exchange(_ValueType* __val,
+ _ValueType* __expected, _ValueType __after,
+ int = 0, int = 0)
+{
+ if (*__val == *__expected) {
+ *__val = __after;
+ return true;
+ }
+ *__expected = *__val;
+ return false;
+}
+
+#endif // _LIBCPP_HAS_NO_THREADS
+
+} // end namespace
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // ATOMIC_SUPPORT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/include/config_elast.h b/contrib/libs/cxxsupp/libcxxmsvc/src/include/config_elast.h
new file mode 100644
index 0000000000..0ed53a3b20
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/include/config_elast.h
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_CONFIG_ELAST
+#define _LIBCPP_CONFIG_ELAST
+
+#include <__config>
+
+#if defined(_LIBCPP_MSVCRT_LIKE)
+#include <stdlib.h>
+#else
+#include <errno.h>
+#endif
+
+// Note: _LIBCPP_ELAST needs to be defined only on platforms
+// where strerror/strerror_r can't handle out-of-range errno values.
+#if defined(ELAST)
+#define _LIBCPP_ELAST ELAST
+#elif defined(_NEWLIB_VERSION)
+#define _LIBCPP_ELAST __ELASTERROR
+#elif defined(__NuttX__)
+// No _LIBCPP_ELAST needed on NuttX
+#elif defined(__Fuchsia__)
+// No _LIBCPP_ELAST needed on Fuchsia
+#elif defined(__wasi__)
+// No _LIBCPP_ELAST needed on WASI
+#elif defined(__linux__) || defined(_LIBCPP_HAS_MUSL_LIBC)
+#define _LIBCPP_ELAST 4095
+#elif defined(__APPLE__)
+// No _LIBCPP_ELAST needed on Apple
+#elif defined(__sun__)
+#define _LIBCPP_ELAST ESTALE
+#elif defined(__MVS__)
+#define _LIBCPP_ELAST 1160
+#elif defined(_LIBCPP_MSVCRT_LIKE)
+#define _LIBCPP_ELAST (_sys_nerr - 1)
+#elif defined(_AIX)
+#define _LIBCPP_ELAST 127
+#else
+// Warn here so that the person doing the libcxx port has an easier time:
+#warning ELAST for this platform not yet implemented
+#endif
+
+#endif // _LIBCPP_CONFIG_ELAST
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/include/refstring.h b/contrib/libs/cxxsupp/libcxxmsvc/src/include/refstring.h
new file mode 100644
index 0000000000..6a0ebda6a2
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/include/refstring.h
@@ -0,0 +1,167 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_REFSTRING_H
+#define _LIBCPP_REFSTRING_H
+
+#include <__config>
+#include <stdexcept>
+#include <cstddef>
+#include <cstring>
+
+#if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_ATOMIC)
+#define _LIBCPP_USE_ATOMIC
+#include <atomic>
+#else
+#include "atomic_support.h"
+#endif
+
+// MacOS and iOS used to ship with libstdc++, and still support old applications
+// linking against libstdc++. The libc++ and libstdc++ exceptions are supposed
+// to be ABI compatible, such that they can be thrown from one library and caught
+// in the other.
+//
+// For that reason, we must look for libstdc++ in the same process and if found,
+// check the string stored in the exception object to see if it is the GCC empty
+// string singleton before manipulating the reference count. This is done so that
+// if an exception is created with a zero-length string in libstdc++, libc++abi
+// won't try to delete the memory.
+#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || \
+ defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)
+# define _LIBCPP_CHECK_FOR_GCC_EMPTY_STRING_STORAGE
+# include <dlfcn.h>
+# include <mach-o/dyld.h>
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace __refstring_imp { namespace {
+typedef int count_t;
+
+struct _Rep_base {
+ std::size_t len;
+ std::size_t cap;
+#ifdef _LIBCPP_USE_ATOMIC
+ std::atomic<count_t> count;
+#else
+ count_t count;
+#endif
+};
+
+inline _Rep_base* rep_from_data(const char *data_) noexcept {
+ char *data = const_cast<char *>(data_);
+ return reinterpret_cast<_Rep_base *>(data - sizeof(_Rep_base));
+}
+
+inline char * data_from_rep(_Rep_base *rep) noexcept {
+ char *data = reinterpret_cast<char *>(rep);
+ return data + sizeof(*rep);
+}
+
+#if defined(_LIBCPP_CHECK_FOR_GCC_EMPTY_STRING_STORAGE)
+inline
+const char* compute_gcc_empty_string_storage() noexcept
+{
+ void* handle = dlopen("/usr/lib/libstdc++.6.dylib", RTLD_NOLOAD);
+ if (handle == nullptr)
+ return nullptr;
+ void* sym = dlsym(handle, "_ZNSs4_Rep20_S_empty_rep_storageE");
+ if (sym == nullptr)
+ return nullptr;
+ return data_from_rep(reinterpret_cast<_Rep_base *>(sym));
+}
+
+inline
+const char*
+get_gcc_empty_string_storage() noexcept
+{
+ static const char* p = compute_gcc_empty_string_storage();
+ return p;
+}
+#endif
+
+}} // namespace __refstring_imp
+
+using namespace __refstring_imp;
+
+inline
+__libcpp_refstring::__libcpp_refstring(const char* msg) {
+ std::size_t len = strlen(msg);
+ _Rep_base* rep = static_cast<_Rep_base *>(::operator new(sizeof(*rep) + len + 1));
+ rep->len = len;
+ rep->cap = len;
+ rep->count = 0;
+ char *data = data_from_rep(rep);
+ std::memcpy(data, msg, len + 1);
+ __imp_ = data;
+}
+
+inline
+__libcpp_refstring::__libcpp_refstring(const __libcpp_refstring &s) noexcept
+ : __imp_(s.__imp_)
+{
+ if (__uses_refcount())
+#ifdef _LIBCPP_USE_ATOMIC
+ rep_from_data(__imp_)->count.fetch_add(1);
+#else
+ __libcpp_atomic_add(&rep_from_data(__imp_)->count, 1);
+#endif
+}
+
+inline
+__libcpp_refstring& __libcpp_refstring::operator=(__libcpp_refstring const& s) noexcept {
+ bool adjust_old_count = __uses_refcount();
+ struct _Rep_base *old_rep = rep_from_data(__imp_);
+ __imp_ = s.__imp_;
+ if (__uses_refcount())
+#ifdef _LIBCPP_USE_ATOMIC
+ rep_from_data(__imp_)->count.fetch_add(1);
+#else
+ __libcpp_atomic_add(&rep_from_data(__imp_)->count, 1);
+#endif
+
+ if (adjust_old_count)
+ {
+#ifdef _LIBCPP_USE_ATOMIC
+ if (old_rep->count.fetch_sub(1) == 0)
+#else
+ if (__libcpp_atomic_add(&old_rep->count, count_t(-1)) < 0)
+#endif
+ {
+ ::operator delete(old_rep);
+ }
+ }
+ return *this;
+}
+
+inline
+__libcpp_refstring::~__libcpp_refstring() {
+ if (__uses_refcount()) {
+ _Rep_base* rep = rep_from_data(__imp_);
+#ifdef _LIBCPP_USE_ATOMIC
+ if (rep->count.fetch_sub(1) == 0) {
+#else
+ if (__sync_add_and_fetch(&rep->count, count_t(-1)) < 0) {
+#endif
+ ::operator delete(rep);
+ }
+ }
+}
+
+inline
+bool __libcpp_refstring::__uses_refcount() const {
+#if defined(_LIBCPP_CHECK_FOR_GCC_EMPTY_STRING_STORAGE)
+ return __imp_ != get_gcc_empty_string_storage();
+#else
+ return true;
+#endif
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif //_LIBCPP_REFSTRING_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/common.h b/contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/common.h
new file mode 100644
index 0000000000..c24115c233
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/common.h
@@ -0,0 +1,108 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (c) Microsoft Corporation.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+// Copyright 2018 Ulf Adams
+// Copyright (c) Microsoft Corporation. All rights reserved.
+
+// Boost Software License - Version 1.0 - August 17th, 2003
+
+// Permission is hereby granted, free of charge, to any person or organization
+// obtaining a copy of the software and accompanying documentation covered by
+// this license (the "Software") to use, reproduce, display, distribute,
+// execute, and transmit the Software, and to prepare derivative works of the
+// Software, and to permit third-parties to whom the Software is furnished to
+// do so, all subject to the following:
+
+// The copyright notices in the Software and this entire statement, including
+// the above license grant, this restriction and the following disclaimer,
+// must be included in all copies of the Software, in whole or in part, and
+// all derivative works of the Software, unless such copies or derivative
+// works are solely in the form of machine-executable object code generated by
+// a source language processor.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#ifndef _LIBCPP_SRC_INCLUDE_RYU_COMMON_H
+#define _LIBCPP_SRC_INCLUDE_RYU_COMMON_H
+
+// Avoid formatting to keep the changes with the original code minimal.
+// clang-format off
+
+#include <__assert>
+#include "__config"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __decimalLength9(const uint32_t __v) {
+ // Function precondition: __v is not a 10-digit number.
+ // (f2s: 9 digits are sufficient for round-tripping.)
+ // (d2fixed: We print 9-digit blocks.)
+ _LIBCPP_ASSERT(__v < 1000000000, "");
+ if (__v >= 100000000) { return 9; }
+ if (__v >= 10000000) { return 8; }
+ if (__v >= 1000000) { return 7; }
+ if (__v >= 100000) { return 6; }
+ if (__v >= 10000) { return 5; }
+ if (__v >= 1000) { return 4; }
+ if (__v >= 100) { return 3; }
+ if (__v >= 10) { return 2; }
+ return 1;
+}
+
+// Returns __e == 0 ? 1 : ceil(log_2(5^__e)).
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline int32_t __pow5bits(const int32_t __e) {
+ // This approximation works up to the point that the multiplication overflows at __e = 3529.
+ // If the multiplication were done in 64 bits, it would fail at 5^4004 which is just greater
+ // than 2^9297.
+ _LIBCPP_ASSERT(__e >= 0, "");
+ _LIBCPP_ASSERT(__e <= 3528, "");
+ return static_cast<int32_t>(((static_cast<uint32_t>(__e) * 1217359) >> 19) + 1);
+}
+
+// Returns floor(log_10(2^__e)).
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __log10Pow2(const int32_t __e) {
+ // The first value this approximation fails for is 2^1651 which is just greater than 10^297.
+ _LIBCPP_ASSERT(__e >= 0, "");
+ _LIBCPP_ASSERT(__e <= 1650, "");
+ return (static_cast<uint32_t>(__e) * 78913) >> 18;
+}
+
+// Returns floor(log_10(5^__e)).
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __log10Pow5(const int32_t __e) {
+ // The first value this approximation fails for is 5^2621 which is just greater than 10^1832.
+ _LIBCPP_ASSERT(__e >= 0, "");
+ _LIBCPP_ASSERT(__e <= 2620, "");
+ return (static_cast<uint32_t>(__e) * 732923) >> 20;
+}
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __float_to_bits(const float __f) {
+ uint32_t __bits = 0;
+ _VSTD::memcpy(&__bits, &__f, sizeof(float));
+ return __bits;
+}
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __double_to_bits(const double __d) {
+ uint64_t __bits = 0;
+ _VSTD::memcpy(&__bits, &__d, sizeof(double));
+ return __bits;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+// clang-format on
+
+#endif // _LIBCPP_SRC_INCLUDE_RYU_COMMON_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/d2fixed.h b/contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/d2fixed.h
new file mode 100644
index 0000000000..b8862de251
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/d2fixed.h
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (c) Microsoft Corporation.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+// Copyright 2018 Ulf Adams
+// Copyright (c) Microsoft Corporation. All rights reserved.
+
+// Boost Software License - Version 1.0 - August 17th, 2003
+
+// Permission is hereby granted, free of charge, to any person or organization
+// obtaining a copy of the software and accompanying documentation covered by
+// this license (the "Software") to use, reproduce, display, distribute,
+// execute, and transmit the Software, and to prepare derivative works of the
+// Software, and to permit third-parties to whom the Software is furnished to
+// do so, all subject to the following:
+
+// The copyright notices in the Software and this entire statement, including
+// the above license grant, this restriction and the following disclaimer,
+// must be included in all copies of the Software, in whole or in part, and
+// all derivative works of the Software, unless such copies or derivative
+// works are solely in the form of machine-executable object code generated by
+// a source language processor.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#ifndef _LIBCPP_SRC_INCLUDE_RYU_D2FIXED_H
+#define _LIBCPP_SRC_INCLUDE_RYU_D2FIXED_H
+
+// Avoid formatting to keep the changes with the original code minimal.
+// clang-format off
+
+#include <__config>
+#include <cstdint>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+void __append_n_digits(const uint32_t __olength, uint32_t __digits, char* const __result);
+void __append_nine_digits(uint32_t __digits, char* const __result);
+
+[[nodiscard]] to_chars_result __d2fixed_buffered_n(char* _First, char* const _Last, const double __d, const uint32_t __precision);
+[[nodiscard]] to_chars_result __d2exp_buffered_n(char* _First, char* const _Last, const double __d, uint32_t __precision);
+
+_LIBCPP_END_NAMESPACE_STD
+
+// clang-format on
+
+#endif // _LIBCPP_SRC_INCLUDE_RYU_D2FIXED_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/d2fixed_full_table.h b/contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/d2fixed_full_table.h
new file mode 100644
index 0000000000..a63d6f2d16
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/d2fixed_full_table.h
@@ -0,0 +1,4451 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (c) Microsoft Corporation.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+// Copyright 2018 Ulf Adams
+// Copyright (c) Microsoft Corporation. All rights reserved.
+
+// Boost Software License - Version 1.0 - August 17th, 2003
+
+// Permission is hereby granted, free of charge, to any person or organization
+// obtaining a copy of the software and accompanying documentation covered by
+// this license (the "Software") to use, reproduce, display, distribute,
+// execute, and transmit the Software, and to prepare derivative works of the
+// Software, and to permit third-parties to whom the Software is furnished to
+// do so, all subject to the following:
+
+// The copyright notices in the Software and this entire statement, including
+// the above license grant, this restriction and the following disclaimer,
+// must be included in all copies of the Software, in whole or in part, and
+// all derivative works of the Software, unless such copies or derivative
+// works are solely in the form of machine-executable object code generated by
+// a source language processor.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#ifndef _LIBCPP_SRC_INCLUDE_RYU_D2FIXED_FULL_TABLE_H
+#define _LIBCPP_SRC_INCLUDE_RYU_D2FIXED_FULL_TABLE_H
+
+// Avoid formatting to keep the changes with the original code minimal.
+// clang-format off
+
+#include <__config>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+inline constexpr int __TABLE_SIZE = 64;
+
+inline constexpr uint16_t __POW10_OFFSET[__TABLE_SIZE] = {
+ 0, 2, 5, 8, 12, 16, 21, 26, 32, 39,
+ 46, 54, 62, 71, 80, 90, 100, 111, 122, 134,
+ 146, 159, 173, 187, 202, 217, 233, 249, 266, 283,
+ 301, 319, 338, 357, 377, 397, 418, 440, 462, 485,
+ 508, 532, 556, 581, 606, 632, 658, 685, 712, 740,
+ 769, 798, 828, 858, 889, 920, 952, 984, 1017, 1050,
+ 1084, 1118, 1153, 1188
+};
+
+inline constexpr uint64_t __POW10_SPLIT[1224][3] = {
+ { 1u, 72057594037927936u, 0u },
+ { 699646928636035157u, 72057594u, 0u },
+ { 1u, 0u, 256u },
+ { 11902091922964236229u, 4722366482869u, 0u },
+ { 6760415703743915872u, 4722u, 0u },
+ { 1u, 0u, 16777216u },
+ { 13369850649504950658u, 309485009821345068u, 0u },
+ { 15151142278969419334u, 309485009u, 0u },
+ { 1u, 0u, 75511627776u },
+ { 4635408826454083567u, 9437866644873197963u, 1099u },
+ { 12367138975830625353u, 20282409603651u, 0u },
+ { 7555853734021184432u, 20282u, 0u },
+ { 1u, 0u, 250037927936u },
+ { 5171444645924616995u, 699646928636035156u, 72057594u },
+ { 16672297533003297786u, 1329227995784915872u, 0u },
+ { 14479142226848862515u, 1329227995u, 0u },
+ { 1u, 0u, 181645213696u },
+ { 12214193123817091081u, 11902091922964236228u, 114366482869u },
+ { 16592893013671929435u, 6760415703743915871u, 4722u },
+ { 4549827147718617003u, 87112285931760u, 0u },
+ { 5274510003815168971u, 87112u, 0u },
+ { 1u, 0u, 44724781056u },
+ { 9794971998307800535u, 13369850649504950657u, 209821345068u },
+ { 14720142899209240169u, 15151142278969419333u, 309485009u },
+ { 4300745446091561535u, 5708990770823839524u, 0u },
+ { 15197156861335443364u, 5708990770u, 0u },
+ { 1u, 0u, 139251286016u },
+ { 13484604155038683037u, 4635408826454083566u, 67670423947u },
+ { 8356963862052375699u, 12367138975830625352u, 58409603651u },
+ { 5850852848337610021u, 7555853734021184431u, 20282u },
+ { 2712780827214982050u, 374144419156711u, 0u },
+ { 7732076577307618052u, 374144u, 0u },
+ { 1u, 0u, 84280344576u },
+ { 17296309485351745867u, 5171444645924616994u, 160903807060u },
+ { 16598859101615853088u, 16672297533003297785u, 219784915872u },
+ { 7469952526870444257u, 14479142226848862514u, 1329227995u },
+ { 13531654022114669524u, 6073184580144670117u, 1u },
+ { 15757609704383306943u, 24519928653u, 0u },
+ { 9590990814237149590u, 24u, 0u },
+ { 1u, 0u, 196662132736u },
+ { 15408590707489433890u, 12214193123817091080u, 95899502532u },
+ { 18332056844289122710u, 16592893013671929434u, 240246646623u },
+ { 11114572877353986193u, 4549827147718617002u, 72285931760u },
+ { 1703393793997526525u, 5274510003815168970u, 87112u },
+ { 5082852056285196265u, 1606938044258990u, 0u },
+ { 816434266573722365u, 1606938u, 0u },
+ { 1u, 0u, 129530986496u },
+ { 5736523019264798742u, 9794971998307800534u, 69797980545u },
+ { 10129314776268243339u, 14720142899209240168u, 36233143877u },
+ { 16511595775483995364u, 4300745446091561534u, 50823839524u },
+ { 12367293405401453325u, 15197156861335443363u, 5708990770u },
+ { 16934621733248854291u, 13078571300009428617u, 5u },
+ { 10278280417769171336u, 105312291668u, 0u },
+ { 5760764486226151240u, 105u, 0u },
+ { 1u, 0u, 238731001856u },
+ { 4128368337188369761u, 13484604155038683036u, 72453031918u },
+ { 10240941003671005056u, 8356963862052375698u, 175317175368u },
+ { 17933378316822368251u, 5850852848337610020u, 231147060143u },
+ { 8346249813075698616u, 2712780827214982049u, 128419156711u },
+ { 15906203609160902695u, 7732076577307618051u, 374144u },
+ { 14525607416135386328u, 6901746346790563u, 0u },
+ { 6397156777364256320u, 6901746u, 0u },
+ { 1u, 0u, 34937634816u },
+ { 16798760952716600048u, 17296309485351745866u, 249899825954u },
+ { 2419982808370854967u, 16598859101615853087u, 50404946937u },
+ { 2922947087773078956u, 7469952526870444256u, 165733552434u },
+ { 15419220167069510190u, 13531654022114669523u, 77854221733u },
+ { 3452124642157173416u, 15757609704383306942u, 24519928653u },
+ { 5979700067267186899u, 9590990814237149589u, 24u },
+ { 4913998146922579597u, 452312848583u, 0u },
+ { 5771037749337678924u, 452u, 0u },
+ { 1u, 0u, 8835301376u },
+ { 3464734175350698519u, 15408590707489433889u, 90993782792u },
+ { 9334527711335850125u, 18332056844289122709u, 170602522202u },
+ { 7269882896518450106u, 11114572877353986192u, 202092341162u },
+ { 1372511258182263196u, 1703393793997526524u, 174275541962u },
+ { 7571228438575951046u, 5082852056285196264u, 26044258990u },
+ { 2992506536646070406u, 816434266573722364u, 1606938u },
+ { 524517896824344606u, 29642774844752946u, 0u },
+ { 15582941400898702773u, 29642774u, 0u },
+ { 1u, 0u, 214310977536u },
+ { 3846112492507251066u, 5736523019264798741u, 104549111254u },
+ { 16681117750123089487u, 10129314776268243338u, 62895095400u },
+ { 14986314536556547267u, 16511595775483995363u, 163670432318u },
+ { 2573712825027107389u, 12367293405401453324u, 137918027683u },
+ { 7504855874008324928u, 16934621733248854290u, 84557186697u },
+ { 9572138030626879787u, 10278280417769171335u, 105312291668u },
+ { 8520676959353394843u, 5760764486226151239u, 105u },
+ { 13448984662897903496u, 1942668892225u, 0u },
+ { 12338883700918130648u, 1942u, 0u },
+ { 1u, 0u, 156223799296u },
+ { 2517285787892561600u, 4128368337188369760u, 146555162524u },
+ { 4338831817635138103u, 10240941003671005055u, 36972170386u },
+ { 1561495325934523196u, 17933378316822368250u, 161452451108u },
+ { 12262635050079398786u, 8346249813075698615u, 3862277025u },
+ { 11144065765517284188u, 15906203609160902694u, 163787434755u },
+ { 1212260522471875711u, 14525607416135386327u, 242346790563u },
+ { 9695352922247418869u, 6397156777364256319u, 6901746u },
+ { 7227025834627242948u, 127314748520905380u, 0u },
+ { 9609008238705447829u, 127314748u, 0u },
+ { 1u, 0u, 74910662656u },
+ { 3609144142396852269u, 16798760952716600047u, 31131187530u },
+ { 11568848377382068865u, 2419982808370854966u, 224158453279u },
+ { 10068303578029323957u, 2922947087773078955u, 211835877600u },
+ { 11645070846862630231u, 15419220167069510189u, 190187140051u },
+ { 12449386705878485055u, 3452124642157173415u, 149324160190u },
+ { 15025619323517318418u, 5979700067267186898u, 199266388373u },
+ { 14996237555047131272u, 4913998146922579596u, 196312848583u },
+ { 10211005638256058413u, 5771037749337678923u, 452u },
+ { 1014743503555840530u, 8343699359066u, 0u },
+ { 12900897707145290678u, 8343u, 0u },
+ { 1u, 0u, 33187823616u },
+ { 4718003016239473662u, 3464734175350698518u, 149506025761u },
+ { 14865830648693666725u, 9334527711335850124u, 144394101141u },
+ { 14754517212823091778u, 7269882896518450105u, 252074403984u },
+ { 11113946551474911901u, 1372511258182263195u, 232410437116u },
+ { 1963520352638130630u, 7571228438575951045u, 252162224104u },
+ { 13342587341404964200u, 2992506536646070405u, 50028434172u },
+ { 6240392545013573291u, 524517896824344605u, 22844752946u },
+ { 14377490861349714758u, 15582941400898702772u, 29642774u },
+ { 1717863312631397839u, 546812681195752981u, 0u },
+ { 3611005143890591770u, 546812681u, 0u },
+ { 1u, 0u, 21208498176u },
+ { 13168252824351245504u, 3846112492507251065u, 138904285205u },
+ { 735883891883379688u, 16681117750123089486u, 227812409738u },
+ { 10609203866866106404u, 14986314536556547266u, 12139521251u },
+ { 12358191111890306470u, 2573712825027107388u, 18406839052u },
+ { 15229916368406413528u, 7504855874008324927u, 135518906642u },
+ { 7241424335568075942u, 9572138030626879786u, 71461906823u },
+ { 6049715868779871913u, 8520676959353394842u, 65729070919u },
+ { 2000548404719336762u, 13448984662897903495u, 150668892225u },
+ { 1410974761895205301u, 12338883700918130647u, 1942u },
+ { 16000132467694084868u, 35835915874844u, 0u },
+ { 16894908866816792556u, 35835u, 0u },
+ { 1u, 0u, 96136462336u },
+ { 589096329272056762u, 2517285787892561599u, 127235208544u },
+ { 7097729792403256904u, 4338831817635138102u, 250084648831u },
+ { 8553736750439287020u, 1561495325934523195u, 183664758778u },
+ { 2114152625261065696u, 12262635050079398785u, 38604121015u },
+ { 9817523680007641224u, 11144065765517284187u, 215065716774u },
+ { 13047215537500048015u, 1212260522471875710u, 63525586135u },
+ { 16755544192002345880u, 9695352922247418868u, 164391777855u },
+ { 6930119832670648356u, 7227025834627242947u, 60520905380u },
+ { 14560698131901886167u, 9609008238705447828u, 127314748u },
+ { 16408020927503338035u, 2348542582773833227u, 0u },
+ { 14274703510609809116u, 2348542582u, 0u },
+ { 1u, 0u, 239195652096u },
+ { 16428432973129962470u, 3609144142396852268u, 54627148527u },
+ { 3721112279790863774u, 11568848377382068864u, 171545803830u },
+ { 18032764903259620753u, 10068303578029323956u, 45631280555u },
+ { 18058455550468776079u, 11645070846862630230u, 167674882605u },
+ { 15692090139033993190u, 12449386705878485054u, 210814540455u },
+ { 389416944300619393u, 15025619323517318417u, 140812947666u },
+ { 12009691357260487293u, 14996237555047131271u, 75553539724u },
+ { 13494259174449809900u, 10211005638256058412u, 90055009355u },
+ { 18288583400616279877u, 1014743503555840529u, 151699359066u },
+ { 7216107869057472u, 12900897707145290677u, 8343u },
+ { 17237061291959073878u, 153914086704665u, 0u },
+ { 1599418782488783273u, 153914u, 0u },
+ { 1u, 0u, 22255763456u },
+ { 9565464987240335777u, 4718003016239473661u, 140805878294u },
+ { 857713933775880687u, 14865830648693666724u, 185799843980u },
+ { 4621617820081363356u, 14754517212823091777u, 155602488249u },
+ { 9630162611715632528u, 11113946551474911900u, 197106442651u },
+ { 9283986497984645815u, 1963520352638130629u, 133723303109u },
+ { 8981807745082630996u, 13342587341404964199u, 29338292357u },
+ { 18350140531565934622u, 6240392545013573290u, 180779405341u },
+ { 4411619033127524143u, 14377490861349714757u, 21093125556u },
+ { 1852297584111266889u, 1717863312631397838u, 9195752981u },
+ { 11746243463811666096u, 3611005143890591769u, 546812681u },
+ { 6335244004343789147u, 10086913586276986678u, 0u },
+ { 5109502367228239844u, 10086913586u, 0u },
+ { 1603272682579847821u, 10u, 0u },
+ { 1u, 0u, 121713852416u },
+ { 6609546910952910052u, 13168252824351245503u, 78039892345u },
+ { 3911171343112928288u, 735883891883379687u, 194575126094u },
+ { 5254510615100863555u, 10609203866866106403u, 60669938882u },
+ { 3881927570803887650u, 12358191111890306469u, 63825615420u },
+ { 6379348759607163190u, 15229916368406413527u, 42392558399u },
+ { 14595733737222406466u, 7241424335568075941u, 154327955754u },
+ { 14670223432002373542u, 6049715868779871912u, 135108449946u },
+ { 4045087795619708513u, 2000548404719336761u, 215076489095u },
+ { 12598467307137142718u, 1410974761895205300u, 28867368919u },
+ { 734704388050777108u, 16000132467694084867u, 251915874844u },
+ { 5682201693687285822u, 16894908866816792555u, 35835u },
+ { 11048712694145438788u, 661055968790248u, 0u },
+ { 17871025777010319485u, 661055u, 0u },
+ { 1u, 0u, 191031934976u },
+ { 15268761435931663695u, 589096329272056761u, 54384768703u },
+ { 5016238054648555438u, 7097729792403256903u, 59463698998u },
+ { 14236047313993899750u, 8553736750439287019u, 129114608443u },
+ { 6957759675154690848u, 2114152625261065695u, 91532209025u },
+ { 18439367135478514473u, 9817523680007641223u, 126707290971u },
+ { 8539004472540641041u, 13047215537500048014u, 244908319870u },
+ { 1908462039431738399u, 16755544192002345879u, 195375682548u },
+ { 714690453250792146u, 6930119832670648355u, 148789337027u },
+ { 13782189447673929633u, 14560698131901886166u, 11889480596u },
+ { 3584742913798803164u, 16408020927503338034u, 118773833227u },
+ { 4347581515245125291u, 14274703510609809115u, 2348542582u },
+ { 16836742268156371392u, 6429475823218628948u, 2u },
+ { 11764082328865615308u, 43322963970u, 0u },
+ { 5957633711383291746u, 43u, 0u },
+ { 1u, 0u, 44890587136u },
+ { 9917186842884466953u, 16428432973129962469u, 128201721900u },
+ { 4751011869809829335u, 3721112279790863773u, 180977558144u },
+ { 11068497969931435029u, 18032764903259620752u, 86978950836u },
+ { 17118056985122509954u, 18058455550468776078u, 62850669910u },
+ { 14607066080907684459u, 15692090139033993189u, 17021110334u },
+ { 11768892370493391107u, 389416944300619392u, 135651046673u },
+ { 4043396447647747170u, 12009691357260487292u, 44731525255u },
+ { 1670341095362518057u, 13494259174449809899u, 17991426092u },
+ { 3190817644167043165u, 18288583400616279876u, 181000391185u },
+ { 10425820027224322486u, 7216107869057471u, 25934422965u },
+ { 13139964660506311565u, 17237061291959073877u, 58086704665u },
+ { 2297772885416059937u, 1599418782488783272u, 153914u },
+ { 7677687919964523763u, 2839213766779714u, 0u },
+ { 14144589152747892828u, 2839213u, 0u },
+ { 1u, 0u, 253518544896u },
+ { 17069730341503660290u, 9565464987240335776u, 164046496765u },
+ { 18167423787163077107u, 857713933775880686u, 65250538404u },
+ { 3765746945827805904u, 4621617820081363355u, 156522052161u },
+ { 10241734342430761691u, 9630162611715632527u, 197503285916u },
+ { 13345717282537140784u, 9283986497984645814u, 103486904773u },
+ { 9313926784816939953u, 8981807745082630995u, 170994763111u },
+ { 550974205049535019u, 18350140531565934621u, 69239154346u },
+ { 4494692285504086222u, 4411619033127524142u, 206100413253u },
+ { 1134308559863725587u, 1852297584111266888u, 25636765134u },
+ { 17587558045116130233u, 11746243463811666095u, 54343434265u },
+ { 9817142032346161594u, 6335244004343789146u, 50276986678u },
+ { 6071944935834172568u, 5109502367228239843u, 10086913586u },
+ { 11564168293299416955u, 1603272682579847820u, 10u },
+ { 12458266507226064437u, 186070713419u, 0u },
+ { 1304432355328256915u, 186u, 0u },
+ { 1u, 0u, 191358304256u },
+ { 15946798815542087355u, 6609546910952910051u, 231212025023u },
+ { 12082566083831286138u, 3911171343112928287u, 35284847591u },
+ { 11449623684706196411u, 5254510615100863554u, 165210439715u },
+ { 17518743620362604446u, 3881927570803887649u, 215345825189u },
+ { 9451061563087633805u, 6379348759607163189u, 165791236311u },
+ { 13191114787623314926u, 14595733737222406465u, 168795274405u },
+ { 8367349876734474799u, 14670223432002373541u, 57219284648u },
+ { 6544253801674393507u, 4045087795619708512u, 180682964281u },
+ { 16113906253336597498u, 12598467307137142717u, 3039828404u },
+ { 10294087136797312392u, 734704388050777107u, 235308032771u },
+ { 9127173070014462803u, 5682201693687285821u, 232598951915u },
+ { 16266900839595484952u, 11048712694145438787u, 63968790248u },
+ { 3299745387370952632u, 17871025777010319484u, 661055u },
+ { 12061115182604399189u, 12194330274671844u, 0u },
+ { 5066801222582989646u, 12194330u, 0u },
+ { 1u, 0u, 185827721216u },
+ { 7568423425299591513u, 15268761435931663694u, 71271930809u },
+ { 16561505984665207377u, 5016238054648555437u, 235771737671u },
+ { 4329114621856906245u, 14236047313993899749u, 223377180907u },
+ { 1477500474861899139u, 6957759675154690847u, 135999600095u },
+ { 16891579639263969684u, 18439367135478514472u, 142462900359u },
+ { 4684451357140027420u, 8539004472540641040u, 151103457934u },
+ { 14727186580409080709u, 1908462039431738398u, 35038743447u },
+ { 15864176859687308834u, 714690453250792145u, 214747133987u },
+ { 1755486942842684438u, 13782189447673929632u, 50194329302u },
+ { 17417077516652710041u, 3584742913798803163u, 219235682866u },
+ { 4290982361913532783u, 4347581515245125290u, 84912721627u },
+ { 11826659981004351409u, 16836742268156371391u, 2637732180u },
+ { 932930645678090820u, 11764082328865615307u, 43322963970u },
+ { 12707792781328052617u, 5957633711383291745u, 43u },
+ { 16491596426880311906u, 799167628880u, 0u },
+ { 3092207065214166010u, 799u, 0u },
+ { 1u, 0u, 229537611776u },
+ { 8142946531605512550u, 9917186842884466952u, 157257552869u },
+ { 5328402096432654515u, 4751011869809829334u, 144600024477u },
+ { 1932004361303814512u, 11068497969931435028u, 142927971728u },
+ { 2511477647985517771u, 17118056985122509953u, 229791850638u },
+ { 17451375493324716694u, 14607066080907684458u, 128637992933u },
+ { 9489266854478998489u, 11768892370493391106u, 124219192960u },
+ { 8803053132063235169u, 4043396447647747169u, 235090549372u },
+ { 16198682197142616773u, 1670341095362518056u, 68172974571u },
+ { 13696242485403414202u, 3190817644167043164u, 191565184836u },
+ { 16409082426079859931u, 10425820027224322485u, 85712318911u },
+ { 11653410736879597610u, 13139964660506311564u, 168124562517u },
+ { 13589514120653213261u, 2297772885416059936u, 66416208296u },
+ { 8032934885905905774u, 7677687919964523762u, 173766779714u },
+ { 2753021350129449273u, 14144589152747892827u, 2839213u },
+ { 16974897459201404133u, 52374249726338269u, 0u },
+ { 13398576176159101589u, 52374249u, 0u },
+ { 1u, 0u, 160925351936u },
+ { 10284586955251725351u, 17069730341503660289u, 238984858016u },
+ { 5294476488634150891u, 18167423787163077106u, 155204141550u },
+ { 15833244538135063323u, 3765746945827805903u, 143555205531u },
+ { 10348512742273116664u, 10241734342430761690u, 182723472783u },
+ { 13658504610142595663u, 13345717282537140783u, 83504908982u },
+ { 11956362239240850266u, 9313926784816939952u, 29029868371u },
+ { 13415901703662731781u, 550974205049535018u, 46243657757u },
+ { 5161774027546852762u, 4494692285504086221u, 72061490990u },
+ { 15274384838790587711u, 1134308559863725586u, 175953423432u },
+ { 14233354597679374929u, 17587558045116130232u, 90532188335u },
+ { 4274656492162486921u, 9817142032346161593u, 227329160794u },
+ { 12040276505541795046u, 6071944935834172567u, 140626894819u },
+ { 13238307206256765457u, 11564168293299416954u, 75675363980u },
+ { 12850161204172713271u, 12458266507226064436u, 186070713419u },
+ { 17531777095001445154u, 1304432355328256914u, 186u },
+ { 5623628114515245990u, 3432398830065u, 0u },
+ { 7357116143579573377u, 3432u, 0u },
+ { 1u, 0u, 227864477696u },
+ { 3555734177475596582u, 15946798815542087354u, 31654997219u },
+ { 14001876724756424382u, 12082566083831286137u, 66620685343u },
+ { 18159905057231476140u, 11449623684706196410u, 33949692994u },
+ { 5585207679308509467u, 17518743620362604445u, 53512343073u },
+ { 13948697622866724672u, 9451061563087633804u, 65715091765u },
+ { 9807691927739036432u, 13191114787623314925u, 165453594945u },
+ { 15818010096140820918u, 8367349876734474798u, 96354764709u },
+ { 5629845624785010943u, 6544253801674393506u, 189873536608u },
+ { 9517635131137734707u, 16113906253336597497u, 19558043581u },
+ { 619338244618780585u, 10294087136797312391u, 61494785043u },
+ { 11632367007491958899u, 9127173070014462802u, 67881830461u },
+ { 12083314261009739916u, 16266900839595484951u, 124178879555u },
+ { 16880538609458881650u, 3299745387370952631u, 228653834364u },
+ { 17404223674486504228u, 12061115182604399188u, 26274671844u },
+ { 7089067015287185433u, 5066801222582989645u, 12194330u },
+ { 2592264228029443648u, 224945689727159819u, 0u },
+ { 13413731084370224440u, 224945689u, 0u },
+ { 1u, 0u, 78410285056u },
+ { 9323915941641553425u, 7568423425299591512u, 173897801038u },
+ { 12155831029092699564u, 16561505984665207376u, 229234681773u },
+ { 17397171276588232676u, 4329114621856906244u, 31080095461u },
+ { 11874560617553253769u, 1477500474861899138u, 40915694367u },
+ { 13444839516837727954u, 16891579639263969683u, 16253944616u },
+ { 16994416043584590671u, 4684451357140027419u, 30798362384u },
+ { 15879694502877015730u, 14727186580409080708u, 209859998750u },
+ { 4234647645735263359u, 15864176859687308833u, 160095165137u },
+ { 7978589901512919496u, 1755486942842684437u, 219944181664u },
+ { 6114237175390859894u, 17417077516652710040u, 170232614619u },
+ { 8658612872088282708u, 4290982361913532782u, 191641124522u },
+ { 10253813330683324853u, 11826659981004351408u, 203050574271u },
+ { 13289465061747830991u, 932930645678090819u, 97688890827u },
+ { 4123165538545565412u, 12707792781328052616u, 80894011233u },
+ { 7846417485927038481u, 16491596426880311905u, 31167628880u },
+ { 10562273346358018864u, 3092207065214166009u, 799u },
+ { 2691512658346619120u, 14742040721959u, 0u },
+ { 751187558544605998u, 14742u, 0u },
+ { 1u, 0u, 8441430016u },
+ { 3757709791947931308u, 8142946531605512549u, 214288853256u },
+ { 3452755398462519465u, 5328402096432654514u, 20104734166u },
+ { 3105818720159874523u, 1932004361303814511u, 129136147476u },
+ { 16859138458894499364u, 2511477647985517770u, 106946040961u },
+ { 12271894740606233755u, 17451375493324716693u, 2514414186u },
+ { 5429638071845793701u, 9489266854478998488u, 97477214466u },
+ { 145278150038876889u, 8803053132063235168u, 40878132321u },
+ { 9050266019724932450u, 16198682197142616772u, 92742474792u },
+ { 11907016253451490866u, 13696242485403414201u, 181889538140u },
+ { 2472757296513770735u, 16409082426079859930u, 140631732661u },
+ { 10558733798178239360u, 11653410736879597609u, 32736689036u },
+ { 15917322570831255850u, 13589514120653213260u, 242435466272u },
+ { 12254334656791355238u, 8032934885905905773u, 91149241586u },
+ { 7869542424662730262u, 2753021350129449272u, 221920211035u },
+ { 1378558986933000253u, 16974897459201404132u, 233726338269u },
+ { 13521405041909411105u, 13398576176159101588u, 52374249u },
+ { 3206744593298092012u, 966134380754314586u, 0u },
+ { 13914648122214918505u, 966134380u, 0u },
+ { 1u, 0u, 1557528576u },
+ { 1235541077112082496u, 10284586955251725350u, 242287014145u },
+ { 12014985518315533846u, 5294476488634150890u, 207858321906u },
+ { 1561535086344155741u, 15833244538135063322u, 218560993999u },
+ { 12761747276316224577u, 10348512742273116663u, 47740429018u },
+ { 9745594781103966137u, 13658504610142595662u, 176648155695u },
+ { 17514238702394846785u, 11956362239240850265u, 42727277488u },
+ { 2428898913707151713u, 13415901703662731780u, 205279820330u },
+ { 71666709959904945u, 5161774027546852761u, 18828026061u },
+ { 4049380135452919193u, 15274384838790587710u, 184771591698u },
+ { 18422240861777453733u, 14233354597679374928u, 185231729592u },
+ { 2914504416394425696u, 4274656492162486920u, 151652704697u },
+ { 12721377795748989418u, 12040276505541795045u, 122717650071u },
+ { 2626074459217717422u, 13238307206256765456u, 52696608634u },
+ { 4261529925046307655u, 12850161204172713270u, 146950399540u },
+ { 11536038685430305586u, 17531777095001445153u, 241304857490u },
+ { 12555757789435162768u, 5623628114515245989u, 104398830065u },
+ { 11905178684546080059u, 7357116143579573376u, 3432u },
+ { 14032797718924543051u, 63316582777114u, 0u },
+ { 10750340288005853484u, 63316u, 0u },
+ { 1u, 0u, 186192756736u },
+ { 9660290106216358253u, 3555734177475596581u, 121759043258u },
+ { 14820142034615351103u, 14001876724756424381u, 186984450425u },
+ { 12674041783707777619u, 18159905057231476139u, 157302774714u },
+ { 15386686816442679994u, 5585207679308509466u, 140756160413u },
+ { 5679510383719146248u, 13948697622866724671u, 237531676044u },
+ { 1391101719248678506u, 9807691927739036431u, 46857496045u },
+ { 3364596672173710517u, 15818010096140820917u, 162305194542u },
+ { 11276509210104319732u, 5629845624785010942u, 249515952034u },
+ { 5316312656902630164u, 9517635131137734706u, 135033574393u },
+ { 17470981304473644647u, 619338244618780584u, 82630591879u },
+ { 7373293636384920591u, 11632367007491958898u, 23655037778u },
+ { 7616810902585191937u, 12083314261009739915u, 183915095831u },
+ { 12740295655921903924u, 16880538609458881649u, 84943484855u },
+ { 18366635945916526940u, 17404223674486504227u, 77384299092u },
+ { 4472171448243407067u, 7089067015287185432u, 11140526925u },
+ { 229592460858185629u, 2592264228029443647u, 25727159819u },
+ { 12749672866417114996u, 13413731084370224439u, 224945689u },
+ { 9452256722867098693u, 4149515568880992958u, 0u },
+ { 16251451636418604634u, 4149515568u, 0u },
+ { 1u, 0u, 88505450496u },
+ { 4515791283442995454u, 9323915941641553424u, 80658968920u },
+ { 13306155670047701346u, 12155831029092699563u, 4943102544u },
+ { 4456930152933417601u, 17397171276588232675u, 130643721220u },
+ { 9089157128546489637u, 11874560617553253768u, 147728846210u },
+ { 12437332180345515840u, 13444839516837727953u, 27921269139u },
+ { 3433060408790452524u, 16994416043584590670u, 132860839963u },
+ { 8275594526021936172u, 15879694502877015729u, 33229560708u },
+ { 3846512444641107689u, 4234647645735263358u, 21432520225u },
+ { 6210962618469046250u, 7978589901512919495u, 152331453461u },
+ { 7272858906616296575u, 6114237175390859893u, 110469384344u },
+ { 3710743300451225347u, 8658612872088282707u, 176555860334u },
+ { 6424677242672030600u, 10253813330683324852u, 67720423344u },
+ { 11485842256170301862u, 13289465061747830990u, 136223517251u },
+ { 7355797963557024308u, 4123165538545565411u, 97425355144u },
+ { 6358188982569427273u, 7846417485927038480u, 249572581985u },
+ { 12475094728768767402u, 10562273346358018863u, 39145907193u },
+ { 17288154837907896183u, 2691512658346619119u, 150040721959u },
+ { 2983850577727105262u, 751187558544605997u, 14742u },
+ { 13918604635001185935u, 271942652322184u, 0u },
+ { 12033220395769876327u, 271942u, 0u },
+ { 1u, 0u, 101203705856u },
+ { 5782377197813462997u, 3757709791947931307u, 178187174245u },
+ { 17732139848231399226u, 3452755398462519464u, 111168366770u },
+ { 3628839527415562921u, 3105818720159874522u, 202913935727u },
+ { 3188692267613601004u, 16859138458894499363u, 149665260746u },
+ { 5168130193478377352u, 12271894740606233754u, 216294341269u },
+ { 12556227529405091290u, 5429638071845793700u, 96007875544u },
+ { 15087090312791441192u, 145278150038876888u, 196490615904u },
+ { 10281804758610642494u, 9050266019724932449u, 185645480644u },
+ { 14238177586158586580u, 11907016253451490865u, 218134048441u },
+ { 7107927498217678128u, 2472757296513770734u, 41572390106u },
+ { 3845814658485364450u, 10558733798178239359u, 76862879785u },
+ { 714293333681725946u, 15917322570831255849u, 109664308812u },
+ { 16766172658649116982u, 12254334656791355237u, 56426608749u },
+ { 812461421432632215u, 7869542424662730261u, 228074731832u },
+ { 15218024718633799196u, 1378558986933000252u, 148732996836u },
+ { 8110797782612805146u, 13521405041909411104u, 90173837972u },
+ { 15941193964933529227u, 3206744593298092011u, 108754314586u },
+ { 14144280602323277933u, 13914648122214918504u, 966134380u },
+ { 15072402647813125245u, 17822033662586700072u, 0u },
+ { 10822706091283369889u, 17822033662u, 0u },
+ { 15163844593710966731u, 17u, 0u },
+ { 1u, 0u, 38066978816u },
+ { 2408529687792073670u, 1235541077112082495u, 234651333670u },
+ { 3980682212356510808u, 12014985518315533845u, 26084650986u },
+ { 4202670442792148519u, 1561535086344155740u, 247691815706u },
+ { 9419583343154651922u, 12761747276316224576u, 78528309751u },
+ { 16359166491570434575u, 9745594781103966136u, 89949448782u },
+ { 12567727056384237385u, 17514238702394846784u, 4131670873u },
+ { 2068388267923286639u, 2428898913707151712u, 153003885060u },
+ { 5689135844565021196u, 71666709959904944u, 62219517337u },
+ { 3104061965171139313u, 4049380135452919192u, 80998671678u },
+ { 7955173880156328016u, 18422240861777453732u, 136157995600u },
+ { 1445179403240833754u, 2914504416394425695u, 229689627272u },
+ { 12538201164459126715u, 12721377795748989417u, 16142359781u },
+ { 7580606719088482667u, 2626074459217717421u, 54231018000u },
+ { 8168318283218819755u, 4261529925046307654u, 33625369910u },
+ { 5249615277755961676u, 11536038685430305585u, 165680648993u },
+ { 6312997372068219831u, 12555757789435162767u, 128645381029u },
+ { 9183815417025176703u, 11905178684546080058u, 26760719488u },
+ { 10683849953373876937u, 14032797718924543050u, 84582777114u },
+ { 17175012155615667568u, 10750340288005853483u, 63316u },
+ { 18003508288378896912u, 1167984798111281u, 0u },
+ { 14722554560950996951u, 1167984u, 0u },
+ { 1u, 0u, 37523685376u },
+ { 15059324482416394930u, 9660290106216358252u, 189803401509u },
+ { 4134778595813308312u, 14820142034615351102u, 171687061181u },
+ { 16321118342639660948u, 12674041783707777618u, 26834113963u },
+ { 1523550293123468805u, 15386686816442679993u, 63307886874u },
+ { 8016371634569878509u, 5679510383719146247u, 15075411775u },
+ { 9884220139611134110u, 1391101719248678505u, 181182395151u },
+ { 7218073002727840414u, 3364596672173710516u, 254611300789u },
+ { 16062235669481359233u, 11276509210104319731u, 50288197886u },
+ { 15558048660560338002u, 5316312656902630163u, 168947103794u },
+ { 8394398745765058609u, 17470981304473644646u, 114399707048u },
+ { 5693296366442904274u, 7373293636384920590u, 139412908146u },
+ { 11783494675061161358u, 7616810902585191936u, 113690652811u },
+ { 13377293110865447894u, 12740295655921903923u, 35995657329u },
+ { 12840734051093062130u, 18366635945916526939u, 24242436899u },
+ { 7009868331566697505u, 4472171448243407066u, 63012446232u },
+ { 5019690705031194477u, 229592460858185628u, 55691161151u },
+ { 8608277240439804984u, 12749672866417114995u, 190512407863u },
+ { 12172482590657749222u, 9452256722867098692u, 48880992958u },
+ { 16613484892678771990u, 16251451636418604633u, 4149515568u },
+ { 5721488662757049244u, 2758075434182769113u, 4u },
+ { 386931106438877039u, 76545051729u, 0u },
+ { 10054429752182825659u, 76u, 0u },
+ { 1u, 0u, 16244801536u },
+ { 8634592106137071313u, 4515791283442995453u, 171721328144u },
+ { 12626356501369830731u, 13306155670047701345u, 227241610667u },
+ { 4803333258178976933u, 4456930152933417600u, 136492724195u },
+ { 13613083223558209297u, 9089157128546489636u, 209674229128u },
+ { 16106967997237446989u, 12437332180345515839u, 78186106577u },
+ { 14832921244380020170u, 3433060408790452523u, 177448620878u },
+ { 13774024637717231397u, 8275594526021936171u, 126208519857u },
+ { 9673012968505228885u, 3846512444641107688u, 199336696958u },
+ { 5391832334264815667u, 6210962618469046249u, 117394262471u },
+ { 16514436292632703088u, 7272858906616296574u, 83201159797u },
+ { 12025036352783454153u, 3710743300451225346u, 180348282451u },
+ { 7059867105311401050u, 6424677242672030599u, 206622648756u },
+ { 12769210631552594670u, 11485842256170301861u, 227398758606u },
+ { 8328873878884556145u, 7355797963557024307u, 16344678115u },
+ { 1016565892414238685u, 6358188982569427272u, 47676276240u },
+ { 9662978461927250281u, 12475094728768767401u, 239937192751u },
+ { 13729967277551868112u, 17288154837907896182u, 45161754863u },
+ { 6371593776693359475u, 2983850577727105261u, 136754529069u },
+ { 17617208110845643245u, 13918604635001185934u, 70652322184u },
+ { 14960960225633086797u, 12033220395769876326u, 271942u },
+ { 12090634301321662558u, 5016456510113118u, 0u },
+ { 9409926148478635503u, 5016456u, 0u },
+ { 1u, 0u, 171313463296u },
+ { 4307062684900157136u, 5782377197813462996u, 168961261227u },
+ { 15300759383869911853u, 17732139848231399225u, 218196719784u },
+ { 16007534237643445447u, 3628839527415562920u, 35172859354u },
+ { 7138502295759677634u, 3188692267613601003u, 154280164899u },
+ { 8218537071653683708u, 5168130193478377351u, 164680674458u },
+ { 2254219416760329296u, 12556227529405091289u, 216817872804u },
+ { 3057410459568460683u, 15087090312791441191u, 97557377752u },
+ { 8217810929938874370u, 10281804758610642493u, 49771853153u },
+ { 11741126472498340929u, 14238177586158586579u, 238385321521u },
+ { 1175325363726654805u, 7107927498217678127u, 127208482030u },
+ { 9428843070696730900u, 3845814658485364449u, 41038721919u },
+ { 12662500978715131896u, 714293333681725945u, 101908896041u },
+ { 6443045597035184564u, 16766172658649116981u, 21044043621u },
+ { 1921385512639171183u, 812461421432632214u, 60824970773u },
+ { 10469475094355551399u, 15218024718633799195u, 32439687228u },
+ { 14679174489076953574u, 8110797782612805145u, 235864173856u },
+ { 11853074234719825644u, 15941193964933529226u, 104766762987u },
+ { 8270896886596139124u, 14144280602323277932u, 40817076584u },
+ { 16532667046659118126u, 15072402647813125244u, 254586700072u },
+ { 148341279888833483u, 10822706091283369888u, 17822033662u },
+ { 10364629296397276041u, 15163844593710966730u, 17u },
+ { 14265682585545771671u, 328758493846u, 0u },
+ { 13991741872911347878u, 328u, 0u },
+ { 1u, 0u, 63130566656u },
+ { 14029045786848724433u, 2408529687792073669u, 21215793215u },
+ { 4005878521026842341u, 3980682212356510807u, 92227827221u },
+ { 3428326338640386488u, 4202670442792148518u, 64510636636u },
+ { 1010001558294829380u, 9419583343154651921u, 184886832192u },
+ { 2012063724327403418u, 16359166491570434574u, 64681297848u },
+ { 10997154538851372612u, 12567727056384237384u, 96112127552u },
+ { 1917749645489607898u, 2068388267923286638u, 176308408672u },
+ { 9763872523711218805u, 5689135844565021195u, 152168271536u },
+ { 15875699078454059311u, 3104061965171139312u, 164431250840u },
+ { 10966529452671276106u, 7955173880156328015u, 95078343332u },
+ { 18073244132105736913u, 1445179403240833753u, 233679697247u },
+ { 4435241176994913173u, 12538201164459126714u, 173410945513u },
+ { 5464400086219074323u, 7580606719088482666u, 70442805421u },
+ { 2445909179323258812u, 8168318283218819754u, 49284582214u },
+ { 873962058644121211u, 5249615277755961675u, 143342228273u },
+ { 16675872194112650857u, 6312997372068219830u, 58497855631u },
+ { 10680102689274800355u, 9183815417025176702u, 74579172666u },
+ { 2370498083108897524u, 10683849953373876936u, 43931059274u },
+ { 15354400521451334666u, 17175012155615667567u, 49975972139u },
+ { 259991949657381021u, 18003508288378896911u, 112798111281u },
+ { 10335286558772966917u, 14722554560950996950u, 1167984u },
+ { 16337526653906757263u, 21545516652742137u, 0u },
+ { 12040967163702784894u, 21545516u, 0u },
+ { 1u, 0u, 108816367616u },
+ { 3373309160242342187u, 15059324482416394929u, 62224146796u },
+ { 13639841054510584221u, 4134778595813308311u, 82884769598u },
+ { 15898855427739708031u, 16321118342639660947u, 185082591826u },
+ { 4544387940067005419u, 1523550293123468804u, 7434568377u },
+ { 5281598644835398575u, 8016371634569878508u, 105535824647u },
+ { 13675642405083408835u, 9884220139611134109u, 180391292521u },
+ { 3973392623768015721u, 7218073002727840413u, 243870735540u },
+ { 4491285101509114191u, 16062235669481359232u, 19843403507u },
+ { 15002304272810270500u, 15558048660560338001u, 102455061267u },
+ { 17325098540619893468u, 8394398745765058608u, 14308634214u },
+ { 1137212864974584822u, 5693296366442904273u, 638784526u },
+ { 2619406097224859078u, 11783494675061161357u, 51725184512u },
+ { 8281347529729293732u, 13377293110865447893u, 91696097587u },
+ { 11344719666795450104u, 12840734051093062129u, 218380005723u },
+ { 17283870506679425783u, 7009868331566697504u, 156272117978u },
+ { 11054210518010603775u, 5019690705031194476u, 115466655644u },
+ { 6399455551799092885u, 8608277240439804983u, 68659871603u },
+ { 12930529916573967170u, 12172482590657749221u, 89900618820u },
+ { 14550097052337552404u, 16613484892678771989u, 217310162521u },
+ { 12487632712206414748u, 5721488662757049243u, 81020975577u },
+ { 5791017277843595715u, 386931106438877038u, 76545051729u },
+ { 10227264183449036113u, 10054429752182825658u, 76u },
+ { 2006055278511721441u, 1412006979354u, 0u },
+ { 128746359043876333u, 1412u, 0u },
+ { 1u, 0u, 253468082176u },
+ { 7408146306870995754u, 8634592106137071312u, 97684476157u },
+ { 8299024588195267962u, 12626356501369830730u, 128260389217u },
+ { 1497052939192040881u, 4803333258178976932u, 36737966720u },
+ { 16771714264265803747u, 13613083223558209296u, 63873160484u },
+ { 142988846654429432u, 16106967997237446988u, 43804094271u },
+ { 11839838367716104145u, 14832921244380020169u, 43746691371u },
+ { 6019646776647679765u, 13774024637717231396u, 232524375083u },
+ { 4611972391702034948u, 9673012968505228884u, 233292291816u },
+ { 16447182322205429545u, 5391832334264815666u, 126895249385u },
+ { 2113477168726764245u, 16514436292632703087u, 2651878526u },
+ { 3536261187802311516u, 12025036352783454152u, 135382716162u },
+ { 18444381860986709854u, 7059867105311401049u, 165692220295u },
+ { 4734315730275909838u, 12769210631552594669u, 51451509157u },
+ { 9974936316849658174u, 8328873878884556144u, 72055108147u },
+ { 11864423681540657642u, 1016565892414238684u, 169523831112u },
+ { 8207245621417902667u, 9662978461927250280u, 118744303017u },
+ { 7992526918695295028u, 13729967277551868111u, 237345404790u },
+ { 8679354522130259987u, 6371593776693359474u, 142955030765u },
+ { 6065763799692166461u, 17617208110845643244u, 102811035278u },
+ { 18143341109049024976u, 14960960225633086796u, 94655434598u },
+ { 15242492331283350570u, 12090634301321662557u, 136510113118u },
+ { 9986352353182266963u, 9409926148478635502u, 5016456u },
+ { 17340463289911536077u, 92537289398950870u, 0u },
+ { 7359344614214233035u, 92537289u, 0u },
+ { 1u, 0u, 212233486336u },
+ { 419091135888749535u, 4307062684900157135u, 57829455828u },
+ { 1073142712661309790u, 15300759383869911852u, 168867770169u },
+ { 11076438902195672286u, 16007534237643445446u, 235386978984u },
+ { 1820390940081322073u, 7138502295759677633u, 135445527787u },
+ { 18417808973944523597u, 8218537071653683707u, 217122201479u },
+ { 10251294197731582957u, 2254219416760329295u, 39165742553u },
+ { 1502394029870156428u, 3057410459568460682u, 61445488423u },
+ { 321014853559106075u, 8217810929938874369u, 211636487741u },
+ { 2390953058510591778u, 11741126472498340928u, 47063714515u },
+ { 10685224265907994087u, 1175325363726654804u, 225511138607u },
+ { 5967405799190505023u, 9428843070696730899u, 249686435553u },
+ { 11210723659228214761u, 12662500978715131895u, 53349278201u },
+ { 12327123641078462773u, 6443045597035184563u, 150104158517u },
+ { 1709976940107894237u, 1921385512639171182u, 27567551382u },
+ { 16607686590938553511u, 10469475094355551398u, 25795759643u },
+ { 18332088094272679457u, 14679174489076953573u, 138642556441u },
+ { 2946170632136780882u, 11853074234719825643u, 108448366218u },
+ { 4824449494694383419u, 8270896886596139123u, 124896237676u },
+ { 17008332258693407134u, 16532667046659118125u, 160008041596u },
+ { 1773419466622750661u, 148341279888833482u, 202561867680u },
+ { 3892343466023784379u, 10364629296397276040u, 150773344202u },
+ { 12001571085575422796u, 14265682585545771670u, 72758493846u },
+ { 12933506765500977582u, 13991741872911347877u, 328u },
+ { 11884830007749143734u, 6064523798049u, 0u },
+ { 9662368568096205337u, 6064u, 0u },
+ { 1u, 0u, 197760516096u },
+ { 16801499925276664442u, 14029045786848724432u, 87217159109u },
+ { 10492407990787637084u, 4005878521026842340u, 38185849943u },
+ { 7673849751013230269u, 3428326338640386487u, 17054752294u },
+ { 6046724489853072367u, 1010001558294829379u, 14109074193u },
+ { 3723941391207507903u, 2012063724327403417u, 72596156942u },
+ { 16844122108860347659u, 10997154538851372611u, 110103961416u },
+ { 10622020182694668027u, 1917749645489607897u, 11529300590u },
+ { 8741198820686854862u, 9763872523711218804u, 240860623371u },
+ { 6855480461211306807u, 15875699078454059310u, 79594496752u },
+ { 10005708458011566304u, 10966529452671276105u, 217979752527u },
+ { 8932093106442919061u, 18073244132105736912u, 186240434905u },
+ { 9062763476260756743u, 4435241176994913172u, 106296225722u },
+ { 13664977682032775521u, 5464400086219074322u, 170132593002u },
+ { 1078499125430623453u, 2445909179323258811u, 75047377578u },
+ { 6554586738078431161u, 873962058644121210u, 182904000843u },
+ { 12177313698643242883u, 16675872194112650856u, 126578969526u },
+ { 16615072271904633953u, 10680102689274800354u, 200128504958u },
+ { 16375404983106569285u, 2370498083108897523u, 111832363720u },
+ { 13552251831473522729u, 15354400521451334665u, 15014094191u },
+ { 8330500218412111874u, 259991949657381020u, 214560277007u },
+ { 7044338079053294004u, 10335286558772966916u, 249885659094u },
+ { 2688849443046530184u, 16337526653906757262u, 44652742137u },
+ { 855940991879596845u, 12040967163702784893u, 21545516u },
+ { 7344363609485825662u, 397444631628981487u, 0u },
+ { 11602660525134634992u, 397444631u, 0u },
+ { 1u, 0u, 177182867456u },
+ { 16945343208344873835u, 3373309160242342186u, 151739417265u },
+ { 9617992661337889145u, 13639841054510584220u, 147861878679u },
+ { 18280344933262742088u, 15898855427739708030u, 4246351763u },
+ { 5179975582362777795u, 4544387940067005418u, 236286316036u },
+ { 1798918997870037130u, 5281598644835398574u, 157741358060u },
+ { 6327667344756325883u, 13675642405083408834u, 157215398045u },
+ { 18380327574124007701u, 3973392623768015720u, 128243473053u },
+ { 18015447557304295289u, 4491285101509114190u, 81813276544u },
+ { 10315590748073249878u, 15002304272810270499u, 48939195473u },
+ { 7697916092577993382u, 17325098540619893467u, 209061648432u },
+ { 3124132817942110723u, 1137212864974584821u, 141141998289u },
+ { 7448238998520507049u, 2619406097224859077u, 213448932749u },
+ { 13892823322374205297u, 8281347529729293731u, 241614998485u },
+ { 11042137840046332564u, 11344719666795450103u, 32936960497u },
+ { 10513966307445593804u, 17283870506679425782u, 108599249952u },
+ { 9388437460943526958u, 11054210518010603774u, 55346915180u },
+ { 10967228614677896228u, 6399455551799092884u, 229700965431u },
+ { 2310996671540235542u, 12930529916573967169u, 21788762341u },
+ { 4989110555003898587u, 14550097052337552403u, 155676955925u },
+ { 16271452421983657679u, 12487632712206414747u, 110313931675u },
+ { 9523160181437090473u, 5791017277843595714u, 186554421102u },
+ { 13137707423765072250u, 10227264183449036112u, 26108748474u },
+ { 16846859744221860705u, 2006055278511721440u, 132006979354u },
+ { 7767140033449795569u, 128746359043876332u, 1412u },
+ { 17169456915721160017u, 26046931378436u, 0u },
+ { 17180899661833327819u, 26046u, 0u },
+ { 1u, 0u, 208401596416u },
+ { 17572520700934791416u, 7408146306870995753u, 74449891024u },
+ { 17968798858233825417u, 8299024588195267961u, 164081155402u },
+ { 15338423313945305609u, 1497052939192040880u, 16909196452u },
+ { 17895321323836726301u, 16771714264265803746u, 76007751440u },
+ { 814069333008965773u, 142988846654429431u, 201641838924u },
+ { 7200328959852723947u, 11839838367716104144u, 36326325705u },
+ { 759884557248133773u, 6019646776647679764u, 84250015524u },
+ { 13410165861863974851u, 4611972391702034947u, 50891603540u },
+ { 6278452420856351570u, 16447182322205429544u, 111114571826u },
+ { 9072115382556676442u, 2113477168726764244u, 200191701103u },
+ { 2755882551854926563u, 3536261187802311515u, 89999871944u },
+ { 8496072611504649269u, 18444381860986709853u, 237256647769u },
+ { 4122009033579215815u, 4734315730275909837u, 112540742381u },
+ { 10222217724450527221u, 9974936316849658173u, 220643171696u },
+ { 2064539481554006325u, 11864423681540657641u, 104444915676u },
+ { 7935605886598063693u, 8207245621417902666u, 207433275752u },
+ { 7805147585347548429u, 7992526918695295027u, 114470508751u },
+ { 5709020905457661273u, 8679354522130259986u, 236328825714u },
+ { 16257370307404906674u, 6065763799692166460u, 76983552492u },
+ { 14971258192939373646u, 18143341109049024975u, 93826297164u },
+ { 1133404845901376390u, 15242492331283350569u, 238541361245u },
+ { 9460827548162822047u, 9986352353182266962u, 214940028398u },
+ { 1273897659779791346u, 17340463289911536076u, 201398950870u },
+ { 7833262224435092783u, 7359344614214233034u, 92537289u },
+ { 3033420566713364587u, 1707011694817242694u, 0u },
+ { 15075466825360349103u, 1707011694u, 0u },
+ { 1u, 0u, 207022718976u },
+ { 2484134775182816690u, 419091135888749534u, 44058175183u },
+ { 18400539815335991277u, 1073142712661309789u, 198600454956u },
+ { 485494064952118286u, 11076438902195672285u, 193098683590u },
+ { 17577048805241314891u, 1820390940081322072u, 251998431425u },
+ { 2863946907557583807u, 18417808973944523596u, 79555723771u },
+ { 13045307417786230800u, 10251294197731582956u, 138081444943u },
+ { 12032088871615097766u, 1502394029870156427u, 1017402250u },
+ { 8848763446997690580u, 321014853559106074u, 64129613825u },
+ { 10031289150307672684u, 2390953058510591777u, 84579247168u },
+ { 11592215575498656563u, 10685224265907994086u, 19323493716u },
+ { 15894436747956898388u, 5967405799190505022u, 247607734547u },
+ { 2091546719588500923u, 11210723659228214760u, 179668254711u },
+ { 5863809244813756109u, 12327123641078462772u, 110092698035u },
+ { 11303008753675411245u, 1709976940107894236u, 166900304494u },
+ { 13238426537506910532u, 16607686590938553510u, 229993784486u },
+ { 17258458071023005565u, 18332088094272679456u, 235159712229u },
+ { 8385733444777075179u, 2946170632136780881u, 115261533931u },
+ { 9530757096163247300u, 4824449494694383418u, 45922023539u },
+ { 14423000845391072217u, 17008332258693407133u, 202096137261u },
+ { 10953140011159884311u, 1773419466622750660u, 136211004362u },
+ { 12228340237948264127u, 3892343466023784378u, 150650606472u },
+ { 11279134946966259189u, 12001571085575422795u, 165701126806u },
+ { 14640097792684582651u, 12933506765500977581u, 33644277925u },
+ { 6232313315128656728u, 11884830007749143733u, 176523798049u },
+ { 16136121832933322088u, 9662368568096205336u, 6064u },
+ { 15074767079673358271u, 111870718431542u, 0u },
+ { 13252722804829281908u, 111870u, 0u },
+ { 1u, 0u, 208910811136u },
+ { 7740175894281560509u, 16801499925276664441u, 228568794576u },
+ { 15670495392425593226u, 10492407990787637083u, 183416000228u },
+ { 15152257626756992778u, 7673849751013230268u, 67327793591u },
+ { 4090073428152440422u, 6046724489853072366u, 153201875267u },
+ { 14450327772834205584u, 3723941391207507902u, 67913121689u },
+ { 4466091895542494216u, 16844122108860347658u, 217575820867u },
+ { 10454115378553795377u, 10622020182694668026u, 116473861337u },
+ { 2267817233475657788u, 8741198820686854861u, 46371636340u },
+ { 5500455702636497521u, 6855480461211306806u, 73542410542u },
+ { 15178768299492252549u, 10005708458011566303u, 208484209737u },
+ { 7062359872332045590u, 8932093106442919060u, 148491293392u },
+ { 12297347290027942576u, 9062763476260756742u, 18740779924u },
+ { 8030124596941085588u, 13664977682032775520u, 187058465554u },
+ { 6526656990996654843u, 1078499125430623452u, 122355324859u },
+ { 6254287345256979850u, 6554586738078431160u, 104660133498u },
+ { 6642007136244870032u, 12177313698643242882u, 226900704872u },
+ { 2027592955437164718u, 16615072271904633952u, 243887712482u },
+ { 942718349157325567u, 16375404983106569284u, 9734669043u },
+ { 14617066671884002278u, 13552251831473522728u, 156451597321u },
+ { 6831631114396133348u, 8330500218412111873u, 4381874332u },
+ { 14603040013386939258u, 7044338079053294003u, 142145762820u },
+ { 9906106765319401103u, 2688849443046530183u, 125046400654u },
+ { 1396179595609933063u, 855940991879596844u, 239398138749u },
+ { 11524884268464976417u, 7344363609485825661u, 23628981487u },
+ { 382929570730827274u, 11602660525134634991u, 397444631u },
+ { 6109721884461301381u, 7331559403129590068u, 0u },
+ { 2390514825000339691u, 7331559403u, 0u },
+ { 6116191454763441755u, 7u, 0u },
+ { 1u, 0u, 42918608896u },
+ { 11598868771099176310u, 16945343208344873834u, 156521392426u },
+ { 14449966445520085105u, 9617992661337889144u, 126990979484u },
+ { 11675595287405614726u, 18280344933262742087u, 234280807038u },
+ { 15860796398550489897u, 5179975582362777794u, 174097519594u },
+ { 16180408435245829662u, 1798918997870037129u, 194343023534u },
+ { 13756992797154950706u, 6327667344756325882u, 104996399554u },
+ { 8830551328786758466u, 18380327574124007700u, 78976619368u },
+ { 16699955256560951264u, 18015447557304295288u, 35559209294u },
+ { 10038983627153402074u, 10315590748073249877u, 219417304867u },
+ { 15085100736692127346u, 7697916092577993381u, 245169359579u },
+ { 10007783780289711125u, 3124132817942110722u, 197403769845u },
+ { 17596907048353602192u, 7448238998520507048u, 163753131461u },
+ { 13530650344896573509u, 13892823322374205296u, 247598595491u },
+ { 6337724853398437005u, 11042137840046332563u, 246569963255u },
+ { 12768885008904063297u, 10513966307445593803u, 254508948214u },
+ { 2759773619512884114u, 9388437460943526957u, 148594534654u },
+ { 8434364600126655292u, 10967228614677896227u, 65125279380u },
+ { 3843827521199949338u, 2310996671540235541u, 19270460225u },
+ { 4661660852957808994u, 4989110555003898586u, 155882077203u },
+ { 15298044134177324417u, 16271452421983657678u, 194516251547u },
+ { 7747773274913338217u, 9523160181437090472u, 80712196546u },
+ { 10348785912020632966u, 13137707423765072249u, 224913270096u },
+ { 4175372293197190170u, 16846859744221860704u, 236421057504u },
+ { 11326064156813083145u, 7767140033449795568u, 4930758124u },
+ { 8100407170505981763u, 17169456915721160016u, 190931378436u },
+ { 1706556116319916846u, 17180899661833327818u, 26046u },
+ { 15028897280749641942u, 480481077043500u, 0u },
+ { 1421201742071739121u, 480481u, 0u },
+ { 1u, 0u, 41952608256u },
+ { 8480737406125178272u, 17572520700934791415u, 121974090537u },
+ { 10947205650755620361u, 17968798858233825416u, 176831497593u },
+ { 868577942165647781u, 15338423313945305608u, 226970107312u },
+ { 16017710019091388479u, 17895321323836726300u, 247044130786u },
+ { 6610879150827623375u, 814069333008965772u, 208390330615u },
+ { 12110095866223762092u, 7200328959852723946u, 20041193424u },
+ { 7756802952949470775u, 759884557248133772u, 3726966548u },
+ { 2941800790804618759u, 13410165861863974850u, 40340355587u },
+ { 11703600274199927522u, 6278452420856351569u, 212491800360u },
+ { 806737539257940346u, 9072115382556676441u, 91149396692u },
+ { 14579028397110132023u, 2755882551854926562u, 93460573019u },
+ { 14247808875344366934u, 8496072611504649268u, 205223454557u },
+ { 9713379923695279513u, 4122009033579215814u, 61554147533u },
+ { 2246428675703313877u, 10222217724450527220u, 233111918909u },
+ { 3549783776592680620u, 2064539481554006324u, 74430190057u },
+ { 12645029747929213033u, 7935605886598063692u, 51423117898u },
+ { 16279009267476580506u, 7805147585347548428u, 18309486643u },
+ { 343358782242907186u, 5709020905457661272u, 60881313810u },
+ { 10077054739085890321u, 16257370307404906673u, 207811593532u },
+ { 10526715404712173586u, 14971258192939373645u, 41061441999u },
+ { 11438715865125144243u, 1133404845901376389u, 82512872489u },
+ { 5040916178827294801u, 9460827548162822046u, 204069058130u },
+ { 16643761637275849508u, 1273897659779791345u, 202424641996u },
+ { 4852542977279030386u, 7833262224435092782u, 70164442058u },
+ { 7883373066544387129u, 3033420566713364586u, 110817242694u },
+ { 16699064314768500978u, 15075466825360349102u, 1707011694u },
+ { 6805863634444817214u, 13042063791413317777u, 1u },
+ { 2266540253968903500u, 31488807865u, 0u },
+ { 9016913589137908810u, 31u, 0u },
+ { 1u, 0u, 222134665216u },
+ { 11654451024602552034u, 2484134775182816689u, 93997495262u },
+ { 5299013208454526793u, 18400539815335991276u, 221026318685u },
+ { 14918550373926182540u, 485494064952118285u, 88952853725u },
+ { 6225552657491071054u, 17577048805241314890u, 76155254872u },
+ { 10344713496596235785u, 2863946907557583806u, 236707187532u },
+ { 12972405634433280209u, 13045307417786230799u, 139652260844u },
+ { 12911885282402784945u, 12032088871615097765u, 26479692427u },
+ { 6934311832970995868u, 8848763446997690579u, 33543797274u },
+ { 9975729197003430461u, 10031289150307672683u, 230628415265u },
+ { 1982857556803548935u, 11592215575498656562u, 62861639142u },
+ { 2095735223386298223u, 15894436747956898387u, 232113382974u },
+ { 7110931538347639365u, 2091546719588500922u, 52317877736u },
+ { 15822183724630969535u, 5863809244813756108u, 220612737332u },
+ { 16931982690156327501u, 11303008753675411244u, 166717656540u },
+ { 6740069226761666110u, 13238426537506910531u, 32935582886u },
+ { 3138792961008474902u, 17258458071023005564u, 81454591520u },
+ { 12154594426971851390u, 8385733444777075178u, 58516663377u },
+ { 15780127219221910902u, 9530757096163247299u, 157781872442u },
+ { 16421541930960194381u, 14423000845391072216u, 196593770909u },
+ { 7485894627196740576u, 10953140011159884310u, 186662899652u },
+ { 8897269432694476707u, 12228340237948264126u, 75611443130u },
+ { 17189823634941678805u, 11279134946966259188u, 173793641291u },
+ { 9585582064286255216u, 14640097792684582650u, 181337854381u },
+ { 12835472279575022097u, 6232313315128656727u, 24874740917u },
+ { 6776016669542754608u, 16136121832933322087u, 54817204760u },
+ { 18340015775620871027u, 15074767079673358270u, 254718431542u },
+ { 5254188752292365830u, 13252722804829281907u, 111870u },
+ { 6798802596750151183u, 2063650512248692u, 0u },
+ { 9449320530215272000u, 2063650u, 0u },
+ { 1u, 0u, 121419595776u },
+ { 17110720482574968811u, 7740175894281560508u, 91849499257u },
+ { 16172441693558688213u, 15670495392425593225u, 188821405531u },
+ { 6234654946353717320u, 15152257626756992777u, 238221723324u },
+ { 11180283100679445438u, 4090073428152440421u, 190783353838u },
+ { 14852260031176961272u, 14450327772834205583u, 10242107326u },
+ { 4481533167346438750u, 4466091895542494215u, 250566718730u },
+ { 4269718344362365664u, 10454115378553795376u, 205122938618u },
+ { 11520029752381101466u, 2267817233475657787u, 54298180301u },
+ { 16778682550309368417u, 5500455702636497520u, 223822842678u },
+ { 9687587467301363608u, 15178768299492252548u, 148382851295u },
+ { 10093971076828497318u, 7062359872332045589u, 6666640532u },
+ { 1913763026490934696u, 12297347290027942575u, 96435313926u },
+ { 12701450127613557000u, 8030124596941085587u, 220353810784u },
+ { 8974572160711134644u, 6526656990996654842u, 184339045596u },
+ { 9890000077336694124u, 6254287345256979849u, 130360063928u },
+ { 4292326716201059148u, 6642007136244870031u, 96109916034u },
+ { 14644519175104337420u, 2027592955437164717u, 68051104864u },
+ { 5051178622270136798u, 942718349157325566u, 40792392772u },
+ { 675983118348065839u, 14617066671884002277u, 1370343464u },
+ { 4431647660065117244u, 6831631114396133347u, 179791632385u },
+ { 8316115180008411962u, 14603040013386939257u, 135537011123u },
+ { 9621158095544965602u, 9906106765319401102u, 44075687047u },
+ { 15283478958951102072u, 1396179595609933062u, 125624765228u },
+ { 13981553073094447813u, 11524884268464976416u, 239020758653u },
+ { 4558368743929911607u, 382929570730827273u, 52331208687u },
+ { 15217004469858477791u, 6109721884461301380u, 235129590068u },
+ { 11589190369996515737u, 2390514825000339690u, 7331559403u },
+ { 3670624237398152929u, 6116191454763441754u, 7u },
+ { 13471713758418039777u, 135243399970u, 0u },
+ { 4489936967610296411u, 135u, 0u },
+ { 1u, 0u, 106628775936u },
+ { 9052049303222747950u, 11598868771099176309u, 120783334250u },
+ { 1011330006193020538u, 14449966445520085104u, 71632935288u },
+ { 17412075644359478612u, 11675595287405614725u, 194859815495u },
+ { 6358678384745980468u, 15860796398550489896u, 137877141698u },
+ { 15262353928842850919u, 16180408435245829661u, 250745768073u },
+ { 11145257686438581736u, 13756992797154950705u, 20478705146u },
+ { 1600562031807691890u, 8830551328786758465u, 120905306388u },
+ { 6775147337046626724u, 16699955256560951263u, 85544214392u },
+ { 15772127322106297822u, 10038983627153402073u, 165817764949u },
+ { 4141472200527441474u, 15085100736692127345u, 2542523045u },
+ { 18246007807879281267u, 10007783780289711124u, 168953930242u },
+ { 960746958654787123u, 17596907048353602191u, 112733498024u },
+ { 11355981212264408477u, 13530650344896573508u, 147343568752u },
+ { 1573078209576251481u, 6337724853398437004u, 203692202643u },
+ { 6245294478780491367u, 12768885008904063296u, 45149607627u },
+ { 7523292955659721510u, 2759773619512884113u, 35457227821u },
+ { 14454736751015226505u, 8434364600126655291u, 21208374307u },
+ { 7219786377781411316u, 3843827521199949337u, 218252709141u },
+ { 10597123082209392431u, 4661660852957808993u, 206829308634u },
+ { 6922353544343010714u, 15298044134177324416u, 168420007630u },
+ { 14317523356293377430u, 7747773274913338216u, 121561008808u },
+ { 4057766168681892717u, 10348785912020632965u, 96226347385u },
+ { 15214083611901244045u, 4175372293197190169u, 240613987168u },
+ { 8390569016883950721u, 11326064156813083144u, 80439123952u },
+ { 10680472538208175055u, 8100407170505981762u, 202092512592u },
+ { 12173567833130544927u, 1706556116319916845u, 44814718154u },
+ { 1386341248286610026u, 15028897280749641941u, 225077043500u },
+ { 12487300952797237352u, 1421201742071739120u, 480481u },
+ { 2614759871804869720u, 8863311460481781u, 0u },
+ { 8494389567327729477u, 8863311u, 0u },
+ { 1u, 0u, 247459741696u },
+ { 6260469580539185878u, 8480737406125178271u, 136593449207u },
+ { 17818573101084525841u, 10947205650755620360u, 8047085704u },
+ { 2201029069927307150u, 868577942165647780u, 28868321800u },
+ { 10397997613804897039u, 16017710019091388478u, 140358376476u },
+ { 14269915965770103741u, 6610879150827623374u, 234656489612u },
+ { 16776139909196366727u, 12110095866223762091u, 140420497130u },
+ { 6246513436385199720u, 7756802952949470774u, 194159475340u },
+ { 2926026498821554288u, 2941800790804618758u, 81634453442u },
+ { 15725499391028340982u, 11703600274199927521u, 89043733329u },
+ { 8576577277771450827u, 806737539257940345u, 226790330713u },
+ { 15523351176022259335u, 14579028397110132022u, 52772375266u },
+ { 4775158829429176134u, 14247808875344366933u, 198526563380u },
+ { 10141817222123532462u, 9713379923695279512u, 244121779142u },
+ { 12847658900242624586u, 2246428675703313876u, 52192434164u },
+ { 13708197964460514655u, 3549783776592680619u, 76685488436u },
+ { 1951540006613246932u, 12645029747929213032u, 12882486860u },
+ { 9979297327280092199u, 16279009267476580505u, 88018613516u },
+ { 15381307706282553684u, 343358782242907185u, 177546278232u },
+ { 10037428657543061177u, 10077054739085890320u, 77570654385u },
+ { 2584877324547208668u, 10526715404712173585u, 133620094029u },
+ { 1126624732730703576u, 11438715865125144242u, 158273268613u },
+ { 1501064139624981020u, 5040916178827294800u, 241902260126u },
+ { 5219661484955306109u, 16643761637275849507u, 46263056881u },
+ { 5336997298570282212u, 4852542977279030385u, 106427358510u },
+ { 12191131175733833362u, 7883373066544387128u, 174905258090u },
+ { 3707068178994436536u, 16699064314768500977u, 145368946606u },
+ { 5045484691732942022u, 6805863634444817213u, 185122869393u },
+ { 14847900542908711232u, 2266540253968903499u, 31488807865u },
+ { 9097257915916965135u, 9016913589137908809u, 31u },
+ { 2472027983230314217u, 580865979874u, 0u },
+ { 15974509111133272205u, 580u, 0u },
+ { 1u, 0u, 177631789056u },
+ { 12099486841948187399u, 11654451024602552033u, 236287260081u },
+ { 5319910566029976328u, 5299013208454526792u, 13808736236u },
+ { 11549214421017285864u, 14918550373926182539u, 74337487885u },
+ { 1998791413186046700u, 6225552657491071053u, 190560788042u },
+ { 17075171930090011210u, 10344713496596235784u, 15703235518u },
+ { 15158296003813501474u, 12972405634433280208u, 165699954703u },
+ { 1360083178079384115u, 12911885282402784944u, 211375909797u },
+ { 6167980558592741158u, 6934311832970995867u, 107540785363u },
+ { 3630180428124865653u, 9975729197003430460u, 50107490923u },
+ { 2276550099763657677u, 1982857556803548934u, 83113610034u },
+ { 407006713016100655u, 2095735223386298222u, 186385484371u },
+ { 14242579061653496002u, 7110931538347639364u, 204857722298u },
+ { 17944493332678643704u, 15822183724630969534u, 44917884620u },
+ { 987185901870869452u, 16931982690156327500u, 67365379884u },
+ { 5578665155415167745u, 6740069226761666109u, 124170154307u },
+ { 4849210377429577536u, 3138792961008474901u, 234658901884u },
+ { 10811995403388891862u, 12154594426971851389u, 195855442410u },
+ { 7051931074990177294u, 15780127219221910901u, 216890213571u },
+ { 2030832259446664275u, 16421541930960194380u, 22405811160u },
+ { 6069512651054767896u, 7485894627196740575u, 190482321942u },
+ { 10608701253763958799u, 8897269432694476706u, 244931862206u },
+ { 15700053443426906717u, 17189823634941678804u, 250519635444u },
+ { 17759719234725541222u, 9585582064286255215u, 87695812346u },
+ { 15187321568916405210u, 12835472279575022096u, 103367328599u },
+ { 11040156458113129594u, 6776016669542754607u, 190994214247u },
+ { 2800727824598008497u, 18340015775620871026u, 115284830142u },
+ { 2997236166375604479u, 5254188752292365829u, 116368563827u },
+ { 6260091886451512841u, 6798802596750151182u, 34512248692u },
+ { 17573059315228347474u, 9449320530215271999u, 2063650u },
+ { 7519453664590169251u, 38067632857031246u, 0u },
+ { 15809436065653866529u, 38067632u, 0u },
+ { 1u, 0u, 188927574016u },
+ { 228921437623588922u, 17110720482574968810u, 137876709820u },
+ { 2195862230003073884u, 16172441693558688212u, 9337981321u },
+ { 960207412233973688u, 6234654946353717319u, 101606084361u },
+ { 2464387149230492479u, 11180283100679445437u, 143805142629u },
+ { 3631866936444955213u, 14852260031176961271u, 7242944399u },
+ { 1578304441149380227u, 4481533167346438749u, 48231461895u },
+ { 18190538519673445181u, 4269718344362365663u, 59624502064u },
+ { 1271000736479934749u, 11520029752381101465u, 112909574203u },
+ { 18292963032817745634u, 16778682550309368416u, 132525165168u },
+ { 17168014021925537455u, 9687587467301363607u, 21547195268u },
+ { 18046757712870378949u, 10093971076828497317u, 175103745301u },
+ { 14857998893911743220u, 1913763026490934695u, 147688546991u },
+ { 11933607369968684575u, 12701450127613556999u, 250486512531u },
+ { 3483798509902859162u, 8974572160711134643u, 137536137978u },
+ { 7378828438829845831u, 9890000077336694123u, 143232687497u },
+ { 15791137430347699565u, 4292326716201059147u, 173793880975u },
+ { 17044141236829932641u, 14644519175104337419u, 254273824941u },
+ { 9075651910862456484u, 5051178622270136797u, 229036645118u },
+ { 17811207355884564095u, 675983118348065838u, 227240240101u },
+ { 4438638126207305937u, 4431647660065117243u, 121450817507u },
+ { 12507972635512950185u, 8316115180008411961u, 142521564025u },
+ { 14658269128098109408u, 9621158095544965601u, 6828519054u },
+ { 3642436268910286111u, 15283478958951102071u, 32757941510u },
+ { 3783099432964819561u, 13981553073094447812u, 9247109664u },
+ { 9497579866027539638u, 4558368743929911606u, 132824915465u },
+ { 3395179445046271361u, 15217004469858477790u, 234628251268u },
+ { 5938502732309497276u, 11589190369996515736u, 90198984938u },
+ { 5793671185917606255u, 3670624237398152928u, 34730303066u },
+ { 889272970253526588u, 13471713758418039776u, 135243399970u },
+ { 8594177504370135501u, 4489936967610296410u, 135u },
+ { 7374354721120724712u, 2494800386918u, 0u },
+ { 14764532643665507567u, 2494u, 0u },
+ { 1u, 0u, 117490712576u },
+ { 5392404173658087695u, 9052049303222747949u, 112054824309u },
+ { 4976586473237854316u, 1011330006193020537u, 133943910512u },
+ { 6308932742419013569u, 17412075644359478611u, 40344704645u },
+ { 4831846642430703059u, 6358678384745980467u, 29827373864u },
+ { 18139507855949846901u, 15262353928842850918u, 49604185629u },
+ { 4865833876326628410u, 11145257686438581735u, 65086766641u },
+ { 14296661839130179261u, 1600562031807691889u, 223367281473u },
+ { 9254773150378118248u, 6775147337046626723u, 217855008735u },
+ { 12174712433727875143u, 15772127322106297821u, 113224509657u },
+ { 705653145340915199u, 4141472200527441473u, 20989118065u },
+ { 17763928858962481812u, 18246007807879281266u, 143052082196u },
+ { 3982836567612046296u, 960746958654787122u, 68615608975u },
+ { 12730849277561967739u, 11355981212264408476u, 140085276740u },
+ { 17314488764367235908u, 1573078209576251480u, 64338558092u },
+ { 15951418930590301119u, 6245294478780491366u, 145407838528u },
+ { 7193356087283467261u, 7523292955659721509u, 59783592849u },
+ { 17592945625696089446u, 14454736751015226504u, 25391385403u },
+ { 3554461664875361428u, 7219786377781411315u, 97574471193u },
+ { 2213779057785318208u, 10597123082209392430u, 128375261537u },
+ { 3880940796082421148u, 6922353544343010713u, 104776154496u },
+ { 4528237545358141043u, 14317523356293377429u, 133219971944u },
+ { 11681196539088147363u, 4057766168681892716u, 25824757125u },
+ { 9835005502912643017u, 15214083611901244044u, 8454853657u },
+ { 4964088126040986696u, 8390569016883950720u, 66578989576u },
+ { 3355564873147047622u, 10680472538208175054u, 45659930434u },
+ { 1853093467828272927u, 12173567833130544926u, 213075153709u },
+ { 14755341584803008677u, 1386341248286610025u, 240676937941u },
+ { 4701571132542556621u, 12487300952797237351u, 245141746416u },
+ { 6128849686644853851u, 2614759871804869719u, 79460481781u },
+ { 12026867901170202094u, 8494389567327729476u, 8863311u },
+ { 17909760324981426303u, 163499238157084246u, 0u },
+ { 2897692901883393664u, 163499238u, 0u },
+ { 1u, 0u, 159339380736u },
+ { 12323704802554838154u, 6260469580539185877u, 8965946783u },
+ { 7135886931147821732u, 17818573101084525840u, 164119318024u },
+ { 15341283120292884947u, 2201029069927307149u, 62563676580u },
+ { 3092789040392634166u, 10397997613804897038u, 206773573694u },
+ { 8811761390822097865u, 14269915965770103740u, 171909436366u },
+ { 16870860798610218169u, 16776139909196366726u, 54338624171u },
+ { 17452041453591904833u, 6246513436385199719u, 6158620214u },
+ { 10314783684009874908u, 2926026498821554287u, 225852481030u },
+ { 4932636630789274903u, 15725499391028340981u, 121464937185u },
+ { 18143884346082124480u, 8576577277771450826u, 54841522553u },
+ { 2823209155405527322u, 15523351176022259334u, 85258861878u },
+ { 16195396106620226251u, 4775158829429176133u, 152549789013u },
+ { 1150544491807648944u, 10141817222123532461u, 212696472984u },
+ { 7767455475523884824u, 12847658900242624585u, 171743122900u },
+ { 15204378045683991808u, 13708197964460514654u, 104105793195u },
+ { 17239732561718805622u, 1951540006613246931u, 153540978792u },
+ { 12886430624522800062u, 9979297327280092198u, 49833822361u },
+ { 18162250541178258136u, 15381307706282553683u, 16544130097u },
+ { 17028935366700158084u, 10037428657543061176u, 17140126480u },
+ { 16075467823964198637u, 2584877324547208667u, 178061074449u },
+ { 9803858825574498304u, 1126624732730703575u, 80081372850u },
+ { 17464070808143041817u, 1501064139624981019u, 35282958416u },
+ { 17682703471239266776u, 5219661484955306108u, 113289319203u },
+ { 18147688354161351336u, 5336997298570282211u, 56660882545u },
+ { 6663423873348080051u, 12191131175733833361u, 241200960568u },
+ { 9417270363716235133u, 3707068178994436535u, 61273516273u },
+ { 9295013721571344179u, 5045484691732942021u, 75804906301u },
+ { 6199479138350037783u, 14847900542908711231u, 73493163339u },
+ { 887603005365085688u, 9097257915916965134u, 226134008905u },
+ { 333989628642975696u, 2472027983230314216u, 68865979874u },
+ { 4620735991403939439u, 15974509111133272204u, 580u },
+ { 12418523063962801201u, 10715086071862u, 0u },
+ { 1587745622680169419u, 10715u, 0u },
+ { 1u, 0u, 225655914496u },
+ { 10968905082284365638u, 12099486841948187398u, 72288392929u },
+ { 14076907092801977812u, 5319910566029976327u, 139626084168u },
+ { 3438322122816124202u, 11549214421017285863u, 77108354699u },
+ { 14645413324829073676u, 1998791413186046699u, 8925646925u },
+ { 12271281439492289999u, 17075171930090011209u, 208821732872u },
+ { 6233751789862708246u, 15158296003813501473u, 176073730256u },
+ { 1962644459455827991u, 1360083178079384114u, 155334366896u },
+ { 8726934184642952500u, 6167980558592741157u, 60196792475u },
+ { 4531087719737475147u, 3630180428124865652u, 6123412028u },
+ { 481513520412720775u, 2276550099763657676u, 110022063878u },
+ { 992149349835802669u, 407006713016100654u, 68772091758u },
+ { 11165474436676191361u, 14242579061653496001u, 190972772932u },
+ { 10240785855143707184u, 17944493332678643703u, 76053515454u },
+ { 10059329918238932466u, 987185901870869451u, 61302420044u },
+ { 14791716450947031886u, 5578665155415167744u, 21262876221u },
+ { 15378882314737417403u, 4849210377429577535u, 125586119445u },
+ { 14726970229242271128u, 10811995403388891861u, 117382285949u },
+ { 5090110549507128156u, 7051931074990177293u, 76110091637u },
+ { 17185220781106503841u, 2030832259446664274u, 223329028940u },
+ { 9858517691519529306u, 6069512651054767895u, 162575098847u },
+ { 5595905546638020703u, 10608701253763958798u, 212851101602u },
+ { 15555173226968030256u, 15700053443426906716u, 111962756308u },
+ { 10745236628845355771u, 17759719234725541221u, 16823306351u },
+ { 9973314042399760760u, 15187321568916405209u, 47598488080u },
+ { 4374506813558796576u, 11040156458113129593u, 114151827759u },
+ { 15960826480426749933u, 2800727824598008496u, 5162480498u },
+ { 9636454862798615738u, 2997236166375604478u, 14339360261u },
+ { 17973331528911319269u, 6260091886451512840u, 63952637454u },
+ { 7366495200039369602u, 17573059315228347473u, 78407630399u },
+ { 10505831326526933399u, 7519453664590169250u, 176857031246u },
+ { 2803218632575724145u, 15809436065653866528u, 38067632u },
+ { 8425731874431741636u, 702223880805592151u, 0u },
+ { 14860552245711912111u, 702223880u, 0u },
+ { 1u, 0u, 234012409856u },
+ { 6993664200669526994u, 228921437623588921u, 212119037930u },
+ { 4065363582031999356u, 2195862230003073883u, 71052052948u },
+ { 6899780515342669867u, 960207412233973687u, 189133594695u },
+ { 17713500890201844939u, 2464387149230492478u, 247196883901u },
+ { 6445781125105107086u, 3631866936444955212u, 93085560055u },
+ { 13563044070717478571u, 1578304441149380226u, 223986111069u },
+ { 13167612994149348885u, 18190538519673445180u, 153068901087u },
+ { 5505463469596727288u, 1271000736479934748u, 96991663513u },
+ { 12125446212518819372u, 18292963032817745633u, 151930679904u },
+ { 12537707724735421794u, 17168014021925537454u, 165978316695u },
+ { 15173675086703777069u, 18046757712870378948u, 167805453733u },
+ { 13535510174093048476u, 14857998893911743219u, 7646922151u },
+ { 10698912997087096629u, 11933607369968684574u, 179188857095u },
+ { 16952559548431933861u, 3483798509902859161u, 107400007091u },
+ { 13528255827744249993u, 7378828438829845830u, 75856039275u },
+ { 14122167436324771955u, 15791137430347699564u, 11923964747u },
+ { 13071007137740038297u, 17044141236829932640u, 221491992075u },
+ { 13011887609328904025u, 9075651910862456483u, 46965547485u },
+ { 3116434332871336590u, 17811207355884564094u, 59240619054u },
+ { 9050993820536772770u, 4438638126207305936u, 57678058555u },
+ { 11993719123438634238u, 12507972635512950184u, 225794626361u },
+ { 1414857165879849301u, 14658269128098109407u, 119197456865u },
+ { 13819438220812375094u, 3642436268910286110u, 196205082231u },
+ { 6073063033888264440u, 3783099432964819560u, 54514864836u },
+ { 6828883869150720294u, 9497579866027539637u, 222184053046u },
+ { 4548265621068768345u, 3395179445046271360u, 152321926878u },
+ { 10422524923581371874u, 5938502732309497275u, 224314075544u },
+ { 1858996082510682634u, 5793671185917606254u, 224048207584u },
+ { 890276727450878316u, 889272970253526587u, 90465891296u },
+ { 3886008133802710905u, 8594177504370135500u, 102399764570u },
+ { 612074409233016757u, 7374354721120724711u, 190800386918u },
+ { 3927020336901729264u, 14764532643665507566u, 2494u },
+ { 5298603480094474942u, 46020944252475u, 0u },
+ { 17418383752590430025u, 46020u, 0u },
+ { 1u, 0u, 45292322816u },
+ { 8973799690601597929u, 5392404173658087694u, 121269781293u },
+ { 1343055462055792431u, 4976586473237854315u, 83342007929u },
+ { 17425118728683169659u, 6308932742419013568u, 51261934931u },
+ { 18389781726026675967u, 4831846642430703058u, 102983344691u },
+ { 272526939565961561u, 18139507855949846900u, 231263777382u },
+ { 11293026845930963228u, 4865833876326628409u, 113775023591u },
+ { 13997416438903902597u, 14296661839130179260u, 163501702257u },
+ { 6186605805999441184u, 9254773150378118247u, 221659992483u },
+ { 4401776373281836138u, 12174712433727875142u, 65038253533u },
+ { 16338917089754547008u, 705653145340915198u, 114962984513u },
+ { 13337700757935003056u, 17763928858962481811u, 50215910002u },
+ { 14612496890816348693u, 3982836567612046295u, 156690140722u },
+ { 3219935399907691719u, 12730849277561967738u, 88938620316u },
+ { 10887238730052330387u, 17314488764367235907u, 102864728152u },
+ { 360256418697768294u, 15951418930590301118u, 37389952614u },
+ { 321440824631118565u, 7193356087283467260u, 136953715493u },
+ { 10069228080701402580u, 17592945625696089445u, 243192687752u },
+ { 9428069607611622975u, 3554461664875361427u, 46120009203u },
+ { 14736799017468812344u, 2213779057785318207u, 153210386222u },
+ { 10875332567307979280u, 3880940796082421147u, 149245476249u },
+ { 4611492910339012807u, 4528237545358141042u, 108633238933u },
+ { 10743508637597314786u, 11681196539088147362u, 140533156716u },
+ { 9356196315668016028u, 9835005502912643016u, 128269103756u },
+ { 15755598617722189347u, 4964088126040986695u, 206181905536u },
+ { 1275276394173375542u, 3355564873147047621u, 30100456398u },
+ { 12644999363867216251u, 1853093467828272926u, 105799888670u },
+ { 4553830511509832021u, 14755341584803008676u, 103254872681u },
+ { 8869400642218174412u, 4701571132542556620u, 87332245607u },
+ { 16570849151159054040u, 6128849686644853850u, 68651977815u },
+ { 16127119334101797673u, 12026867901170202093u, 86970890052u },
+ { 9686867250420930550u, 17909760324981426302u, 230157084246u },
+ { 10678226869774428035u, 2897692901883393663u, 163499238u },
+ { 7767227962910162068u, 3016028602530220424u, 0u },
+ { 9780840471948993674u, 3016028602u, 0u },
+ { 1u, 0u, 213668069376u },
+ { 6288709332106746357u, 12323704802554838153u, 16386837205u },
+ { 9066785620141948673u, 7135886931147821731u, 141831652624u },
+ { 8442375916704414909u, 15341283120292884946u, 14167660429u },
+ { 11604629218100425803u, 3092789040392634165u, 188477686542u },
+ { 3877248044010875762u, 8811761390822097864u, 134914571196u },
+ { 16435137704395217283u, 16870860798610218168u, 103946077062u },
+ { 14994442577577813271u, 17452041453591904832u, 111559165543u },
+ { 4410105917142436089u, 10314783684009874907u, 245267398767u },
+ { 4632574728444936970u, 4932636630789274902u, 202983581941u },
+ { 9117147535650050359u, 18143884346082124479u, 134153046474u },
+ { 588939301256904809u, 2823209155405527321u, 69877954182u },
+ { 324393982565305683u, 16195396106620226250u, 173062371141u },
+ { 9380909186923521175u, 1150544491807648943u, 73421074605u },
+ { 4463385697777230217u, 7767455475523884823u, 94824230985u },
+ { 16378985502426333808u, 15204378045683991807u, 211934567774u },
+ { 18210894922387834354u, 17239732561718805621u, 38698574803u },
+ { 1555748035329493205u, 12886430624522800061u, 83984577574u },
+ { 4277055533891898507u, 18162250541178258135u, 184923140435u },
+ { 11574429772510874408u, 17028935366700158083u, 219871452856u },
+ { 17391099253493808815u, 16075467823964198636u, 215531468251u },
+ { 5791212393959129882u, 9803858825574498303u, 27946729175u },
+ { 11254268231455680880u, 17464070808143041816u, 124958581275u },
+ { 16355477587312235322u, 17682703471239266775u, 227983788156u },
+ { 2411485149249320633u, 18147688354161351335u, 145361224931u },
+ { 12763114642070638360u, 6663423873348080050u, 183510511249u },
+ { 1147543073987366419u, 9417270363716235132u, 197503883703u },
+ { 8410777835225272692u, 9295013721571344178u, 63336074437u },
+ { 8134725822306818018u, 6199479138350037782u, 14048117055u },
+ { 8899607004752328377u, 887603005365085687u, 232018105614u },
+ { 690976506652396830u, 333989628642975695u, 140250490600u },
+ { 12281570945595192074u, 4620735991403939438u, 54673209484u },
+ { 12592957291365552899u, 12418523063962801200u, 219086071862u },
+ { 13595807339013970272u, 1587745622680169418u, 10715u },
+ { 9698096389749839992u, 197658450495420u, 0u },
+ { 8310173728816391804u, 197658u, 0u },
+};
+
+inline constexpr int __TABLE_SIZE_2 = 69;
+inline constexpr int __ADDITIONAL_BITS_2 = 120;
+
+inline constexpr uint16_t __POW10_OFFSET_2[__TABLE_SIZE_2] = {
+ 0, 2, 6, 12, 20, 29, 40, 52, 66, 80,
+ 95, 112, 130, 150, 170, 192, 215, 240, 265, 292,
+ 320, 350, 381, 413, 446, 480, 516, 552, 590, 629,
+ 670, 712, 755, 799, 845, 892, 940, 989, 1040, 1092,
+ 1145, 1199, 1254, 1311, 1369, 1428, 1488, 1550, 1613, 1678,
+ 1743, 1810, 1878, 1947, 2017, 2088, 2161, 2235, 2311, 2387,
+ 2465, 2544, 2625, 2706, 2789, 2873, 2959, 3046, 3133
+};
+
+inline constexpr uint8_t __MIN_BLOCK_2[__TABLE_SIZE_2] = {
+ 0, 0, 0, 0, 0, 0, 1, 1, 2, 3,
+ 3, 4, 4, 5, 5, 6, 6, 7, 7, 8,
+ 8, 9, 9, 10, 11, 11, 12, 12, 13, 13,
+ 14, 14, 15, 15, 16, 16, 17, 17, 18, 19,
+ 19, 20, 20, 21, 21, 22, 22, 23, 23, 24,
+ 24, 25, 26, 26, 27, 27, 28, 28, 29, 29,
+ 30, 30, 31, 31, 32, 32, 33, 34, 0
+};
+
+inline constexpr uint64_t __POW10_SPLIT_2[3133][3] = {
+ { 0u, 0u, 3906250u },
+ { 0u, 0u, 202000000000u },
+ { 0u, 11153727427136454656u, 59u },
+ { 0u, 7205759403792793600u, 59604644775u },
+ { 0u, 0u, 167390625000u },
+ { 0u, 0u, 232000000000u },
+ { 0u, 16777216000000000u, 0u },
+ { 0u, 12945425605062557696u, 909494u },
+ { 0u, 4388757836872548352u, 182701772928u },
+ { 0u, 1152921504606846976u, 128237915039u },
+ { 0u, 0u, 159062500000u },
+ { 0u, 0u, 160000000000u },
+ { 0u, 256000000000u, 0u },
+ { 0u, 16192327041775828992u, 13u },
+ { 0u, 15024075324038053888u, 13877787807u },
+ { 0u, 5449091666327633920u, 159814456755u },
+ { 0u, 2494994193563254784u, 179295395851u },
+ { 0u, 4611686018427387904u, 11135253906u },
+ { 0u, 0u, 146250000000u },
+ { 0u, 0u, 128000000000u },
+ { 0u, 3906250u, 0u },
+ { 0u, 3906250000000000u, 0u },
+ { 0u, 4368439412768899072u, 211758u },
+ { 0u, 1563676642168012800u, 46236813575u },
+ { 0u, 11532349341402398720u, 7084767080u },
+ { 0u, 9048364970084925440u, 104625169910u },
+ { 0u, 16609275425742389248u, 246490512847u },
+ { 0u, 0u, 207900390625u },
+ { 0u, 0u, 225000000000u },
+ { 11153727427136454656u, 59u, 0u },
+ { 7205759403792793600u, 59604644775u, 0u },
+ { 0u, 4264412554261970152u, 3u },
+ { 0u, 14485570586272534528u, 3231174267u },
+ { 0u, 17827675094632103936u, 123785264354u },
+ { 0u, 7347197909193981952u, 226966440203u },
+ { 0u, 13677404030777688064u, 11398292396u },
+ { 0u, 3810326759732150272u, 172741453558u },
+ { 0u, 9943947977234055168u, 246206558227u },
+ { 0u, 0u, 19539062500u },
+ { 0u, 0u, 228000000000u },
+ { 12945425605062557696u, 909494u, 0u },
+ { 4388757836872548352u, 909494701772928u, 0u },
+ { 1152921504606846976u, 14878706826214591391u, 49303u },
+ { 0u, 4387341015746028192u, 151806576313u },
+ { 0u, 651726680428265472u, 185237838233u },
+ { 0u, 2570638187944738816u, 153035330174u },
+ { 0u, 7419175577111756800u, 126139354575u },
+ { 0u, 17299322326264840192u, 207402194313u },
+ { 0u, 7990511638862102528u, 137937798142u },
+ { 0u, 16717361816799281152u, 254433166503u },
+ { 0u, 0u, 167906250000u },
+ { 0u, 0u, 16000000000u },
+ { 16192327041775828992u, 13u, 0u },
+ { 15024075324038053888u, 13877787807u, 0u },
+ { 5449091666327633920u, 13877787807814456755u, 0u },
+ { 2494994193563254784u, 9707857417284919307u, 752316384u },
+ { 4611686018427387904u, 1844515466944871826u, 224526264005u },
+ { 0u, 15167599819856275072u, 197099991383u },
+ { 0u, 14830185305589481472u, 87822237233u },
+ { 0u, 6163721531743535104u, 49803945956u },
+ { 0u, 14122847407012052992u, 228334136013u },
+ { 0u, 335491783960035328u, 205765601092u },
+ { 0u, 941252322120433664u, 68018187046u },
+ { 0u, 11529215046068469760u, 38051025390u },
+ { 0u, 0u, 238625000000u },
+ { 0u, 0u, 64000000000u },
+ { 4368439412768899072u, 211758u, 0u },
+ { 1563676642168012800u, 211758236813575u, 0u },
+ { 11532349341402398720u, 8061591463141767016u, 11479u },
+ { 9048364970084925440u, 16628725344207857142u, 215437019748u },
+ { 16609275425742389248u, 3555541870038531535u, 100901445007u },
+ { 0u, 18316647450161853665u, 143192746310u },
+ { 0u, 16709574568378075648u, 70992947447u },
+ { 0u, 7696022835795591168u, 247905827852u },
+ { 0u, 16664449640376041472u, 12417202233u },
+ { 0u, 3109186955116544000u, 57903381625u },
+ { 0u, 10515518101817131008u, 121168549362u },
+ { 0u, 9961962375743537152u, 242570047378u },
+ { 0u, 9223372036854775808u, 146540039062u },
+ { 0u, 0u, 150500000000u },
+ { 14485570586272534528u, 3231174267u, 0u },
+ { 17827675094632103936u, 3231174267785264354u, 0u },
+ { 7347197909193981952u, 748977172262750475u, 175162308u },
+ { 13677404030777688064u, 15965033457315095468u, 196040602133u },
+ { 3810326759732150272u, 16809402149066729206u, 21865466197u },
+ { 9943947977234055168u, 7563769067065700371u, 85911239516u },
+ { 0u, 13550322810840051428u, 92410032742u },
+ { 0u, 8663209637545764864u, 102734564471u },
+ { 0u, 8969247575312957440u, 119469633535u },
+ { 0u, 6193172891660451840u, 255486223885u },
+ { 0u, 3427954273864908800u, 13335732575u },
+ { 0u, 10058367555266936832u, 95185829773u },
+ { 0u, 13907115649320091648u, 141545265197u },
+ { 0u, 0u, 45753906250u },
+ { 0u, 0u, 74000000000u },
+ { 14878706826214591391u, 49303u, 0u },
+ { 4387341015746028192u, 49303806576313u, 0u },
+ { 651726680428265472u, 14106411361315920281u, 2672u },
+ { 2570638187944738816u, 3609034283485221502u, 112764710092u },
+ { 7419175577111756800u, 9896072247338192335u, 204195646140u },
+ { 17299322326264840192u, 8889095178479228297u, 188536467151u },
+ { 7990511638862102528u, 3631796911038383102u, 207481878815u },
+ { 16717361816799281152u, 898318840772166823u, 31196880105u },
+ { 0u, 17293677953982795024u, 233048697961u },
+ { 0u, 7353628266884669440u, 105937492160u },
+ { 0u, 2404693032470315008u, 192398640987u },
+ { 0u, 9191155893041889280u, 91130358670u },
+ { 0u, 6353946855033798656u, 142498253559u },
+ { 0u, 3767824038248841216u, 247344448149u },
+ { 0u, 7205759403792793600u, 149204254150u },
+ { 0u, 0u, 198390625000u },
+ { 0u, 0u, 232000000000u },
+ { 9707857417284919307u, 752316384u, 0u },
+ { 1844515466944871826u, 752316384526264005u, 0u },
+ { 15167599819856275072u, 17063068157692817751u, 40783152u },
+ { 14830185305589481472u, 5385330256507239985u, 48924990778u },
+ { 6163721531743535104u, 3373050282752075748u, 58291939338u },
+ { 14122847407012052992u, 4116064001262906061u, 10182853422u },
+ { 335491783960035328u, 11306582046748043076u, 46223132276u },
+ { 941252322120433664u, 17035410946089626406u, 116612931040u },
+ { 11529215046068469760u, 15618595715183448558u, 224923491477u },
+ { 0u, 5141740092277295680u, 149846685770u },
+ { 0u, 16973644291514990592u, 74278734288u },
+ { 0u, 14625255268443750400u, 208920143100u },
+ { 0u, 14021170507320131584u, 252792836676u },
+ { 0u, 4451355232865091584u, 68760089176u },
+ { 0u, 12891553933348044800u, 88241308450u },
+ { 0u, 1152921504606846976u, 34698852539u },
+ { 0u, 0u, 187062500000u },
+ { 0u, 0u, 160000000000u },
+ { 8061591463141767016u, 11479u, 0u },
+ { 16628725344207857142u, 11479437019748u, 0u },
+ { 3555541870038531535u, 5562205901560339855u, 622u },
+ { 18316647450161853665u, 2106077949367544134u, 110301527786u },
+ { 16709574568378075648u, 7496855998374373623u, 234114170714u },
+ { 7696022835795591168u, 229183437194837004u, 90406405378u },
+ { 16664449640376041472u, 465169186276472889u, 2012424059u },
+ { 3109186955116544000u, 2152980561625316473u, 123025216872u },
+ { 10515518101817131008u, 2059790725449340402u, 104116713310u },
+ { 9961962375743537152u, 17891190926410198930u, 94111661478u },
+ { 9223372036854775808u, 9930696175609809814u, 166969883403u },
+ { 0u, 7276914261609005312u, 11538344118u },
+ { 0u, 10539762974036983808u, 182394482312u },
+ { 0u, 12851089458992250880u, 136571361695u },
+ { 0u, 9449311677678878720u, 159696658955u },
+ { 0u, 8699564697382289408u, 11512248212u },
+ { 0u, 4224376450473525248u, 148471604347u },
+ { 0u, 4611686018427387904u, 123229003906u },
+ { 0u, 0u, 130250000000u },
+ { 0u, 0u, 128000000000u },
+ { 748977172262750475u, 175162308u, 0u },
+ { 15965033457315095468u, 175162308040602133u, 0u },
+ { 16809402149066729206u, 13756840147955779925u, 9495567u },
+ { 7563769067065700371u, 13788447602092505948u, 15745759798u },
+ { 13550322810840051428u, 4972540435632173670u, 54747473242u },
+ { 8663209637545764864u, 2844874687533091959u, 90269561957u },
+ { 8969247575312957440u, 15377573779532804095u, 101154220965u },
+ { 6193172891660451840u, 17824715805091194381u, 165833619944u },
+ { 3427954273864908800u, 18277569135638159711u, 232966279779u },
+ { 10058367555266936832u, 4254645803379752845u, 99990829008u },
+ { 13907115649320091648u, 2933643244178200621u, 208230644811u },
+ { 0u, 17188148801879487562u, 75159033118u },
+ { 0u, 11069762501163246592u, 30931771413u },
+ { 0u, 11676570643941818368u, 21600093027u },
+ { 0u, 17840016768744030208u, 99632988162u },
+ { 0u, 16463817321652158464u, 2967109246u },
+ { 0u, 6954191143357644800u, 126892505325u },
+ { 0u, 5080060379673919488u, 237376987457u },
+ { 0u, 0u, 65275390625u },
+ { 0u, 0u, 161000000000u },
+ { 14106411361315920281u, 2672u, 0u },
+ { 3609034283485221502u, 2672764710092u, 0u },
+ { 9896072247338192335u, 16433563478020213436u, 144u },
+ { 8889095178479228297u, 4194750497955655375u, 144890865261u },
+ { 3631796911038383102u, 2691539602252904735u, 109227397880u },
+ { 898318840772166823u, 3775467271962795241u, 248145908654u },
+ { 17293677953982795024u, 16980212613224918121u, 174204668490u },
+ { 7353628266884669440u, 4172857038337333440u, 74920499170u },
+ { 2404693032470315008u, 5936867627376461659u, 226226211033u },
+ { 9191155893041889280u, 17856837443266866062u, 217321838238u },
+ { 6353946855033798656u, 8956297047799810807u, 158968021097u },
+ { 3767824038248841216u, 15356974049716912789u, 105485521835u },
+ { 7205759403792793600u, 6923608913322982854u, 171832503231u },
+ { 0u, 4855902993563955944u, 191375329591u },
+ { 0u, 13835893222288330752u, 55263239028u },
+ { 0u, 9114973913760137216u, 116750045274u },
+ { 0u, 17937099003422310400u, 90494123725u },
+ { 0u, 7007960010734960640u, 205972372085u },
+ { 0u, 7683422439270776832u, 117379902273u },
+ { 0u, 720575940379279360u, 65416519165u },
+ { 0u, 0u, 253039062500u },
+ { 0u, 0u, 228000000000u },
+ { 17063068157692817751u, 40783152u, 0u },
+ { 5385330256507239985u, 40783152924990778u, 0u },
+ { 3373050282752075748u, 2768933352715741194u, 2210859u },
+ { 4116064001262906061u, 15201941611824153390u, 43150104177u },
+ { 11306582046748043076u, 1418128541727000180u, 113824098906u },
+ { 17035410946089626406u, 5353350204565757408u, 90076876902u },
+ { 15618595715183448558u, 1721001680354286741u, 102290205696u },
+ { 5141740092277295680u, 637631411660453962u, 93295688u },
+ { 16973644291514990592u, 1630012588870568400u, 72034566068u },
+ { 14625255268443750400u, 9253063571656828156u, 180088363159u },
+ { 14021170507320131584u, 6029146854993203780u, 151501609581u },
+ { 4451355232865091584u, 16987401965352759896u, 109326840705u },
+ { 12891553933348044800u, 14499131620542087970u, 129920888905u },
+ { 1152921504606846976u, 1978417255298660539u, 73785999500u },
+ { 0u, 5790079354402454176u, 140107250214u },
+ { 0u, 13748918935842078720u, 38313880830u },
+ { 0u, 18047438014740692992u, 254745330388u },
+ { 0u, 3116889656839372800u, 212978353575u },
+ { 0u, 15995952446606147584u, 167168966926u },
+ { 0u, 12530140063251562496u, 14867142319u },
+ { 0u, 16717361816799281152u, 175679260253u },
+ { 0u, 0u, 93906250000u },
+ { 0u, 0u, 16000000000u },
+ { 5562205901560339855u, 622u, 0u },
+ { 2106077949367544134u, 622301527786u, 0u },
+ { 7496855998374373623u, 13558973353698967386u, 33u },
+ { 229183437194837004u, 6228991722850501890u, 33735033418u },
+ { 465169186276472889u, 16886831391703377787u, 74337674317u },
+ { 2152980561625316473u, 1181713637872883048u, 77915436964u },
+ { 2059790725449340402u, 12393932434925221726u, 164064060824u },
+ { 17891190926410198930u, 10684799845419711910u, 152671876423u },
+ { 9930696175609809814u, 4590318792215640843u, 71579224160u },
+ { 7276914261609005312u, 6383712187366189238u, 96248841680u },
+ { 10539762974036983808u, 1904270214927675016u, 208346061731u },
+ { 12851089458992250880u, 3711506775113308575u, 163103230695u },
+ { 9449311677678878720u, 8091219444738793995u, 231201201185u },
+ { 8699564697382289408u, 39436684991068052u, 33438625885u },
+ { 4224376450473525248u, 18025182908196512891u, 93002137866u },
+ { 4611686018427387904u, 7853924592034603138u, 10977147123u },
+ { 0u, 4815749283615688320u, 243425762105u },
+ { 0u, 14242399906544287744u, 57261062291u },
+ { 0u, 76242322576113664u, 147772082046u },
+ { 0u, 10858088421377703936u, 126004133104u },
+ { 0u, 14293835879041466368u, 240588618152u },
+ { 0u, 12182236992037191680u, 168774870395u },
+ { 0u, 11529215046068469760u, 123660400390u },
+ { 0u, 0u, 6625000000u },
+ { 0u, 0u, 64000000000u },
+ { 13756840147955779925u, 9495567u, 0u },
+ { 13788447602092505948u, 9495567745759798u, 0u },
+ { 4972540435632173670u, 14000097438505379162u, 514755u },
+ { 2844874687533091959u, 16451062686452429925u, 195758946802u },
+ { 15377573779532804095u, 4009347599785716645u, 242891813895u },
+ { 17824715805091194381u, 16544162347546196456u, 7217347168u },
+ { 18277569135638159711u, 17674258299745817187u, 96896860837u },
+ { 4254645803379752845u, 5215238411201214416u, 165958123462u },
+ { 2933643244178200621u, 14253990228345322571u, 198282718640u },
+ { 17188148801879487562u, 11214836553940194590u, 176772710358u },
+ { 11069762501163246592u, 14620711348380590101u, 214607957507u },
+ { 11676570643941818368u, 6638710787931587427u, 3792590350u },
+ { 17840016768744030208u, 17320000343692853250u, 14359885232u },
+ { 16463817321652158464u, 75147386268843646u, 176938919100u },
+ { 6954191143357644800u, 17938801582125480173u, 188004073747u },
+ { 5080060379673919488u, 6573358613626446145u, 19972464382u },
+ { 0u, 8688505427903736481u, 254356342484u },
+ { 0u, 539870168696556032u, 212471004823u },
+ { 0u, 9002861336394465280u, 151029266420u },
+ { 0u, 17989846818158018560u, 244488046090u },
+ { 0u, 2700938287723315200u, 10975231550u },
+ { 0u, 17800090499088908288u, 62146418157u },
+ { 0u, 8809040871136690176u, 237964944839u },
+ { 0u, 9223372036854775808u, 199477539062u },
+ { 0u, 0u, 246500000000u },
+ { 16433563478020213436u, 144u, 0u },
+ { 4194750497955655375u, 144890865261u, 0u },
+ { 2691539602252904735u, 15763656745260536568u, 7u },
+ { 3775467271962795241u, 8787336846248645550u, 7854549544u },
+ { 16980212613224918121u, 17584084447880694346u, 40476362484u },
+ { 4172857038337333440u, 18041672551129683938u, 244953235127u },
+ { 5936867627376461659u, 14025886302294509785u, 183978041028u },
+ { 17856837443266866062u, 18430498103283160734u, 196760344819u },
+ { 8956297047799810807u, 3292348826238025833u, 243999119304u },
+ { 15356974049716912789u, 9211721212658275243u, 200178478587u },
+ { 6923608913322982854u, 10233245872666307519u, 251499368407u },
+ { 4855902993563955944u, 6200995035623311671u, 215554745370u },
+ { 13835893222288330752u, 8480542380570450804u, 26336156614u },
+ { 9114973913760137216u, 11870363864499900506u, 198459731123u },
+ { 17937099003422310400u, 9301051379839581901u, 179643493714u },
+ { 7007960010734960640u, 11456694803569638005u, 82504211005u },
+ { 7683422439270776832u, 14327208890643983169u, 61621068669u },
+ { 720575940379279360u, 4510081789599866365u, 125776679550u },
+ { 0u, 13255356976020303332u, 126244492023u },
+ { 0u, 9658806854127314944u, 247718574341u },
+ { 0u, 13708435528809971712u, 5523604968u },
+ { 0u, 1580190652103131136u, 232743135779u },
+ { 0u, 16557336970347413504u, 35085662306u },
+ { 0u, 12751520132434493440u, 98897575035u },
+ { 0u, 9295429630892703744u, 123691261291u },
+ { 0u, 0u, 107503906250u },
+ { 0u, 0u, 202000000000u },
+ { 2768933352715741194u, 2210859u, 0u },
+ { 15201941611824153390u, 2210859150104177u, 0u },
+ { 1418128541727000180u, 16872870088062921306u, 119850u },
+ { 5353350204565757408u, 5112979788807802982u, 42914680120u },
+ { 1721001680354286741u, 13742728082020150272u, 56277175189u },
+ { 637631411660453962u, 2217110934613627976u, 149744994782u },
+ { 1630012588870568400u, 11021433940188610484u, 222120189824u },
+ { 9253063571656828156u, 1713669895470733463u, 128597473131u },
+ { 6029146854993203780u, 3313382510572018285u, 107092898231u },
+ { 16987401965352759896u, 14976595232784069505u, 183179618825u },
+ { 14499131620542087970u, 7213172372862496841u, 9811882854u },
+ { 1978417255298660539u, 15836474542502248588u, 102391026857u },
+ { 5790079354402454176u, 3221099285878340134u, 169858497005u },
+ { 13748918935842078720u, 3265814602578095358u, 237174616142u },
+ { 18047438014740692992u, 6502528252282225364u, 78177040164u },
+ { 3116889656839372800u, 16392476834556790183u, 36352502762u },
+ { 15995952446606147584u, 15167629413417091342u, 234888637949u },
+ { 12530140063251562496u, 1366763272626280111u, 253822238838u },
+ { 16717361816799281152u, 8720523635169216093u, 118074092385u },
+ { 0u, 9649171375767398672u, 97472740533u },
+ { 0u, 7647980704001073152u, 181523082628u },
+ { 0u, 13286434495608651776u, 132414597864u },
+ { 0u, 4358271637167013888u, 232720259057u },
+ { 0u, 15954987941890097152u, 241236262378u },
+ { 0u, 7911135695429697536u, 234864921629u },
+ { 0u, 7205759403792793600u, 29428863525u },
+ { 0u, 0u, 37390625000u },
+ { 0u, 0u, 232000000000u },
+ { 13558973353698967386u, 33u, 0u },
+ { 6228991722850501890u, 33735033418u, 0u },
+ { 16886831391703377787u, 15288289344628122701u, 1u },
+ { 1181713637872883048u, 952589339068938148u, 1828779826u },
+ { 12393932434925221726u, 10058155040190817688u, 50051639971u },
+ { 10684799845419711910u, 5322725640026584391u, 163545253677u },
+ { 4590318792215640843u, 2269982385930389600u, 45288545535u },
+ { 6383712187366189238u, 13216683679976310224u, 255123055991u },
+ { 1904270214927675016u, 17417440642083494819u, 119716477857u },
+ { 3711506775113308575u, 3029180749090900711u, 161944201349u },
+ { 8091219444738793995u, 8315443826261908513u, 133164212217u },
+ { 39436684991068052u, 1488962797247197277u, 249450781113u },
+ { 18025182908196512891u, 18009099634999034122u, 185080716834u },
+ { 7853924592034603138u, 8092455412807497971u, 34976275247u },
+ { 4815749283615688320u, 17808458047236758329u, 47438692886u },
+ { 14242399906544287744u, 3164591817527425171u, 22965398445u },
+ { 76242322576113664u, 3314036340472350590u, 173171552866u },
+ { 10858088421377703936u, 33234902404332784u, 98179654270u },
+ { 14293835879041466368u, 12349284717857274280u, 126001801667u },
+ { 12182236992037191680u, 18209607903013119355u, 195669456065u },
+ { 11529215046068469760u, 7891549145984268038u, 193987144822u },
+ { 0u, 7703609897518594624u, 118427801736u },
+ { 0u, 6336912652634587136u, 136417613529u },
+ { 0u, 4461621834659397632u, 217343524723u },
+ { 0u, 5484660635557953536u, 115241865004u },
+ { 0u, 15142619273265938432u, 44297324048u },
+ { 0u, 12170977992968765440u, 16820883035u },
+ { 0u, 1152921504606846976u, 91659790039u },
+ { 0u, 0u, 215062500000u },
+ { 0u, 0u, 160000000000u },
+ { 14000097438505379162u, 514755u, 0u },
+ { 16451062686452429925u, 514755758946802u, 0u },
+ { 4009347599785716645u, 17812314011563521031u, 27904u },
+ { 16544162347546196456u, 7684138864490314336u, 965607477u },
+ { 17674258299745817187u, 9740522787420029605u, 53416558002u },
+ { 5215238411201214416u, 6701109407732989894u, 178528034798u },
+ { 14253990228345322571u, 16534886227502443952u, 238363267868u },
+ { 11214836553940194590u, 8908667306968317910u, 28896357978u },
+ { 14620711348380590101u, 7531472173477105155u, 90482939822u },
+ { 6638710787931587427u, 11527371604834801166u, 174408281924u },
+ { 17320000343692853250u, 15688593496691078576u, 68624900066u },
+ { 75147386268843646u, 11394944804253312188u, 226850480357u },
+ { 17938801582125480173u, 11182279880854372627u, 229617721195u },
+ { 6573358613626446145u, 150579373068361470u, 107606192607u },
+ { 8688505427903736481u, 3147220002440857300u, 223008162924u },
+ { 539870168696556032u, 3630514817795505815u, 108170611138u },
+ { 9002861336394465280u, 11708796588334233588u, 194196810602u },
+ { 17989846818158018560u, 16844495466426369546u, 106634735134u },
+ { 2700938287723315200u, 17636655472325475902u, 30913141928u },
+ { 17800090499088908288u, 17038926655686645229u, 168956085008u },
+ { 8809040871136690176u, 15602838456783529415u, 16923682064u },
+ { 9223372036854775808u, 10869815869248876790u, 16845831567u },
+ { 0u, 18407124180939800832u, 143589253898u },
+ { 0u, 5705018517251293184u, 10997852201u },
+ { 0u, 9660452258743058432u, 41309269673u },
+ { 0u, 5646292272224927744u, 169523694166u },
+ { 0u, 7410409304047484928u, 86306086117u },
+ { 0u, 5953758707383795712u, 229401719093u },
+ { 0u, 4611686018427387904u, 53322753906u },
+ { 0u, 0u, 114250000000u },
+ { 0u, 0u, 128000000000u },
+ { 15763656745260536568u, 7u, 0u },
+ { 8787336846248645550u, 7854549544u, 0u },
+ { 17584084447880694346u, 7854549544476362484u, 0u },
+ { 18041672551129683938u, 15035424419724983u, 425795984u },
+ { 14025886302294509785u, 18280822466032836292u, 144000815071u },
+ { 18430498103283160734u, 11524250747302615283u, 223991005371u },
+ { 3292348826238025833u, 15212285943691810760u, 187624730884u },
+ { 9211721212658275243u, 7951804027551297019u, 4824659673u },
+ { 10233245872666307519u, 1706416229965221847u, 217431068160u },
+ { 6200995035623311671u, 3406023111930700826u, 92505009u },
+ { 8480542380570450804u, 16132696204133391302u, 177184640882u },
+ { 11870363864499900506u, 11593846688794356915u, 114874555213u },
+ { 9301051379839581901u, 6875759884161133906u, 77628503688u },
+ { 11456694803569638005u, 3593593325323835965u, 136372735690u },
+ { 14327208890643983169u, 9542049733257388925u, 202194809084u },
+ { 4510081789599866365u, 9926551925937787518u, 252517275552u },
+ { 13255356976020303332u, 3128491553219547895u, 160538119458u },
+ { 9658806854127314944u, 17158408656931354885u, 34169595866u },
+ { 13708435528809971712u, 2065169543154992616u, 218930159197u },
+ { 1580190652103131136u, 4832622393556232739u, 93111953065u },
+ { 16557336970347413504u, 16505930714733656162u, 169261976984u },
+ { 12751520132434493440u, 18270988073492888699u, 152894788296u },
+ { 9295429630892703744u, 2525111411519708523u, 200990472248u },
+ { 0u, 16728989342518570442u, 56136886563u },
+ { 0u, 7974052022039438336u, 35906880329u },
+ { 0u, 5356554962386550784u, 73432274226u },
+ { 0u, 6693869495028547584u, 50290379426u },
+ { 0u, 8157517147199766528u, 162362875392u },
+ { 0u, 12065776720423157760u, 442219890u },
+ { 0u, 11997589407315001344u, 114654087066u },
+ { 0u, 0u, 154650390625u },
+ { 0u, 0u, 97000000000u },
+ { 16872870088062921306u, 119850u, 0u },
+ { 5112979788807802982u, 119850914680120u, 0u },
+ { 13742728082020150272u, 2418433229320326037u, 6497u },
+ { 2217110934613627976u, 1143911773589293534u, 97131103528u },
+ { 11021433940188610484u, 9276183703610924928u, 40062011581u },
+ { 1713669895470733463u, 3532180128827684715u, 189502862926u },
+ { 3313382510572018285u, 8563997501322031543u, 78191479868u },
+ { 14976595232784069505u, 14843890409658460681u, 60464255234u },
+ { 7213172372862496841u, 9489417861634552678u, 2804688911u },
+ { 15836474542502248588u, 1113198223322322089u, 15514422373u },
+ { 3221099285878340134u, 11190777557146597869u, 101060346596u },
+ { 3265814602578095358u, 17764553645932638286u, 228606653266u },
+ { 6502528252282225364u, 14900777150991234852u, 82963018382u },
+ { 16392476834556790183u, 17364899863357893610u, 142807772747u },
+ { 15167629413417091342u, 15537570181590167037u, 75941353107u },
+ { 1366763272626280111u, 5558052627121307766u, 147842293367u },
+ { 8720523635169216093u, 12095241565795232609u, 119301302636u },
+ { 9649171375767398672u, 2187936505958366389u, 108655684359u },
+ { 7647980704001073152u, 12009203621325860228u, 7118608275u },
+ { 13286434495608651776u, 14814842834750302952u, 147651020232u },
+ { 4358271637167013888u, 5965296499605198833u, 200803114239u },
+ { 15954987941890097152u, 4051026394962148842u, 255323379371u },
+ { 7911135695429697536u, 16799526299141688349u, 171219606580u },
+ { 7205759403792793600u, 9460214166646215205u, 52910704145u },
+ { 0u, 10750736995029068008u, 17512839237u },
+ { 0u, 5377963045376430080u, 69582798620u },
+ { 0u, 15996910350253424640u, 28291539960u },
+ { 0u, 13651157529655246848u, 248867194247u },
+ { 0u, 9771305410219737088u, 135740030732u },
+ { 0u, 12709439623416250368u, 12529703527u },
+ { 0u, 9943947977234055168u, 103688980102u },
+ { 0u, 0u, 134539062500u },
+ { 0u, 0u, 228000000000u },
+ { 952589339068938148u, 1828779826u, 0u },
+ { 10058155040190817688u, 1828779826051639971u, 0u },
+ { 5322725640026584391u, 371564423966525229u, 99138353u },
+ { 2269982385930389600u, 14464859121514339583u, 49020142547u },
+ { 13216683679976310224u, 3913119023023056247u, 211784141584u },
+ { 17417440642083494819u, 5493396321716566945u, 16212130607u },
+ { 3029180749090900711u, 5837454566818211973u, 47297797611u },
+ { 8315443826261908513u, 2886670683193253881u, 235316449046u },
+ { 1488962797247197277u, 5504823105587173817u, 22156486731u },
+ { 18009099634999034122u, 9431834277334851106u, 75298417058u },
+ { 8092455412807497971u, 12921661346456247087u, 162511300760u },
+ { 17808458047236758329u, 3643076516404724246u, 152700484665u },
+ { 3164591817527425171u, 12559396953196866477u, 57197491573u },
+ { 3314036340472350590u, 1626880974916825698u, 117680846273u },
+ { 33234902404332784u, 6806994170946429566u, 193088193394u },
+ { 12349284717857274280u, 7596631230206896579u, 114369007893u },
+ { 18209607903013119355u, 3100480253729502401u, 21411814204u },
+ { 7891549145984268038u, 6310570748781063286u, 60168077371u },
+ { 7703609897518594624u, 14251867077375744136u, 59342096725u },
+ { 6336912652634587136u, 6701165793751570137u, 85772595262u },
+ { 4461621834659397632u, 10856833140463959923u, 62363270925u },
+ { 5484660635557953536u, 15867563727561248556u, 13588550103u },
+ { 15142619273265938432u, 5048961008671491600u, 215860182353u },
+ { 12170977992968765440u, 13278183119599849051u, 81273704724u },
+ { 1152921504606846976u, 4547591784941053655u, 20719811749u },
+ { 0u, 11815437715887182496u, 165246525444u },
+ { 0u, 398495392178782208u, 4640516162u },
+ { 0u, 9154841240825495552u, 66021602478u },
+ { 0u, 1902683298245640192u, 174496284938u },
+ { 0u, 5081900962138816512u, 10103144668u },
+ { 0u, 3234710432358858752u, 220275490403u },
+ { 0u, 16717361816799281152u, 99175354003u },
+ { 0u, 0u, 147906250000u },
+ { 0u, 0u, 16000000000u },
+ { 17812314011563521031u, 27904u, 0u },
+ { 7684138864490314336u, 27904965607477u, 0u },
+ { 9740522787420029605u, 13488568028574514610u, 1512u },
+ { 6701109407732989894u, 275784718433886190u, 232731216738u },
+ { 16534886227502443952u, 10020568880357102364u, 98014950319u },
+ { 8908667306968317910u, 8876397213146246746u, 175543216127u },
+ { 7531472173477105155u, 2155905919114811310u, 255481190457u },
+ { 11527371604834801166u, 1087100407155601220u, 57116871894u },
+ { 15688593496691078576u, 2903498381705011170u, 214058931831u },
+ { 11394944804253312188u, 12223476257006657765u, 119157398962u },
+ { 11182279880854372627u, 12148657163736735595u, 178662635975u },
+ { 150579373068361470u, 8951241323311673823u, 199658580024u },
+ { 3147220002440857300u, 8463862715901576300u, 56485247764u },
+ { 3630514817795505815u, 3873401978748963266u, 20458826917u },
+ { 11708796588334233588u, 248364795947002730u, 165209977542u },
+ { 16844495466426369546u, 10454378025404001822u, 198013463882u },
+ { 17636655472325475902u, 6574176865628265640u, 74566732968u },
+ { 17038926655686645229u, 16703315293848336u, 168356386842u },
+ { 15602838456783529415u, 9896033222450013456u, 26000905488u },
+ { 10869815869248876790u, 17311376269334085007u, 16536465035u },
+ { 18407124180939800832u, 18378511316495639306u, 139938451587u },
+ { 5705018517251293184u, 15120796393727584297u, 131996301094u },
+ { 9660452258743058432u, 18253447805740347049u, 38819700014u },
+ { 5646292272224927744u, 5842497225601731158u, 46989521388u },
+ { 7410409304047484928u, 4369968404176723173u, 236316722409u },
+ { 5953758707383795712u, 16142207253674488117u, 233236896461u },
+ { 4611686018427387904u, 12124259227391928178u, 205875070808u },
+ { 0u, 13019483264566077056u, 88657257409u },
+ { 0u, 74901376448135168u, 193705787602u },
+ { 0u, 13897060093813325824u, 210004060411u },
+ { 0u, 4495486210810052608u, 251753361137u },
+ { 0u, 14885496280087265280u, 241243700795u },
+ { 0u, 4976477588244398080u, 59806944370u },
+ { 0u, 11529215046068469760u, 114269775390u },
+ { 0u, 0u, 30625000000u },
+ { 0u, 0u, 64000000000u },
+ { 15035424419724983u, 425795984u, 0u },
+ { 18280822466032836292u, 425795984000815071u, 0u },
+ { 11524250747302615283u, 10043594327130472635u, 23082446u },
+ { 15212285943691810760u, 8336034337032909060u, 206544464339u },
+ { 7951804027551297019u, 16717215784895280857u, 211451897326u },
+ { 1706416229965221847u, 10968831263951212032u, 238906242083u },
+ { 3406023111930700826u, 5536629379734406065u, 35594621534u },
+ { 16132696204133391302u, 1618806894932332402u, 94300141280u },
+ { 11593846688794356915u, 11363331325254998861u, 224087755697u },
+ { 6875759884161133906u, 8775167772751754888u, 177616007425u },
+ { 3593593325323835965u, 2898202945316114122u, 1475702798u },
+ { 9542049733257388925u, 8868842714495185148u, 14157111896u },
+ { 9926551925937787518u, 17052094667531999136u, 88480780926u },
+ { 3128491553219547895u, 3658615537031138594u, 126924395904u },
+ { 17158408656931354885u, 12486952437987190746u, 128198333945u },
+ { 2065169543154992616u, 912079238520577629u, 249676919048u },
+ { 4832622393556232739u, 10960072898031888041u, 8049443914u },
+ { 16505930714733656162u, 6129550094334741912u, 74594146742u },
+ { 18270988073492888699u, 7965724516573729480u, 182332283576u },
+ { 2525111411519708523u, 5801761178810791992u, 184431822791u },
+ { 16728989342518570442u, 13197466483098446115u, 199314514103u },
+ { 7974052022039438336u, 11326268638393107273u, 183715436091u },
+ { 5356554962386550784u, 3597339351794947378u, 59613998253u },
+ { 6693869495028547584u, 353880726151383714u, 173195012157u },
+ { 8157517147199766528u, 11154818162602073600u, 61019183912u },
+ { 12065776720423157760u, 5141043976157511026u, 40604703904u },
+ { 11997589407315001344u, 7188225141808859034u, 160278696552u },
+ { 0u, 13894168943295705185u, 104389674465u },
+ { 0u, 12176538069834828288u, 225753204407u },
+ { 0u, 7994239409235165184u, 183660091451u },
+ { 0u, 13707777025480065024u, 59433368586u },
+ { 0u, 10120227247676719104u, 10743100081u },
+ { 0u, 7358494763030413312u, 177548618618u },
+ { 0u, 7656119366529843200u, 122398904800u },
+ { 0u, 9223372036854775808u, 224415039062u },
+ { 0u, 0u, 86500000000u },
+ { 2418433229320326037u, 6497u, 0u },
+ { 1143911773589293534u, 6497131103528u, 0u },
+ { 9276183703610924928u, 3877189582299842749u, 352u },
+ { 3532180128827684715u, 7625565791857948238u, 96210182868u },
+ { 8563997501322031543u, 16568435163612007484u, 212413382749u },
+ { 14843890409658460681u, 17592071940521808130u, 93898176669u },
+ { 9489417861634552678u, 15158637878035490831u, 157953668130u },
+ { 1113198223322322089u, 17789243229146401893u, 34821751405u },
+ { 11190777557146597869u, 14677686051252896484u, 109964356807u },
+ { 17764553645932638286u, 3531237481269211986u, 199795678955u },
+ { 14900777150991234852u, 8074435404989280910u, 235191428767u },
+ { 17364899863357893610u, 7086549341467684427u, 159437716020u },
+ { 15537570181590167037u, 10556134770918626963u, 52384162609u },
+ { 5558052627121307766u, 10772666134712966775u, 49572249212u },
+ { 12095241565795232609u, 6195173298198112620u, 124583987401u },
+ { 2187936505958366389u, 8144773843324250887u, 201335841017u },
+ { 12009203621325860228u, 14144284817150924691u, 249441529074u },
+ { 14814842834750302952u, 6464447844648863176u, 242766763216u },
+ { 5965296499605198833u, 15760468443293179135u, 208350438419u },
+ { 4051026394962148842u, 5172191224908322475u, 19854376706u },
+ { 16799526299141688349u, 2357554307308969012u, 2280385048u },
+ { 9460214166646215205u, 1602046917604361745u, 24127803275u },
+ { 10750736995029068008u, 7830970218109515845u, 139086847137u },
+ { 5377963045376430080u, 2899479134887821084u, 161424517746u },
+ { 15996910350253424640u, 15792042302392017912u, 114157181078u },
+ { 13651157529655246848u, 11286099112296056199u, 150856088328u },
+ { 9771305410219737088u, 15161477829153947404u, 8611820658u },
+ { 12709439623416250368u, 423831848142641767u, 114821905360u },
+ { 9943947977234055168u, 9707413321046312582u, 208022975970u },
+ { 0u, 10969483299803835620u, 226526239930u },
+ { 0u, 4326479556120930304u, 186594656881u },
+ { 0u, 12876227232041795584u, 113234538926u },
+ { 0u, 16967986827791171584u, 174698021676u },
+ { 0u, 1288146316538413056u, 44919836409u },
+ { 0u, 13715290452691779584u, 249069830551u },
+ { 0u, 4683743612465315840u, 151743507385u },
+ { 0u, 0u, 185253906250u },
+ { 0u, 0u, 74000000000u },
+ { 371564423966525229u, 99138353u, 0u },
+ { 14464859121514339583u, 99138353020142547u, 0u },
+ { 3913119023023056247u, 16344805304534272784u, 5374300u },
+ { 5493396321716566945u, 26429987091348271u, 92886053671u },
+ { 5837454566818211973u, 8691371289609838059u, 39001432772u },
+ { 2886670683193253881u, 12980168378493046550u, 196471160181u },
+ { 5504823105587173817u, 14010125458129496139u, 117703656337u },
+ { 9431834277334851106u, 17061829677031795106u, 145759490422u },
+ { 12921661346456247087u, 2227928323072698520u, 118924923640u },
+ { 3643076516404724246u, 7394752319272287289u, 248120776236u },
+ { 12559396953196866477u, 8805771303577744757u, 44400870326u },
+ { 1626880974916825698u, 16371027194302248385u, 182477361818u },
+ { 6806994170946429566u, 9114324123731231602u, 154887475162u },
+ { 7596631230206896579u, 14468189808746991893u, 218494088500u },
+ { 3100480253729502401u, 2376054557800684348u, 52784322141u },
+ { 6310570748781063286u, 12462238943546048571u, 93128806175u },
+ { 14251867077375744136u, 15334855370842605909u, 31675579326u },
+ { 6701165793751570137u, 7211347914013798462u, 190831304175u },
+ { 10856833140463959923u, 13763642332572548877u, 239390927953u },
+ { 15867563727561248556u, 16868268377740071383u, 81746128545u },
+ { 5048961008671491600u, 1120013377627684177u, 161914430661u },
+ { 13278183119599849051u, 15898107650717274388u, 197060716046u },
+ { 4547591784941053655u, 12281923376333274277u, 14861838142u },
+ { 11815437715887182496u, 6383530489286615044u, 62665804400u },
+ { 398495392178782208u, 4253822060257126466u, 112346051881u },
+ { 9154841240825495552u, 17614372438391501998u, 41230600155u },
+ { 1902683298245640192u, 4309951310554333450u, 219954877043u },
+ { 5081900962138816512u, 13106185988973773020u, 115233642928u },
+ { 3234710432358858752u, 2070134359761960547u, 176710487766u },
+ { 16717361816799281152u, 9399359914137865875u, 214112222208u },
+ { 0u, 17415053284723541264u, 509540321u },
+ { 0u, 4840502610448261120u, 225944071930u },
+ { 0u, 5690599259712258048u, 250262404172u },
+ { 0u, 114769594245185536u, 76308488004u },
+ { 0u, 3150620882578178048u, 68006221672u },
+ { 0u, 5136918324969472000u, 104170795500u },
+ { 0u, 7205759403792793600u, 236278472900u },
+ { 0u, 0u, 196390625000u },
+ { 0u, 0u, 232000000000u },
+ { 13488568028574514610u, 1512u, 0u },
+ { 275784718433886190u, 1512731216738u, 0u },
+ { 10020568880357102364u, 98202693831717807u, 82u },
+ { 8876397213146246746u, 12909287260170414079u, 82005323578u },
+ { 2155905919114811310u, 11728631949380786233u, 58699813864u },
+ { 1087100407155601220u, 18263701925522197718u, 232635810411u },
+ { 2903498381705011170u, 4868886449713321591u, 107990077265u },
+ { 12223476257006657765u, 5870139507184082354u, 81263942863u },
+ { 12148657163736735595u, 5978562500822661575u, 207318220900u },
+ { 8951241323311673823u, 10821136839630268472u, 100324098522u },
+ { 8463862715901576300u, 9490907630136752916u, 218586615003u },
+ { 3873401978748963266u, 10564005678001613989u, 219514503133u },
+ { 248364795947002730u, 5754050547468481222u, 221572675895u },
+ { 10454378025404001822u, 3833909949855542602u, 55311927705u },
+ { 6574176865628265640u, 15446538552665967784u, 153207836674u },
+ { 16703315293848336u, 14924837848804399130u, 2837358532u },
+ { 9896033222450013456u, 18140170340418344208u, 196809077080u },
+ { 17311376269334085007u, 11380424819825208971u, 88983380604u },
+ { 18378511316495639306u, 12416915664152252547u, 124616934065u },
+ { 15120796393727584297u, 17195282241626289958u, 177673122346u },
+ { 18253447805740347049u, 2649541045825281326u, 42932158118u },
+ { 5842497225601731158u, 16577429864268509676u, 166143631907u },
+ { 4369968404176723173u, 12051257060168107241u, 35898664273u },
+ { 16142207253674488117u, 5363884561143470797u, 81653299954u },
+ { 12124259227391928178u, 13054029903083620184u, 242290776764u },
+ { 13019483264566077056u, 566314952158634945u, 188707660379u },
+ { 74901376448135168u, 1329472079642345682u, 91030699995u },
+ { 13897060093813325824u, 15686237486658857211u, 219072070825u },
+ { 4495486210810052608u, 1069073549290598129u, 169850352638u },
+ { 14885496280087265280u, 4323599065125928507u, 254057954593u },
+ { 4976477588244398080u, 17861823329752681586u, 33234382774u },
+ { 11529215046068469760u, 17220149985412802078u, 182968291382u },
+ { 0u, 4344934572159429184u, 54933506201u },
+ { 0u, 2252927464837120000u, 153235539375u },
+ { 0u, 10910018171964489728u, 175122131442u },
+ { 0u, 3597328585515335680u, 242591433270u },
+ { 0u, 6972808074239148032u, 54195011573u },
+ { 0u, 2227030015734710272u, 245377996683u },
+ { 0u, 1152921504606846976u, 139120727539u },
+ { 0u, 0u, 243062500000u },
+ { 0u, 0u, 160000000000u },
+ { 10043594327130472635u, 23082446u, 0u },
+ { 8336034337032909060u, 23082446544464339u, 0u },
+ { 16717215784895280857u, 17238287503805244910u, 1251301u },
+ { 10968831263951212032u, 1434575446038410275u, 229934489438u },
+ { 5536629379734406065u, 14009569747841241694u, 94077768490u },
+ { 1618806894932332402u, 14938795732275951328u, 42759460297u },
+ { 11363331325254998861u, 6687653542888983473u, 201809833739u },
+ { 8775167772751754888u, 28238723295162625u, 11362538425u },
+ { 2898202945316114122u, 4745270274832691214u, 185001530824u },
+ { 8868842714495185148u, 926478968112308824u, 200257241617u },
+ { 17052094667531999136u, 9213681606604198526u, 17050224525u },
+ { 3658615537031138594u, 13346223820579313024u, 141499474680u },
+ { 12486952437987190746u, 691642518601291257u, 248723500243u },
+ { 912079238520577629u, 1153720150033789192u, 211037494016u },
+ { 10960072898031888041u, 12089015034721780810u, 62543294u },
+ { 6129550094334741912u, 3555868702841788854u, 190655346818u },
+ { 7965724516573729480u, 11708406782758214328u, 130192764028u },
+ { 5801761178810791992u, 9417497762905343943u, 124634714003u },
+ { 13197466483098446115u, 12838336066957615287u, 147510523576u },
+ { 11326268638393107273u, 13737708142128207419u, 184695967592u },
+ { 3597339351794947378u, 11683434809834695853u, 104744722650u },
+ { 353880726151383714u, 2689114340106315837u, 218633360270u },
+ { 11154818162602073600u, 8859225263374261032u, 142145777180u },
+ { 5141043976157511026u, 15761671984578600096u, 28480259563u },
+ { 7188225141808859034u, 7087267079878005352u, 235854441950u },
+ { 13894168943295705185u, 4601291730423121377u, 222384201518u },
+ { 12176538069834828288u, 9559411037059581623u, 46249436524u },
+ { 7994239409235165184u, 12969820289641388091u, 108518216710u },
+ { 13707777025480065024u, 13628239920285957130u, 6703095366u },
+ { 10120227247676719104u, 8049893933765800625u, 70738788366u },
+ { 7358494763030413312u, 10391755948840250234u, 14436385624u },
+ { 7656119366529843200u, 14454650777462444512u, 88563338218u },
+ { 9223372036854775808u, 14244638523341127254u, 234783588188u },
+ { 0u, 12246016810439753984u, 92772203401u },
+ { 0u, 9382741764551081984u, 137663857901u },
+ { 0u, 4608696190291148800u, 237508639450u },
+ { 0u, 1696483666416369664u, 218249837921u },
+ { 0u, 15416683541605384192u, 97091966563u },
+ { 0u, 7683140964294066176u, 99835740089u },
+ { 0u, 4611686018427387904u, 185416503906u },
+ { 0u, 0u, 98250000000u },
+ { 0u, 0u, 128000000000u },
+ { 3877189582299842749u, 352u, 0u },
+ { 7625565791857948238u, 352210182868u, 0u },
+ { 16568435163612007484u, 1722045467931902045u, 19u },
+ { 17592071940521808130u, 16095324008152856733u, 19093352271u },
+ { 15158637878035490831u, 15216188060094280738u, 79872529262u },
+ { 17789243229146401893u, 10793385929903030893u, 110824871207u },
+ { 14677686051252896484u, 12613277226875940039u, 39585110623u },
+ { 3531237481269211986u, 10644539625155600107u, 95683767128u },
+ { 8074435404989280910u, 6181262895644173983u, 88577041649u },
+ { 7086549341467684427u, 148914399627082292u, 241335086933u },
+ { 10556134770918626963u, 14379289774887985969u, 85008072665u },
+ { 10772666134712966775u, 11743339675582627452u, 217779502860u },
+ { 6195173298198112620u, 7841621929809463497u, 12636607719u },
+ { 8144773843324250887u, 11168944680251236601u, 231425095176u },
+ { 14144284817150924691u, 6178560202529287410u, 8605469704u },
+ { 6464447844648863176u, 13295243308201596112u, 8334940419u },
+ { 15760468443293179135u, 17040673746172470291u, 3720736583u },
+ { 5172191224908322475u, 14957442487039409922u, 71923776774u },
+ { 2357554307308969012u, 17778155426506992152u, 6810844581u },
+ { 1602046917604361745u, 14945404984219733899u, 165963755736u },
+ { 7830970218109515845u, 11590754866058681505u, 216810192027u },
+ { 2899479134887821084u, 6020790784469412466u, 155628336080u },
+ { 15792042302392017912u, 7934351824569522326u, 208326387722u },
+ { 11286099112296056199u, 5038361112172116744u, 10430122074u },
+ { 15161477829153947404u, 3305187319649924210u, 90273130103u },
+ { 423831848142641767u, 11470175511099161552u, 119179174563u },
+ { 9707413321046312582u, 7308362160352048610u, 163621799460u },
+ { 10969483299803835620u, 10666410671225576634u, 36396187106u },
+ { 4326479556120930304u, 2181639019945820785u, 226578227281u },
+ { 12876227232041795584u, 4615749499734847918u, 81118266888u },
+ { 16967986827791171584u, 14076159200958497580u, 8250220281u },
+ { 1288146316538413056u, 5470405257862074105u, 249763070119u },
+ { 13715290452691779584u, 4565741478181339543u, 167296551263u },
+ { 4683743612465315840u, 8901832997861862329u, 95247509341u },
+ { 0u, 14190141170191714122u, 93482569333u },
+ { 0u, 4240772322245764096u, 117769249094u },
+ { 0u, 4422842195340951552u, 70229892728u },
+ { 0u, 15448426386733137920u, 120239762755u },
+ { 0u, 9203504548935630848u, 67837460872u },
+ { 0u, 5936377627571912704u, 136498922981u },
+ { 0u, 468374361246531584u, 229321811676u },
+ { 0u, 0u, 220025390625u },
+ { 0u, 0u, 33000000000u },
+ { 16344805304534272784u, 5374300u, 0u },
+ { 26429987091348271u, 5374300886053671u, 0u },
+ { 8691371289609838059u, 8020875056524075716u, 291341u },
+ { 12980168378493046550u, 1400288714762747253u, 13434812508u },
+ { 14010125458129496139u, 6136037711314764689u, 92075909803u },
+ { 17061829677031795106u, 15735488086392394102u, 171332635270u },
+ { 2227928323072698520u, 7735094782793634552u, 134853022518u },
+ { 7394752319272287289u, 7273689191766726188u, 54419320328u },
+ { 8805771303577744757u, 3410634565056431030u, 8394307481u },
+ { 16371027194302248385u, 4600927904885215898u, 153184890870u },
+ { 9114324123731231602u, 9154871331680374746u, 246249416801u },
+ { 14468189808746991893u, 6117978272461042996u, 97496286569u },
+ { 2376054557800684348u, 13116904339287496285u, 105331656266u },
+ { 12462238943546048571u, 867037205615660831u, 74711068809u },
+ { 15334855370842605909u, 1802487145191504830u, 137047002181u },
+ { 7211347914013798462u, 17242009718457409007u, 69097713023u },
+ { 13763642332572548877u, 13620802355488468049u, 127934691219u },
+ { 16868268377740071383u, 4442227880594435745u, 147738385175u },
+ { 1120013377627684177u, 17354849212854314181u, 23240813655u },
+ { 15898107650717274388u, 18202319179831567886u, 87940808260u },
+ { 12281923376333274277u, 17568634016348874558u, 68986749699u },
+ { 6383530489286615044u, 7496925598312450672u, 3952397558u },
+ { 4253822060257126466u, 601870379496813865u, 246406409151u },
+ { 17614372438391501998u, 11995106565680728027u, 191032627458u },
+ { 4309951310554333450u, 16331071694764184179u, 2650256029u },
+ { 13106185988973773020u, 9665962217000524208u, 157885309170u },
+ { 2070134359761960547u, 13682661374415474390u, 242523992861u },
+ { 9399359914137865875u, 6940361789924260864u, 29741738559u },
+ { 17415053284723541264u, 9658039831644010465u, 63376237766u },
+ { 4840502610448261120u, 6843715893910236922u, 198523563388u },
+ { 5690599259712258048u, 47089792870595660u, 124370998582u },
+ { 114769594245185536u, 14510386192097156932u, 54002552742u },
+ { 3150620882578178048u, 12059931208360040296u, 166786609611u },
+ { 5136918324969472000u, 14877013468459184620u, 203653770180u },
+ { 7205759403792793600u, 2397668560671695044u, 196806484516u },
+ { 0u, 2195572305559232232u, 36129977873u },
+ { 0u, 3261686279425953792u, 17119022213u },
+ { 0u, 9333850662059900928u, 133176816367u },
+ { 0u, 5036522340217782272u, 239505989058u },
+ { 0u, 2800120215143186432u, 194273030423u },
+ { 0u, 441634238459019264u, 23151794821u },
+ { 0u, 720575940379279360u, 133023941040u },
+ { 0u, 0u, 176039062500u },
+ { 0u, 0u, 228000000000u },
+ { 98202693831717807u, 82u, 0u },
+ { 12909287260170414079u, 82005323578u, 0u },
+ { 11728631949380786233u, 8218347283861607400u, 4u },
+ { 18263701925522197718u, 17896200385973633643u, 4445517498u },
+ { 4868886449713321591u, 16333242102094352209u, 186970154966u },
+ { 5870139507184082354u, 9981905728606788815u, 214885426828u },
+ { 5978562500822661575u, 15219470018924839012u, 140541120193u },
+ { 10821136839630268472u, 17152070168529617370u, 193825049122u },
+ { 9490907630136752916u, 17841343440958328027u, 34929815586u },
+ { 10564005678001613989u, 17291078023923990493u, 34967181165u },
+ { 5754050547468481222u, 16744804581790759223u, 109937351217u },
+ { 3833909949855542602u, 5001622214111594905u, 49907737675u },
+ { 15446538552665967784u, 9676746897435398146u, 75271138483u },
+ { 14924837848804399130u, 8109025833995118532u, 179524577500u },
+ { 18140170340418344208u, 5495826424046694744u, 220439591171u },
+ { 11380424819825208971u, 7890288164365705852u, 3297929347u },
+ { 12416915664152252547u, 8616438349039895217u, 131427733378u },
+ { 17195282241626289958u, 15787154801788760618u, 130467098058u },
+ { 2649541045825281326u, 12418659311480782502u, 202855823376u },
+ { 16577429864268509676u, 4486988874116669987u, 16673216870u },
+ { 12051257060168107241u, 4828971301551875409u, 102243240154u },
+ { 5363884561143470797u, 14769106422014442226u, 218261779058u },
+ { 13054029903083620184u, 7763933466423188156u, 114800634863u },
+ { 566314952158634945u, 10449097116253839963u, 239420883676u },
+ { 1329472079642345682u, 12870692502472900571u, 220566446689u },
+ { 15686237486658857211u, 11597479481311003817u, 97697721638u },
+ { 1069073549290598129u, 8294994869530047486u, 38628700622u },
+ { 4323599065125928507u, 16879315829924478241u, 206449672572u },
+ { 17861823329752681586u, 11873324837601439670u, 124915029544u },
+ { 17220149985412802078u, 3277599055636107318u, 40643654229u },
+ { 4344934572159429184u, 15363467897354242201u, 85177679000u },
+ { 2252927464837120000u, 10351182204479784367u, 152832855263u },
+ { 10910018171964489728u, 12811517584931924466u, 223561138711u },
+ { 3597328585515335680u, 16988930699558748726u, 23694513759u },
+ { 6972808074239148032u, 11683499918824718325u, 95920971778u },
+ { 2227030015734710272u, 13119300691281647499u, 2633363799u },
+ { 1152921504606846976u, 10125549106595354099u, 87711198715u },
+ { 0u, 17505352699870800544u, 251548907116u },
+ { 0u, 6756039242241163264u, 108948967071u },
+ { 0u, 3537338758766526464u, 159366245621u },
+ { 0u, 6522626374119718912u, 245191759518u },
+ { 0u, 4733294203482669056u, 158353592284u },
+ { 0u, 16997710893603094528u, 220256592392u },
+ { 0u, 16717361816799281152u, 8921447753u },
+ { 0u, 0u, 73906250000u },
+ { 0u, 0u, 16000000000u },
+ { 17238287503805244910u, 1251301u, 0u },
+ { 1434575446038410275u, 1251301934489438u, 0u },
+ { 14009569747841241694u, 3943737498063000362u, 67833u },
+ { 14938795732275951328u, 2870731037991212489u, 249213790438u },
+ { 6687653542888983473u, 7389433400402095883u, 230155622641u },
+ { 28238723295162625u, 5675049236146197433u, 241400581987u },
+ { 4745270274832691214u, 9953779846262904264u, 99307645035u },
+ { 926478968112308824u, 12691978937179636241u, 107539595486u },
+ { 9213681606604198526u, 15523327331528198029u, 222688033556u },
+ { 13346223820579313024u, 15722603279568118520u, 20841521260u },
+ { 691642518601291257u, 11838632364171816147u, 108852324031u },
+ { 1153720150033789192u, 7832751832367143680u, 191641773546u },
+ { 12089015034721780810u, 12167724027162940862u, 234424614327u },
+ { 3555868702841788854u, 4108211144748152962u, 183659613641u },
+ { 11708406782758214328u, 7530983398136343676u, 201222706572u },
+ { 9417497762905343943u, 1117587133956542355u, 140408255428u },
+ { 12838336066957615287u, 17134748625149490872u, 196060584519u },
+ { 13737708142128207419u, 4039918359454207848u, 71928876584u },
+ { 11683434809834695853u, 1830218764589441242u, 40219004413u },
+ { 2689114340106315837u, 637895981480825742u, 253099216358u },
+ { 8859225263374261032u, 8246879226348334620u, 230034580410u },
+ { 15761671984578600096u, 12389239568142583275u, 186447064218u },
+ { 7087267079878005352u, 14041257178803154398u, 154671622022u },
+ { 4601291730423121377u, 16312515716494630702u, 134761178076u },
+ { 9559411037059581623u, 17088522799596987756u, 220884303248u },
+ { 12969820289641388091u, 3588932524637852678u, 144926370677u },
+ { 13628239920285957130u, 107218049069817414u, 117194556422u },
+ { 8049893933765800625u, 1596707240462008334u, 6005812302u },
+ { 10391755948840250234u, 17461913142391587672u, 78086557672u },
+ { 14454650777462444512u, 4366474266651610090u, 232946612208u },
+ { 14244638523341127254u, 5539304013194805084u, 240236707044u },
+ { 12246016810439753984u, 4762470619211987849u, 228300286272u },
+ { 9382741764551081984u, 10835638458986644717u, 64258174049u },
+ { 4608696190291148800u, 16141642290510052058u, 97587401137u },
+ { 1696483666416369664u, 17390568670756355425u, 177875040181u },
+ { 15416683541605384192u, 12536768491333867107u, 181942744616u },
+ { 7683140964294066176u, 13145148522871947193u, 40679619581u },
+ { 4611686018427387904u, 5665349945233068642u, 253712599929u },
+ { 0u, 17074607537751066240u, 121307119235u },
+ { 0u, 6241525660962062336u, 131925616329u },
+ { 0u, 1142860629783085056u, 201338353784u },
+ { 0u, 16287527416870469632u, 120061954598u },
+ { 0u, 9028002014738513920u, 38882948630u },
+ { 0u, 16217462258161156096u, 22489408969u },
+ { 0u, 11529215046068469760u, 201879150390u },
+ { 0u, 0u, 54625000000u },
+ { 0u, 0u, 64000000000u },
+ { 1722045467931902045u, 19u, 0u },
+ { 16095324008152856733u, 19093352271u, 0u },
+ { 15216188060094280738u, 646608198162977646u, 1u },
+ { 10793385929903030893u, 12170458846894708007u, 1035052700u },
+ { 12613277226875940039u, 1797330480103086687u, 156659761896u },
+ { 10644539625155600107u, 10332188564497263448u, 232097433480u },
+ { 6181262895644173983u, 7524259485079594225u, 136560109064u },
+ { 148914399627082292u, 62681109059153749u, 8407890924u },
+ { 14379289774887985969u, 13480636451804037081u, 236003397949u },
+ { 11743339675582627452u, 6948168233012789004u, 61730786766u },
+ { 7841621929809463497u, 12015502974041806055u, 206376660954u },
+ { 11168944680251236601u, 7343801660689004040u, 218651361721u },
+ { 6178560202529287410u, 13670580858640731144u, 185398108285u },
+ { 13295243308201596112u, 5605073897566574851u, 125741083673u },
+ { 17040673746172470291u, 15387788940505247559u, 25303851664u },
+ { 14957442487039409922u, 17565181499678113030u, 144834173709u },
+ { 17778155426506992152u, 1893743623847493029u, 13952210397u },
+ { 14945404984219733899u, 10243498996716269784u, 221102660047u },
+ { 11590754866058681505u, 5619675836950314139u, 207555301193u },
+ { 6020790784469412466u, 10224869737511515088u, 73304643237u },
+ { 7934351824569522326u, 2574495974386198538u, 165554291299u },
+ { 5038361112172116744u, 7825756347302873178u, 99139563706u },
+ { 3305187319649924210u, 12071550103794656887u, 186424235101u },
+ { 11470175511099161552u, 7195875213867606691u, 93654400042u },
+ { 7308362160352048610u, 18271364438406891044u, 42390089176u },
+ { 10666410671225576634u, 16966521933952564706u, 216990492650u },
+ { 2181639019945820785u, 289920862029570129u, 234919756997u },
+ { 4615749499734847918u, 7804199568098625032u, 197015716641u },
+ { 14076159200958497580u, 5758118571242446585u, 33423066506u },
+ { 5470405257862074105u, 4030788293606375591u, 138312148233u },
+ { 4565741478181339543u, 4387716460037196127u, 9218509471u },
+ { 8901832997861862329u, 16807506478881285981u, 159237858585u },
+ { 14190141170191714122u, 17033060604413529717u, 25911136751u },
+ { 4240772322245764096u, 10498418508292170054u, 239923364065u },
+ { 4422842195340951552u, 13237752038744465016u, 225569120407u },
+ { 15448426386733137920u, 17737618428304633155u, 151717619975u },
+ { 9203504548935630848u, 13546183833248825736u, 7961558221u },
+ { 5936377627571912704u, 826778452978976229u, 205734340097u },
+ { 468374361246531584u, 13728076626990147292u, 1044819749u },
+ { 0u, 2794860281883592225u, 37744200525u },
+ { 0u, 8680705720425908736u, 77151509679u },
+ { 0u, 731520517439488000u, 175470582000u },
+ { 0u, 13120812320768917504u, 240039655806u },
+ { 0u, 2722954908557901824u, 126711280661u },
+ { 0u, 6860847004205973504u, 21147611681u },
+ { 0u, 6503197861922996224u, 33371927261u },
+ { 0u, 9223372036854775808u, 221352539062u },
+ { 0u, 0u, 182500000000u },
+ { 8020875056524075716u, 291341u, 0u },
+ { 1400288714762747253u, 291341434812508u, 0u },
+ { 6136037711314764689u, 12005656413127238315u, 15793u },
+ { 15735488086392394102u, 4821130826186787462u, 177650827938u },
+ { 7735094782793634552u, 14377899467066168118u, 162261354025u },
+ { 7273689191766726188u, 16575613239625444872u, 41779427491u },
+ { 3410634565056431030u, 4317827099179284377u, 163898565794u },
+ { 4600927904885215898u, 1242354770412171254u, 162234069876u },
+ { 9154871331680374746u, 994838588328896609u, 116067348187u },
+ { 6117978272461042996u, 17283309862013060457u, 219053930307u },
+ { 13116904339287496285u, 124242522249856586u, 67936930105u },
+ { 867037205615660831u, 11564608014666985609u, 57006735200u },
+ { 1802487145191504830u, 12401028575581654085u, 96626918656u },
+ { 17242009718457409007u, 2490725392961465727u, 672261106u },
+ { 13620802355488468049u, 1949482237120640915u, 242135022494u },
+ { 4442227880594435745u, 15410502396166200087u, 158105681643u },
+ { 17354849212854314181u, 15694919529799920727u, 235835405008u },
+ { 18202319179831567886u, 10324869370171768388u, 208850823292u },
+ { 17568634016348874558u, 1631866459122189059u, 124559712290u },
+ { 7496925598312450672u, 172020494461226230u, 34088463658u },
+ { 601870379496813865u, 12734610307908856767u, 42009325249u },
+ { 11995106565680728027u, 1467513250829340930u, 193690344608u },
+ { 16331071694764184179u, 13558759428494307997u, 160079554052u },
+ { 9665962217000524208u, 7915355143999496434u, 4735021821u },
+ { 13682661374415474390u, 2876370200608797469u, 253429092262u },
+ { 6940361789924260864u, 343685370404989503u, 166155928341u },
+ { 9658039831644010465u, 4837266557407634630u, 21018631221u },
+ { 6843715893910236922u, 9622591415747161468u, 53262228745u },
+ { 47089792870595660u, 16503783814424220982u, 9521641725u },
+ { 14510386192097156932u, 5377083431343591334u, 253894671913u },
+ { 12059931208360040296u, 16508482371299291595u, 41291492276u },
+ { 14877013468459184620u, 10515883558812249028u, 180894926622u },
+ { 2397668560671695044u, 63492062913405476u, 30570067190u },
+ { 2195572305559232232u, 11571919759617799697u, 246003441911u },
+ { 3261686279425953792u, 2956602334970088581u, 247627315027u },
+ { 9333850662059900928u, 13604736747717849839u, 83160277733u },
+ { 5036522340217782272u, 16573540719338151362u, 229737514256u },
+ { 2800120215143186432u, 12620703004601168151u, 16898453442u },
+ { 441634238459019264u, 14649407809089591941u, 194684169680u },
+ { 720575940379279360u, 11290375247898624432u, 208794145988u },
+ { 0u, 11020319450292874212u, 196612052468u },
+ { 0u, 8754634933362354176u, 244597412714u },
+ { 0u, 12976319450332528640u, 106474589710u },
+ { 0u, 17447331119627239424u, 14703447686u },
+ { 0u, 3665184902673858560u, 134945821715u },
+ { 0u, 12949678516038795264u, 19198690071u },
+ { 0u, 72057594037927936u, 23702003479u },
+ { 0u, 0u, 23003906250u },
+ { 0u, 0u, 202000000000u },
+ { 8218347283861607400u, 4u, 0u },
+ { 17896200385973633643u, 4445517498u, 0u },
+ { 16333242102094352209u, 4445517498970154966u, 0u },
+ { 9981905728606788815u, 9413159735776077452u, 240991986u },
+ { 15219470018924839012u, 14279163482889998017u, 242510288411u },
+ { 17152070168529617370u, 8693044629541194274u, 27774075003u },
+ { 17841343440958328027u, 11863110253260222498u, 123471250893u },
+ { 17291078023923990493u, 8319293368489531245u, 205643100495u },
+ { 16744804581790759223u, 3376307525676489265u, 79450989797u },
+ { 5001622214111594905u, 13205662254759912523u, 229183029997u },
+ { 9676746897435398146u, 5276250334231686323u, 237715880385u },
+ { 8109025833995118532u, 13790198520922745052u, 193286026103u },
+ { 5495826424046694744u, 14195535250150996227u, 119747568159u },
+ { 7890288164365705852u, 16425228796427004035u, 31769541507u },
+ { 8616438349039895217u, 4295900841296269186u, 131890413437u },
+ { 15787154801788760618u, 4533952595483946442u, 125232881251u },
+ { 12418659311480782502u, 12885038019373447184u, 99245786062u },
+ { 4486988874116669987u, 12140736240487831910u, 206698499310u },
+ { 4828971301551875409u, 6927124077155322074u, 238658150630u },
+ { 14769106422014442226u, 12477788342407819890u, 230375520148u },
+ { 7763933466423188156u, 7980854329409711087u, 148676422261u },
+ { 10449097116253839963u, 2062671021810827996u, 117432642980u },
+ { 12870692502472900571u, 2739521363598172769u, 164111817620u },
+ { 11597479481311003817u, 12897585686593465638u, 148148509750u },
+ { 8294994869530047486u, 1127632646629044686u, 54699179521u },
+ { 16879315829924478241u, 4833775019274666364u, 1061129088u },
+ { 11873324837601439670u, 15867662672939849256u, 128262039468u },
+ { 3277599055636107318u, 2092350330982953557u, 172860187717u },
+ { 15363467897354242201u, 13330062299842493592u, 69113426538u },
+ { 10351182204479784367u, 4479193352178519263u, 106722624125u },
+ { 12811517584931924466u, 3149393938889064983u, 125242817558u },
+ { 16988930699558748726u, 9736379904070620767u, 22170728987u },
+ { 11683499918824718325u, 3816238703055069186u, 27527810212u },
+ { 13119300691281647499u, 11598915938798661975u, 164206878714u },
+ { 10125549106595354099u, 17821633264606555643u, 250628778492u },
+ { 17505352699870800544u, 2514623558764574316u, 252966112675u },
+ { 6756039242241163264u, 4976730480406253215u, 163136318016u },
+ { 3537338758766526464u, 17276563697191611637u, 64269789099u },
+ { 6522626374119718912u, 12524734095940998814u, 171936564394u },
+ { 4733294203482669056u, 15331551308930355164u, 170678967195u },
+ { 16997710893603094528u, 15417115581125943816u, 155831125061u },
+ { 16717361816799281152u, 6010750237807115593u, 69835763510u },
+ { 0u, 5624630987553628432u, 54325843423u },
+ { 0u, 14881848243837640704u, 223304911856u },
+ { 0u, 15281613886881529856u, 240806746609u },
+ { 0u, 14057902358273196032u, 241828417948u },
+ { 0u, 16075318494433902592u, 156762080413u },
+ { 0u, 13891916000577716224u, 157871444761u },
+ { 0u, 7205759403792793600u, 25753082275u },
+ { 0u, 0u, 163390625000u },
+ { 0u, 0u, 232000000000u },
+ { 3943737498063000362u, 67833u, 0u },
+ { 2870731037991212489u, 67833213790438u, 0u },
+ { 7389433400402095883u, 4535831408134330609u, 3677u },
+ { 5675049236146197433u, 6204770794376564579u, 93245887913u },
+ { 9953779846262904264u, 13869812122751887467u, 169336361298u },
+ { 12691978937179636241u, 14253229412394467550u, 82751884021u },
+ { 15523327331528198029u, 12776557610216045332u, 245772669114u },
+ { 15722603279568118520u, 16493640728678654060u, 186692618575u },
+ { 11838632364171816147u, 9434398296825833151u, 79894122055u },
+ { 7832751832367143680u, 8773374058285327850u, 71511439756u },
+ { 12167724027162940862u, 12932015276748029367u, 140475605560u },
+ { 4108211144748152962u, 16293958583527755209u, 56701045952u },
+ { 7530983398136343676u, 13511893936143127948u, 192883297264u },
+ { 1117587133956542355u, 18409936402005226436u, 240732481237u },
+ { 17134748625149490872u, 2189663026458466887u, 213998004652u },
+ { 4039918359454207848u, 9497725274248154664u, 172118701870u },
+ { 1830218764589441242u, 14766925481127792125u, 46514872718u },
+ { 637895981480825742u, 6982373971809635814u, 142800516634u },
+ { 8246879226348334620u, 8616702383006884794u, 26378515251u },
+ { 12389239568142583275u, 3059473300040871066u, 51467112372u },
+ { 14041257178803154398u, 17123843157031495558u, 180165854379u },
+ { 16312515716494630702u, 11210627174210626524u, 171928285397u },
+ { 17088522799596987756u, 15868067138625928592u, 213607729316u },
+ { 3588932524637852678u, 4467869511636937589u, 164860209643u },
+ { 107218049069817414u, 10052108125844341766u, 235242203691u },
+ { 1596707240462008334u, 7470588003218451534u, 43544925873u },
+ { 17461913142391587672u, 2613527085490786280u, 177404981387u },
+ { 4366474266651610090u, 3632919450036549616u, 139141679587u },
+ { 5539304013194805084u, 179367907231218916u, 227196940958u },
+ { 4762470619211987849u, 13553068184555874624u, 158009723553u },
+ { 10835638458986644717u, 8798774862365584481u, 161734713298u },
+ { 16141642290510052058u, 910911255817064881u, 210476982541u },
+ { 17390568670756355425u, 2304331144765093813u, 13049380598u },
+ { 12536768491333867107u, 12248937023083640360u, 246124918041u },
+ { 13145148522871947193u, 10206039550662130685u, 25664016206u },
+ { 5665349945233068642u, 12267881323837852537u, 78553270512u },
+ { 17074607537751066240u, 2858642007937891971u, 240665043179u },
+ { 6241525660962062336u, 14171330289750320841u, 235154967293u },
+ { 1142860629783085056u, 6601103619749017720u, 253768229354u },
+ { 16287527416870469632u, 4919573414486739494u, 234357846544u },
+ { 9028002014738513920u, 3401998285294974486u, 16266690609u },
+ { 16217462258161156096u, 10799436256515532233u, 49184422696u },
+ { 11529215046068469760u, 10083786644665753398u, 40585438612u },
+ { 0u, 6481194517685688896u, 148546643169u },
+ { 0u, 15104161756860547072u, 225351346258u },
+ { 0u, 9556039274244079616u, 82818798249u },
+ { 0u, 1376343134954323968u, 169518033927u },
+ { 0u, 15682488278596976640u, 7074611710u },
+ { 0u, 1506454075355430912u, 254850149393u },
+ { 0u, 1152921504606846976u, 17081665039u },
+ { 0u, 0u, 15062500000u },
+ { 0u, 0u, 160000000000u },
+ { 12170458846894708007u, 1035052700u, 0u },
+ { 1797330480103086687u, 1035052700659761896u, 0u },
+ { 10332188564497263448u, 6172559441576707976u, 56110319u },
+ { 7524259485079594225u, 15083329738554729992u, 239334615117u },
+ { 62681109059153749u, 10013126833549229036u, 77817668943u },
+ { 13480636451804037081u, 5817156823499936061u, 79542812693u },
+ { 6948168233012789004u, 5282692560913632718u, 21315348703u },
+ { 12015502974041806055u, 10252307034225766362u, 223286375337u },
+ { 7343801660689004040u, 17981881283247669689u, 169555778677u },
+ { 13670580858640731144u, 11689290159733383293u, 117974799737u },
+ { 5605073897566574851u, 5530668968487988249u, 121633677689u },
+ { 15387788940505247559u, 10083765740821947024u, 121299818165u },
+ { 17565181499678113030u, 2798423656816843533u, 181546642036u },
+ { 1893743623847493029u, 7614494481582904797u, 116151702850u },
+ { 10243498996716269784u, 17811318500083423695u, 66412782572u },
+ { 5619675836950314139u, 11641467412200329033u, 236965553510u },
+ { 10224869737511515088u, 17733593025296340645u, 102631085212u },
+ { 2574495974386198538u, 3689424000190644835u, 156961340004u },
+ { 7825756347302873178u, 14966634145516728506u, 100200004075u },
+ { 12071550103794656887u, 14171681941562070109u, 235811342862u },
+ { 7195875213867606691u, 8130575762882608170u, 14768248417u },
+ { 18271364438406891044u, 5234550794400656856u, 97440759395u },
+ { 16966521933952564706u, 3020576149360486378u, 99283765567u },
+ { 289920862029570129u, 3038675756589057221u, 63163745761u },
+ { 7804199568098625032u, 15470260187120878369u, 225164726942u },
+ { 5758118571242446585u, 3497929414841828746u, 158838644485u },
+ { 4030788293606375591u, 9935840636861015305u, 5189623133u },
+ { 4387716460037196127u, 3647355485153741471u, 93538623000u },
+ { 16807506478881285981u, 766100215038272793u, 24197723537u },
+ { 17033060604413529717u, 16128087474216800751u, 145041530375u },
+ { 10498418508292170054u, 16216631732633731297u, 7874305373u },
+ { 13237752038744465016u, 13760220872779997335u, 93879105367u },
+ { 17737618428304633155u, 3826276262374222087u, 87745943068u },
+ { 13546183833248825736u, 14938032745839181005u, 28207422851u },
+ { 826778452978976229u, 14479259995009508865u, 131809792377u },
+ { 13728076626990147292u, 2372033248156102437u, 121784922257u },
+ { 2794860281883592225u, 792005346826701645u, 145128588180u },
+ { 8680705720425908736u, 16278924527931792559u, 148042934695u },
+ { 731520517439488000u, 17442516423538940144u, 167882482266u },
+ { 13120812320768917504u, 13844184233048446u, 90945560710u },
+ { 2722954908557901824u, 13486193870480782357u, 134000750494u },
+ { 6860847004205973504u, 11931315179184648737u, 158731088034u },
+ { 6503197861922996224u, 16492562205587485405u, 162646797891u },
+ { 9223372036854775808u, 12128987217680380854u, 67894063588u },
+ { 0u, 10568123814189138176u, 228657513714u },
+ { 0u, 17007583519117541376u, 242572899139u },
+ { 0u, 143791533903052800u, 67921982950u },
+ { 0u, 12398714235792654336u, 230007794954u },
+ { 0u, 9659957317919047680u, 10672135645u },
+ { 0u, 9412523221204336640u, 221523667335u },
+ { 0u, 4611686018427387904u, 135510253906u },
+ { 0u, 0u, 82250000000u },
+ { 0u, 0u, 128000000000u },
+ { 12005656413127238315u, 15793u, 0u },
+ { 4821130826186787462u, 15793650827938u, 0u },
+ { 14377899467066168118u, 3237900842885170729u, 856u },
+ { 16575613239625444872u, 7515893506498066595u, 88175526956u },
+ { 4317827099179284377u, 7300206309181072546u, 44407437403u },
+ { 1242354770412171254u, 5999737279837044u, 91395744977u },
+ { 994838588328896609u, 7556839307242450651u, 209000325246u },
+ { 17283309862013060457u, 12946035041643640643u, 126409657079u },
+ { 124242522249856586u, 15885877642352740665u, 247701805965u },
+ { 11564608014666985609u, 10770818348246089568u, 141861175152u },
+ { 12401028575581654085u, 11635415503599551744u, 112583887232u },
+ { 2490725392961465727u, 6248053924100826098u, 128630757138u },
+ { 1949482237120640915u, 16894170802729859998u, 18338707681u },
+ { 15410502396166200087u, 6143589029651889899u, 225915834834u },
+ { 15694919529799920727u, 11812087701837886160u, 210333044628u },
+ { 10324869370171768388u, 7306705080150829180u, 148640334557u },
+ { 1631866459122189059u, 1485332570280714274u, 221396097276u },
+ { 172020494461226230u, 18042602303295630634u, 252080520039u },
+ { 12734610307908856767u, 13397029889257074369u, 103978091430u },
+ { 1467513250829340930u, 9948104869613411488u, 166726254445u },
+ { 13558759428494307997u, 10836066241170646532u, 109539287845u },
+ { 7915355143999496434u, 18330574781234459389u, 37587424327u },
+ { 2876370200608797469u, 666297360208433062u, 71993702450u },
+ { 343685370404989503u, 5035352224889324309u, 50036120052u },
+ { 4837266557407634630u, 1341745796439923765u, 244272966991u },
+ { 9622591415747161468u, 6846932182653803785u, 79072736185u },
+ { 16503783814424220982u, 6727685027257825533u, 185371172937u },
+ { 5377083431343591334u, 2168538874806877737u, 73364708536u },
+ { 16508482371299291595u, 17694936100676971444u, 184117556727u },
+ { 10515883558812249028u, 2163944241059563294u, 247959244408u },
+ { 63492062913405476u, 6727780864524301558u, 120117307652u },
+ { 11571919759617799697u, 8599551977795002615u, 4364713731u },
+ { 2956602334970088581u, 15428264807806859091u, 3466182646u },
+ { 13604736747717849839u, 2126771385339683557u, 246836367911u },
+ { 16573540719338151362u, 15094316562082972944u, 39115292507u },
+ { 12620703004601168151u, 8111300598225956802u, 91818264540u },
+ { 14649407809089591941u, 9481215200564260304u, 220439714486u },
+ { 11290375247898624432u, 16836674128623424708u, 182513977705u },
+ { 11020319450292874212u, 7087243115299722740u, 105912717933u },
+ { 8754634933362354176u, 2343560867338408810u, 109384200219u },
+ { 12976319450332528640u, 3431385749090422286u, 27127044689u },
+ { 17447331119627239424u, 3504545517469224582u, 81186015794u },
+ { 3665184902673858560u, 3333759805712094227u, 50189981793u },
+ { 12949678516038795264u, 3595183476205994775u, 97180723481u },
+ { 72057594037927936u, 14191566632569921303u, 25194895286u },
+ { 0u, 12917427671358095562u, 182769326368u },
+ { 0u, 3883793922738316288u, 32700255157u },
+ { 0u, 7857281689266421760u, 181210540890u },
+ { 0u, 15987081651486195712u, 90425944093u },
+ { 0u, 16827562156399525888u, 29866661432u },
+ { 0u, 7012737938513461248u, 56912223972u },
+ { 0u, 7385903388887613440u, 228380161285u },
+ { 0u, 0u, 5400390625u },
+ { 0u, 0u, 225000000000u },
+ { 9413159735776077452u, 240991986u, 0u },
+ { 14279163482889998017u, 240991986510288411u, 0u },
+ { 8693044629541194274u, 14135788013842776187u, 13064201u },
+ { 11863110253260222498u, 13284322918167594445u, 9766302603u },
+ { 8319293368489531245u, 7264587765474046287u, 139720144588u },
+ { 3376307525676489265u, 16176482219778368741u, 204393814091u },
+ { 13205662254759912523u, 5401983818872095469u, 75876928858u },
+ { 5276250334231686323u, 11208857446851049921u, 90292842129u },
+ { 13790198520922745052u, 13794690008281035639u, 145607633379u },
+ { 14195535250150996227u, 14519782740993303071u, 227747811643u },
+ { 16425228796427004035u, 10885858587044789123u, 59787118999u },
+ { 4295900841296269186u, 8710500938899914621u, 151590123576u },
+ { 4533952595483946442u, 1284182587483102819u, 56472197202u },
+ { 12885038019373447184u, 10346074482131502030u, 82069615677u },
+ { 12140736240487831910u, 9429804686255246574u, 61560861821u },
+ { 6927124077155322074u, 6412022633845121254u, 125511190736u },
+ { 12477788342407819890u, 8892351297529018260u, 208347596443u },
+ { 7980854329409711087u, 14098160105983060597u, 155482055329u },
+ { 2062671021810827996u, 13793833029739474340u, 161764262790u },
+ { 2739521363598172769u, 16367653765996977044u, 134747765186u },
+ { 12897585686593465638u, 10684788343333772342u, 194887292288u },
+ { 1127632646629044686u, 13272681218705145345u, 128579223536u },
+ { 4833775019274666364u, 11093568615497829248u, 240719513490u },
+ { 15867662672939849256u, 12488220765137758124u, 146601383559u },
+ { 2092350330982953557u, 3727114642519696453u, 135676987804u },
+ { 13330062299842493592u, 11549865375695057514u, 156202047289u },
+ { 4479193352178519263u, 11292809154908783229u, 57626119456u },
+ { 3149393938889064983u, 17723904861837310998u, 32612184410u },
+ { 9736379904070620767u, 14877674388187150875u, 90960814807u },
+ { 3816238703055069186u, 12178961950105734308u, 215806520344u },
+ { 11598915938798661975u, 4540604068069253114u, 24660222850u },
+ { 17821633264606555643u, 13832478722153359868u, 130246146639u },
+ { 2514623558764574316u, 1308046668730371491u, 79749860174u },
+ { 4976730480406253215u, 18400531023544756800u, 78070909351u },
+ { 17276563697191611637u, 9789823458621466539u, 167997494785u },
+ { 12524734095940998814u, 1924870562610267306u, 1530707393u },
+ { 15331551308930355164u, 5290016144582400923u, 193104347442u },
+ { 15417115581125943816u, 15162883663174059077u, 50286772349u },
+ { 6010750237807115593u, 8078086116520046390u, 125821981570u },
+ { 5624630987553628432u, 15731407332173190623u, 130437913925u },
+ { 14881848243837640704u, 5346389182763011056u, 69852801300u },
+ { 15281613886881529856u, 6368422217216252401u, 20289828338u },
+ { 14057902358273196032u, 2961453088119116188u, 242345232860u },
+ { 16075318494433902592u, 10932141691610170525u, 220160540693u },
+ { 13891916000577716224u, 11034016191361782553u, 21592632588u },
+ { 7205759403792793600u, 5455325785621453219u, 12598155216u },
+ { 0u, 7735615202566149352u, 208295733803u },
+ { 0u, 7502396497775759360u, 43419348540u },
+ { 0u, 1601286435751591936u, 60406705729u },
+ { 0u, 11449383158571597824u, 65086805911u },
+ { 0u, 13043944595690356736u, 151620672304u },
+ { 0u, 7773494431818186752u, 48707113653u },
+ { 0u, 9943947977234055168u, 181421401977u },
+ { 0u, 0u, 121539062500u },
+ { 0u, 0u, 228000000000u },
+ { 4535831408134330609u, 3677u, 0u },
+ { 6204770794376564579u, 3677245887913u, 0u },
+ { 13869812122751887467u, 6343817245135589714u, 199u },
+ { 14253229412394467550u, 17549323075660516085u, 199343899021u },
+ { 12776557610216045332u, 3948641822109421754u, 141951350710u },
+ { 16493640728678654060u, 1750739713693534543u, 182214056302u },
+ { 9434398296825833151u, 962163898128633415u, 110094907790u },
+ { 8773374058285327850u, 7967320249386531212u, 142052159009u },
+ { 12932015276748029367u, 3018466665533383224u, 33431909296u },
+ { 16293958583527755209u, 15076865731854945472u, 176163631405u },
+ { 13511893936143127948u, 691187172844604400u, 45817318529u },
+ { 18409936402005226436u, 13274492813370992341u, 129037469331u },
+ { 2189663026458466887u, 6364168818499152300u, 147719611697u },
+ { 9497725274248154664u, 17599380787401914158u, 49345002282u },
+ { 14766925481127792125u, 3782323149461692814u, 42954064344u },
+ { 6982373971809635814u, 14470163442442237466u, 216205040148u },
+ { 8616702383006884794u, 476109872130437939u, 20784429132u },
+ { 3059473300040871066u, 16330548844673355700u, 76025809967u },
+ { 17123843157031495558u, 14089158961463739563u, 47885280826u },
+ { 11210627174210626524u, 13385510793074798805u, 58763774837u },
+ { 15868067138625928592u, 1549401308746959012u, 117725629994u },
+ { 4467869511636937589u, 4607384943843027435u, 42083993213u },
+ { 10052108125844341766u, 5157353797716093483u, 125249766838u },
+ { 7470588003218451534u, 10846828782671550129u, 182279580709u },
+ { 2613527085490786280u, 9915857350819131531u, 37588007766u },
+ { 3632919450036549616u, 1673544973504317923u, 86537539704u },
+ { 179367907231218916u, 14780986291622785694u, 120090723054u },
+ { 13553068184555874624u, 8168111319515466401u, 238801278872u },
+ { 8798774862365584481u, 16345760387859734482u, 152442794201u },
+ { 910911255817064881u, 3177475373321281805u, 217886105446u },
+ { 2304331144765093813u, 2558676822419554038u, 102172251285u },
+ { 12248937023083640360u, 8813474062662382873u, 149138706148u },
+ { 10206039550662130685u, 5426294560236228430u, 228477779386u },
+ { 12267881323837852537u, 9919177474128333040u, 186294160017u },
+ { 2858642007937891971u, 6197383943089627371u, 145537719688u },
+ { 14171330289750320841u, 13673239314867423997u, 136335960856u },
+ { 6601103619749017720u, 9309584098968723946u, 24741227788u },
+ { 4919573414486739494u, 4647101757759615504u, 12504673565u },
+ { 3401998285294974486u, 1405809295505096753u, 29251919891u },
+ { 10799436256515532233u, 11332704079573859112u, 19076209074u },
+ { 10083786644665753398u, 2960072434514044308u, 178614347119u },
+ { 6481194517685688896u, 3887266602785432801u, 111160465848u },
+ { 15104161756860547072u, 14545546084687849554u, 184210729144u },
+ { 9556039274244079616u, 4617763804182385321u, 184788515633u },
+ { 1376343134954323968u, 7857823815580249095u, 49250329477u },
+ { 15682488278596976640u, 10939326736548364798u, 133425973482u },
+ { 1506454075355430912u, 12262012446566951953u, 234593022090u },
+ { 1152921504606846976u, 12555024338687723023u, 138664725026u },
+ { 0u, 3332969632922829472u, 34680609233u },
+ { 0u, 15535060143360327680u, 209180680645u },
+ { 0u, 15794322927987458048u, 197842157297u },
+ { 0u, 10571474314433921024u, 241856211961u },
+ { 0u, 16679514427547975680u, 249573080770u },
+ { 0u, 16925653299565166592u, 194904198288u },
+ { 0u, 16717361816799281152u, 144917541503u },
+ { 0u, 0u, 127906250000u },
+ { 0u, 0u, 16000000000u },
+ { 6172559441576707976u, 56110319u, 0u },
+ { 15083329738554729992u, 56110319334615117u, 0u },
+ { 10013126833549229036u, 9335385384027907407u, 3041746u },
+ { 5817156823499936061u, 13237828406194798613u, 210506072255u },
+ { 5282692560913632718u, 15667486867836528863u, 191717624115u },
+ { 10252307034225766362u, 17982325043592934313u, 51849336164u },
+ { 17981881283247669689u, 17159117626917379189u, 100974823793u },
+ { 11689290159733383293u, 8336208968408929657u, 113930197630u },
+ { 5530668968487988249u, 12767090573379150201u, 126451906793u },
+ { 10083765740821947024u, 14736070002412246709u, 233692105366u },
+ { 2798423656816843533u, 9697296975344560756u, 150798843955u },
+ { 7614494481582904797u, 7291706381199103298u, 51525691522u },
+ { 17811318500083423695u, 18098546597780825068u, 130395284194u },
+ { 11641467412200329033u, 132913902678533478u, 226981124177u },
+ { 17733593025296340645u, 1879347741692007580u, 81007205277u },
+ { 3689424000190644835u, 4056624629214083684u, 157101879645u },
+ { 14966634145516728506u, 14713227692042795499u, 93219910061u },
+ { 14171681941562070109u, 7366415124022528526u, 173797605671u },
+ { 8130575762882608170u, 825770353378039393u, 39399334164u },
+ { 5234550794400656856u, 10244023944395357795u, 20044765100u },
+ { 3020576149360486378u, 14302658294713551167u, 172555329650u },
+ { 3038675756589057221u, 14246653166206862817u, 114775348659u },
+ { 15470260187120878369u, 12404486258134291102u, 179772312615u },
+ { 3497929414841828746u, 8887442218637942533u, 39672448547u },
+ { 9935840636861015305u, 1186724038081863005u, 35481789208u },
+ { 3647355485153741471u, 211331772484951576u, 24064332439u },
+ { 766100215038272793u, 6311919513247413649u, 151011456318u },
+ { 16128087474216800751u, 8131780018703965703u, 62342169842u },
+ { 16216631732633731297u, 2262544347226725725u, 242440824678u },
+ { 13760220872779997335u, 15318188749880522583u, 102122652774u },
+ { 3826276262374222087u, 1073117094162650652u, 102830400676u },
+ { 14938032745839181005u, 4447950380665871747u, 164058173794u },
+ { 14479259995009508865u, 5373227185066463609u, 98241123873u },
+ { 2372033248156102437u, 6739731406934274193u, 33291283229u },
+ { 792005346826701645u, 12328812617001239444u, 29365361571u },
+ { 16278924527931792559u, 3246111484407310759u, 163668346271u },
+ { 17442516423538940144u, 3250825415176839770u, 159175972056u },
+ { 13844184233048446u, 16146270540000862342u, 216176227598u },
+ { 13486193870480782357u, 15686773375425916830u, 14875291079u },
+ { 11931315179184648737u, 11920791905793880226u, 199850381688u },
+ { 16492562205587485405u, 1853290561644080707u, 120646227424u },
+ { 12128987217680380854u, 12157689141506159076u, 224100467082u },
+ { 10568123814189138176u, 18100318838862562546u, 138659069648u },
+ { 17007583519117541376u, 7171257882533475139u, 208981220250u },
+ { 143791533903052800u, 14477550873015039462u, 154388754668u },
+ { 12398714235792654336u, 8109481182495403274u, 236784829605u },
+ { 9659957317919047680u, 14565395719337663965u, 165439615855u },
+ { 9412523221204336640u, 1860318978161305991u, 111789591684u },
+ { 4611686018427387904u, 16268646275151585618u, 132100848093u },
+ { 0u, 13759019338835519104u, 221881925081u },
+ { 0u, 17003783176010661888u, 217745877932u },
+ { 0u, 18357489540307877888u, 172921776932u },
+ { 0u, 905481790074912768u, 36995161502u },
+ { 0u, 3638882110636294144u, 158049086266u },
+ { 0u, 9011702854368362496u, 58197264194u },
+ { 0u, 11529215046068469760u, 66488525390u },
+ { 0u, 0u, 78625000000u },
+ { 0u, 0u, 64000000000u },
+ { 3237900842885170729u, 856u, 0u },
+ { 7515893506498066595u, 856175526956u, 0u },
+ { 7300206309181072546u, 7625299565768063067u, 46u },
+ { 5999737279837044u, 13889021769065194705u, 46413368317u },
+ { 7556839307242450651u, 14498170692313014398u, 253752925378u },
+ { 12946035041643640643u, 1541631360972245751u, 194785947408u },
+ { 15885877642352740665u, 9903958882920799117u, 16083572003u },
+ { 10770818348246089568u, 15744148547788062576u, 35536894686u },
+ { 11635415503599551744u, 17936061801321712000u, 222853492002u },
+ { 6248053924100826098u, 9986394078324430610u, 34972315858u },
+ { 16894170802729859998u, 13849561248103430369u, 210541363507u },
+ { 6143589029651889899u, 12142378807953854930u, 51750786219u },
+ { 11812087701837886160u, 2513847703931031444u, 171658239674u },
+ { 7306705080150829180u, 1752183758129038045u, 186136275957u },
+ { 1485332570280714274u, 15824833342220556540u, 245094986071u },
+ { 18042602303295630634u, 8168747198299470695u, 87857865934u },
+ { 13397029889257074369u, 17414799840149357478u, 206442828672u },
+ { 9948104869613411488u, 83147520704167789u, 128944058191u },
+ { 10836066241170646532u, 2383542703041471269u, 79004507436u },
+ { 18330574781234459389u, 15540952725549257799u, 44129212108u },
+ { 666297360208433062u, 6949835416232048690u, 204842476735u },
+ { 5035352224889324309u, 15398868937585367540u, 191376751332u },
+ { 1341745796439923765u, 14710915985268256079u, 228834774357u },
+ { 6846932182653803785u, 9665704836873335737u, 85797480353u },
+ { 6727685027257825533u, 2528789298740305993u, 161523978909u },
+ { 2168538874806877737u, 10562914675687726264u, 157137085942u },
+ { 17694936100676971444u, 17671658300096837111u, 246572616751u },
+ { 2163944241059563294u, 356471401631698552u, 47957982516u },
+ { 6727780864524301558u, 7450677157218003204u, 52019324353u },
+ { 8599551977795002615u, 317174560787152643u, 193403902018u },
+ { 15428264807806859091u, 7251937674440720374u, 66017194067u },
+ { 2126771385339683557u, 1252631516699038247u, 83393128329u },
+ { 15094316562082972944u, 10818009768860843867u, 137067905290u },
+ { 8111300598225956802u, 12330114194950162396u, 10586445484u },
+ { 9481215200564260304u, 15826681638261168822u, 172668416829u },
+ { 16836674128623424708u, 14240150078499211625u, 61857966130u },
+ { 7087243115299722740u, 10725372116242125421u, 50771960082u },
+ { 2343560867338408810u, 8434925524647833627u, 18581423587u },
+ { 3431385749090422286u, 17133902668520348241u, 227457258228u },
+ { 3504545517469224582u, 15093996047981365810u, 244928830724u },
+ { 3333759805712094227u, 6187974166976813153u, 4818247165u },
+ { 3595183476205994775u, 13946144707720259865u, 253335450751u },
+ { 14191566632569921303u, 9138079832881862582u, 127756022019u },
+ { 12917427671358095562u, 6600697628576225568u, 3495376300u },
+ { 3883793922738316288u, 8137099536646556597u, 172357824535u },
+ { 7857281689266421760u, 14169855543453903706u, 23441113049u },
+ { 15987081651486195712u, 3706403268650100765u, 217768149408u },
+ { 16827562156399525888u, 14736932266877982264u, 160200924523u },
+ { 7012737938513461248u, 18004795125138956004u, 107798890698u },
+ { 7385903388887613440u, 9068489270661002501u, 202976041899u },
+ { 0u, 7758835715193269217u, 171491603788u },
+ { 0u, 16943947811135261184u, 76420607326u },
+ { 0u, 6745843108403216384u, 94918533251u },
+ { 0u, 12338229654069444608u, 131365692887u },
+ { 0u, 14358176069683511296u, 215668856769u },
+ { 0u, 7083775185760813056u, 193778358284u },
+ { 0u, 5350276357316149248u, 12384012222u },
+ { 0u, 9223372036854775808u, 190290039062u },
+ { 0u, 0u, 22500000000u },
+ { 14135788013842776187u, 13064201u, 0u },
+ { 13284322918167594445u, 13064201766302603u, 0u },
+ { 7264587765474046287u, 14699116688460625612u, 708211u },
+ { 16176482219778368741u, 6684126021499623499u, 115796840712u },
+ { 5401983818872095469u, 12614606079692508506u, 8362347197u },
+ { 11208857446851049921u, 15358270276683001489u, 189683839165u },
+ { 13794690008281035639u, 18077126190953408995u, 189832573499u },
+ { 14519782740993303071u, 7864121581925945659u, 59979962974u },
+ { 10885858587044789123u, 3518026639210514839u, 94426314885u },
+ { 8710500938899914621u, 4698310163811252280u, 133190712606u },
+ { 1284182587483102819u, 6101155398200416338u, 30254695904u },
+ { 10346074482131502030u, 16049178580360033341u, 224330744296u },
+ { 9429804686255246574u, 3167464649127375997u, 232870027714u },
+ { 6412022633845121254u, 12778923935480989904u, 194171708602u },
+ { 8892351297529018260u, 11875553912612980379u, 186692746854u },
+ { 14098160105983060597u, 10628760849351697057u, 102643775067u },
+ { 13793833029739474340u, 3408944711673234310u, 91576186280u },
+ { 16367653765996977044u, 2102091496050506178u, 168184799263u },
+ { 10684788343333772342u, 6254611118630245760u, 31113954608u },
+ { 13272681218705145345u, 2647941151989776368u, 48339063148u },
+ { 11093568615497829248u, 8855437735410157458u, 108143545177u },
+ { 12488220765137758124u, 10184270603132180103u, 89480054241u },
+ { 3727114642519696453u, 12079083162535627164u, 225552090415u },
+ { 11549865375695057514u, 5952952868716156729u, 47654808410u },
+ { 11292809154908783229u, 11958907037815852320u, 90322710221u },
+ { 17723904861837310998u, 10101562137321697626u, 205648293649u },
+ { 14877674388187150875u, 13633527411279258327u, 17547606780u },
+ { 12178961950105734308u, 16555627393501768728u, 252739075001u },
+ { 4540604068069253114u, 6359650463500280706u, 185897482359u },
+ { 13832478722153359868u, 8093923611102181967u, 119344757342u },
+ { 1308046668730371491u, 2848827352928635726u, 94438772478u },
+ { 18400531023544756800u, 4686723431961561511u, 254154435240u },
+ { 9789823458621466539u, 6245554925867652609u, 168254067786u },
+ { 1924870562610267306u, 17527406820792516033u, 74338572210u },
+ { 5290016144582400923u, 12119966834653692210u, 178950162627u },
+ { 15162883663174059077u, 11606502845877928061u, 195657024718u },
+ { 8078086116520046390u, 424311496652297090u, 206629189780u },
+ { 15731407332173190623u, 5977664048034127173u, 148023001972u },
+ { 5346389182763011056u, 6702712461535947028u, 116324049817u },
+ { 6368422217216252401u, 11384349854055020018u, 153363354770u },
+ { 2961453088119116188u, 3782955013294836188u, 146617146842u },
+ { 10932141691610170525u, 3531805968821207061u, 218205074402u },
+ { 11034016191361782553u, 3867566898657193228u, 226191459585u },
+ { 5455325785621453219u, 12688734637425072080u, 1209661221u },
+ { 7735615202566149352u, 18435982764454619691u, 37687857682u },
+ { 7502396497775759360u, 4728836163964677692u, 18999416628u },
+ { 1601286435751591936u, 2120012917348838977u, 52256350722u },
+ { 11449383158571597824u, 9856965465824679831u, 2114926130u },
+ { 13043944595690356736u, 11217197671061248816u, 50534347168u },
+ { 7773494431818186752u, 3840562972677739189u, 160608085504u },
+ { 9943947977234055168u, 17104366978925258617u, 208197335u },
+ { 0u, 16177877219841993444u, 215927229591u },
+ { 0u, 7338522384267208704u, 151877004481u },
+ { 0u, 10935240458612244480u, 193397822095u },
+ { 0u, 1732868046462124032u, 143592800573u },
+ { 0u, 557965042578882560u, 61093938965u },
+ { 0u, 10454684322475540480u, 21030247345u },
+ { 0u, 13907115649320091648u, 177566749572u },
+ { 0u, 0u, 132753906250u },
+ { 0u, 0u, 74000000000u },
+ { 6343817245135589714u, 199u, 0u },
+ { 17549323075660516085u, 199343899021u, 0u },
+ { 3948641822109421754u, 14876458284855834550u, 10u },
+ { 1750739713693534543u, 10450704926982265198u, 10806454419u },
+ { 962163898128633415u, 5385653213018257806u, 147566533849u },
+ { 7967320249386531212u, 12735569669880147489u, 217291956845u },
+ { 3018466665533383224u, 3619762560577729456u, 109690396615u },
+ { 15076865731854945472u, 11123448126624084269u, 199196227721u },
+ { 691187172844604400u, 4072715118852885633u, 137603003331u },
+ { 13274492813370992341u, 18239087231420827283u, 195220782328u },
+ { 6364168818499152300u, 423431461216085297u, 248988742900u },
+ { 17599380787401914158u, 9360976716520160042u, 244022954265u },
+ { 3782323149461692814u, 11655927117263208920u, 25507459564u },
+ { 14470163442442237466u, 2646622721938364948u, 236631869075u },
+ { 476109872130437939u, 4496462484548171852u, 147143473705u },
+ { 16330548844673355700u, 13140258519803350063u, 41243753719u },
+ { 14089158961463739563u, 13089764333320627770u, 247712334841u },
+ { 13385510793074798805u, 6926286827289840501u, 249709597546u },
+ { 1549401308746959012u, 4985580225290866218u, 106375474761u },
+ { 4607384943843027435u, 10478790837359789693u, 73270268845u },
+ { 5157353797716093483u, 10041191967455692214u, 173568056389u },
+ { 10846828782671550129u, 5035461258013813797u, 69544334107u },
+ { 9915857350819131531u, 14208759661559249750u, 27272972901u },
+ { 1673544973504317923u, 12347272163241758840u, 101770258404u },
+ { 14780986291622785694u, 3372534174410277614u, 228669346965u },
+ { 8168111319515466401u, 17226704187274712984u, 149182825443u },
+ { 16345760387859734482u, 4250480179449852121u, 227933861505u },
+ { 3177475373321281805u, 4303723537755414374u, 129230418992u },
+ { 2558676822419554038u, 8680503847344854165u, 48233305320u },
+ { 8813474062662382873u, 8817608623911079652u, 232470571056u },
+ { 5426294560236228430u, 5692030448698539450u, 48478003521u },
+ { 9919177474128333040u, 16908836314686769809u, 65308565588u },
+ { 6197383943089627371u, 6073762347067727240u, 84916629853u },
+ { 13673239314867423997u, 10931066692585106200u, 93329259316u },
+ { 9309584098968723946u, 14466591364061539596u, 52592574312u },
+ { 4647101757759615504u, 4958077340960173341u, 104784235489u },
+ { 1405809295505096753u, 4076890037156765715u, 225268777911u },
+ { 11332704079573859112u, 14083973146609179058u, 183221008651u },
+ { 2960072434514044308u, 2565183738039805295u, 11763493714u },
+ { 3887266602785432801u, 1482420938751351224u, 82139058889u },
+ { 14545546084687849554u, 2151089495335413944u, 201080362200u },
+ { 4617763804182385321u, 3738604531753220913u, 216116610795u },
+ { 7857823815580249095u, 14195686514836005765u, 235202670157u },
+ { 10939326736548364798u, 17808833916231796970u, 77769549707u },
+ { 12262012446566951953u, 1302384553035657354u, 139965418821u },
+ { 12555024338687723023u, 1672033517974833698u, 69070602408u },
+ { 3332969632922829472u, 11673925532927662545u, 168090641118u },
+ { 15535060143360327680u, 3905334232240480709u, 222632844771u },
+ { 15794322927987458048u, 17411087320267472625u, 227211708592u },
+ { 10571474314433921024u, 16573305231063706617u, 176943856934u },
+ { 16679514427547975680u, 15481103236037148354u, 38898440676u },
+ { 16925653299565166592u, 907440704754420880u, 228839232288u },
+ { 16717361816799281152u, 3224970785139077759u, 32049192459u },
+ { 0u, 10560826509734608144u, 11174826016u },
+ { 0u, 4700940027512659968u, 32572503552u },
+ { 0u, 9733694683502084096u, 254838469u },
+ { 0u, 1995535635724632064u, 197527664646u },
+ { 0u, 10629833226245373952u, 6108178203u },
+ { 0u, 15729384648544878592u, 27576244413u },
+ { 0u, 7205759403792793600u, 189852691650u },
+ { 0u, 0u, 194390625000u },
+ { 0u, 0u, 232000000000u },
+ { 9335385384027907407u, 3041746u, 0u },
+ { 13237828406194798613u, 3041746506072255u, 0u },
+ { 15667486867836528863u, 7535526066623007027u, 164893u },
+ { 17982325043592934313u, 11302146918409311588u, 29408501686u },
+ { 17159117626917379189u, 2480833299122194801u, 182612690612u },
+ { 8336208968408929657u, 11513226205589330558u, 180134486242u },
+ { 12767090573379150201u, 4073957068281936105u, 226624133243u },
+ { 14736070002412246709u, 3729887061093812886u, 123220849655u },
+ { 9697296975344560756u, 13616911779739451443u, 247202197582u },
+ { 7291706381199103298u, 13039053282195777666u, 78738174266u },
+ { 18098546597780825068u, 14490756113210417890u, 58706848494u },
+ { 132913902678533478u, 17432486112977557585u, 238785545462u },
+ { 1879347741692007580u, 14308820825344039837u, 246945016965u },
+ { 4056624629214083684u, 4190949538817536349u, 133775682731u },
+ { 14713227692042795499u, 13616552502810964397u, 171227191829u },
+ { 7366415124022528526u, 4898145803694965031u, 21738154790u },
+ { 825770353378039393u, 1399036321001644308u, 38265529016u },
+ { 10244023944395357795u, 17170331128243738540u, 184075841910u },
+ { 14302658294713551167u, 10641321388205367410u, 118930805515u },
+ { 14246653166206862817u, 6648873641312572851u, 11576867188u },
+ { 12404486258134291102u, 5988456964560374823u, 116360436162u },
+ { 8887442218637942533u, 9972593758348346915u, 194324634902u },
+ { 1186724038081863005u, 16709668921872818968u, 22540615390u },
+ { 211331772484951576u, 6094829131503407767u, 222905832967u },
+ { 6311919513247413649u, 4892016478899926334u, 7330401349u },
+ { 8131780018703965703u, 13150857244079031538u, 69265196744u },
+ { 2262544347226725725u, 12983943395318785894u, 200712909399u },
+ { 15318188749880522583u, 15341644584614757478u, 87703860981u },
+ { 1073117094162650652u, 7507635124856644772u, 245831672219u },
+ { 4447950380665871747u, 11619655367084544354u, 155406989715u },
+ { 5373227185066463609u, 11553116952478783009u, 147629902779u },
+ { 6739731406934274193u, 17392150014233193245u, 187626295724u },
+ { 12328812617001239444u, 8877887560294980515u, 172942830341u },
+ { 3246111484407310759u, 18404180619915609503u, 5481271248u },
+ { 3250825415176839770u, 10079413095288181976u, 208997692630u },
+ { 16146270540000862342u, 14102802966539105550u, 214546406078u },
+ { 15686773375425916830u, 13333966026135891399u, 190764514480u },
+ { 11920791905793880226u, 12344968670173516152u, 176722835746u },
+ { 1853290561644080707u, 10577007819804726752u, 34669222092u },
+ { 12157689141506159076u, 15337041354031088010u, 204573380742u },
+ { 18100318838862562546u, 14333607285614673616u, 134831422677u },
+ { 7171257882533475139u, 17171597563219696538u, 213777026407u },
+ { 14477550873015039462u, 2849642930482147564u, 103930874169u },
+ { 8109481182495403274u, 14791248423979435173u, 57154479452u },
+ { 14565395719337663965u, 13882371364576310127u, 92801835183u },
+ { 1860318978161305991u, 11735995808941329540u, 175752564859u },
+ { 16268646275151585618u, 11376996674339273181u, 123636209607u },
+ { 13759019338835519104u, 9849638057168043481u, 199616748225u },
+ { 17003783176010661888u, 18241520229279361964u, 193533949948u },
+ { 18357489540307877888u, 1865852368526961444u, 252988874793u },
+ { 905481790074912768u, 10601487369276448158u, 41101148059u },
+ { 3638882110636294144u, 15999931310312762170u, 155574707781u },
+ { 9011702854368362496u, 5773775867713013570u, 69867358014u },
+ { 11529215046068469760u, 17726239863982547534u, 62312997016u },
+ { 0u, 9711316695888316992u, 152960941388u },
+ { 0u, 17872002620723724288u, 76526451532u },
+ { 0u, 7429694208660733952u, 76968843203u },
+ { 0u, 1782821038871019520u, 195402764530u },
+ { 0u, 3225250234313474048u, 242096646922u },
+ { 0u, 10009250171830927360u, 10174841165u },
+ { 0u, 1152921504606846976u, 77542602539u },
+ { 0u, 0u, 43062500000u },
+ { 0u, 0u, 160000000000u },
+ { 7625299565768063067u, 46u, 0u },
+ { 13889021769065194705u, 46413368317u, 0u },
+ { 14498170692313014398u, 9519880170333822146u, 2u },
+ { 1541631360972245751u, 2285186318012886800u, 2516073738u },
+ { 9903958882920799117u, 9706420951402272035u, 10123880198u },
+ { 15744148547788062576u, 2369632031840402142u, 6526186134u },
+ { 17936061801321712000u, 15599123897979399458u, 150128458009u },
+ { 9986394078324430610u, 17579576584023912658u, 25845630200u },
+ { 13849561248103430369u, 3480927339588501811u, 248952990756u },
+ { 12142378807953854930u, 3547346616671294635u, 36188701449u },
+ { 2513847703931031444u, 7705317123868384954u, 9192302045u },
+ { 1752183758129038045u, 4969425237478353909u, 221417706078u },
+ { 15824833342220556540u, 17043246700132217175u, 94269393081u },
+ { 8168747198299470695u, 17053788362783499470u, 185923916254u },
+ { 17414799840149357478u, 11102988228454224768u, 222924487719u },
+ { 83147520704167789u, 16944305387801685839u, 39601894197u },
+ { 2383542703041471269u, 11725142977459199276u, 53918552635u },
+ { 15540952725549257799u, 8175984171998533324u, 59635621274u },
+ { 6949835416232048690u, 1372352885142856895u, 154443220990u },
+ { 15398868937585367540u, 17975093466502888164u, 254074395398u },
+ { 14710915985268256079u, 6467823391459085653u, 6974431769u },
+ { 9665704836873335737u, 11319386883146885025u, 25350621408u },
+ { 2528789298740305993u, 9141999262922068637u, 224613625192u },
+ { 10562914675687726264u, 1587330393383478774u, 104495588773u },
+ { 17671658300096837111u, 884187548095712303u, 165086049353u },
+ { 356471401631698552u, 488841225726377268u, 73047931903u },
+ { 7450677157218003204u, 17462624199405856193u, 255026500135u },
+ { 317174560787152643u, 13183677579115583554u, 39946650754u },
+ { 7251937674440720374u, 11645015818917277779u, 130714688593u },
+ { 1252631516699038247u, 8760523002035971977u, 81631277572u },
+ { 10818009768860843867u, 10068817678491468042u, 4474908903u },
+ { 12330114194950162396u, 1273658177787418284u, 231545831700u },
+ { 15826681638261168822u, 3100019384328057661u, 20069045148u },
+ { 14240150078499211625u, 10363063568089458738u, 156168052387u },
+ { 10725372116242125421u, 13030756371481403666u, 163561782801u },
+ { 8434925524647833627u, 6538878900684195299u, 17706398718u },
+ { 17133902668520348241u, 8984884716779098868u, 254354473335u },
+ { 15093996047981365810u, 8728727397070363908u, 119487071576u },
+ { 6187974166976813153u, 6398650562917867005u, 88473185260u },
+ { 13946144707720259865u, 1190873176164938879u, 236346871542u },
+ { 9138079832881862582u, 4383628525805121795u, 246064557364u },
+ { 6600697628576225568u, 10189374699734119852u, 52237636978u },
+ { 8137099536646556597u, 5276291920541626391u, 114552367109u },
+ { 14169855543453903706u, 2692252373800386521u, 5286028358u },
+ { 3706403268650100765u, 11578684995169173920u, 70145947293u },
+ { 14736932266877982264u, 5799408022254132587u, 157627681771u },
+ { 18004795125138956004u, 15548569837712345290u, 235314386538u },
+ { 9068489270661002501u, 15763030464322902955u, 106842889659u },
+ { 7758835715193269217u, 13257749746581255500u, 187854515593u },
+ { 16943947811135261184u, 16152470009188707678u, 137718704053u },
+ { 6745843108403216384u, 13806790848493904003u, 181875627153u },
+ { 12338229654069444608u, 11981226523265951191u, 145748467631u },
+ { 14358176069683511296u, 5133628726077003713u, 175649503591u },
+ { 7083775185760813056u, 16183955741910833164u, 103278294570u },
+ { 5350276357316149248u, 13640425554331371454u, 42877333998u },
+ { 9223372036854775808u, 18108120906868035862u, 238739448950u },
+ { 0u, 6324011669895037184u, 118981643201u },
+ { 0u, 10444437689515769856u, 193342825359u },
+ { 0u, 12324712543665782784u, 143566194101u },
+ { 0u, 13928941951563857920u, 181668124005u },
+ { 0u, 3975288688270639104u, 101755089456u },
+ { 0u, 11141905478114607104u, 48215500831u },
+ { 0u, 4611686018427387904u, 31604003906u },
+ { 0u, 0u, 66250000000u },
+ { 0u, 0u, 128000000000u },
+ { 14699116688460625612u, 708211u, 0u },
+ { 6684126021499623499u, 708211796840712u, 0u },
+ { 12614606079692508506u, 4398362855256705725u, 38392u },
+ { 15358270276683001489u, 2812083125569302717u, 248238435728u },
+ { 18077126190953408995u, 12868509142973100603u, 144152443331u },
+ { 7864121581925945659u, 8726243776748165726u, 195697603278u },
+ { 3518026639210514839u, 358304413426858117u, 206473050623u },
+ { 4698310163811252280u, 3180720351566429470u, 255019423721u },
+ { 6101155398200416338u, 14053818240400098784u, 233172427195u },
+ { 16049178580360033341u, 7340140541492429288u, 187761859013u },
+ { 3167464649127375997u, 1323571167904965058u, 197397909816u },
+ { 12778923935480989904u, 14463851737583396026u, 56071750936u },
+ { 11875553912612980379u, 15122784818916048486u, 24784086973u },
+ { 10628760849351697057u, 13557974621377508955u, 189819807807u },
+ { 3408944711673234310u, 17525172074563876264u, 63734979276u },
+ { 2102091496050506178u, 15148880683074215967u, 204950041481u },
+ { 6254611118630245760u, 6744828147558597936u, 137821222467u },
+ { 2647941151989776368u, 9799290779647971692u, 67365637866u },
+ { 8855437735410157458u, 11170890203898678105u, 234531220617u },
+ { 10184270603132180103u, 7068779781287527905u, 137605575171u },
+ { 12079083162535627164u, 14474741922505540911u, 3383199319u },
+ { 5952952868716156729u, 17107062680405191514u, 87784677331u },
+ { 11958907037815852320u, 2712598571300237005u, 211927375726u },
+ { 10101562137321697626u, 3767556054903418641u, 110147050263u },
+ { 13633527411279258327u, 18158239681706277628u, 23204239622u },
+ { 16555627393501768728u, 10531652712128330681u, 6984360145u },
+ { 6359650463500280706u, 9548395326934120567u, 209570922037u },
+ { 8093923611102181967u, 15875647850297719390u, 53517619547u },
+ { 2848827352928635726u, 8215825295203192574u, 91860620594u },
+ { 4686723431961561511u, 12747310908260543144u, 50445380781u },
+ { 6245554925867652609u, 77706528053613642u, 173691033109u },
+ { 17527406820792516033u, 6024737704056756146u, 21004212479u },
+ { 12119966834653692210u, 6819452388570089667u, 255326601685u },
+ { 11606502845877928061u, 13695926775373186254u, 213369683254u },
+ { 424311496652297090u, 3746531715392682132u, 54742457678u },
+ { 5977664048034127173u, 4717376233154528116u, 78203099891u },
+ { 6702712461535947028u, 385190957950313369u, 243255729478u },
+ { 11384349854055020018u, 12388374310648616082u, 70020881243u },
+ { 3782955013294836188u, 1078067332084407770u, 91671575117u },
+ { 3531805968821207061u, 3257295319358714850u, 77058442147u },
+ { 3867566898657193228u, 1545453099660723457u, 163176578333u },
+ { 12688734637425072080u, 7495477664653506341u, 29083779180u },
+ { 18435982764454619691u, 7225503732673614354u, 108406330658u },
+ { 4728836163964677692u, 3935478326103643956u, 34391695342u },
+ { 2120012917348838977u, 10082240682742686210u, 238213342707u },
+ { 9856965465824679831u, 10838712705567897138u, 243546559362u },
+ { 11217197671061248816u, 2142546572501643680u, 130587567793u },
+ { 3840562972677739189u, 7893042119150331392u, 177116147682u },
+ { 17104366978925258617u, 12084811642251302615u, 226427882670u },
+ { 16177877219841993444u, 15317234482572954775u, 174655118951u },
+ { 7338522384267208704u, 2283226355108359361u, 103830348945u },
+ { 10935240458612244480u, 13359725152575722127u, 145123773948u },
+ { 1732868046462124032u, 13126551011491594557u, 252724232151u },
+ { 557965042578882560u, 3598021288691861269u, 215711591756u },
+ { 10454684322475540480u, 16462621795896662961u, 76195049124u },
+ { 13907115649320091648u, 14682112756964627332u, 164892440515u },
+ { 0u, 7174112100896070218u, 195795918927u },
+ { 0u, 5023109019590616064u, 79388909396u },
+ { 0u, 10765223023086141440u, 84272303285u },
+ { 0u, 8228137177297453056u, 181583583909u },
+ { 0u, 2891199497780592640u, 165446048210u },
+ { 0u, 15294857653247803392u, 210156732238u },
+ { 0u, 14303432416528695296u, 78829135894u },
+ { 0u, 0u, 22775390625u },
+ { 0u, 0u, 161000000000u },
+ { 14876458284855834550u, 10u, 0u },
+ { 10450704926982265198u, 10806454419u, 0u },
+ { 5385653213018257806u, 10806454419566533849u, 0u },
+ { 12735569669880147489u, 17118225092618494573u, 585819067u },
+ { 3619762560577729456u, 13385738875341807559u, 187927980841u },
+ { 11123448126624084269u, 8272682717439277193u, 41725642358u },
+ { 4072715118852885633u, 13402436483369350083u, 118448463028u },
+ { 18239087231420827283u, 10946328903241612536u, 180726547537u },
+ { 423431461216085297u, 16265808923426731252u, 81593401678u },
+ { 9360976716520160042u, 11080374459871185177u, 78881771268u },
+ { 11655927117263208920u, 1240761893433831916u, 4600668303u },
+ { 2646622721938364948u, 367264070493390483u, 143067261837u },
+ { 4496462484548171852u, 2863675693461092905u, 141019909425u },
+ { 13140258519803350063u, 7511929581752138999u, 49155240170u },
+ { 13089764333320627770u, 11154557789993845753u, 234407222518u },
+ { 6926286827289840501u, 8325416539745948522u, 246604689789u },
+ { 4985580225290866218u, 17745129874679852617u, 125451321734u },
+ { 10478790837359789693u, 1074820986392253357u, 134961965418u },
+ { 10041191967455692214u, 7820952682162838597u, 106058266162u },
+ { 5035461258013813797u, 8215518006273528603u, 50423974694u },
+ { 14208759661559249750u, 9680426791089900133u, 38445364123u },
+ { 12347272163241758840u, 16128495723604797412u, 155524776987u },
+ { 3372534174410277614u, 2264789053583348885u, 27874327505u },
+ { 17226704187274712984u, 11175458488686298083u, 209122774460u },
+ { 4250480179449852121u, 11026777810412287617u, 188605822818u },
+ { 4303723537755414374u, 16199890034895598640u, 98597762822u },
+ { 8680503847344854165u, 9094320719494763752u, 6878197798u },
+ { 8817608623911079652u, 1250835564687222832u, 38493004114u },
+ { 5692030448698539450u, 15362466642459337025u, 82067807931u },
+ { 16908836314686769809u, 7831109835595423828u, 187832800985u },
+ { 6073762347067727240u, 15426237284335022429u, 217424525314u },
+ { 10931066692585106200u, 15636308361455434548u, 2836257998u },
+ { 14466591364061539596u, 13967173875944980328u, 206847645974u },
+ { 4958077340960173341u, 18245979923595824097u, 22757162012u },
+ { 4076890037156765715u, 11335054479675278263u, 28989116553u },
+ { 14083973146609179058u, 11165339882630461707u, 137614474534u },
+ { 2565183738039805295u, 15944437408299395922u, 38605274287u },
+ { 1482420938751351224u, 15806416348777321161u, 175864349683u },
+ { 2151089495335413944u, 4201030477408556248u, 243856867547u },
+ { 3738604531753220913u, 9485474942554588907u, 219227738318u },
+ { 14195686514836005765u, 18238757647663230541u, 206514208626u },
+ { 17808833916231796970u, 4642199687824746379u, 114988725033u },
+ { 1302384553035657354u, 6134575894869364037u, 41251654149u },
+ { 1672033517974833698u, 11524208547121316008u, 5332556025u },
+ { 11673925532927662545u, 2734683241527878366u, 249624728597u },
+ { 3905334232240480709u, 10629223456178675171u, 21148247475u },
+ { 17411087320267472625u, 2788042336985254064u, 179576211358u },
+ { 16573305231063706617u, 17285498758066142502u, 158151140077u },
+ { 15481103236037148354u, 5525538192421886436u, 237937048765u },
+ { 907440704754420880u, 11414325503043801888u, 189299540025u },
+ { 3224970785139077759u, 7246608114685173259u, 57618771825u },
+ { 10560826509734608144u, 1007884269852184608u, 113392839413u },
+ { 4700940027512659968u, 13823717876510029312u, 245054637515u },
+ { 9733694683502084096u, 12487410768239429317u, 203749385247u },
+ { 1995535635724632064u, 3361062421598631942u, 31676943894u },
+ { 10629833226245373952u, 17853337379088328475u, 22182203558u },
+ { 15729384648544878592u, 11551561037491869885u, 166967831358u },
+ { 7205759403792793600u, 11480877996635204802u, 62626211378u },
+ { 0u, 5527488381934471912u, 50622379643u },
+ { 0u, 11143438404407726080u, 123299645745u },
+ { 0u, 6472279730688098304u, 49604087006u },
+ { 0u, 4561816853579563008u, 222350862987u },
+ { 0u, 2888714464062865408u, 139247296587u },
+ { 0u, 16258276129784201216u, 75156597524u },
+ { 0u, 720575940379279360u, 20881362915u },
+ { 0u, 0u, 227039062500u },
+ { 0u, 0u, 228000000000u },
+ { 7535526066623007027u, 164893u, 0u },
+ { 11302146918409311588u, 164893408501686u, 0u },
+ { 2480833299122194801u, 16409970870640346804u, 8938u },
+ { 11513226205589330558u, 7721907286269370594u, 234889586303u },
+ { 4073957068281936105u, 14300743897882155131u, 127418605432u },
+ { 3729887061093812886u, 2068482633821123575u, 120775244880u },
+ { 13616911779739451443u, 4922882895416406094u, 80112132668u },
+ { 13039053282195777666u, 9317632875623428410u, 60266870016u },
+ { 14490756113210417890u, 5693844901999766254u, 505109890u },
+ { 17432486112977557585u, 11569484900262102262u, 130308663950u },
+ { 14308820825344039837u, 3138170119352085637u, 142627183033u },
+ { 4190949538817536349u, 950584692575235243u, 185170120543u },
+ { 13616552502810964397u, 8136430299747162645u, 95051531299u },
+ { 4898145803694965031u, 6698711700804594470u, 35441076770u },
+ { 1399036321001644308u, 17401191571004302008u, 34363137888u },
+ { 17170331128243738540u, 4721732028538188150u, 96943320485u },
+ { 10641321388205367410u, 2984214103553086219u, 165255965606u },
+ { 6648873641312572851u, 13128675202005662068u, 166161774570u },
+ { 5988456964560374823u, 14638512997670672834u, 234711706908u },
+ { 9972593758348346915u, 12942085665769692438u, 28793555379u },
+ { 16709668921872818968u, 14131134357119205086u, 179701591869u },
+ { 6094829131503407767u, 8921946894736102919u, 61766050328u },
+ { 4892016478899926334u, 5601522560505809989u, 24483659710u },
+ { 13150857244079031538u, 8602606493507716808u, 190303659146u },
+ { 12983943395318785894u, 8576789731078566487u, 138466348232u },
+ { 15341644584614757478u, 17881118138842658549u, 200464948702u },
+ { 7507635124856644772u, 11624372674432704923u, 222969337356u },
+ { 11619655367084544354u, 6826284072848095635u, 12630158505u },
+ { 11553116952478783009u, 1646466632033733563u, 169370053601u },
+ { 17392150014233193245u, 17871081657060299180u, 225089255134u },
+ { 8877887560294980515u, 15910893124677544709u, 222968793277u },
+ { 18404180619915609503u, 11031217459450580944u, 189862531244u },
+ { 10079413095288181976u, 13554987390037243094u, 172598003496u },
+ { 14102802966539105550u, 15026714590903687870u, 40734817338u },
+ { 13333966026135891399u, 4406379654994689200u, 58814599830u },
+ { 12344968670173516152u, 13596329092861950242u, 150238870319u },
+ { 10577007819804726752u, 284812388227373260u, 47737058477u },
+ { 15337041354031088010u, 9285079159392309382u, 173015439710u },
+ { 14333607285614673616u, 15046108141952711893u, 94503345149u },
+ { 17171597563219696538u, 13795366909944958311u, 253815651156u },
+ { 2849642930482147564u, 12909920641180059961u, 84747848338u },
+ { 14791248423979435173u, 5333762939889788252u, 146699848200u },
+ { 13882371364576310127u, 6411331390005944495u, 8289143868u },
+ { 11735995808941329540u, 1447104583224217723u, 60347558971u },
+ { 11376996674339273181u, 11940049226167932871u, 59078447696u },
+ { 9849638057168043481u, 9772290783590472385u, 80647271365u },
+ { 18241520229279361964u, 16351989577831528444u, 197529756944u },
+ { 1865852368526961444u, 4376738725895725097u, 16886443131u },
+ { 10601487369276448158u, 13851276297739812763u, 123237263481u },
+ { 15999931310312762170u, 12641996203470333509u, 121750879192u },
+ { 5773775867713013570u, 7707081716407945022u, 216685323987u },
+ { 17726239863982547534u, 417638323657040024u, 211417801737u },
+ { 9711316695888316992u, 16438047707692449100u, 9022640218u },
+ { 17872002620723724288u, 14850108107043306316u, 90891108351u },
+ { 7429694208660733952u, 10423290807904720835u, 255805025973u },
+ { 1782821038871019520u, 16951162310302339314u, 181565047726u },
+ { 3225250234313474048u, 2752437506572397322u, 174918924350u },
+ { 10009250171830927360u, 3925815842962784589u, 62149209936u },
+ { 1152921504606846976u, 5274166674003605291u, 80212818903u },
+ { 0u, 5538963350863452832u, 215285913148u },
+ { 0u, 16900671634439028736u, 60300267804u },
+ { 0u, 2326997710751662080u, 28916187245u },
+ { 0u, 12327726161625874432u, 109126146798u },
+ { 0u, 5756455743825903616u, 238668287374u },
+ { 0u, 3018537650245074944u, 142312058091u },
+ { 0u, 16717361816799281152u, 235163635253u },
+ { 0u, 0u, 53906250000u },
+ { 0u, 0u, 16000000000u },
+ { 2285186318012886800u, 2516073738u, 0u },
+ { 9706420951402272035u, 2516073738123880198u, 0u },
+ { 2369632031840402142u, 11997425759292732054u, 136396630u },
+ { 15599123897979399458u, 11491152661270395161u, 86650381753u },
+ { 17579576584023912658u, 18181063258234881272u, 185622936633u },
+ { 3480927339588501811u, 2466921813123869732u, 57985597414u },
+ { 3547346616671294635u, 8430880678232179465u, 230133732099u },
+ { 7705317123868384954u, 6738034873677997533u, 3457038957u },
+ { 4969425237478353909u, 7678250951042929246u, 109365269602u },
+ { 17043246700132217175u, 1853560606315563193u, 98416238818u },
+ { 17053788362783499470u, 14942676593409905118u, 226100481721u },
+ { 11102988228454224768u, 4909892170837638183u, 185810044121u },
+ { 16944305387801685839u, 16871149368312132405u, 217266165787u },
+ { 11725142977459199276u, 16096130589333770811u, 27914586839u },
+ { 8175984171998533324u, 12512479187631824282u, 215872572987u },
+ { 1372352885142856895u, 16980304980540557310u, 59678302855u },
+ { 17975093466502888164u, 8640919162749295366u, 135920504177u },
+ { 6467823391459085653u, 7862382415464063513u, 113468425166u },
+ { 11319386883146885025u, 14534157903009925344u, 206426220604u },
+ { 9141999262922068637u, 12627464554215107944u, 60787898278u },
+ { 1587330393383478774u, 2456849734836299173u, 166684536225u },
+ { 884187548095712303u, 18428252197697827913u, 161133186090u },
+ { 488841225726377268u, 7244734215936736255u, 42998997553u },
+ { 17462624199405856193u, 14756175050504770087u, 49392737828u },
+ { 13183677579115583554u, 6764116534566945922u, 36799933852u },
+ { 11645015818917277779u, 1588822142405565521u, 156366683492u },
+ { 8760523002035971977u, 17053265624843842052u, 100086130220u },
+ { 10068817678491468042u, 16996891591759999207u, 44924459381u },
+ { 1273658177787418284u, 8565556232370585876u, 117921403339u },
+ { 3100019384328057661u, 14464960359145886620u, 203464339733u },
+ { 10363063568089458738u, 5813189542048784035u, 21784147072u },
+ { 13030756371481403666u, 9739241026882027025u, 128315133636u },
+ { 6538878900684195299u, 18175068535675302910u, 196527965313u },
+ { 8984884716779098868u, 10562697212061761911u, 129985272439u },
+ { 8728727397070363908u, 4264834835660801368u, 119572604963u },
+ { 6398650562917867005u, 13019066443690126316u, 35231197159u },
+ { 1190873176164938879u, 1828040177823321846u, 231705765006u },
+ { 4383628525805121795u, 11240369830376975668u, 142099098256u },
+ { 10189374699734119852u, 8886938465302549874u, 144609341669u },
+ { 5276291920541626391u, 9985240313589688325u, 229481761899u },
+ { 2692252373800386521u, 722909126956573766u, 107541300962u },
+ { 11578684995169173920u, 5493363474638452381u, 226039188982u },
+ { 5799408022254132587u, 12410535279213120491u, 246297795830u },
+ { 15548569837712345290u, 10543108918366869098u, 246672776465u },
+ { 15763030464322902955u, 12953909016524823995u, 17571543079u },
+ { 13257749746581255500u, 16505942145872588169u, 39702232814u },
+ { 16152470009188707678u, 12428594380392015797u, 238894788916u },
+ { 13806790848493904003u, 7528259605829768337u, 52673755451u },
+ { 11981226523265951191u, 18147447600042811311u, 59408107770u },
+ { 5133628726077003713u, 12021069431116183911u, 250983775105u },
+ { 16183955741910833164u, 11819985069665662506u, 129651663479u },
+ { 13640425554331371454u, 10401877114068152814u, 119640762674u },
+ { 18108120906868035862u, 4611631138117837942u, 50563886888u },
+ { 6324011669895037184u, 17200813398607252417u, 40249997024u },
+ { 10444437689515769856u, 14100466137553658767u, 224932457962u },
+ { 12324712543665782784u, 17887776768825509301u, 234764387800u },
+ { 13928941951563857920u, 12632656857970087269u, 216969698321u },
+ { 3975288688270639104u, 8923681664054686256u, 17684817700u },
+ { 11141905478114607104u, 6213926103737837599u, 36483753752u },
+ { 4611686018427387904u, 1233118281776157762u, 24336857609u },
+ { 0u, 30716279628678784u, 9066847476u },
+ { 0u, 15775734650898546688u, 244001665132u },
+ { 0u, 976806005729918976u, 108855204289u },
+ { 0u, 12460098853279891456u, 193052952759u },
+ { 0u, 5635665595421687808u, 183675463312u },
+ { 0u, 1805943450575568896u, 144305510044u },
+ { 0u, 11529215046068469760u, 156097900390u },
+ { 0u, 0u, 102625000000u },
+ { 0u, 0u, 64000000000u },
+ { 4398362855256705725u, 38392u, 0u },
+ { 2812083125569302717u, 38392238435728u, 0u },
+ { 12868509142973100603u, 4564018338575530435u, 2081u },
+ { 8726243776748165726u, 16553437246451512014u, 33247415929u },
+ { 358304413426858117u, 4339777136957372927u, 121897363631u },
+ { 3180720351566429470u, 18439463366554654697u, 175235259789u },
+ { 14053818240400098784u, 1370067356680643003u, 141999605312u },
+ { 7340140541492429288u, 4210124040914115013u, 64074271500u },
+ { 1323571167904965058u, 10692225626142609720u, 12228231281u },
+ { 14463851737583396026u, 11592856673895384344u, 113579626712u },
+ { 15122784818916048486u, 10284479231227406269u, 216628450019u },
+ { 13557974621377508955u, 4961071383534266431u, 227557522736u },
+ { 17525172074563876264u, 10960611551445686988u, 48268940218u },
+ { 15148880683074215967u, 14616396723115619209u, 186594175942u },
+ { 6744828147558597936u, 1025604265437492803u, 198792356454u },
+ { 9799290779647971692u, 11711588454892179178u, 102055598118u },
+ { 11170890203898678105u, 5580373263251565705u, 38634886482u },
+ { 7068779781287527905u, 14109334653033148931u, 82302512640u },
+ { 14474741922505540911u, 2899414033769399895u, 764868564u },
+ { 17107062680405191514u, 13233457234892808147u, 212157177549u },
+ { 2712598571300237005u, 3287946691509034862u, 205717387154u },
+ { 3767556054903418641u, 5488480288717445911u, 146178239947u },
+ { 18158239681706277628u, 11687233053874362630u, 203297531112u },
+ { 10531652712128330681u, 6783772100089274577u, 232633566173u },
+ { 9548395326934120567u, 7898291058728402485u, 221367749022u },
+ { 15875647850297719390u, 4423684977486598491u, 158428167216u },
+ { 8215825295203192574u, 2750833684599526706u, 48239808443u },
+ { 12747310908260543144u, 15669689830489025709u, 187149122992u },
+ { 77706528053613642u, 15117307274214954517u, 176849455587u },
+ { 6024737704056756146u, 8148639818575698175u, 227819510869u },
+ { 6819452388570089667u, 13006484426078994901u, 85441738649u },
+ { 13695926775373186254u, 10287496057845513526u, 153705082933u },
+ { 3746531715392682132u, 14159876032966532430u, 53557686278u },
+ { 4717376233154528116u, 15742212196465548019u, 6767608417u },
+ { 385190957950313369u, 2892220461917134150u, 97853387033u },
+ { 12388374310648616082u, 7487151560715393883u, 25156787585u },
+ { 1078067332084407770u, 7245756744165177933u, 129405879299u },
+ { 3257295319358714850u, 3067122860671533987u, 3392793260u },
+ { 1545453099660723457u, 8135043905834122525u, 172166269063u },
+ { 7495477664653506341u, 14730019368921022572u, 135441001613u },
+ { 7225503732673614354u, 495969939682055458u, 141798515950u },
+ { 3935478326103643956u, 5617761407265775598u, 238026886584u },
+ { 10082240682742686210u, 2087044847072781811u, 184304539456u },
+ { 10838712705567897138u, 15929674232061203330u, 64113138927u },
+ { 2142546572501643680u, 8658086469608285873u, 239863549370u },
+ { 7893042119150331392u, 18369871790780313570u, 186469355807u },
+ { 12084811642251302615u, 3545648451947416750u, 31995832745u },
+ { 15317234482572954775u, 13347376792767929959u, 169192209987u },
+ { 2283226355108359361u, 14482164459838203025u, 67723562745u },
+ { 13359725152575722127u, 8899577765623565820u, 249785079708u },
+ { 13126551011491594557u, 7095320096604405719u, 156482447077u },
+ { 3598021288691861269u, 2968593824439315788u, 229384638073u },
+ { 16462621795896662961u, 12621408323612585636u, 121160927793u },
+ { 14682112756964627332u, 3954422936414648259u, 49684207916u },
+ { 7174112100896070218u, 17143730087577690191u, 44214369696u },
+ { 5023109019590616064u, 5033045529399041876u, 160929363470u },
+ { 10765223023086141440u, 15857648521994521781u, 14272841944u },
+ { 8228137177297453056u, 16655573486499109541u, 216859644848u },
+ { 2891199497780592640u, 16652154439190075858u, 176902900447u },
+ { 15294857653247803392u, 18016950600164130638u, 223902715100u },
+ { 14303432416528695296u, 2086292996072613910u, 220976700849u },
+ { 0u, 17324462585194799521u, 177113098169u },
+ { 0u, 11079151463184927232u, 185939160998u },
+ { 0u, 5239846817488961536u, 166600602004u },
+ { 0u, 2778806963520143360u, 148284052665u },
+ { 0u, 6240890740138835968u, 185150639427u },
+ { 0u, 17250651344549707776u, 67338319364u },
+ { 0u, 4197354852709302272u, 4935159683u },
+ { 0u, 9223372036854775808u, 131227539062u },
+ { 0u, 0u, 118500000000u },
+ { 17118225092618494573u, 585819067u, 0u },
+ { 13385738875341807559u, 585819067927980841u, 0u },
+ { 8272682717439277193u, 5654803392547571318u, 31757315u },
+ { 13402436483369350083u, 2931628102185393332u, 3306547506u },
+ { 10946328903241612536u, 15964697617980212305u, 50158923877u },
+ { 16265808923426731252u, 450380868305846606u, 101865447992u },
+ { 11080374459871185177u, 14631133530814566148u, 56024415195u },
+ { 1240761893433831916u, 31969822783742095u, 219793155338u },
+ { 367264070493390483u, 10437269029385743245u, 10001733087u },
+ { 2863675693461092905u, 15196146496377392433u, 223565805487u },
+ { 7511929581752138999u, 4409099735137480938u, 175823784752u },
+ { 11154557789993845753u, 10644987914903248118u, 48239017775u },
+ { 8325416539745948522u, 3154431617534062973u, 47577065951u },
+ { 17745129874679852617u, 11702056331247960454u, 223171002080u },
+ { 1074820986392253357u, 15575315065965259114u, 224634369744u },
+ { 7820952682162838597u, 10759747609480050226u, 208844339521u },
+ { 8215518006273528603u, 12538236653960743718u, 65583287086u },
+ { 9680426791089900133u, 17857942663978005403u, 46679699170u },
+ { 16128495723604797412u, 11443004154750813211u, 226968081011u },
+ { 2264789053583348885u, 4004313188770806737u, 115620326498u },
+ { 11175458488686298083u, 17134872954824183228u, 98217074252u },
+ { 11026777810412287617u, 2659553912986171234u, 76928883324u },
+ { 16199890034895598640u, 9501854300969137926u, 124144174706u },
+ { 9094320719494763752u, 14528169966301018150u, 114515096553u },
+ { 1250835564687222832u, 18172091996515901778u, 233787573671u },
+ { 15362466642459337025u, 1133541705604751035u, 167985111081u },
+ { 7831109835595423828u, 18280349987988641497u, 41061449418u },
+ { 15426237284335022429u, 9936015874712336386u, 202990979758u },
+ { 15636308361455434548u, 15876720399740689614u, 174538632499u },
+ { 13967173875944980328u, 8618117825152456982u, 51860678737u },
+ { 18245979923595824097u, 8085525680745921564u, 81467189103u },
+ { 11335054479675278263u, 8072355444669730953u, 111438317225u },
+ { 11165339882630461707u, 9395030504766848294u, 169437603265u },
+ { 15944437408299395922u, 3537903114058185903u, 193509305624u },
+ { 15806416348777321161u, 2126094743961928691u, 24191790112u },
+ { 4201030477408556248u, 289185362555601115u, 32115255827u },
+ { 9485474942554588907u, 16909937501450129614u, 19015676769u },
+ { 18238757647663230541u, 14449642060360499058u, 97916689548u },
+ { 4642199687824746379u, 12433818908498244393u, 140783316665u },
+ { 6134575894869364037u, 11884444034578008581u, 185674038673u },
+ { 11524208547121316008u, 988625838444140793u, 145644257002u },
+ { 2734683241527878366u, 1675370907158909973u, 234053593514u },
+ { 10629223456178675171u, 15920186275316934067u, 170090822038u },
+ { 2788042336985254064u, 5600921198503757726u, 150863035027u },
+ { 17285498758066142502u, 10457357161776341741u, 147303626546u },
+ { 5525538192421886436u, 12225356765775740093u, 50566894467u },
+ { 11414325503043801888u, 4486633318598164537u, 131662737918u },
+ { 7246608114685173259u, 10302486602879381361u, 254243220879u },
+ { 1007884269852184608u, 15536428611301239541u, 143558498917u },
+ { 13823717876510029312u, 12026126645955462603u, 101842231482u },
+ { 12487410768239429317u, 14877968141142123551u, 186651937631u },
+ { 3361062421598631942u, 734560801645383190u, 95806536269u },
+ { 17853337379088328475u, 15648943144911081638u, 77039820620u },
+ { 11551561037491869885u, 13664182862003235646u, 76848330907u },
+ { 11480877996635204802u, 3895127525902132786u, 155740736837u },
+ { 5527488381934471912u, 5249187334214137467u, 69211155286u },
+ { 11143438404407726080u, 10642260063359027505u, 86284559015u },
+ { 6472279730688098304u, 783598951897779422u, 167576918074u },
+ { 4561816853579563008u, 5538576558607624843u, 58042478984u },
+ { 2888714464062865408u, 15974581187564609611u, 136300246836u },
+ { 16258276129784201216u, 7474269406918257428u, 52865983781u },
+ { 720575940379279360u, 8045286838779138019u, 37405180956u },
+ { 0u, 8184246376556341732u, 28436135873u },
+ { 0u, 1493267152679331840u, 193443668885u },
+ { 0u, 10179074811222818816u, 149080950174u },
+ { 0u, 3892499202005008384u, 158551808751u },
+ { 0u, 10341173215925108736u, 239211012804u },
+ { 0u, 6230307872002015232u, 196560596123u },
+ { 0u, 9295429630892703744u, 155337745666u },
+ { 0u, 0u, 2503906250u },
+ { 0u, 0u, 202000000000u },
+ { 16409970870640346804u, 8938u, 0u },
+ { 7721907286269370594u, 8938889586303u, 0u },
+ { 14300743897882155131u, 10665454627995623288u, 484u },
+ { 2068482633821123575u, 16803537892767562832u, 228578175453u },
+ { 4922882895416406094u, 8099123106849104444u, 221910921614u },
+ { 9317632875623428410u, 7077413686679401728u, 142439054343u },
+ { 5693844901999766254u, 13536636358372449666u, 7383667364u },
+ { 11569484900262102262u, 7280632235418610318u, 164733822527u },
+ { 3138170119352085637u, 6187823673116858809u, 63394683864u },
+ { 950584692575235243u, 8624343686231740255u, 216335442593u },
+ { 8136430299747162645u, 806211610822132771u, 161467526608u },
+ { 6698711700804594470u, 18388078233202190882u, 208043704818u },
+ { 17401191571004302008u, 7628864426595573600u, 242996819718u },
+ { 4721732028538188150u, 4530799784343874981u, 6413561569u },
+ { 2984214103553086219u, 8561580552078486438u, 225245615148u },
+ { 13128675202005662068u, 13349114951221999594u, 44464124211u },
+ { 14638512997670672834u, 10029144738508991772u, 51723656971u },
+ { 12942085665769692438u, 12601907197916268979u, 11543681025u },
+ { 14131134357119205086u, 1329580921391066941u, 1683150758u },
+ { 8921946894736102919u, 3198179786356761112u, 166072076726u },
+ { 5601522560505809989u, 11406753413634654142u, 182173373673u },
+ { 8602606493507716808u, 11131812960525182090u, 233618361341u },
+ { 8576789731078566487u, 14299636753645227208u, 253603456789u },
+ { 17881118138842658549u, 12964114684643663326u, 21775184861u },
+ { 11624372674432704923u, 5019257593846306316u, 221702786065u },
+ { 6826284072848095635u, 6929086798159998121u, 17272094499u },
+ { 1646466632033733563u, 18359765766933703649u, 35375626547u },
+ { 17871081657060299180u, 9993076234752063198u, 51995284896u },
+ { 15910893124677544709u, 3257189215046584509u, 160541725748u },
+ { 11031217459450580944u, 2905234736672690348u, 52176572581u },
+ { 13554987390037243094u, 12064985302079670056u, 165157493090u },
+ { 15026714590903687870u, 14315096064942799930u, 98654044163u },
+ { 4406379654994689200u, 11943971043551974038u, 3776022912u },
+ { 13596329092861950242u, 12472773152119929647u, 128647483967u },
+ { 284812388227373260u, 7791259796982183085u, 63676150387u },
+ { 9285079159392309382u, 16866829442051086686u, 115422365039u },
+ { 15046108141952711893u, 3702498393844653053u, 111914352656u },
+ { 13795366909944958311u, 2057239613841701716u, 16200712840u },
+ { 12909920641180059961u, 17201969976738286226u, 136111523182u },
+ { 5333762939889788252u, 18271566505443461640u, 110932520660u },
+ { 6411331390005944495u, 18368509115417119804u, 212990503604u },
+ { 1447104583224217723u, 7613923684154518587u, 180995758874u },
+ { 11940049226167932871u, 17984805084714865232u, 26412751629u },
+ { 9772290783590472385u, 4220802739051410373u, 13974958237u },
+ { 16351989577831528444u, 17812459042810815760u, 157228810174u },
+ { 4376738725895725097u, 10629526089664605307u, 190965615339u },
+ { 13851276297739812763u, 17437443267816548473u, 235576227763u },
+ { 12641996203470333509u, 12506371893701049304u, 179945285693u },
+ { 7707081716407945022u, 15737221540003030739u, 61677971778u },
+ { 417638323657040024u, 2358380859011605513u, 66853116489u },
+ { 16438047707692449100u, 10042972713837039706u, 73127848082u },
+ { 14850108107043306316u, 13424397272769642495u, 146544430641u },
+ { 10423290807904720835u, 6867102315755663029u, 49727738034u },
+ { 16951162310302339314u, 8690748404825506734u, 178372266362u },
+ { 2752437506572397322u, 956229930815387710u, 122471126415u },
+ { 3925815842962784589u, 7734449506297687888u, 143051837328u },
+ { 5274166674003605291u, 16332184961683848151u, 144419285347u },
+ { 5538963350863452832u, 15580777817612768828u, 99885369520u },
+ { 16900671634439028736u, 17404245271944696092u, 176844635657u },
+ { 2326997710751662080u, 13201420160494469229u, 9943486026u },
+ { 12327726161625874432u, 16511717657124068078u, 74715650420u },
+ { 5756455743825903616u, 14131292492116594062u, 116895102007u },
+ { 3018537650245074944u, 18429136031865875691u, 55766058900u },
+ { 16717361816799281152u, 2563978348305862197u, 148999045466u },
+ { 0u, 14239974392147482896u, 90138993544u },
+ { 0u, 11164201396098998272u, 136771950558u },
+ { 0u, 7116971104932986880u, 222605212570u },
+ { 0u, 12437629862867369984u, 154385811776u },
+ { 0u, 16501893821638901760u, 64674245265u },
+ { 0u, 10649324268870959104u, 145894569456u },
+ { 0u, 7205759403792793600u, 240577301025u },
+ { 0u, 0u, 33390625000u },
+ { 0u, 0u, 232000000000u },
+ { 11997425759292732054u, 136396630u, 0u },
+ { 11491152661270395161u, 136396630650381753u, 0u },
+ { 18181063258234881272u, 3016823727048309817u, 7394076u },
+ { 2466921813123869732u, 17405973192644624358u, 28163542341u },
+ { 8430880678232179465u, 8937219978302591747u, 69943579697u },
+ { 6738034873677997533u, 15178463196824222317u, 49484487665u },
+ { 7678250951042929246u, 11979404627460330594u, 241822826138u },
+ { 1853560606315563193u, 2006448052689740002u, 154649404826u },
+ { 14942676593409905118u, 16330465320863239865u, 154108769766u },
+ { 4909892170837638183u, 17136208883957646553u, 230885276298u },
+ { 16871149368312132405u, 140455118208931867u, 138928955745u },
+ { 16096130589333770811u, 3964972929179372247u, 97007614087u },
+ { 12512479187631824282u, 3378050330022776379u, 135214941613u },
+ { 16980304980540557310u, 6065353437512901255u, 173183124475u },
+ { 8640919162749295366u, 12768753059854699889u, 251328803468u },
+ { 7862382415464063513u, 6848720690951013326u, 140692195490u },
+ { 14534157903009925344u, 10953228058585475132u, 162371269892u },
+ { 12627464554215107944u, 15539127852083296166u, 4593775682u },
+ { 2456849734836299173u, 14534853647735598497u, 66842377808u },
+ { 18428252197697827913u, 1506909603576368170u, 80787935995u },
+ { 7244734215936736255u, 5475702579938239025u, 251081689733u },
+ { 14756175050504770087u, 12039747373985783332u, 133296838431u },
+ { 6764116534566945922u, 17572399137760898460u, 31652676012u },
+ { 1588822142405565521u, 869552790852091236u, 172952601666u },
+ { 17053265624843842052u, 4549585778048181804u, 66047138551u },
+ { 16996891591759999207u, 4121918231767210357u, 247246633539u },
+ { 8565556232370585876u, 1558397953312543179u, 67223449635u },
+ { 14464960359145886620u, 6067524298738069781u, 35084480922u },
+ { 5813189542048784035u, 5811095224555517056u, 154328921151u },
+ { 9739241026882027025u, 6440894514158997188u, 63315020103u },
+ { 18175068535675302910u, 4612748874388784257u, 71349161591u },
+ { 10562697212061761911u, 9908101430749813367u, 119250057617u },
+ { 4264834835660801368u, 15150017990912190499u, 145537119254u },
+ { 13019066443690126316u, 17470426264690059239u, 22821284120u },
+ { 1828040177823321846u, 9615161096851907726u, 24947073705u },
+ { 11240369830376975668u, 9227932132124142224u, 169521238927u },
+ { 8886938465302549874u, 4794113194321211621u, 143500247203u },
+ { 9985240313589688325u, 391512698859146347u, 163259889397u },
+ { 722909126956573766u, 17209658878068655842u, 245021223945u },
+ { 5493363474638452381u, 3077364726606876150u, 9932937477u },
+ { 12410535279213120491u, 1952989567673965814u, 5166824276u },
+ { 10543108918366869098u, 11172860676923186449u, 84105871776u },
+ { 12953909016524823995u, 17338078544784947239u, 160605681990u },
+ { 16505942145872588169u, 4593380466519703278u, 70939899121u },
+ { 12428594380392015797u, 786884753602720052u, 241249007654u },
+ { 7528259605829768337u, 17848875822468020539u, 38042657107u },
+ { 18147447600042811311u, 2899664567187130618u, 83967589497u },
+ { 12021069431116183911u, 2973178834961857409u, 121157191131u },
+ { 11819985069665662506u, 11117453141176836727u, 219161176347u },
+ { 10401877114068152814u, 7535238370146462002u, 27602678342u },
+ { 4611631138117837942u, 10246175467290865448u, 70408486090u },
+ { 17200813398607252417u, 1203128834127050464u, 202555446285u },
+ { 14100466137553658767u, 14518048959078919658u, 13065221744u },
+ { 17887776768825509301u, 1553474987376920024u, 112787025011u },
+ { 12632656857970087269u, 14956572380830948369u, 115084214047u },
+ { 8923681664054686256u, 7594162606042048292u, 31810797413u },
+ { 6213926103737837599u, 14461296147288811288u, 101411680379u },
+ { 1233118281776157762u, 18305427728131488265u, 123783948434u },
+ { 30716279628678784u, 10253208939347909876u, 146992339225u },
+ { 15775734650898546688u, 6446028915490812012u, 25555827570u },
+ { 976806005729918976u, 12986063676957432257u, 114349439927u },
+ { 12460098853279891456u, 9769714697972762807u, 183703975922u },
+ { 5635665595421687808u, 97429465146664592u, 242529617295u },
+ { 1805943450575568896u, 16395571728207795868u, 143005281661u },
+ { 11529215046068469760u, 6331668478323650406u, 125888805724u },
+ { 0u, 18129911846294207040u, 92343240435u },
+ { 0u, 9890094564876124160u, 243982824490u },
+ { 0u, 12290856656987750400u, 42536143100u },
+ { 0u, 8498454992640802816u, 252666288674u },
+ { 0u, 5341660584200896512u, 34460702168u },
+ { 0u, 9288674231451648000u, 216289572000u },
+ { 0u, 1152921504606846976u, 160503540039u },
+ { 0u, 0u, 71062500000u },
+ { 0u, 0u, 160000000000u },
+ { 4564018338575530435u, 2081u, 0u },
+ { 16553437246451512014u, 2081247415929u, 0u },
+ { 4339777136957372927u, 15212079674427582639u, 112u },
+ { 18439463366554654697u, 10179808126814248333u, 112824648491u },
+ { 1370067356680643003u, 6066766544199222848u, 43551848504u },
+ { 4210124040914115013u, 6625308131806923532u, 56328880073u },
+ { 10692225626142609720u, 9122786786400665713u, 201359158673u },
+ { 11592856673895384344u, 11932880778639151320u, 145494547262u },
+ { 10284479231227406269u, 3884040911779255011u, 62646882763u },
+ { 4961071383534266431u, 13441817515637357872u, 203210554279u },
+ { 10960611551445686988u, 11628577856022352826u, 167728682387u },
+ { 14616396723115619209u, 13296656925520243654u, 147630386468u },
+ { 1025604265437492803u, 5020720704545399398u, 36720813216u },
+ { 11711588454892179178u, 14121973606499014694u, 160272173814u },
+ { 5580373263251565705u, 3642481034345420114u, 246765553723u },
+ { 14109334653033148931u, 9845536238569696768u, 59197459292u },
+ { 2899414033769399895u, 17655403572195686356u, 92533727588u },
+ { 13233457234892808147u, 8377495365136654029u, 100957101345u },
+ { 3287946691509034862u, 13713682649609025426u, 33454144933u },
+ { 5488480288717445911u, 1367709905452854731u, 165743420226u },
+ { 11687233053874362630u, 9981467701727208680u, 66074143702u },
+ { 6783772100089274577u, 6277920117543306205u, 214541096448u },
+ { 7898291058728402485u, 9344111460418701726u, 340326731u },
+ { 4423684977486598491u, 4918507011364617264u, 75506545297u },
+ { 2750833684599526706u, 6554777203830755259u, 145266632799u },
+ { 15669689830489025709u, 4198262173120265648u, 95355335184u },
+ { 15117307274214954517u, 8080325935698446819u, 16227588248u },
+ { 8148639818575698175u, 12797633874200091733u, 152438035346u },
+ { 13006484426078994901u, 8376502502208665497u, 146693761122u },
+ { 10287496057845513526u, 9891973386793349173u, 98454091110u },
+ { 14159876032966532430u, 14877430279003795462u, 102536244951u },
+ { 15742212196465548019u, 8759933935842067041u, 215806507111u },
+ { 2892220461917134150u, 3753418510388703513u, 103474876970u },
+ { 7487151560715393883u, 2961383332545305985u, 42203473225u },
+ { 7245756744165177933u, 2497674184068629507u, 73160536912u },
+ { 3067122860671533987u, 15244544070742305452u, 80135399188u },
+ { 8135043905834122525u, 45953573565810823u, 20826408390u },
+ { 14730019368921022572u, 3960077421351906445u, 198002491148u },
+ { 495969939682055458u, 3173330011013883118u, 12214676227u },
+ { 5617761407265775598u, 11026266219545759160u, 3172026564u },
+ { 2087044847072781811u, 8886757764964685632u, 196597735089u },
+ { 15929674232061203330u, 13952322129918090479u, 177481752103u },
+ { 8658086469608285873u, 4127250666614902202u, 39756356898u },
+ { 18369871790780313570u, 17649958504065306911u, 34223738706u },
+ { 3545648451947416750u, 13269305359002216873u, 82956806167u },
+ { 13347376792767929959u, 16236593433831947843u, 23719330484u },
+ { 14482164459838203025u, 13580930396682424057u, 180880187493u },
+ { 8899577765623565820u, 421976357197961116u, 101736223712u },
+ { 7095320096604405719u, 2962130818798626533u, 224022875384u },
+ { 2968593824439315788u, 8234383947306356345u, 248160577433u },
+ { 12621408323612585636u, 4380469931801381425u, 153446386848u },
+ { 3954422936414648259u, 15279887469027055916u, 160237465750u },
+ { 17143730087577690191u, 8534542821713755552u, 150828324359u },
+ { 5033045529399041876u, 7814613482565088782u, 7462658493u },
+ { 15857648521994521781u, 13771954404705323224u, 189423631045u },
+ { 16655573486499109541u, 4568173274762548144u, 197746579144u },
+ { 16652154439190075858u, 8105292616250821343u, 200247641169u },
+ { 18016950600164130638u, 2923678426777275612u, 81439388793u },
+ { 2086292996072613910u, 1808633176918384049u, 121158492925u },
+ { 17324462585194799521u, 18118642609460438969u, 253098046200u },
+ { 11079151463184927232u, 18138164175864360870u, 248982213583u },
+ { 5239846817488961536u, 4031433690465792404u, 207983271850u },
+ { 2778806963520143360u, 5012226396942308537u, 170218544458u },
+ { 6240890740138835968u, 7889712298793536835u, 74271713337u },
+ { 17250651344549707776u, 13500762396543628804u, 57427702160u },
+ { 4197354852709302272u, 501020624068841347u, 144731877796u },
+ { 9223372036854775808u, 8370653768288261750u, 164027160382u },
+ { 0u, 647579990023635200u, 62453774050u },
+ { 0u, 11106569307181154304u, 226035105381u },
+ { 0u, 10797461613892861952u, 101602088328u },
+ { 0u, 17627230675448889344u, 136585331566u },
+ { 0u, 12197735707942322176u, 110955574089u },
+ { 0u, 12871287735024877568u, 73661240577u },
+ { 0u, 4611686018427387904u, 1697753906u },
+ { 0u, 0u, 50250000000u },
+ { 0u, 0u, 128000000000u },
+ { 5654803392547571318u, 31757315u, 0u },
+ { 2931628102185393332u, 31757315306547506u, 0u },
+ { 15964697617980212305u, 9451803574512021605u, 1721567u },
+ { 450380868305846606u, 8662766454758138424u, 223512383298u },
+ { 14631133530814566148u, 9207992007314947035u, 66469609510u },
+ { 31969822783742095u, 17118602861291201802u, 38499166246u },
+ { 10437269029385743245u, 11186560605745599967u, 38928001320u },
+ { 15196146496377392433u, 10505549821532796847u, 40606424665u },
+ { 4409099735137480938u, 18133667530488679216u, 89569506996u },
+ { 10644987914903248118u, 10778135771244330799u, 180983028086u },
+ { 3154431617534062973u, 17087985777033767391u, 118584283910u },
+ { 11702056331247960454u, 2639185991757283040u, 6926341565u },
+ { 15575315065965259114u, 5401720287293896400u, 189143070559u },
+ { 10759747609480050226u, 9816495392633895233u, 95292827843u },
+ { 12538236653960743718u, 10042051500090034990u, 195532153281u },
+ { 17857942663978005403u, 11629689537856384738u, 193544380702u },
+ { 11443004154750813211u, 2099086731766010483u, 30630446733u },
+ { 4004313188770806737u, 13665537898516458594u, 141113791719u },
+ { 17134872954824183228u, 16375672064669490764u, 231740810293u },
+ { 2659553912986171234u, 7770550512184564348u, 53887726961u },
+ { 9501854300969137926u, 6197048880720627314u, 113421242387u },
+ { 14528169966301018150u, 17963594118523106281u, 19335942692u },
+ { 18172091996515901778u, 8255454642407818663u, 36973808388u },
+ { 1133541705604751035u, 16744201957549498409u, 4447529092u },
+ { 18280349987988641497u, 17442505417202859722u, 132907705006u },
+ { 9936015874712336386u, 6383975767786687150u, 174945560113u },
+ { 15876720399740689614u, 15245442964998335795u, 49346076019u },
+ { 8618117825152456982u, 2910016124519524433u, 115826457119u },
+ { 8085525680745921564u, 3847913871169988463u, 31157752290u },
+ { 8072355444669730953u, 17210451512590059177u, 226208595828u },
+ { 9395030504766848294u, 17899408909991454145u, 116932980445u },
+ { 3537903114058185903u, 5920601932753251608u, 221970328901u },
+ { 2126094743961928691u, 16521781895108979744u, 69320956473u },
+ { 289185362555601115u, 3697493405554698771u, 57895647591u },
+ { 16909937501450129614u, 2816108280295732065u, 103200441519u },
+ { 14449642060360499058u, 14251078772056398988u, 175152661535u },
+ { 12433818908498244393u, 4543066550096031417u, 31772552528u },
+ { 11884444034578008581u, 3099369389734296977u, 80246280131u },
+ { 988625838444140793u, 5243484113636490986u, 195168017151u },
+ { 1675370907158909973u, 6823370511605197226u, 255284249843u },
+ { 15920186275316934067u, 11396290277624641942u, 243369895656u },
+ { 5600921198503757726u, 15934361408437566099u, 232617794133u },
+ { 10457357161776341741u, 14939272230935131954u, 85863803462u },
+ { 12225356765775740093u, 7500666177940329347u, 70809859570u },
+ { 4486633318598164537u, 4806714453065462270u, 242406611928u },
+ { 10302486602879381361u, 11557851247268441487u, 216260572512u },
+ { 15536428611301239541u, 10655523157206817381u, 96626552371u },
+ { 12026126645955462603u, 14769600176490881210u, 51577637067u },
+ { 14877968141142123551u, 16688495540925795167u, 203800661629u },
+ { 734560801645383190u, 909793965395524173u, 125904685156u },
+ { 15648943144911081638u, 12724590949761703756u, 100049320029u },
+ { 13664182862003235646u, 10810739657314826395u, 93689801457u },
+ { 3895127525902132786u, 2431218615388671301u, 241586051371u },
+ { 5249187334214137467u, 4235001167959059286u, 43131796625u },
+ { 10642260063359027505u, 6253317787396334247u, 145229579873u },
+ { 783598951897779422u, 9534525563070371898u, 97338993036u },
+ { 5538576558607624843u, 8392783992374030728u, 140516867666u },
+ { 15974581187564609611u, 16356257019231647540u, 82454973731u },
+ { 7474269406918257428u, 12896334001521091877u, 35886674469u },
+ { 8045286838779138019u, 1427636373320877084u, 37699111667u },
+ { 8184246376556341732u, 16116755731295043521u, 243077392322u },
+ { 1493267152679331840u, 15945633911163986837u, 194873691078u },
+ { 10179074811222818816u, 7510154241072743838u, 198864414546u },
+ { 3892499202005008384u, 3571560509790395119u, 82407126277u },
+ { 10341173215925108736u, 3576991649007035076u, 5193614683u },
+ { 6230307872002015232u, 15509961892750732443u, 91193909105u },
+ { 9295429630892703744u, 17789791359353349378u, 113840796718u },
+ { 0u, 18331227331079738314u, 46964386521u },
+ { 0u, 15386712883100476416u, 217993737824u },
+ { 0u, 14082462055028752384u, 96834115376u },
+ { 0u, 12919043128765186048u, 48763411797u },
+ { 0u, 6125373368465096704u, 85700342731u },
+ { 0u, 12335992698065387520u, 203332057155u },
+ { 0u, 2774217370460225536u, 67668735504u },
+ { 0u, 0u, 16150390625u },
+ { 0u, 0u, 97000000000u },
+ { 10665454627995623288u, 484u, 0u },
+ { 16803537892767562832u, 484578175453u, 0u },
+ { 8099123106849104444u, 4962829537462579598u, 26u },
+ { 7077413686679401728u, 5711259460785241095u, 26269035528u },
+ { 13536636358372449666u, 13845894607204897444u, 8309607995u },
+ { 7280632235418610318u, 12116633056637003327u, 59750587450u },
+ { 6187823673116858809u, 2965791047992089560u, 58656843994u },
+ { 8624343686231740255u, 16021997451315962529u, 218160775854u },
+ { 806211610822132771u, 3942052271663803856u, 174868554222u },
+ { 18388078233202190882u, 15669876414782439922u, 238213699081u },
+ { 7628864426595573600u, 10594415915406145286u, 9849465702u },
+ { 4530799784343874981u, 10789820553031921377u, 102574324437u },
+ { 8561580552078486438u, 3989990218583987244u, 213584917344u },
+ { 13349114951221999594u, 2937341169808224563u, 96216297803u },
+ { 10029144738508991772u, 16267436558584536843u, 75159233583u },
+ { 12601907197916268979u, 16221580362814625793u, 47881859502u },
+ { 1329580921391066941u, 9695437602320209830u, 174879373633u },
+ { 3198179786356761112u, 10729753156793715126u, 65525590725u },
+ { 11406753413634654142u, 2609241432056861929u, 197581661084u },
+ { 11131812960525182090u, 8462663743997037565u, 156141447261u },
+ { 14299636753645227208u, 14993422143908194069u, 93458761920u },
+ { 12964114684643663326u, 1307443894537745373u, 192812795043u },
+ { 5019257593846306316u, 10017257439419829265u, 163070876675u },
+ { 6929086798159998121u, 16754772009970777891u, 3543036613u },
+ { 18359765766933703649u, 11722573031602862387u, 197908278010u },
+ { 9993076234752063198u, 7363764277467092384u, 250635481957u },
+ { 3257189215046584509u, 6733958494847390772u, 101399190461u },
+ { 2905234736672690348u, 8799796600227451045u, 189365048621u },
+ { 12064985302079670056u, 10512023194742249826u, 45477037929u },
+ { 14315096064942799930u, 4572542132337197059u, 105569857919u },
+ { 11943971043551974038u, 12600500455757416832u, 127247878005u },
+ { 12472773152119929647u, 7873789864743195199u, 117683074498u },
+ { 7791259796982183085u, 15724851676325671539u, 194426839003u },
+ { 16866829442051086686u, 8748017220462413167u, 219852445917u },
+ { 3702498393844653053u, 14172589522760466448u, 221474230963u },
+ { 2057239613841701716u, 9520545591489413768u, 179768297617u },
+ { 17201969976738286226u, 12488551088392570222u, 145516109810u },
+ { 18271566505443461640u, 1135798823651241684u, 242677005711u },
+ { 18368509115417119804u, 11168725610120161972u, 143061571777u },
+ { 7613923684154518587u, 9580104948718508826u, 193605457828u },
+ { 17984805084714865232u, 16638722716909738765u, 164519338529u },
+ { 4220802739051410373u, 15732724012348272797u, 33901986965u },
+ { 17812459042810815760u, 12269722190021214142u, 149852872677u },
+ { 10629526089664605307u, 13110655916311972587u, 229665142972u },
+ { 17437443267816548473u, 6618112997062866867u, 188710730081u },
+ { 12506371893701049304u, 8457936459015989309u, 97358768624u },
+ { 15737221540003030739u, 3329167139937134914u, 240458505654u },
+ { 2358380859011605513u, 5245511557216705097u, 182180474512u },
+ { 10042972713837039706u, 5655931353280440466u, 144284359751u },
+ { 13424397272769642495u, 604622132328697393u, 71306608653u },
+ { 6867102315755663029u, 8673282619234652338u, 13032776631u },
+ { 8690748404825506734u, 16929477433058445690u, 183470179592u },
+ { 956229930815387710u, 11036952409253549455u, 8917748810u },
+ { 7734449506297687888u, 18199392190170386320u, 74598314388u },
+ { 16332184961683848151u, 9683116091880335715u, 148986591027u },
+ { 15580777817612768828u, 2993913337608915120u, 51524922775u },
+ { 17404245271944696092u, 4490779842162392585u, 151162300367u },
+ { 13201420160494469229u, 946849923353644618u, 207243445663u },
+ { 16511717657124068078u, 3613491058474899828u, 159051328837u },
+ { 14131292492116594062u, 14624054199004410935u, 69195887742u },
+ { 18429136031865875691u, 12088470271991908244u, 126792771566u },
+ { 2563978348305862197u, 10071980927725011290u, 238655317286u },
+ { 14239974392147482896u, 2833441711428854664u, 38546003180u },
+ { 11164201396098998272u, 17655572411864340446u, 236153601182u },
+ { 7116971104932986880u, 4997642792058747802u, 158957110498u },
+ { 12437629862867369984u, 11489200787635734848u, 226270922758u },
+ { 16501893821638901760u, 12983586226429536913u, 6622830822u },
+ { 10649324268870959104u, 12311150768725063152u, 230703841619u },
+ { 7205759403792793600u, 8530052476845967905u, 83667388820u },
+ { 0u, 6282736361499820264u, 148462415071u },
+ { 0u, 11337164765929082880u, 223340587820u },
+ { 0u, 8343856200414134272u, 44614588933u },
+ { 0u, 17889330377156198400u, 5452321350u },
+ { 0u, 17730714064155312128u, 70969782542u },
+ { 0u, 7449235258647511040u, 14961183935u },
+ { 0u, 9943947977234055168u, 191403823852u },
+ { 0u, 0u, 236539062500u },
+ { 0u, 0u, 228000000000u },
+ { 3016823727048309817u, 7394076u, 0u },
+ { 17405973192644624358u, 7394076163542341u, 0u },
+ { 8937219978302591747u, 12396245121240683569u, 400833u },
+ { 15178463196824222317u, 10248996648596888561u, 193672001794u },
+ { 11979404627460330594u, 11257495103713935002u, 2555599221u },
+ { 2006448052689740002u, 7555396579247433114u, 117610270032u },
+ { 16330465320863239865u, 4805022328730367462u, 80409578869u },
+ { 17136208883957646553u, 7056637817080232586u, 117260480782u },
+ { 140455118208931867u, 10811411483818434913u, 14382541102u },
+ { 3964972929179372247u, 16962406704495245447u, 46586087790u },
+ { 3378050330022776379u, 18074517319117194669u, 110919533909u },
+ { 6065353437512901255u, 3702019776117654523u, 85979821547u },
+ { 12768753059854699889u, 3551977551381082764u, 235200686894u },
+ { 6848720690951013326u, 16442608985936005282u, 46192553088u },
+ { 10953228058585475132u, 3580046275479139588u, 128891355619u },
+ { 15539127852083296166u, 8737412692712715330u, 227194074697u },
+ { 14534853647735598497u, 3082033243045084752u, 73473656091u },
+ { 1506909603576368170u, 16401023756841128699u, 27167077356u },
+ { 5475702579938239025u, 7520296082779572869u, 236889101279u },
+ { 12039747373985783332u, 9854104766152464159u, 223407676067u },
+ { 17572399137760898460u, 14169188802648310188u, 163534192089u },
+ { 869552790852091236u, 2018609909210367042u, 217768113264u },
+ { 4549585778048181804u, 8270271948267674359u, 112109429062u },
+ { 4121918231767210357u, 12320338602894572099u, 70448332340u },
+ { 1558397953312543179u, 17538536685990080547u, 52667886893u },
+ { 6067524298738069781u, 15833914616956760474u, 45950765978u },
+ { 5811095224555517056u, 6137696141415969855u, 154858358231u },
+ { 6440894514158997188u, 9757490468419438919u, 215332725174u },
+ { 4612748874388784257u, 3566639201356598903u, 182528954618u },
+ { 9908101430749813367u, 9760900035773954449u, 250193347898u },
+ { 15150017990912190499u, 3873778773990716438u, 58529139451u },
+ { 17470426264690059239u, 2295668377270167832u, 251209997968u },
+ { 9615161096851907726u, 1791721710912807593u, 144124448432u },
+ { 9227932132124142224u, 10571009006922683279u, 176097129428u },
+ { 4794113194321211621u, 9840791932778184867u, 212573055546u },
+ { 391512698859146347u, 11525464956561274613u, 58533470399u },
+ { 17209658878068655842u, 4435781488897895433u, 191624796707u },
+ { 3077364726606876150u, 6395563367070996741u, 35240464196u },
+ { 1952989567673965814u, 15538690795135662932u, 68346704184u },
+ { 11172860676923186449u, 16294558813563371936u, 56842354115u },
+ { 17338078544784947239u, 4942096228426070342u, 195883329803u },
+ { 4593380466519703278u, 6910116424372647153u, 11267911573u },
+ { 786884753602720052u, 17923400669760829478u, 149374598161u },
+ { 17848875822468020539u, 4134686917293039955u, 17971629497u },
+ { 2899664567187130618u, 16857102463116098681u, 185224141826u },
+ { 2973178834961857409u, 11364321508775167451u, 2913825355u },
+ { 11117453141176836727u, 7966947780972783899u, 75616061103u },
+ { 7535238370146462002u, 11261055695926686278u, 175431889104u },
+ { 10246175467290865448u, 9227040437353594058u, 208610463052u },
+ { 1203128834127050464u, 7185344074282882061u, 76500198864u },
+ { 14518048959078919658u, 14197856148610578032u, 208389518282u },
+ { 1553474987376920024u, 885688687260429427u, 202769667324u },
+ { 14956572380830948369u, 17407816160380305183u, 252048013279u },
+ { 7594162606042048292u, 17812728703806357349u, 223943679604u },
+ { 14461296147288811288u, 17120198191964319867u, 116965629957u },
+ { 18305427728131488265u, 12091952048375408786u, 5928087803u },
+ { 10253208939347909876u, 405056939269888281u, 251655506034u },
+ { 6446028915490812012u, 12485440679452408690u, 114021958180u },
+ { 12986063676957432257u, 8394369900823444407u, 36676837095u },
+ { 9769714697972762807u, 2877421667354294258u, 231455059704u },
+ { 97429465146664592u, 2676980714750756239u, 248155985341u },
+ { 16395571728207795868u, 6119309228579057021u, 189145119415u },
+ { 6331668478323650406u, 18203256146533333852u, 183331728417u },
+ { 18129911846294207040u, 351919978865493747u, 33986800493u },
+ { 9890094564876124160u, 5190010931882390570u, 109019077620u },
+ { 12290856656987750400u, 6982466386088036604u, 244281351056u },
+ { 8498454992640802816u, 4707293888784996898u, 144378520261u },
+ { 5341660584200896512u, 690306801165964760u, 197255182913u },
+ { 9288674231451648000u, 12456770961278956704u, 65037421606u },
+ { 1152921504606846976u, 16946092489294063943u, 38675282906u },
+ { 0u, 11098404173866185376u, 218918649514u },
+ { 0u, 15152070965853306880u, 170601645695u },
+ { 0u, 17370091362040414208u, 127821395412u },
+ { 0u, 10141938552171134976u, 212941634539u },
+ { 0u, 10586988556645826560u, 235549795590u },
+ { 0u, 12169852093061922816u, 6573921799u },
+ { 0u, 16717361816799281152u, 7659729003u },
+ { 0u, 0u, 107906250000u },
+ { 0u, 0u, 16000000000u },
+ { 15212079674427582639u, 112u, 0u },
+ { 10179808126814248333u, 112824648491u, 0u },
+ { 6066766544199222848u, 2144184049294538808u, 6u },
+ { 6625308131806923532u, 4108002197393276873u, 6116236450u },
+ { 9122786786400665713u, 6446230217393892753u, 162222695245u },
+ { 11932880778639151320u, 5571068025259989822u, 77349450840u },
+ { 3884040911779255011u, 14804812668872528331u, 88302008202u },
+ { 13441817515637357872u, 17369928488562523047u, 138802570502u },
+ { 11628577856022352826u, 2967474173531035027u, 6941625710u },
+ { 13296656925520243654u, 5291425437992807716u, 110160867097u },
+ { 5020720704545399398u, 14219547193739388064u, 25286848747u },
+ { 14121973606499014694u, 17720313647158217462u, 235770843197u },
+ { 3642481034345420114u, 12334850628290578491u, 61960620127u },
+ { 9845536238569696768u, 7818499847417334620u, 95668673592u },
+ { 17655403572195686356u, 136007040922198372u, 56423841726u },
+ { 8377495365136654029u, 8523477092112604449u, 190007372956u },
+ { 13713682649609025426u, 367934822655966629u, 156462058619u },
+ { 1367709905452854731u, 12964987687054730050u, 123019945786u },
+ { 9981467701727208680u, 15267036012420885462u, 58702833390u },
+ { 6277920117543306205u, 11142900264750765568u, 238827627680u },
+ { 9344111460418701726u, 13680181547777718603u, 160604057833u },
+ { 4918507011364617264u, 13001922925761426065u, 233741604127u },
+ { 6554777203830755259u, 2397730045956515935u, 31704835654u },
+ { 4198262173120265648u, 4482395522588406288u, 70129981206u },
+ { 8080325935698446819u, 3255525722490493080u, 22242991148u },
+ { 12797633874200091733u, 836222287193822098u, 44176482403u },
+ { 8376502502208665497u, 420898743993182306u, 99045331701u },
+ { 9891973386793349173u, 11652649973356574054u, 245022816966u },
+ { 14877430279003795462u, 15058402726661910231u, 198631691420u },
+ { 8759933935842067041u, 9600134495208339559u, 156816317647u },
+ { 3753418510388703513u, 14626343323989004842u, 207520424333u },
+ { 2961383332545305985u, 6813981265331086665u, 141792895660u },
+ { 2497674184068629507u, 10281745288790487888u, 172369386664u },
+ { 15244544070742305452u, 17569829347075761940u, 168557374528u },
+ { 45953573565810823u, 7654580675237889478u, 64952462357u },
+ { 3960077421351906445u, 16194838649686212364u, 21414955649u },
+ { 3173330011013883118u, 6495102772252453635u, 129877923962u },
+ { 11026266219545759160u, 14935159852819761348u, 122352100226u },
+ { 8886757764964685632u, 17381879863441579697u, 130809636637u },
+ { 13952322129918090479u, 9062335510435372583u, 29942273595u },
+ { 4127250666614902202u, 7569219009130126626u, 59491270192u },
+ { 17649958504065306911u, 12652124168176193362u, 48410328184u },
+ { 13269305359002216873u, 8940200224697247767u, 120685873025u },
+ { 16236593433831947843u, 5600570701927432884u, 129484649225u },
+ { 13580930396682424057u, 2018432801986093157u, 9303607546u },
+ { 421976357197961116u, 8235849749361824736u, 250109419461u },
+ { 2962130818798626533u, 9705097287982370040u, 197446466309u },
+ { 8234383947306356345u, 3517483139049842585u, 5526114378u },
+ { 4380469931801381425u, 958281614186777760u, 74190683143u },
+ { 15279887469027055916u, 7336473432636108950u, 7051948550u },
+ { 8534542821713755552u, 12955383920176764423u, 6397711021u },
+ { 7814613482565088782u, 10735469126281273789u, 173702312769u },
+ { 13771954404705323224u, 8637888232514730693u, 65581970947u },
+ { 4568173274762548144u, 6806336737533581000u, 3468260859u },
+ { 8105292616250821343u, 16142569672872330321u, 251368972253u },
+ { 2923678426777275612u, 8141285259947963513u, 221875090455u },
+ { 1808633176918384049u, 5220241098754220797u, 23441339958u },
+ { 18118642609460438969u, 154438799943119608u, 54282989837u },
+ { 18138164175864360870u, 2226876628677628879u, 13008372144u },
+ { 4031433690465792404u, 17219557081221357482u, 176120719223u },
+ { 5012226396942308537u, 15401507148161015114u, 119933474059u },
+ { 7889712298793536835u, 8842629766613985337u, 11834917375u },
+ { 13500762396543628804u, 3180100571546071440u, 255479359920u },
+ { 501020624068841347u, 7740848704392475044u, 176172393597u },
+ { 8370653768288261750u, 2014314126623495998u, 125419632249u },
+ { 647579990023635200u, 11209566016506885858u, 121109196187u },
+ { 11106569307181154304u, 7117166613733441125u, 155607671791u },
+ { 10797461613892861952u, 4197646860931880328u, 239385822375u },
+ { 17627230675448889344u, 5487263271238026094u, 167227554892u },
+ { 12197735707942322176u, 18148076225293562697u, 76297465137u },
+ { 12871287735024877568u, 9127276943027950849u, 49983809183u },
+ { 4611686018427387904u, 9691696125379324722u, 159494790674u },
+ { 0u, 13102362262487705216u, 18525387899u },
+ { 0u, 8929385439893192704u, 123710280481u },
+ { 0u, 11891353410743566336u, 33484062954u },
+ { 0u, 1587423090877399040u, 234644631560u },
+ { 0u, 3489137423026225152u, 8086054378u },
+ { 0u, 13046928120492326912u, 234189146518u },
+ { 0u, 11529215046068469760u, 150707275390u },
+ { 0u, 0u, 126625000000u },
+ { 0u, 0u, 64000000000u },
+ { 9451803574512021605u, 1721567u, 0u },
+ { 8662766454758138424u, 1721567512383298u, 0u },
+ { 9207992007314947035u, 6674960280855494694u, 93326u },
+ { 17118602861291201802u, 16378845781483497510u, 142361850321u },
+ { 11186560605745599967u, 17606907750956804392u, 209887899008u },
+ { 10505549821532796847u, 13225609159240506969u, 128954472381u },
+ { 18133667530488679216u, 2668084873338435252u, 189716961709u },
+ { 10778135771244330799u, 14802814305275861366u, 173144637170u },
+ { 17087985777033767391u, 8005510553372365574u, 242802462171u },
+ { 2639185991757283040u, 12748500143273514429u, 219433979596u },
+ { 5401720287293896400u, 10393733905569036127u, 204691097577u },
+ { 9816495392633895233u, 603389089974790339u, 233563445444u },
+ { 10042051500090034990u, 2033494532597735873u, 196032709788u },
+ { 11629689537856384738u, 9204796763694620958u, 156110235959u },
+ { 2099086731766010483u, 7826260310402107021u, 55498993032u },
+ { 13665537898516458594u, 10122690201685169383u, 136424262421u },
+ { 16375672064669490764u, 7438455564568110133u, 21548752135u },
+ { 7770550512184564348u, 2805412574380520817u, 7403239484u },
+ { 6197048880720627314u, 7250965427231182867u, 60152081720u },
+ { 17963594118523106281u, 8136242944826085924u, 56393075623u },
+ { 8255454642407818663u, 15357191647956011780u, 167441066613u },
+ { 16744201957549498409u, 7369614426695395460u, 117832515027u },
+ { 17442505417202859722u, 10886957545142526638u, 211399507598u },
+ { 6383975767786687150u, 2030047207417538097u, 142590183151u },
+ { 15245442964998335795u, 11557093828502314355u, 239110049079u },
+ { 2910016124519524433u, 15201062539664128543u, 55626511311u },
+ { 3847913871169988463u, 8846936323343880674u, 207824051251u },
+ { 17210451512590059177u, 1485291750116245364u, 51479593379u },
+ { 17899408909991454145u, 2076024439668322013u, 163080517827u },
+ { 5920601932753251608u, 7029497773682748741u, 195112541510u },
+ { 16521781895108979744u, 16333533921668749881u, 70381069837u },
+ { 3697493405554698771u, 2065057316131928423u, 13885442648u },
+ { 2816108280295732065u, 7800502648925570223u, 88111946981u },
+ { 14251078772056398988u, 17011619967093802015u, 229422866095u },
+ { 4543066550096031417u, 5368819344429198672u, 175922201766u },
+ { 3099369389734296977u, 15598879366754275267u, 166291044279u },
+ { 5243484113636490986u, 16393893486035835647u, 183845616944u },
+ { 6823370511605197226u, 12042046205096920307u, 48888714746u },
+ { 11396290277624641942u, 15437070428008474344u, 250652800632u },
+ { 15934361408437566099u, 13704569163204647509u, 120836845264u },
+ { 14939272230935131954u, 18192483750856993350u, 208742926182u },
+ { 7500666177940329347u, 5152535865317963250u, 102986216520u },
+ { 4806714453065462270u, 17512614083933854680u, 72279319528u },
+ { 11557851247268441487u, 14481918350603613536u, 232949360711u },
+ { 10655523157206817381u, 16124419709964004915u, 71785066366u },
+ { 14769600176490881210u, 18088011566435813579u, 126874106543u },
+ { 16688495540925795167u, 15008862380698848893u, 175980553071u },
+ { 909793965395524173u, 18160498644611827812u, 111813632059u },
+ { 12724590949761703756u, 3604680497457231965u, 59984482604u },
+ { 10810739657314826395u, 5957615565551495921u, 44195410121u },
+ { 2431218615388671301u, 17528455034961565995u, 201322962986u },
+ { 4235001167959059286u, 8503772325120113809u, 42950219451u },
+ { 6253317787396334247u, 8501492578048509537u, 187460990421u },
+ { 9534525563070371898u, 2296237701094386060u, 213460866836u },
+ { 8392783992374030728u, 3753593040591076946u, 20124479295u },
+ { 16356257019231647540u, 8518075399775653155u, 63203482686u },
+ { 12896334001521091877u, 12757855675959554597u, 62461765792u },
+ { 1427636373320877084u, 121631169379748595u, 160691604742u },
+ { 16116755731295043521u, 16679062494579173314u, 6006593638u },
+ { 15945633911163986837u, 10739912744743898054u, 102904173789u },
+ { 7510154241072743838u, 9367340677776287570u, 221582211836u },
+ { 3571560509790395119u, 12227321512794715397u, 252507804555u },
+ { 3576991649007035076u, 7241061891859170651u, 139662844427u },
+ { 15509961892750732443u, 13148571323079237489u, 11392538751u },
+ { 17789791359353349378u, 12509763434355012654u, 127712785479u },
+ { 18331227331079738314u, 11812768946960181977u, 71678155634u },
+ { 15386712883100476416u, 14170358803552564832u, 114640371487u },
+ { 14082462055028752384u, 18179989524780635952u, 31768176689u },
+ { 12919043128765186048u, 17091718978514754901u, 49985539206u },
+ { 6125373368465096704u, 7394768384359232459u, 134926543942u },
+ { 12335992698065387520u, 6778628272692852803u, 70400871197u },
+ { 2774217370460225536u, 18193335045875234320u, 29367470174u },
+ { 0u, 1378519212560967521u, 94986262669u },
+ { 0u, 4677732610631043584u, 141074729676u },
+ { 0u, 17296098591070486528u, 204253580392u },
+ { 0u, 7343735382392963072u, 104937623383u },
+ { 0u, 14525996728454217728u, 87398104692u },
+ { 0u, 9691359370008330240u, 116787455860u },
+ { 0u, 3044433348102455296u, 116525369644u },
+ { 0u, 9223372036854775808u, 44165039062u },
+ { 0u, 0u, 214500000000u },
+ { 4962829537462579598u, 26u, 0u },
+ { 5711259460785241095u, 26269035528u, 0u },
+ { 13845894607204897444u, 7822291454600056379u, 1u },
+ { 12116633056637003327u, 8201586317771250746u, 1424047269u },
+ { 2965791047992089560u, 3278889188817135834u, 165444608885u },
+ { 16021997451315962529u, 1710725240251040430u, 117177748939u },
+ { 3942052271663803856u, 1850175733663425006u, 203092738601u },
+ { 15669876414782439922u, 9147599666163914249u, 41100298227u },
+ { 10594415915406145286u, 10221885933644344166u, 243495892371u },
+ { 10789820553031921377u, 14901479793736678101u, 147554129546u },
+ { 3989990218583987244u, 5181831442059703136u, 138807810838u },
+ { 2937341169808224563u, 6396246577759793483u, 22280907645u },
+ { 16267436558584536843u, 14167229556464870447u, 125346741221u },
+ { 16221580362814625793u, 2969982933326311854u, 229768007053u },
+ { 9695437602320209830u, 7892677766222018881u, 141161003097u },
+ { 10729753156793715126u, 798698968922663621u, 89427862919u },
+ { 2609241432056861929u, 15926812109043458972u, 135043297557u },
+ { 8462663743997037565u, 8663842590352697437u, 21863394214u },
+ { 14993422143908194069u, 17093523026636671168u, 166469667847u },
+ { 1307443894537745373u, 839764004742743203u, 7926641740u },
+ { 10017257439419829265u, 16894643909298232323u, 76045523697u },
+ { 16754772009970777891u, 9066702926218949317u, 241915860481u },
+ { 11722573031602862387u, 9119392417260546810u, 1491506950u },
+ { 7363764277467092384u, 9723021096578315109u, 6494363253u },
+ { 6733958494847390772u, 14787464248751217597u, 117527086029u },
+ { 8799796600227451045u, 3733434565920249133u, 205801630043u },
+ { 10512023194742249826u, 6643788868836820841u, 91202389893u },
+ { 4572542132337197059u, 4729646697422664063u, 133360160516u },
+ { 12600500455757416832u, 4090144564201555829u, 4256394661u },
+ { 7873789864743195199u, 2109480737093400002u, 165221727181u },
+ { 15724851676325671539u, 16577155033369419739u, 205114355179u },
+ { 8748017220462413167u, 745377248603805917u, 235898649375u },
+ { 14172589522760466448u, 11305561465807999667u, 31040406981u },
+ { 9520545591489413768u, 2211245518782892177u, 197612875715u },
+ { 12488551088392570222u, 14170095199249735666u, 195119871859u },
+ { 1135798823651241684u, 17849973668116118927u, 115768162399u },
+ { 11168725610120161972u, 9020960204585720001u, 95967649011u },
+ { 9580104948718508826u, 10807134002871850916u, 243489027232u },
+ { 16638722716909738765u, 3925122626254791201u, 160585855908u },
+ { 15732724012348272797u, 17208463291312718997u, 164212781323u },
+ { 12269722190021214142u, 5145077219589447653u, 11932872664u },
+ { 13110655916311972587u, 17602397765035489468u, 216278915194u },
+ { 6618112997062866867u, 16422643262490753377u, 122954227894u },
+ { 8457936459015989309u, 2902509461400906224u, 182890273275u },
+ { 3329167139937134914u, 3422418805967265206u, 251157345353u },
+ { 5245511557216705097u, 4228874576277237392u, 73185529695u },
+ { 5655931353280440466u, 2553488530807495751u, 95229247750u },
+ { 604622132328697393u, 11546099176912486413u, 6138424890u },
+ { 8673282619234652338u, 10460791037534167991u, 58625915290u },
+ { 16929477433058445690u, 8127117908566000904u, 154567080618u },
+ { 11036952409253549455u, 11541304458088287306u, 170440571944u },
+ { 18199392190170386320u, 6249718665174839700u, 40625655368u },
+ { 9683116091880335715u, 13102508413386290995u, 72338797927u },
+ { 2993913337608915120u, 6274675218640661911u, 103710288404u },
+ { 4490779842162392585u, 3404497118599817167u, 20340150825u },
+ { 946849923353644618u, 11258566093988562335u, 41184558158u },
+ { 3613491058474899828u, 16762592482501635397u, 78610328090u },
+ { 14624054199004410935u, 5550125446725071998u, 26908701959u },
+ { 12088470271991908244u, 6370033225258510318u, 7300872903u },
+ { 10071980927725011290u, 1503521728674735398u, 199345320193u },
+ { 2833441711428854664u, 4250415082606384364u, 1081506076u },
+ { 17655572411864340446u, 6020091901030562974u, 28230415463u },
+ { 4997642792058747802u, 16288222967151527138u, 103326349835u },
+ { 11489200787635734848u, 6377016228656203782u, 11882986336u },
+ { 12983586226429536913u, 8378856515587563750u, 96345698742u },
+ { 12311150768725063152u, 15812881490200838483u, 182454218721u },
+ { 8530052476845967905u, 4548570371183413652u, 225857218023u },
+ { 6282736361499820264u, 16731431495283420383u, 231246578493u },
+ { 11337164765929082880u, 14737727629551135532u, 61907012718u },
+ { 8343856200414134272u, 12413722258104293893u, 110798933815u },
+ { 17889330377156198400u, 800899742400762438u, 55672949232u },
+ { 17730714064155312128u, 603197008376033550u, 240043416862u },
+ { 7449235258647511040u, 6380777281587743935u, 30032699375u },
+ { 9943947977234055168u, 10001440249018225388u, 239345902629u },
+ { 0u, 5505914461980436708u, 37542179162u },
+ { 0u, 1105464290051876864u, 90298476221u },
+ { 0u, 4500443576769970176u, 189059927339u },
+ { 0u, 2843045143185981440u, 43243969535u },
+ { 0u, 660949699682893824u, 255154121786u },
+ { 0u, 276549164618219520u, 58035830155u },
+ { 0u, 4683743612465315840u, 139014991760u },
+ { 0u, 0u, 144253906250u },
+ { 0u, 0u, 74000000000u },
+ { 12396245121240683569u, 400833u, 0u },
+ { 10248996648596888561u, 400833672001794u, 0u },
+ { 11257495103713935002u, 4370024159708535157u, 21729u },
+ { 7555396579247433114u, 7166684413908503888u, 225236899484u },
+ { 4805022328730367462u, 10217286283215687029u, 156388506740u },
+ { 7056637817080232586u, 4767369911989629198u, 116553880199u },
+ { 10811411483818434913u, 14407999214182082862u, 135258439640u },
+ { 16962406704495245447u, 8472271297615317358u, 216781059202u },
+ { 18074517319117194669u, 6236024012584764757u, 130459282747u },
+ { 3702019776117654523u, 1951826556984620523u, 59338055539u },
+ { 3551977551381082764u, 12357130551551830830u, 115105808729u },
+ { 16442608985936005282u, 8927758011099278464u, 89669881389u },
+ { 3580046275479139588u, 10199854049407140323u, 45483974731u },
+ { 8737412692712715330u, 17895455027038549577u, 75552935195u },
+ { 3082033243045084752u, 16539200343720527131u, 27970114560u },
+ { 16401023756841128699u, 3536976106235802604u, 896591847u },
+ { 7520296082779572869u, 16980391644793590751u, 231191739858u },
+ { 9854104766152464159u, 10090294316609084067u, 210920508875u },
+ { 14169188802648310188u, 17603457857266236889u, 203546995950u },
+ { 2018609909210367042u, 11164962743035868272u, 238954285362u },
+ { 8270271948267674359u, 1585686890718568774u, 50605253843u },
+ { 12320338602894572099u, 10882524700472655412u, 211085960258u },
+ { 17538536685990080547u, 2194808754940947757u, 66589942846u },
+ { 15833914616956760474u, 274100791137209242u, 62118980821u },
+ { 6137696141415969855u, 12203404582981010903u, 213014859033u },
+ { 9757490468419438919u, 541940706340938166u, 25661547888u },
+ { 3566639201356598903u, 10305434016011833594u, 112029378664u },
+ { 9760900035773954449u, 7900783531944543546u, 104558658697u },
+ { 3873778773990716438u, 8920818625012419323u, 137428302333u },
+ { 2295668377270167832u, 12532363335400447632u, 253483598546u },
+ { 1791721710912807593u, 13483507182924762800u, 210679380777u },
+ { 10571009006922683279u, 415911049779278804u, 41730942389u },
+ { 9840791932778184867u, 3441628281170127418u, 181022546583u },
+ { 11525464956561274613u, 17830811568183566527u, 151186571042u },
+ { 4435781488897895433u, 17897295813176613411u, 34966610231u },
+ { 6395563367070996741u, 2086148701331574596u, 55970214350u },
+ { 15538690795135662932u, 13015567826878853432u, 206113090347u },
+ { 16294558813563371936u, 12944531121587846595u, 43705575345u },
+ { 4942096228426070342u, 3534180912913737995u, 177701724438u },
+ { 6910116424372647153u, 3447584022400118677u, 22191588331u },
+ { 17923400669760829478u, 6375676813770849297u, 235186893904u },
+ { 4134686917293039955u, 11580694081479200185u, 80345626132u },
+ { 16857102463116098681u, 1872134358882196482u, 20627790684u },
+ { 11364321508775167451u, 17602652840520938059u, 92101488606u },
+ { 7966947780972783899u, 10331040597716338351u, 222954241722u },
+ { 11261055695926686278u, 73785407041056976u, 186560046833u },
+ { 9227040437353594058u, 17166209109167902028u, 241003999914u },
+ { 7185344074282882061u, 8762475644006589904u, 170930582060u },
+ { 14197856148610578032u, 8839001228645872586u, 44475014756u },
+ { 885688687260429427u, 13558262784529110268u, 100479163216u },
+ { 17407816160380305183u, 5640853896420358111u, 80734994898u },
+ { 17812728703806357349u, 8459930353450835572u, 210305791302u },
+ { 17120198191964319867u, 7643830211500171269u, 70458613743u },
+ { 12091952048375408786u, 1308629115231236347u, 239414372866u },
+ { 405056939269888281u, 8957268500971669618u, 2070940926u },
+ { 12485440679452408690u, 7645679094277669412u, 254485574498u },
+ { 8394369900823444407u, 3821107497040617191u, 98414473094u },
+ { 2877421667354294258u, 8847137191985934072u, 134207142652u },
+ { 2676980714750756239u, 3531126524756088253u, 252479604268u },
+ { 6119309228579057021u, 8726915034124352183u, 44191422752u },
+ { 18203256146533333852u, 17611136727168068641u, 32473087011u },
+ { 351919978865493747u, 18017743272784259949u, 35954701634u },
+ { 5190010931882390570u, 18113575006829616116u, 66976743819u },
+ { 6982466386088036604u, 12805550441678740368u, 139981938868u },
+ { 4707293888784996898u, 8061966093393027781u, 180694190280u },
+ { 690306801165964760u, 11954593141554100801u, 200437040057u },
+ { 12456770961278956704u, 14068656112359197734u, 185648059792u },
+ { 16946092489294063943u, 895878255770467290u, 144762663376u },
+ { 11098404173866185376u, 10319906489512197802u, 208048565657u },
+ { 15152070965853306880u, 14551142616794302079u, 153559443251u },
+ { 17370091362040414208u, 15933181735739307476u, 51788819021u },
+ { 10141938552171134976u, 11524527334398983147u, 77863739512u },
+ { 10586988556645826560u, 11828012606225556742u, 120624745878u },
+ { 12169852093061922816u, 3556238869349799431u, 150641197848u },
+ { 16717361816799281152u, 7403090230513381483u, 24192784095u },
+ { 0u, 10172292854665622800u, 223401322325u },
+ { 0u, 11240746576366182400u, 85551441100u },
+ { 0u, 17021927826892259328u, 204609362092u },
+ { 0u, 9046328496309141504u, 172922760556u },
+ { 0u, 8038996803112140800u, 108490402450u },
+ { 0u, 17098478935265509376u, 146435794889u },
+ { 0u, 7205759403792793600u, 201926910400u },
+ { 0u, 0u, 192390625000u },
+ { 0u, 0u, 232000000000u },
+ { 2144184049294538808u, 6u, 0u },
+ { 4108002197393276873u, 6116236450u, 0u },
+ { 6446230217393892753u, 6116236450222695245u, 0u },
+ { 5571068025259989822u, 6240972538554414168u, 331561842u },
+ { 14804812668872528331u, 4356262642990299018u, 114338323799u },
+ { 17369928488562523047u, 1335108558830511366u, 87236153471u },
+ { 2967474173531035027u, 18435704923261947246u, 127072376379u },
+ { 5291425437992807716u, 8395401931972636441u, 59999401566u },
+ { 14219547193739388064u, 12482665946362458347u, 94455115650u },
+ { 17720313647158217462u, 16101242875289374781u, 130676686676u },
+ { 12334850628290578491u, 4708983440241068127u, 84872850125u },
+ { 7818499847417334620u, 14856666972541426744u, 205255274503u },
+ { 136007040922198372u, 6938795288315789246u, 7805381530u },
+ { 8523477092112604449u, 5556307628265073820u, 154376152846u },
+ { 367934822655966629u, 1441404248927865979u, 14301208040u },
+ { 12964987687054730050u, 16710378912353838906u, 232078138680u },
+ { 15267036012420885462u, 18289940136919312110u, 56905871455u },
+ { 11142900264750765568u, 10217414145292657824u, 95991499641u },
+ { 13680181547777718603u, 12461165826430955753u, 121553887130u },
+ { 13001922925761426065u, 662762458988270879u, 154675521153u },
+ { 2397730045956515935u, 16488546856395302470u, 129035928424u },
+ { 4482395522588406288u, 2612816787977180950u, 104893845916u },
+ { 3255525722490493080u, 16446616379327454252u, 156141641081u },
+ { 836222287193822098u, 7842178508581740643u, 121891572860u },
+ { 420898743993182306u, 14779029861369369333u, 124425125348u },
+ { 11652649973356574054u, 2697664446153849542u, 228801172814u },
+ { 15058402726661910231u, 12135106444393649308u, 78146240682u },
+ { 9600134495208339559u, 9550285041205189839u, 170657845438u },
+ { 14626343323989004842u, 8790318168586740109u, 190517721989u },
+ { 6813981265331086665u, 14038474217155846828u, 133476524102u },
+ { 10281745288790487888u, 4263144264274812072u, 70761027212u },
+ { 17569829347075761940u, 11940456333341715520u, 140231105513u },
+ { 7654580675237889478u, 15751110736831573013u, 233647293434u },
+ { 16194838649686212364u, 18384528705472318081u, 250853869423u },
+ { 6495102772252453635u, 2393654818032310394u, 111996627298u },
+ { 14935159852819761348u, 12812209822018626434u, 98129760287u },
+ { 17381879863441579697u, 3110778569433458461u, 31694551286u },
+ { 9062335510435372583u, 2860264756226872891u, 246168635644u },
+ { 7569219009130126626u, 2384146980060315184u, 252155055263u },
+ { 12652124168176193362u, 14117430062880324728u, 159129244866u },
+ { 8940200224697247767u, 3769610173216737153u, 194765307417u },
+ { 5600570701927432884u, 17731974340232672009u, 25204350976u },
+ { 2018432801986093157u, 1971479303384713466u, 961252255u },
+ { 8235849749361824736u, 3449462959779012549u, 159106874107u },
+ { 9705097287982370040u, 13743454852043766533u, 251186995761u },
+ { 3517483139049842585u, 7417711187131879498u, 49745034180u },
+ { 958281614186777760u, 3650992383501007879u, 196402114929u },
+ { 7336473432636108950u, 12838770342493958662u, 113197920693u },
+ { 12955383920176764423u, 16025068246546338477u, 181695991134u },
+ { 10735469126281273789u, 6579965938260177729u, 94868720690u },
+ { 8637888232514730693u, 4742939430174291459u, 50356700668u },
+ { 6806336737533581000u, 13062256857527449083u, 252257115261u },
+ { 16142569672872330321u, 2301174570202439645u, 125708106363u },
+ { 8141285259947963513u, 7638687886069412887u, 123124746923u },
+ { 5220241098754220797u, 936322449610274358u, 171414094100u },
+ { 154438799943119608u, 12926010544311283981u, 20050758141u },
+ { 2226876628677628879u, 12647854908989899184u, 253700720435u },
+ { 17219557081221357482u, 8862093163358513015u, 51685641588u },
+ { 15401507148161015114u, 444784343917630731u, 116480415033u },
+ { 8842629766613985337u, 11033952249213387263u, 57024111807u },
+ { 3180100571546071440u, 18168634046363183536u, 191598151749u },
+ { 7740848704392475044u, 3837904761417065597u, 69984923625u },
+ { 2014314126623495998u, 111459007020906105u, 233208053234u },
+ { 11209566016506885858u, 16191761957496794523u, 242006042204u },
+ { 7117166613733441125u, 9856250800340378607u, 92877757174u },
+ { 4197646860931880328u, 9491800102275105959u, 246534308426u },
+ { 5487263271238026094u, 10777328578953608268u, 74514551514u },
+ { 18148076225293562697u, 17424440628313779505u, 218584240152u },
+ { 9127276943027950849u, 3285814872419755679u, 24944580819u },
+ { 9691696125379324722u, 2824823424107240978u, 211178124381u },
+ { 13102362262487705216u, 12271707680713669755u, 93153133984u },
+ { 8929385439893192704u, 6951481875178001185u, 160665250606u },
+ { 11891353410743566336u, 10202522487003824362u, 46376840587u },
+ { 1587423090877399040u, 4834668463880990728u, 139553079852u },
+ { 3489137423026225152u, 10871520987687904746u, 44262087902u },
+ { 13046928120492326912u, 12057698794225322390u, 222589346333u },
+ { 11529215046068469760u, 7263351819222681214u, 29653649161u },
+ { 0u, 1778055686910650944u, 9393747091u },
+ { 0u, 17108187120491986944u, 147096388591u },
+ { 0u, 3067636961549221888u, 239927436682u },
+ { 0u, 16702141595163557888u, 138166296932u },
+ { 0u, 2432053749942845440u, 100905424910u },
+ { 0u, 17791470327927144448u, 14131841897u },
+ { 0u, 1152921504606846976u, 105964477539u },
+ { 0u, 0u, 99062500000u },
+ { 0u, 0u, 160000000000u },
+ { 6674960280855494694u, 93326u, 0u },
+ { 16378845781483497510u, 93326361850321u, 0u },
+ { 17606907750956804392u, 4283581425266273664u, 5059u },
+ { 13225609159240506969u, 6725911039793895357u, 195232213414u },
+ { 2668084873338435252u, 1188689198788975021u, 166364612368u },
+ { 14802814305275861366u, 10825527435847761650u, 16064438970u },
+ { 8005510553372365574u, 3917696829526085083u, 186586853018u },
+ { 12748500143273514429u, 12646861173976387276u, 154212378770u },
+ { 10393733905569036127u, 18398576063183996905u, 146685587717u },
+ { 603389089974790339u, 16919251228485834948u, 5997388806u },
+ { 2033494532597735873u, 17296019588687185052u, 6917194446u },
+ { 9204796763694620958u, 12365301604512770359u, 206937619100u },
+ { 7826260310402107021u, 2814271599679204744u, 156670324343u },
+ { 10122690201685169383u, 2154994415780170517u, 119152561969u },
+ { 7438455564568110133u, 6717373824370072839u, 49116822481u },
+ { 2805412574380520817u, 12709155755801344060u, 209364149564u },
+ { 7250965427231182867u, 826847911966403896u, 60688964714u },
+ { 8136242944826085924u, 2277322703890025383u, 106044823515u },
+ { 15357191647956011780u, 2774508958389496437u, 219123453911u },
+ { 7369614426695395460u, 245697774950120915u, 215150406432u },
+ { 10886957545142526638u, 1268929063431863950u, 32013319303u },
+ { 2030047207417538097u, 6735665673159411439u, 135068788782u },
+ { 11557093828502314355u, 14734771742997073207u, 46365141167u },
+ { 15201062539664128543u, 13683287077957612495u, 175798773576u },
+ { 8846936323343880674u, 15370263741354826803u, 72741772478u },
+ { 1485291750116245364u, 48035913070297507u, 190833223667u },
+ { 2076024439668322013u, 1206547475966802115u, 243002604032u },
+ { 7029497773682748741u, 13512340386605768006u, 65407069u },
+ { 16333533921668749881u, 2325760467700278797u, 93732505440u },
+ { 2065057316131928423u, 10848110652847753816u, 96126079727u },
+ { 7800502648925570223u, 15846378960784301285u, 239588077256u },
+ { 17011619967093802015u, 14121839924449844911u, 200859033924u },
+ { 5368819344429198672u, 5147613424753296550u, 68765546476u },
+ { 15598879366754275267u, 16817040482828810167u, 236279052682u },
+ { 16393893486035835647u, 5773528746119363888u, 138911653591u },
+ { 12042046205096920307u, 8716201595536184826u, 215312983620u },
+ { 15437070428008474344u, 5259122109038474872u, 68472506235u },
+ { 13704569163204647509u, 14744540084230155984u, 123285097580u },
+ { 18192483750856993350u, 10719345477982635878u, 108799303119u },
+ { 5152535865317963250u, 13698037261310555208u, 207581096882u },
+ { 17512614083933854680u, 16141171632951976936u, 178742572087u },
+ { 14481918350603613536u, 10060790174955808839u, 55875014667u },
+ { 16124419709964004915u, 4250043307981877118u, 11545396528u },
+ { 18088011566435813579u, 7075646198054337199u, 48230395309u },
+ { 15008862380698848893u, 18141738384245531503u, 173383571548u },
+ { 18160498644611827812u, 8174370508376809531u, 92983465608u },
+ { 3604680497457231965u, 3581964982731575596u, 136443133513u },
+ { 5957615565551495921u, 14798509948722114761u, 73194178710u },
+ { 17528455034961565995u, 14713923334885122090u, 150802228831u },
+ { 8503772325120113809u, 5042978054260414139u, 95797643382u },
+ { 8501492578048509537u, 2052996319372883413u, 118273380388u },
+ { 2296237701094386060u, 8825683007899981588u, 36111293153u },
+ { 3753593040591076946u, 9992196755378745151u, 225478441234u },
+ { 8518075399775653155u, 9301073417573669950u, 18541678071u },
+ { 12757855675959554597u, 5331614769144850592u, 247504212200u },
+ { 121631169379748595u, 14354009428310052102u, 232289027415u },
+ { 16679062494579173314u, 5581221063029119078u, 87778132410u },
+ { 10739912744743898054u, 1529260335339476189u, 186302558600u },
+ { 9367340677776287570u, 16483061525949201148u, 136082901368u },
+ { 12227321512794715397u, 14431217812333089675u, 120893548555u },
+ { 7241061891859170651u, 3452349151135392267u, 11782317885u },
+ { 13148571323079237489u, 9075317899834447999u, 61187152222u },
+ { 12509763434355012654u, 2764331337978901575u, 94491973969u },
+ { 11812768946960181977u, 1942890683708857202u, 81149854702u },
+ { 14170358803552564832u, 165089169728028447u, 238105324315u },
+ { 18179989524780635952u, 15193620741871233073u, 27008949501u },
+ { 17091718978514754901u, 14995000835194145926u, 253823647830u },
+ { 7394768384359232459u, 1788823614552255558u, 86812880624u },
+ { 6778628272692852803u, 8384901184618498845u, 240096972322u },
+ { 18193335045875234320u, 405511217862281310u, 34454546404u },
+ { 1378519212560967521u, 3111530463755196557u, 228021982807u },
+ { 4677732610631043584u, 7893558450035460812u, 87168676404u },
+ { 17296098591070486528u, 156573858237402216u, 52427910661u },
+ { 7343735382392963072u, 15915324019419451223u, 5008487885u },
+ { 14525996728454217728u, 16293363012778802804u, 205862771443u },
+ { 9691359370008330240u, 14342105318291351412u, 243883264978u },
+ { 3044433348102455296u, 3788398842525387052u, 210777487087u },
+ { 9223372036854775808u, 14118764407048307670u, 239205369512u },
+ { 0u, 2705021334614720768u, 168765379752u },
+ { 0u, 7017988973805568000u, 168146639500u },
+ { 0u, 10956732053634154496u, 140380445944u },
+ { 0u, 14657517938546835456u, 248593965634u },
+ { 0u, 11268868284797157376u, 66794585639u },
+ { 0u, 14600669991935148032u, 39610886573u },
+ { 0u, 4611686018427387904u, 173791503906u },
+ { 0u, 0u, 34250000000u },
+ { 0u, 0u, 128000000000u },
+ { 8201586317771250746u, 1424047269u, 0u },
+ { 3278889188817135834u, 1424047269444608885u, 0u },
+ { 1710725240251040430u, 3001188830946823627u, 77197757u },
+ { 1850175733663425006u, 9732296932705387049u, 189162694772u },
+ { 9147599666163914249u, 16337535782679529459u, 116527588873u },
+ { 10221885933644344166u, 7969742269895046547u, 9885659589u },
+ { 14901479793736678101u, 2923592083903829642u, 197432040594u },
+ { 5181831442059703136u, 8144196241160608534u, 146158488244u },
+ { 6396246577759793483u, 16431078457793424253u, 180441497762u },
+ { 14167229556464870447u, 202362949592775653u, 162890730548u },
+ { 2969982933326311854u, 8835125248522947981u, 52010970117u },
+ { 7892677766222018881u, 7959873808777345113u, 5478953099u },
+ { 798698968922663621u, 14929747122315126151u, 139431505623u },
+ { 15926812109043458972u, 4310328817360515349u, 215809343213u },
+ { 8663842590352697437u, 7294899422760201126u, 237233663393u },
+ { 17093523026636671168u, 2047461597291187207u, 161395457290u },
+ { 839764004742743203u, 10942374468813517900u, 10110993115u },
+ { 16894643909298232323u, 10364795403063433969u, 219593187308u },
+ { 9066702926218949317u, 12330859528790939137u, 236561876684u },
+ { 9119392417260546810u, 8973160144879916806u, 204668457234u },
+ { 9723021096578315109u, 2895354388547509877u, 18486435986u },
+ { 14787464248751217597u, 16766844772497556429u, 146156957475u },
+ { 3733434565920249133u, 7442407174620948827u, 35908932476u },
+ { 6643788868836820841u, 6683013428676659077u, 124403453701u },
+ { 4729646697422664063u, 16713703375071907588u, 5362286883u },
+ { 4090144564201555829u, 8791044883080637861u, 35906051675u },
+ { 2109480737093400002u, 602844107089214413u, 91476563498u },
+ { 16577155033369419739u, 9754832281172880875u, 42032680244u },
+ { 745377248603805917u, 10587846778003503903u, 52528810517u },
+ { 11305561465807999667u, 17206244172922947013u, 21573968323u },
+ { 2211245518782892177u, 11620628420699303875u, 195932752365u },
+ { 14170095199249735666u, 17864732368219338611u, 237629955528u },
+ { 17849973668116118927u, 4146383014621345887u, 200968449082u },
+ { 9020960204585720001u, 11445705075042688243u, 58224775873u },
+ { 10807134002871850916u, 7369147888966546592u, 193620472915u },
+ { 3925122626254791201u, 9762476865090597796u, 83399482307u },
+ { 17208463291312718997u, 5507001428194242827u, 195529224931u },
+ { 5145077219589447653u, 11371471148365328344u, 227298535145u },
+ { 17602397765035489468u, 3148788104946538618u, 233616448686u },
+ { 16422643262490753377u, 3762722308424507574u, 174170696145u },
+ { 2902509461400906224u, 1156171244825745915u, 209203977585u },
+ { 3422418805967265206u, 14208921674868257865u, 113062676168u },
+ { 4228874576277237392u, 7903080886897905503u, 200770267187u },
+ { 2553488530807495751u, 6367240794154270982u, 51428426873u },
+ { 11546099176912486413u, 1623672396662369850u, 121345168815u },
+ { 10460791037534167991u, 18323231215381674394u, 175088019456u },
+ { 8127117908566000904u, 9842279843006544554u, 993304354u },
+ { 11541304458088287306u, 7376839231308610600u, 34533551059u },
+ { 6249718665174839700u, 609751749293657672u, 211399899256u },
+ { 13102508413386290995u, 10386457966860989799u, 120033054708u },
+ { 6274675218640661911u, 11160336020836149780u, 244563051014u },
+ { 3404497118599817167u, 17947559933847409193u, 6605003027u },
+ { 11258566093988562335u, 10229787001712704590u, 19972939173u },
+ { 16762592482501635397u, 10441677090043619866u, 165554557864u },
+ { 5550125446725071998u, 4996681336392922375u, 168566044449u },
+ { 6370033225258510318u, 124497102381021895u, 33270870638u },
+ { 1503521728674735398u, 8180812057779384577u, 110006749001u },
+ { 4250415082606384364u, 5294232873532946716u, 73443482710u },
+ { 6020091901030562974u, 2885620189169448039u, 86287000939u },
+ { 16288222967151527138u, 16662526875008170507u, 107156429783u },
+ { 6377016228656203782u, 15663095032402672480u, 215903277391u },
+ { 8378856515587563750u, 1824281504410546614u, 79849098083u },
+ { 15812881490200838483u, 9506565509584809953u, 99098894498u },
+ { 4548570371183413652u, 16941136942345070055u, 162515351948u },
+ { 16731431495283420383u, 15924115693705937725u, 140918380873u },
+ { 14737727629551135532u, 9247807690406628462u, 73863248041u },
+ { 12413722258104293893u, 7993916633864834871u, 169501324659u },
+ { 800899742400762438u, 1018504409177639408u, 115433351089u },
+ { 603197008376033550u, 12097800686634130718u, 177055213234u },
+ { 6380777281587743935u, 6221488888422637551u, 178655823089u },
+ { 10001440249018225388u, 8229322865256080421u, 241337267588u },
+ { 5505914461980436708u, 7927745108183101786u, 132446112486u },
+ { 1105464290051876864u, 8488683721235326653u, 230429763923u },
+ { 4500443576769970176u, 11165516518170922283u, 83460172466u },
+ { 2843045143185981440u, 5463648141113596927u, 178605283863u },
+ { 660949699682893824u, 3958440403860778042u, 23296184959u },
+ { 276549164618219520u, 5091534813990256011u, 127214587484u },
+ { 4683743612465315840u, 6100166970623291280u, 92276012655u },
+ { 0u, 1913011027739012426u, 111330690714u },
+ { 0u, 11310957650604221440u, 154103704535u },
+ { 0u, 16303817257009020928u, 215613168242u },
+ { 0u, 9090406322154766336u, 114883831704u },
+ { 0u, 3003279315069566976u, 152492791914u },
+ { 0u, 16582887146675765248u, 106162808097u },
+ { 0u, 9691746398101307392u, 33898960113u },
+ { 0u, 0u, 241525390625u },
+ { 0u, 0u, 33000000000u },
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+// clang-format on
+
+#endif // _LIBCPP_SRC_INCLUDE_RYU_D2FIXED_FULL_TABLE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/d2s.h b/contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/d2s.h
new file mode 100644
index 0000000000..3d9f10c0f1
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/d2s.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
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (c) Microsoft Corporation.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+// Copyright 2018 Ulf Adams
+// Copyright (c) Microsoft Corporation. All rights reserved.
+
+// Boost Software License - Version 1.0 - August 17th, 2003
+
+// Permission is hereby granted, free of charge, to any person or organization
+// obtaining a copy of the software and accompanying documentation covered by
+// this license (the "Software") to use, reproduce, display, distribute,
+// execute, and transmit the Software, and to prepare derivative works of the
+// Software, and to permit third-parties to whom the Software is furnished to
+// do so, all subject to the following:
+
+// The copyright notices in the Software and this entire statement, including
+// the above license grant, this restriction and the following disclaimer,
+// must be included in all copies of the Software, in whole or in part, and
+// all derivative works of the Software, unless such copies or derivative
+// works are solely in the form of machine-executable object code generated by
+// a source language processor.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#ifndef _LIBCPP_SRC_INCLUDE_RYU_DS2_H
+#define _LIBCPP_SRC_INCLUDE_RYU_DS2_H
+
+// Avoid formatting to keep the changes with the original code minimal.
+// clang-format off
+
+#include <__config>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+inline constexpr int __DOUBLE_MANTISSA_BITS = 52;
+inline constexpr int __DOUBLE_EXPONENT_BITS = 11;
+inline constexpr int __DOUBLE_BIAS = 1023;
+
+inline constexpr int __DOUBLE_POW5_INV_BITCOUNT = 122;
+inline constexpr int __DOUBLE_POW5_BITCOUNT = 121;
+
+[[nodiscard]] to_chars_result __d2s_buffered_n(char* const _First, char* const _Last, const double __f, const chars_format _Fmt);
+
+_LIBCPP_END_NAMESPACE_STD
+
+// clang-format on
+
+#endif // _LIBCPP_SRC_INCLUDE_RYU_DS2_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/d2s_full_table.h b/contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/d2s_full_table.h
new file mode 100644
index 0000000000..96307f6986
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/d2s_full_table.h
@@ -0,0 +1,368 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (c) Microsoft Corporation.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+// Copyright 2018 Ulf Adams
+// Copyright (c) Microsoft Corporation. All rights reserved.
+
+// Boost Software License - Version 1.0 - August 17th, 2003
+
+// Permission is hereby granted, free of charge, to any person or organization
+// obtaining a copy of the software and accompanying documentation covered by
+// this license (the "Software") to use, reproduce, display, distribute,
+// execute, and transmit the Software, and to prepare derivative works of the
+// Software, and to permit third-parties to whom the Software is furnished to
+// do so, all subject to the following:
+
+// The copyright notices in the Software and this entire statement, including
+// the above license grant, this restriction and the following disclaimer,
+// must be included in all copies of the Software, in whole or in part, and
+// all derivative works of the Software, unless such copies or derivative
+// works are solely in the form of machine-executable object code generated by
+// a source language processor.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#ifndef _LIBCPP_SRC_INCLUDE_RYU_D2S_FULL_TABLE_H
+#define _LIBCPP_SRC_INCLUDE_RYU_D2S_FULL_TABLE_H
+
+// Avoid formatting to keep the changes with the original code minimal.
+// clang-format off
+
+#include <__config>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+inline constexpr uint64_t __DOUBLE_POW5_INV_SPLIT[292][2] = {
+ { 1u, 288230376151711744u }, { 3689348814741910324u, 230584300921369395u },
+ { 2951479051793528259u, 184467440737095516u }, { 17118578500402463900u, 147573952589676412u },
+ { 12632330341676300947u, 236118324143482260u }, { 10105864273341040758u, 188894659314785808u },
+ { 15463389048156653253u, 151115727451828646u }, { 17362724847566824558u, 241785163922925834u },
+ { 17579528692795369969u, 193428131138340667u }, { 6684925324752475329u, 154742504910672534u },
+ { 18074578149087781173u, 247588007857076054u }, { 18149011334012135262u, 198070406285660843u },
+ { 3451162622983977240u, 158456325028528675u }, { 5521860196774363583u, 253530120045645880u },
+ { 4417488157419490867u, 202824096036516704u }, { 7223339340677503017u, 162259276829213363u },
+ { 7867994130342094503u, 259614842926741381u }, { 2605046489531765280u, 207691874341393105u },
+ { 2084037191625412224u, 166153499473114484u }, { 10713157136084480204u, 265845599156983174u },
+ { 12259874523609494487u, 212676479325586539u }, { 13497248433629505913u, 170141183460469231u },
+ { 14216899864323388813u, 272225893536750770u }, { 11373519891458711051u, 217780714829400616u },
+ { 5409467098425058518u, 174224571863520493u }, { 4965798542738183305u, 278759314981632789u },
+ { 7661987648932456967u, 223007451985306231u }, { 2440241304404055250u, 178405961588244985u },
+ { 3904386087046488400u, 285449538541191976u }, { 17880904128604832013u, 228359630832953580u },
+ { 14304723302883865611u, 182687704666362864u }, { 15133127457049002812u, 146150163733090291u },
+ { 16834306301794583852u, 233840261972944466u }, { 9778096226693756759u, 187072209578355573u },
+ { 15201174610838826053u, 149657767662684458u }, { 2185786488890659746u, 239452428260295134u },
+ { 5437978005854438120u, 191561942608236107u }, { 15418428848909281466u, 153249554086588885u },
+ { 6222742084545298729u, 245199286538542217u }, { 16046240111861969953u, 196159429230833773u },
+ { 1768945645263844993u, 156927543384667019u }, { 10209010661905972635u, 251084069415467230u },
+ { 8167208529524778108u, 200867255532373784u }, { 10223115638361732810u, 160693804425899027u },
+ { 1599589762411131202u, 257110087081438444u }, { 4969020624670815285u, 205688069665150755u },
+ { 3975216499736652228u, 164550455732120604u }, { 13739044029062464211u, 263280729171392966u },
+ { 7301886408508061046u, 210624583337114373u }, { 13220206756290269483u, 168499666669691498u },
+ { 17462981995322520850u, 269599466671506397u }, { 6591687966774196033u, 215679573337205118u },
+ { 12652048002903177473u, 172543658669764094u }, { 9175230360419352987u, 276069853871622551u },
+ { 3650835473593572067u, 220855883097298041u }, { 17678063637842498946u, 176684706477838432u },
+ { 13527506561580357021u, 282695530364541492u }, { 3443307619780464970u, 226156424291633194u },
+ { 6443994910566282300u, 180925139433306555u }, { 5155195928453025840u, 144740111546645244u },
+ { 15627011115008661990u, 231584178474632390u }, { 12501608892006929592u, 185267342779705912u },
+ { 2622589484121723027u, 148213874223764730u }, { 4196143174594756843u, 237142198758023568u },
+ { 10735612169159626121u, 189713759006418854u }, { 12277838550069611220u, 151771007205135083u },
+ { 15955192865369467629u, 242833611528216133u }, { 1696107848069843133u, 194266889222572907u },
+ { 12424932722681605476u, 155413511378058325u }, { 1433148282581017146u, 248661618204893321u },
+ { 15903913885032455010u, 198929294563914656u }, { 9033782293284053685u, 159143435651131725u },
+ { 14454051669254485895u, 254629497041810760u }, { 11563241335403588716u, 203703597633448608u },
+ { 16629290697806691620u, 162962878106758886u }, { 781423413297334329u, 260740604970814219u },
+ { 4314487545379777786u, 208592483976651375u }, { 3451590036303822229u, 166873987181321100u },
+ { 5522544058086115566u, 266998379490113760u }, { 4418035246468892453u, 213598703592091008u },
+ { 10913125826658934609u, 170878962873672806u }, { 10082303693170474728u, 273406340597876490u },
+ { 8065842954536379782u, 218725072478301192u }, { 17520720807854834795u, 174980057982640953u },
+ { 5897060404116273733u, 279968092772225526u }, { 1028299508551108663u, 223974474217780421u },
+ { 15580034865808528224u, 179179579374224336u }, { 17549358155809824511u, 286687326998758938u },
+ { 2971440080422128639u, 229349861599007151u }, { 17134547323305344204u, 183479889279205720u },
+ { 13707637858644275364u, 146783911423364576u }, { 14553522944347019935u, 234854258277383322u },
+ { 4264120725993795302u, 187883406621906658u }, { 10789994210278856888u, 150306725297525326u },
+ { 9885293106962350374u, 240490760476040522u }, { 529536856086059653u, 192392608380832418u },
+ { 7802327114352668369u, 153914086704665934u }, { 1415676938738538420u, 246262538727465495u },
+ { 1132541550990830736u, 197010030981972396u }, { 15663428499760305882u, 157608024785577916u },
+ { 17682787970132668764u, 252172839656924666u }, { 10456881561364224688u, 201738271725539733u },
+ { 15744202878575200397u, 161390617380431786u }, { 17812026976236499989u, 258224987808690858u },
+ { 3181575136763469022u, 206579990246952687u }, { 13613306553636506187u, 165263992197562149u },
+ { 10713244041592678929u, 264422387516099439u }, { 12259944048016053467u, 211537910012879551u },
+ { 6118606423670932450u, 169230328010303641u }, { 2411072648389671274u, 270768524816485826u },
+ { 16686253377679378312u, 216614819853188660u }, { 13349002702143502650u, 173291855882550928u },
+ { 17669055508687693916u, 277266969412081485u }, { 14135244406950155133u, 221813575529665188u },
+ { 240149081334393137u, 177450860423732151u }, { 11452284974360759988u, 283921376677971441u },
+ { 5472479164746697667u, 227137101342377153u }, { 11756680961281178780u, 181709681073901722u },
+ { 2026647139541122378u, 145367744859121378u }, { 18000030682233437097u, 232588391774594204u },
+ { 18089373360528660001u, 186070713419675363u }, { 3403452244197197031u, 148856570735740291u },
+ { 16513570034941246220u, 238170513177184465u }, { 13210856027952996976u, 190536410541747572u },
+ { 3189987192878576934u, 152429128433398058u }, { 1414630693863812771u, 243886605493436893u },
+ { 8510402184574870864u, 195109284394749514u }, { 10497670562401807014u, 156087427515799611u },
+ { 9417575270359070576u, 249739884025279378u }, { 14912757845771077107u, 199791907220223502u },
+ { 4551508647133041040u, 159833525776178802u }, { 10971762650154775986u, 255733641241886083u },
+ { 16156107749607641435u, 204586912993508866u }, { 9235537384944202825u, 163669530394807093u },
+ { 11087511001168814197u, 261871248631691349u }, { 12559357615676961681u, 209496998905353079u },
+ { 13736834907283479668u, 167597599124282463u }, { 18289587036911657145u, 268156158598851941u },
+ { 10942320814787415393u, 214524926879081553u }, { 16132554281313752961u, 171619941503265242u },
+ { 11054691591134363444u, 274591906405224388u }, { 16222450902391311402u, 219673525124179510u },
+ { 12977960721913049122u, 175738820099343608u }, { 17075388340318968271u, 281182112158949773u },
+ { 2592264228029443648u, 224945689727159819u }, { 5763160197165465241u, 179956551781727855u },
+ { 9221056315464744386u, 287930482850764568u }, { 14755542681855616155u, 230344386280611654u },
+ { 15493782960226403247u, 184275509024489323u }, { 1326979923955391628u, 147420407219591459u },
+ { 9501865507812447252u, 235872651551346334u }, { 11290841220991868125u, 188698121241077067u },
+ { 1653975347309673853u, 150958496992861654u }, { 10025058185179298811u, 241533595188578646u },
+ { 4330697733401528726u, 193226876150862917u }, { 14532604630946953951u, 154581500920690333u },
+ { 1116074521063664381u, 247330401473104534u }, { 4582208431592841828u, 197864321178483627u },
+ { 14733813189500004432u, 158291456942786901u }, { 16195403473716186445u, 253266331108459042u },
+ { 5577625149489128510u, 202613064886767234u }, { 8151448934333213131u, 162090451909413787u },
+ { 16731667109675051333u, 259344723055062059u }, { 17074682502481951390u, 207475778444049647u },
+ { 6281048372501740465u, 165980622755239718u }, { 6360328581260874421u, 265568996408383549u },
+ { 8777611679750609860u, 212455197126706839u }, { 10711438158542398211u, 169964157701365471u },
+ { 9759603424184016492u, 271942652322184754u }, { 11497031554089123517u, 217554121857747803u },
+ { 16576322872755119460u, 174043297486198242u }, { 11764721337440549842u, 278469275977917188u },
+ { 16790474699436260520u, 222775420782333750u }, { 13432379759549008416u, 178220336625867000u },
+ { 3045063541568861850u, 285152538601387201u }, { 17193446092222730773u, 228122030881109760u },
+ { 13754756873778184618u, 182497624704887808u }, { 18382503128506368341u, 145998099763910246u },
+ { 3586563302416817083u, 233596959622256395u }, { 2869250641933453667u, 186877567697805116u },
+ { 17052795772514404226u, 149502054158244092u }, { 12527077977055405469u, 239203286653190548u },
+ { 17400360011128145022u, 191362629322552438u }, { 2852241564676785048u, 153090103458041951u },
+ { 15631632947708587046u, 244944165532867121u }, { 8815957543424959314u, 195955332426293697u },
+ { 18120812478965698421u, 156764265941034957u }, { 14235904707377476180u, 250822825505655932u },
+ { 4010026136418160298u, 200658260404524746u }, { 17965416168102169531u, 160526608323619796u },
+ { 2919224165770098987u, 256842573317791675u }, { 2335379332616079190u, 205474058654233340u },
+ { 1868303466092863352u, 164379246923386672u }, { 6678634360490491686u, 263006795077418675u },
+ { 5342907488392393349u, 210405436061934940u }, { 4274325990713914679u, 168324348849547952u },
+ { 10528270399884173809u, 269318958159276723u }, { 15801313949391159694u, 215455166527421378u },
+ { 1573004715287196786u, 172364133221937103u }, { 17274202803427156150u, 275782613155099364u },
+ { 17508711057483635243u, 220626090524079491u }, { 10317620031244997871u, 176500872419263593u },
+ { 12818843235250086271u, 282401395870821749u }, { 13944423402941979340u, 225921116696657399u },
+ { 14844887537095493795u, 180736893357325919u }, { 15565258844418305359u, 144589514685860735u },
+ { 6457670077359736959u, 231343223497377177u }, { 16234182506113520537u, 185074578797901741u },
+ { 9297997190148906106u, 148059663038321393u }, { 11187446689496339446u, 236895460861314229u },
+ { 12639306166338981880u, 189516368689051383u }, { 17490142562555006151u, 151613094951241106u },
+ { 2158786396894637579u, 242580951921985771u }, { 16484424376483351356u, 194064761537588616u },
+ { 9498190686444770762u, 155251809230070893u }, { 11507756283569722895u, 248402894768113429u },
+ { 12895553841597688639u, 198722315814490743u }, { 17695140702761971558u, 158977852651592594u },
+ { 17244178680193423523u, 254364564242548151u }, { 10105994129412828495u, 203491651394038521u },
+ { 4395446488788352473u, 162793321115230817u }, { 10722063196803274280u, 260469313784369307u },
+ { 1198952927958798777u, 208375451027495446u }, { 15716557601334680315u, 166700360821996356u },
+ { 17767794532651667857u, 266720577315194170u }, { 14214235626121334286u, 213376461852155336u },
+ { 7682039686155157106u, 170701169481724269u }, { 1223217053622520399u, 273121871170758831u },
+ { 15735968901865657612u, 218497496936607064u }, { 16278123936234436413u, 174797997549285651u },
+ { 219556594781725998u, 279676796078857043u }, { 7554342905309201445u, 223741436863085634u },
+ { 9732823138989271479u, 178993149490468507u }, { 815121763415193074u, 286389039184749612u },
+ { 11720143854957885429u, 229111231347799689u }, { 13065463898708218666u, 183288985078239751u },
+ { 6763022304224664610u, 146631188062591801u }, { 3442138057275642729u, 234609900900146882u },
+ { 13821756890046245153u, 187687920720117505u }, { 11057405512036996122u, 150150336576094004u },
+ { 6623802375033462826u, 240240538521750407u }, { 16367088344252501231u, 192192430817400325u },
+ { 13093670675402000985u, 153753944653920260u }, { 2503129006933649959u, 246006311446272417u },
+ { 13070549649772650937u, 196805049157017933u }, { 17835137349301941396u, 157444039325614346u },
+ { 2710778055689733971u, 251910462920982955u }, { 2168622444551787177u, 201528370336786364u },
+ { 5424246770383340065u, 161222696269429091u }, { 1300097203129523457u, 257956314031086546u },
+ { 15797473021471260058u, 206365051224869236u }, { 8948629602435097724u, 165092040979895389u },
+ { 3249760919670425388u, 264147265567832623u }, { 9978506365220160957u, 211317812454266098u },
+ { 15361502721659949412u, 169054249963412878u }, { 2442311466204457120u, 270486799941460606u },
+ { 16711244431931206989u, 216389439953168484u }, { 17058344360286875914u, 173111551962534787u },
+ { 12535955717491360170u, 276978483140055660u }, { 10028764573993088136u, 221582786512044528u },
+ { 15401709288678291155u, 177266229209635622u }, { 9885339602917624555u, 283625966735416996u },
+ { 4218922867592189321u, 226900773388333597u }, { 14443184738299482427u, 181520618710666877u },
+ { 4175850161155765295u, 145216494968533502u }, { 10370709072591134795u, 232346391949653603u },
+ { 15675264887556728482u, 185877113559722882u }, { 5161514280561562140u, 148701690847778306u },
+ { 879725219414678777u, 237922705356445290u }, { 703780175531743021u, 190338164285156232u },
+ { 11631070584651125387u, 152270531428124985u }, { 162968861732249003u, 243632850284999977u },
+ { 11198421533611530172u, 194906280227999981u }, { 5269388412147313814u, 155925024182399985u },
+ { 8431021459435702103u, 249480038691839976u }, { 3055468352806651359u, 199584030953471981u },
+ { 17201769941212962380u, 159667224762777584u }, { 16454785461715008838u, 255467559620444135u },
+ { 13163828369372007071u, 204374047696355308u }, { 17909760324981426303u, 163499238157084246u },
+ { 2830174816776909822u, 261598781051334795u }, { 2264139853421527858u, 209279024841067836u },
+ { 16568707141704863579u, 167423219872854268u }, { 4373838538276319787u, 267877151796566830u },
+ { 3499070830621055830u, 214301721437253464u }, { 6488605479238754987u, 171441377149802771u },
+ { 3003071137298187333u, 274306203439684434u }, { 6091805724580460189u, 219444962751747547u },
+ { 15941491023890099121u, 175555970201398037u }, { 10748990379256517301u, 280889552322236860u },
+ { 8599192303405213841u, 224711641857789488u }, { 14258051472207991719u, 179769313486231590u }
+};
+
+inline constexpr uint64_t __DOUBLE_POW5_SPLIT[326][2] = {
+ { 0u, 72057594037927936u }, { 0u, 90071992547409920u },
+ { 0u, 112589990684262400u }, { 0u, 140737488355328000u },
+ { 0u, 87960930222080000u }, { 0u, 109951162777600000u },
+ { 0u, 137438953472000000u }, { 0u, 85899345920000000u },
+ { 0u, 107374182400000000u }, { 0u, 134217728000000000u },
+ { 0u, 83886080000000000u }, { 0u, 104857600000000000u },
+ { 0u, 131072000000000000u }, { 0u, 81920000000000000u },
+ { 0u, 102400000000000000u }, { 0u, 128000000000000000u },
+ { 0u, 80000000000000000u }, { 0u, 100000000000000000u },
+ { 0u, 125000000000000000u }, { 0u, 78125000000000000u },
+ { 0u, 97656250000000000u }, { 0u, 122070312500000000u },
+ { 0u, 76293945312500000u }, { 0u, 95367431640625000u },
+ { 0u, 119209289550781250u }, { 4611686018427387904u, 74505805969238281u },
+ { 10376293541461622784u, 93132257461547851u }, { 8358680908399640576u, 116415321826934814u },
+ { 612489549322387456u, 72759576141834259u }, { 14600669991935148032u, 90949470177292823u },
+ { 13639151471491547136u, 113686837721616029u }, { 3213881284082270208u, 142108547152020037u },
+ { 4314518811765112832u, 88817841970012523u }, { 781462496279003136u, 111022302462515654u },
+ { 10200200157203529728u, 138777878078144567u }, { 13292654125893287936u, 86736173798840354u },
+ { 7392445620511834112u, 108420217248550443u }, { 4628871007212404736u, 135525271560688054u },
+ { 16728102434789916672u, 84703294725430033u }, { 7075069988205232128u, 105879118406787542u },
+ { 18067209522111315968u, 132348898008484427u }, { 8986162942105878528u, 82718061255302767u },
+ { 6621017659204960256u, 103397576569128459u }, { 3664586055578812416u, 129246970711410574u },
+ { 16125424340018921472u, 80779356694631608u }, { 1710036351314100224u, 100974195868289511u },
+ { 15972603494424788992u, 126217744835361888u }, { 9982877184015493120u, 78886090522101180u },
+ { 12478596480019366400u, 98607613152626475u }, { 10986559581596820096u, 123259516440783094u },
+ { 2254913720070624656u, 77037197775489434u }, { 12042014186943056628u, 96296497219361792u },
+ { 15052517733678820785u, 120370621524202240u }, { 9407823583549262990u, 75231638452626400u },
+ { 11759779479436578738u, 94039548065783000u }, { 14699724349295723422u, 117549435082228750u },
+ { 4575641699882439235u, 73468396926392969u }, { 10331238143280436948u, 91835496157991211u },
+ { 8302361660673158281u, 114794370197489014u }, { 1154580038986672043u, 143492962746861268u },
+ { 9944984561221445835u, 89683101716788292u }, { 12431230701526807293u, 112103877145985365u },
+ { 1703980321626345405u, 140129846432481707u }, { 17205888765512323542u, 87581154020301066u },
+ { 12283988920035628619u, 109476442525376333u }, { 1519928094762372062u, 136845553156720417u },
+ { 12479170105294952299u, 85528470722950260u }, { 15598962631618690374u, 106910588403687825u },
+ { 5663645234241199255u, 133638235504609782u }, { 17374836326682913246u, 83523897190381113u },
+ { 7883487353071477846u, 104404871487976392u }, { 9854359191339347308u, 130506089359970490u },
+ { 10770660513014479971u, 81566305849981556u }, { 13463325641268099964u, 101957882312476945u },
+ { 2994098996302961243u, 127447352890596182u }, { 15706369927971514489u, 79654595556622613u },
+ { 5797904354682229399u, 99568244445778267u }, { 2635694424925398845u, 124460305557222834u },
+ { 6258995034005762182u, 77787690973264271u }, { 3212057774079814824u, 97234613716580339u },
+ { 17850130272881932242u, 121543267145725423u }, { 18073860448192289507u, 75964541966078389u },
+ { 8757267504958198172u, 94955677457597987u }, { 6334898362770359811u, 118694596821997484u },
+ { 13182683513586250689u, 74184123013748427u }, { 11866668373555425458u, 92730153767185534u },
+ { 5609963430089506015u, 115912692208981918u }, { 17341285199088104971u, 72445432630613698u },
+ { 12453234462005355406u, 90556790788267123u }, { 10954857059079306353u, 113195988485333904u },
+ { 13693571323849132942u, 141494985606667380u }, { 17781854114260483896u, 88434366004167112u },
+ { 3780573569116053255u, 110542957505208891u }, { 114030942967678664u, 138178696881511114u },
+ { 4682955357782187069u, 86361685550944446u }, { 15077066234082509644u, 107952106938680557u },
+ { 5011274737320973344u, 134940133673350697u }, { 14661261756894078100u, 84337583545844185u },
+ { 4491519140835433913u, 105421979432305232u }, { 5614398926044292391u, 131777474290381540u },
+ { 12732371365632458552u, 82360921431488462u }, { 6692092170185797382u, 102951151789360578u },
+ { 17588487249587022536u, 128688939736700722u }, { 15604490549419276989u, 80430587335437951u },
+ { 14893927168346708332u, 100538234169297439u }, { 14005722942005997511u, 125672792711621799u },
+ { 15671105866394830300u, 78545495444763624u }, { 1142138259283986260u, 98181869305954531u },
+ { 15262730879387146537u, 122727336632443163u }, { 7233363790403272633u, 76704585395276977u },
+ { 13653390756431478696u, 95880731744096221u }, { 3231680390257184658u, 119850914680120277u },
+ { 4325643253124434363u, 74906821675075173u }, { 10018740084832930858u, 93633527093843966u },
+ { 3300053069186387764u, 117041908867304958u }, { 15897591223523656064u, 73151193042065598u },
+ { 10648616992549794273u, 91438991302581998u }, { 4087399203832467033u, 114298739128227498u },
+ { 14332621041645359599u, 142873423910284372u }, { 18181260187883125557u, 89295889943927732u },
+ { 4279831161144355331u, 111619862429909666u }, { 14573160988285219972u, 139524828037387082u },
+ { 13719911636105650386u, 87203017523366926u }, { 7926517508277287175u, 109003771904208658u },
+ { 684774848491833161u, 136254714880260823u }, { 7345513307948477581u, 85159196800163014u },
+ { 18405263671790372785u, 106448996000203767u }, { 18394893571310578077u, 133061245000254709u },
+ { 13802651491282805250u, 83163278125159193u }, { 3418256308821342851u, 103954097656448992u },
+ { 4272820386026678563u, 129942622070561240u }, { 2670512741266674102u, 81214138794100775u },
+ { 17173198981865506339u, 101517673492625968u }, { 3019754653622331308u, 126897091865782461u },
+ { 4193189667727651020u, 79310682416114038u }, { 14464859121514339583u, 99138353020142547u },
+ { 13469387883465536574u, 123922941275178184u }, { 8418367427165960359u, 77451838296986365u },
+ { 15134645302384838353u, 96814797871232956u }, { 471562554271496325u, 121018497339041196u },
+ { 9518098633274461011u, 75636560836900747u }, { 7285937273165688360u, 94545701046125934u },
+ { 18330793628311886258u, 118182126307657417u }, { 4539216990053847055u, 73863828942285886u },
+ { 14897393274422084627u, 92329786177857357u }, { 4786683537745442072u, 115412232722321697u },
+ { 14520892257159371055u, 72132645451451060u }, { 18151115321449213818u, 90165806814313825u },
+ { 8853836096529353561u, 112707258517892282u }, { 1843923083806916143u, 140884073147365353u },
+ { 12681666973447792349u, 88052545717103345u }, { 2017025661527576725u, 110065682146379182u },
+ { 11744654113764246714u, 137582102682973977u }, { 422879793461572340u, 85988814176858736u },
+ { 528599741826965425u, 107486017721073420u }, { 660749677283706782u, 134357522151341775u },
+ { 7330497575943398595u, 83973451344588609u }, { 13774807988356636147u, 104966814180735761u },
+ { 3383451930163631472u, 131208517725919702u }, { 15949715511634433382u, 82005323578699813u },
+ { 6102086334260878016u, 102506654473374767u }, { 3015921899398709616u, 128133318091718459u },
+ { 18025852251620051174u, 80083323807324036u }, { 4085571240815512351u, 100104154759155046u },
+ { 14330336087874166247u, 125130193448943807u }, { 15873989082562435760u, 78206370905589879u },
+ { 15230800334775656796u, 97757963631987349u }, { 5203442363187407284u, 122197454539984187u },
+ { 946308467778435600u, 76373409087490117u }, { 5794571603150432404u, 95466761359362646u },
+ { 16466586540792816313u, 119333451699203307u }, { 7985773578781816244u, 74583407312002067u },
+ { 5370530955049882401u, 93229259140002584u }, { 6713163693812353001u, 116536573925003230u },
+ { 18030785363914884337u, 72835358703127018u }, { 13315109668038829614u, 91044198378908773u },
+ { 2808829029766373305u, 113805247973635967u }, { 17346094342490130344u, 142256559967044958u },
+ { 6229622945628943561u, 88910349979403099u }, { 3175342663608791547u, 111137937474253874u },
+ { 13192550366365765242u, 138922421842817342u }, { 3633657960551215372u, 86826513651760839u },
+ { 18377130505971182927u, 108533142064701048u }, { 4524669058754427043u, 135666427580876311u },
+ { 9745447189362598758u, 84791517238047694u }, { 2958436949848472639u, 105989396547559618u },
+ { 12921418224165366607u, 132486745684449522u }, { 12687572408530742033u, 82804216052780951u },
+ { 11247779492236039638u, 103505270065976189u }, { 224666310012885835u, 129381587582470237u },
+ { 2446259452971747599u, 80863492239043898u }, { 12281196353069460307u, 101079365298804872u },
+ { 15351495441336825384u, 126349206623506090u }, { 14206370669262903769u, 78968254139691306u },
+ { 8534591299723853903u, 98710317674614133u }, { 15279925143082205283u, 123387897093267666u },
+ { 14161639232853766206u, 77117435683292291u }, { 13090363022639819853u, 96396794604115364u },
+ { 16362953778299774816u, 120495993255144205u }, { 12532689120651053212u, 75309995784465128u },
+ { 15665861400813816515u, 94137494730581410u }, { 10358954714162494836u, 117671868413226763u },
+ { 4168503687137865320u, 73544917758266727u }, { 598943590494943747u, 91931147197833409u },
+ { 5360365506546067587u, 114913933997291761u }, { 11312142901609972388u, 143642417496614701u },
+ { 9375932322719926695u, 89776510935384188u }, { 11719915403399908368u, 112220638669230235u },
+ { 10038208235822497557u, 140275798336537794u }, { 10885566165816448877u, 87672373960336121u },
+ { 18218643725697949000u, 109590467450420151u }, { 18161618638695048346u, 136988084313025189u },
+ { 13656854658398099168u, 85617552695640743u }, { 12459382304570236056u, 107021940869550929u },
+ { 1739169825430631358u, 133777426086938662u }, { 14922039196176308311u, 83610891304336663u },
+ { 14040862976792997485u, 104513614130420829u }, { 3716020665709083144u, 130642017663026037u },
+ { 4628355925281870917u, 81651261039391273u }, { 10397130925029726550u, 102064076299239091u },
+ { 8384727637859770284u, 127580095374048864u }, { 5240454773662356427u, 79737559608780540u },
+ { 6550568467077945534u, 99671949510975675u }, { 3576524565420044014u, 124589936888719594u },
+ { 6847013871814915412u, 77868710555449746u }, { 17782139376623420074u, 97335888194312182u },
+ { 13004302183924499284u, 121669860242890228u }, { 17351060901807587860u, 76043662651806392u },
+ { 3242082053549933210u, 95054578314757991u }, { 17887660622219580224u, 118818222893447488u },
+ { 11179787888887237640u, 74261389308404680u }, { 13974734861109047050u, 92826736635505850u },
+ { 8245046539531533005u, 116033420794382313u }, { 16682369133275677888u, 72520887996488945u },
+ { 7017903361312433648u, 90651109995611182u }, { 17995751238495317868u, 113313887494513977u },
+ { 8659630992836983623u, 141642359368142472u }, { 5412269370523114764u, 88526474605089045u },
+ { 11377022731581281359u, 110658093256361306u }, { 4997906377621825891u, 138322616570451633u },
+ { 14652906532082110942u, 86451635356532270u }, { 9092761128247862869u, 108064544195665338u },
+ { 2142579373455052779u, 135080680244581673u }, { 12868327154477877747u, 84425425152863545u },
+ { 2250350887815183471u, 105531781441079432u }, { 2812938609768979339u, 131914726801349290u },
+ { 6369772649532999991u, 82446704250843306u }, { 17185587848771025797u, 103058380313554132u },
+ { 3035240737254230630u, 128822975391942666u }, { 6508711479211282048u, 80514359619964166u },
+ { 17359261385868878368u, 100642949524955207u }, { 17087390713908710056u, 125803686906194009u },
+ { 3762090168551861929u, 78627304316371256u }, { 4702612710689827411u, 98284130395464070u },
+ { 15101637925217060072u, 122855162994330087u }, { 16356052730901744401u, 76784476871456304u },
+ { 1998321839917628885u, 95980596089320381u }, { 7109588318324424010u, 119975745111650476u },
+ { 13666864735807540814u, 74984840694781547u }, { 12471894901332038114u, 93731050868476934u },
+ { 6366496589810271835u, 117163813585596168u }, { 3979060368631419896u, 73227383490997605u },
+ { 9585511479216662775u, 91534229363747006u }, { 2758517312166052660u, 114417786704683758u },
+ { 12671518677062341634u, 143022233380854697u }, { 1002170145522881665u, 89388895863034186u },
+ { 10476084718758377889u, 111736119828792732u }, { 13095105898447972362u, 139670149785990915u },
+ { 5878598177316288774u, 87293843616244322u }, { 16571619758500136775u, 109117304520305402u },
+ { 11491152661270395161u, 136396630650381753u }, { 264441385652915120u, 85247894156488596u },
+ { 330551732066143900u, 106559867695610745u }, { 5024875683510067779u, 133199834619513431u },
+ { 10058076329834874218u, 83249896637195894u }, { 3349223375438816964u, 104062370796494868u },
+ { 4186529219298521205u, 130077963495618585u }, { 14145795808130045513u, 81298727184761615u },
+ { 13070558741735168987u, 101623408980952019u }, { 11726512408741573330u, 127029261226190024u },
+ { 7329070255463483331u, 79393288266368765u }, { 13773023837756742068u, 99241610332960956u },
+ { 17216279797195927585u, 124052012916201195u }, { 8454331864033760789u, 77532508072625747u },
+ { 5956228811614813082u, 96915635090782184u }, { 7445286014518516353u, 121144543863477730u },
+ { 9264989777501460624u, 75715339914673581u }, { 16192923240304213684u, 94644174893341976u },
+ { 1794409976670715490u, 118305218616677471u }, { 8039035263060279037u, 73940761635423419u },
+ { 5437108060397960892u, 92425952044279274u }, { 16019757112352226923u, 115532440055349092u },
+ { 788976158365366019u, 72207775034593183u }, { 14821278253238871236u, 90259718793241478u },
+ { 9303225779693813237u, 112824648491551848u }, { 11629032224617266546u, 141030810614439810u },
+ { 11879831158813179495u, 88144256634024881u }, { 1014730893234310657u, 110180320792531102u },
+ { 10491785653397664129u, 137725400990663877u }, { 8863209042587234033u, 86078375619164923u },
+ { 6467325284806654637u, 107597969523956154u }, { 17307528642863094104u, 134497461904945192u },
+ { 10817205401789433815u, 84060913690590745u }, { 18133192770664180173u, 105076142113238431u },
+ { 18054804944902837312u, 131345177641548039u }, { 18201782118205355176u, 82090736025967524u },
+ { 4305483574047142354u, 102613420032459406u }, { 14605226504413703751u, 128266775040574257u },
+ { 2210737537617482988u, 80166734400358911u }, { 16598479977304017447u, 100208418000448638u },
+ { 11524727934775246001u, 125260522500560798u }, { 2591268940807140847u, 78287826562850499u },
+ { 17074144231291089770u, 97859783203563123u }, { 16730994270686474309u, 122324729004453904u },
+ { 10456871419179046443u, 76452955627783690u }, { 3847717237119032246u, 95566194534729613u },
+ { 9421332564826178211u, 119457743168412016u }, { 5888332853016361382u, 74661089480257510u },
+ { 16583788103125227536u, 93326361850321887u }, { 16118049110479146516u, 116657952312902359u },
+ { 16991309721690548428u, 72911220195563974u }, { 12015765115258409727u, 91139025244454968u },
+ { 15019706394073012159u, 113923781555568710u }, { 9551260955736489391u, 142404726944460888u },
+ { 5969538097335305869u, 89002954340288055u }, { 2850236603241744433u, 111253692925360069u }
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+// clang-format on
+
+#endif // _LIBCPP_SRC_INCLUDE_RYU_D2S_FULL_TABLE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/d2s_intrinsics.h b/contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/d2s_intrinsics.h
new file mode 100644
index 0000000000..762763f9b9
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/d2s_intrinsics.h
@@ -0,0 +1,260 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (c) Microsoft Corporation.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+// Copyright 2018 Ulf Adams
+// Copyright (c) Microsoft Corporation. All rights reserved.
+
+// Boost Software License - Version 1.0 - August 17th, 2003
+
+// Permission is hereby granted, free of charge, to any person or organization
+// obtaining a copy of the software and accompanying documentation covered by
+// this license (the "Software") to use, reproduce, display, distribute,
+// execute, and transmit the Software, and to prepare derivative works of the
+// Software, and to permit third-parties to whom the Software is furnished to
+// do so, all subject to the following:
+
+// The copyright notices in the Software and this entire statement, including
+// the above license grant, this restriction and the following disclaimer,
+// must be included in all copies of the Software, in whole or in part, and
+// all derivative works of the Software, unless such copies or derivative
+// works are solely in the form of machine-executable object code generated by
+// a source language processor.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#ifndef _LIBCPP_SRC_INCLUDE_RYU_DS2_INTRINSICS_H
+#define _LIBCPP_SRC_INCLUDE_RYU_DS2_INTRINSICS_H
+
+// Avoid formatting to keep the changes with the original code minimal.
+// clang-format off
+
+#include <__assert>
+#include <__config>
+
+#include "include/ryu/ryu.h"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if defined(_M_X64) && defined(_MSC_VER)
+#define _LIBCPP_INTRINSIC128 1
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __ryu_umul128(const uint64_t __a, const uint64_t __b, uint64_t* const __productHi) {
+ return _umul128(__a, __b, __productHi);
+}
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __ryu_shiftright128(const uint64_t __lo, const uint64_t __hi, const uint32_t __dist) {
+ // For the __shiftright128 intrinsic, the shift value is always
+ // modulo 64.
+ // In the current implementation of the double-precision version
+ // of Ryu, the shift value is always < 64.
+ // (The shift value is in the range [49, 58].)
+ // Check this here in case a future change requires larger shift
+ // values. In this case this function needs to be adjusted.
+ _LIBCPP_ASSERT(__dist < 64, "");
+ return __shiftright128(__lo, __hi, static_cast<unsigned char>(__dist));
+}
+
+// ^^^ intrinsics available ^^^ / vvv __int128 available vvv
+#elif defined(__SIZEOF_INT128__) && ( \
+ (defined(__clang__) && !defined(_MSC_VER)) || \
+ (defined(__GNUC__) && !defined(__clang__) && !defined(__CUDACC__)))
+#define _LIBCPP_INTRINSIC128 1
+ // We have __uint128 support in clang or gcc
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __ryu_umul128(const uint64_t __a, const uint64_t __b, uint64_t* const __productHi) {
+ auto __temp = __a * (unsigned __int128)__b;
+ *__productHi = __temp >> 64;
+ return static_cast<uint64_t>(__temp);
+}
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __ryu_shiftright128(const uint64_t __lo, const uint64_t __hi, const uint32_t __dist) {
+ // In the current implementation of the double-precision version
+ // of Ryu, the shift value is always < 64.
+ // (The shift value is in the range [49, 58].)
+ // Check this here in case a future change requires larger shift
+ // values. In this case this function needs to be adjusted.
+ _LIBCPP_ASSERT(__dist < 64, "");
+ auto __temp = __lo | ((unsigned __int128)__hi << 64);
+ // For x64 128-bit shfits using the `shrd` instruction and two 64-bit
+ // registers, the shift value is modulo 64. Thus the `& 63` is free.
+ return static_cast<uint64_t>(__temp >> (__dist & 63));
+}
+#else // ^^^ __int128 available ^^^ / vvv intrinsics unavailable vvv
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline _LIBCPP_ALWAYS_INLINE uint64_t __ryu_umul128(const uint64_t __a, const uint64_t __b, uint64_t* const __productHi) {
+ // TRANSITION, VSO-634761
+ // The casts here help MSVC to avoid calls to the __allmul library function.
+ const uint32_t __aLo = static_cast<uint32_t>(__a);
+ const uint32_t __aHi = static_cast<uint32_t>(__a >> 32);
+ const uint32_t __bLo = static_cast<uint32_t>(__b);
+ const uint32_t __bHi = static_cast<uint32_t>(__b >> 32);
+
+ const uint64_t __b00 = static_cast<uint64_t>(__aLo) * __bLo;
+ const uint64_t __b01 = static_cast<uint64_t>(__aLo) * __bHi;
+ const uint64_t __b10 = static_cast<uint64_t>(__aHi) * __bLo;
+ const uint64_t __b11 = static_cast<uint64_t>(__aHi) * __bHi;
+
+ const uint32_t __b00Lo = static_cast<uint32_t>(__b00);
+ const uint32_t __b00Hi = static_cast<uint32_t>(__b00 >> 32);
+
+ const uint64_t __mid1 = __b10 + __b00Hi;
+ const uint32_t __mid1Lo = static_cast<uint32_t>(__mid1);
+ const uint32_t __mid1Hi = static_cast<uint32_t>(__mid1 >> 32);
+
+ const uint64_t __mid2 = __b01 + __mid1Lo;
+ const uint32_t __mid2Lo = static_cast<uint32_t>(__mid2);
+ const uint32_t __mid2Hi = static_cast<uint32_t>(__mid2 >> 32);
+
+ const uint64_t __pHi = __b11 + __mid1Hi + __mid2Hi;
+ const uint64_t __pLo = (static_cast<uint64_t>(__mid2Lo) << 32) | __b00Lo;
+
+ *__productHi = __pHi;
+ return __pLo;
+}
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __ryu_shiftright128(const uint64_t __lo, const uint64_t __hi, const uint32_t __dist) {
+ // We don't need to handle the case __dist >= 64 here (see above).
+ _LIBCPP_ASSERT(__dist < 64, "");
+#ifdef _LIBCPP_64_BIT
+ _LIBCPP_ASSERT(__dist > 0, "");
+ return (__hi << (64 - __dist)) | (__lo >> __dist);
+#else // ^^^ 64-bit ^^^ / vvv 32-bit vvv
+ // Avoid a 64-bit shift by taking advantage of the range of shift values.
+ _LIBCPP_ASSERT(__dist >= 32, "");
+ return (__hi << (64 - __dist)) | (static_cast<uint32_t>(__lo >> 32) >> (__dist - 32));
+#endif // ^^^ 32-bit ^^^
+}
+
+#endif // ^^^ intrinsics unavailable ^^^
+
+#ifndef _LIBCPP_64_BIT
+
+// Returns the high 64 bits of the 128-bit product of __a and __b.
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __umulh(const uint64_t __a, const uint64_t __b) {
+ // Reuse the __ryu_umul128 implementation.
+ // Optimizers will likely eliminate the instructions used to compute the
+ // low part of the product.
+ uint64_t __hi;
+ (void) __ryu_umul128(__a, __b, &__hi);
+ return __hi;
+}
+
+// On 32-bit platforms, compilers typically generate calls to library
+// functions for 64-bit divisions, even if the divisor is a constant.
+//
+// TRANSITION, LLVM-37932
+//
+// The functions here perform division-by-constant using multiplications
+// in the same way as 64-bit compilers would do.
+//
+// NB:
+// The multipliers and shift values are the ones generated by clang x64
+// for expressions like x/5, x/10, etc.
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __div5(const uint64_t __x) {
+ return __umulh(__x, 0xCCCCCCCCCCCCCCCDu) >> 2;
+}
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __div10(const uint64_t __x) {
+ return __umulh(__x, 0xCCCCCCCCCCCCCCCDu) >> 3;
+}
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __div100(const uint64_t __x) {
+ return __umulh(__x >> 2, 0x28F5C28F5C28F5C3u) >> 2;
+}
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __div1e8(const uint64_t __x) {
+ return __umulh(__x, 0xABCC77118461CEFDu) >> 26;
+}
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __div1e9(const uint64_t __x) {
+ return __umulh(__x >> 9, 0x44B82FA09B5A53u) >> 11;
+}
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __mod1e9(const uint64_t __x) {
+ // Avoid 64-bit math as much as possible.
+ // Returning static_cast<uint32_t>(__x - 1000000000 * __div1e9(__x)) would
+ // perform 32x64-bit multiplication and 64-bit subtraction.
+ // __x and 1000000000 * __div1e9(__x) are guaranteed to differ by
+ // less than 10^9, so their highest 32 bits must be identical,
+ // so we can truncate both sides to uint32_t before subtracting.
+ // We can also simplify static_cast<uint32_t>(1000000000 * __div1e9(__x)).
+ // We can truncate before multiplying instead of after, as multiplying
+ // the highest 32 bits of __div1e9(__x) can't affect the lowest 32 bits.
+ return static_cast<uint32_t>(__x) - 1000000000 * static_cast<uint32_t>(__div1e9(__x));
+}
+
+#else // ^^^ 32-bit ^^^ / vvv 64-bit vvv
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __div5(const uint64_t __x) {
+ return __x / 5;
+}
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __div10(const uint64_t __x) {
+ return __x / 10;
+}
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __div100(const uint64_t __x) {
+ return __x / 100;
+}
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __div1e8(const uint64_t __x) {
+ return __x / 100000000;
+}
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __div1e9(const uint64_t __x) {
+ return __x / 1000000000;
+}
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __mod1e9(const uint64_t __x) {
+ return static_cast<uint32_t>(__x - 1000000000 * __div1e9(__x));
+}
+
+#endif // ^^^ 64-bit ^^^
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __pow5Factor(uint64_t __value) {
+ uint32_t __count = 0;
+ for (;;) {
+ _LIBCPP_ASSERT(__value != 0, "");
+ const uint64_t __q = __div5(__value);
+ const uint32_t __r = static_cast<uint32_t>(__value) - 5 * static_cast<uint32_t>(__q);
+ if (__r != 0) {
+ break;
+ }
+ __value = __q;
+ ++__count;
+ }
+ return __count;
+}
+
+// Returns true if __value is divisible by 5^__p.
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline bool __multipleOfPowerOf5(const uint64_t __value, const uint32_t __p) {
+ // I tried a case distinction on __p, but there was no performance difference.
+ return __pow5Factor(__value) >= __p;
+}
+
+// Returns true if __value is divisible by 2^__p.
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline bool __multipleOfPowerOf2(const uint64_t __value, const uint32_t __p) {
+ _LIBCPP_ASSERT(__value != 0, "");
+ _LIBCPP_ASSERT(__p < 64, "");
+ // __builtin_ctzll doesn't appear to be faster here.
+ return (__value & ((1ull << __p) - 1)) == 0;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+// clang-format on
+
+#endif // _LIBCPP_SRC_INCLUDE_RYU_DS2_INTRINSICS_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/digit_table.h b/contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/digit_table.h
new file mode 100644
index 0000000000..e4ee94ce26
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/digit_table.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
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (c) Microsoft Corporation.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+// Copyright 2018 Ulf Adams
+// Copyright (c) Microsoft Corporation. All rights reserved.
+
+// Boost Software License - Version 1.0 - August 17th, 2003
+
+// Permission is hereby granted, free of charge, to any person or organization
+// obtaining a copy of the software and accompanying documentation covered by
+// this license (the "Software") to use, reproduce, display, distribute,
+// execute, and transmit the Software, and to prepare derivative works of the
+// Software, and to permit third-parties to whom the Software is furnished to
+// do so, all subject to the following:
+
+// The copyright notices in the Software and this entire statement, including
+// the above license grant, this restriction and the following disclaimer,
+// must be included in all copies of the Software, in whole or in part, and
+// all derivative works of the Software, unless such copies or derivative
+// works are solely in the form of machine-executable object code generated by
+// a source language processor.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#ifndef _LIBCPP_SRC_INCLUDE_RYU_DIGIT_TABLE_H
+#define _LIBCPP_SRC_INCLUDE_RYU_DIGIT_TABLE_H
+
+// Avoid formatting to keep the changes with the original code minimal.
+// clang-format off
+
+#include <__config>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// A table of all two-digit numbers. This is used to speed up decimal digit
+// generation by copying pairs of digits into the final output.
+inline constexpr char __DIGIT_TABLE[200] = {
+ '0','0','0','1','0','2','0','3','0','4','0','5','0','6','0','7','0','8','0','9',
+ '1','0','1','1','1','2','1','3','1','4','1','5','1','6','1','7','1','8','1','9',
+ '2','0','2','1','2','2','2','3','2','4','2','5','2','6','2','7','2','8','2','9',
+ '3','0','3','1','3','2','3','3','3','4','3','5','3','6','3','7','3','8','3','9',
+ '4','0','4','1','4','2','4','3','4','4','4','5','4','6','4','7','4','8','4','9',
+ '5','0','5','1','5','2','5','3','5','4','5','5','5','6','5','7','5','8','5','9',
+ '6','0','6','1','6','2','6','3','6','4','6','5','6','6','6','7','6','8','6','9',
+ '7','0','7','1','7','2','7','3','7','4','7','5','7','6','7','7','7','8','7','9',
+ '8','0','8','1','8','2','8','3','8','4','8','5','8','6','8','7','8','8','8','9',
+ '9','0','9','1','9','2','9','3','9','4','9','5','9','6','9','7','9','8','9','9'
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+// clang-format on
+
+#endif // _LIBCPP_SRC_INCLUDE_RYU_DIGIT_TABLE_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/f2s.h b/contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/f2s.h
new file mode 100644
index 0000000000..be304c2f9c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/f2s.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
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (c) Microsoft Corporation.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+// Copyright 2018 Ulf Adams
+// Copyright (c) Microsoft Corporation. All rights reserved.
+
+// Boost Software License - Version 1.0 - August 17th, 2003
+
+// Permission is hereby granted, free of charge, to any person or organization
+// obtaining a copy of the software and accompanying documentation covered by
+// this license (the "Software") to use, reproduce, display, distribute,
+// execute, and transmit the Software, and to prepare derivative works of the
+// Software, and to permit third-parties to whom the Software is furnished to
+// do so, all subject to the following:
+
+// The copyright notices in the Software and this entire statement, including
+// the above license grant, this restriction and the following disclaimer,
+// must be included in all copies of the Software, in whole or in part, and
+// all derivative works of the Software, unless such copies or derivative
+// works are solely in the form of machine-executable object code generated by
+// a source language processor.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#ifndef _LIBCPP_SRC_INCLUDE_RYU_FS2_H
+#define _LIBCPP_SRC_INCLUDE_RYU_FS2_H
+
+// Avoid formatting to keep the changes with the original code minimal.
+// clang-format off
+
+#include <__config>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+[[nodiscard]] to_chars_result __f2s_buffered_n(char* const _First, char* const _Last, const float __f, const chars_format _Fmt);
+
+_LIBCPP_END_NAMESPACE_STD
+
+// clang-format on
+
+#endif // _LIBCPP_SRC_INCLUDE_RYU_FS2_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/ryu.h b/contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/ryu.h
new file mode 100644
index 0000000000..cb44bd3fef
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/include/ryu/ryu.h
@@ -0,0 +1,149 @@
+// -*- 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
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (c) Microsoft Corporation.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+
+// Copyright 2018 Ulf Adams
+// Copyright (c) Microsoft Corporation. All rights reserved.
+
+// Boost Software License - Version 1.0 - August 17th, 2003
+
+// Permission is hereby granted, free of charge, to any person or organization
+// obtaining a copy of the software and accompanying documentation covered by
+// this license (the "Software") to use, reproduce, display, distribute,
+// execute, and transmit the Software, and to prepare derivative works of the
+// Software, and to permit third-parties to whom the Software is furnished to
+// do so, all subject to the following:
+
+// The copyright notices in the Software and this entire statement, including
+// the above license grant, this restriction and the following disclaimer,
+// must be included in all copies of the Software, in whole or in part, and
+// all derivative works of the Software, unless such copies or derivative
+// works are solely in the form of machine-executable object code generated by
+// a source language processor.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#ifndef _LIBCPP_SRC_INCLUDE_RYU_RYU_H
+#define _LIBCPP_SRC_INCLUDE_RYU_RYU_H
+
+// Avoid formatting to keep the changes with the original code minimal.
+// clang-format off
+
+#include <__charconv/chars_format.h>
+#include <__charconv/to_chars_result.h>
+#include <__config>
+#include <__debug>
+#include <__errc>
+#include <cstdint>
+#include <cstring>
+#include <type_traits>
+
+#include "include/ryu/f2s.h"
+#include "include/ryu/d2s.h"
+#include "include/ryu/d2fixed.h"
+
+#if defined(_MSC_VER)
+#include <intrin.h> // for _umul128(), __shiftright128(), _BitScanForward{,64}
+#endif // defined(_MSC_VER)
+
+#if defined(_WIN64) || defined(_M_AMD64) || defined(__x86_64__) || defined(__aarch64__)
+#define _LIBCPP_64_BIT
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// https://github.com/ulfjack/ryu/tree/59661c3/ryu
+
+#if !defined(_MSC_VER)
+_LIBCPP_HIDE_FROM_ABI inline unsigned char _BitScanForward64(unsigned long* __index, unsigned long long __mask) {
+ if (__mask == 0) {
+ return false;
+ }
+ *__index = __builtin_ctzll(__mask);
+ return true;
+}
+
+_LIBCPP_HIDE_FROM_ABI inline unsigned char _BitScanForward(unsigned long* __index, unsigned int __mask) {
+ if (__mask == 0) {
+ return false;
+ }
+ *__index = __builtin_ctz(__mask);
+ return true;
+}
+#endif // !_MSC_VER
+
+template <class _Floating>
+[[nodiscard]] to_chars_result _Floating_to_chars_ryu(
+ char* const _First, char* const _Last, const _Floating _Value, const chars_format _Fmt) noexcept {
+ if constexpr (_IsSame<_Floating, float>::value) {
+ return __f2s_buffered_n(_First, _Last, _Value, _Fmt);
+ } else {
+ return __d2s_buffered_n(_First, _Last, _Value, _Fmt);
+ }
+}
+
+template <class _Floating>
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI to_chars_result _Floating_to_chars_scientific_precision(
+ char* const _First, char* const _Last, const _Floating _Value, int _Precision) noexcept {
+
+ // C11 7.21.6.1 "The fprintf function"/5:
+ // "A negative precision argument is taken as if the precision were omitted."
+ // /8: "e,E [...] if the precision is missing, it is taken as 6"
+
+ if (_Precision < 0) {
+ _Precision = 6;
+ } else if (_Precision < 1'000'000'000) { // Match ' to fix compilation with GCC in C++11 mode
+ // _Precision is ok.
+ } else {
+ // Avoid integer overflow.
+ // (This defensive check is slightly nonconformant; it can be carefully improved in the future.)
+ return {_Last, errc::value_too_large};
+ }
+
+ return __d2exp_buffered_n(_First, _Last, _Value, static_cast<uint32_t>(_Precision));
+}
+
+template <class _Floating>
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI to_chars_result _Floating_to_chars_fixed_precision(
+ char* const _First, char* const _Last, const _Floating _Value, int _Precision) noexcept {
+
+ // C11 7.21.6.1 "The fprintf function"/5:
+ // "A negative precision argument is taken as if the precision were omitted."
+ // /8: "f,F [...] If the precision is missing, it is taken as 6"
+
+ if (_Precision < 0) {
+ _Precision = 6;
+ } else if (_Precision < 1'000'000'000) { // Match ' to fix compilation with GCC in C++11 mode
+ // _Precision is ok.
+ } else {
+ // Avoid integer overflow.
+ // (This defensive check is slightly nonconformant; it can be carefully improved in the future.)
+ return {_Last, errc::value_too_large};
+ }
+
+ return __d2fixed_buffered_n(_First, _Last, _Value, static_cast<uint32_t>(_Precision));
+}
+
+#undef _LIBCPP_64_BIT
+#undef _LIBCPP_INTRINSIC128
+
+_LIBCPP_END_NAMESPACE_STD
+
+// clang-format on
+
+#endif // _LIBCPP_SRC_INCLUDE_RYU_RYU_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/include/sso_allocator.h b/contrib/libs/cxxsupp/libcxxmsvc/src/include/sso_allocator.h
new file mode 100644
index 0000000000..2baf599c5c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/include/sso_allocator.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_SSO_ALLOCATOR_H
+#define _LIBCPP_SSO_ALLOCATOR_H
+
+#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==(const __sso_allocator& __a) const {return &buf_ == &__a.buf_;}
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(const __sso_allocator& __a) const {return &buf_ != &__a.buf_;}
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_SSO_ALLOCATOR_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/include/to_chars_floating_point.h b/contrib/libs/cxxsupp/libcxxmsvc/src/include/to_chars_floating_point.h
new file mode 100644
index 0000000000..0bb45d0b97
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/include/to_chars_floating_point.h
@@ -0,0 +1,1078 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (c) Microsoft Corporation.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+// This implementation is dedicated to the memory of Mary and Thavatchai.
+
+#ifndef _LIBCPP_SRC_INCLUDE_TO_CHARS_FLOATING_POINT_H
+#define _LIBCPP_SRC_INCLUDE_TO_CHARS_FLOATING_POINT_H
+
+// Avoid formatting to keep the changes with the original code minimal.
+// clang-format off
+
+#include <__algorithm/find.h>
+#include <__algorithm/find_if.h>
+#include <__algorithm/lower_bound.h>
+#include <__algorithm/min.h>
+#include <__assert>
+#include <__config>
+#include <__iterator/access.h>
+#include <__iterator/size.h>
+#include <bit>
+#include <cfloat>
+#include <climits>
+
+#include "include/ryu/ryu.h"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace __itoa {
+inline constexpr char _Charconv_digits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e',
+ 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
+static_assert(_VSTD::size(_Charconv_digits) == 36);
+} // __itoa
+
+// vvvvvvvvvv DERIVED FROM corecrt_internal_fltintrn.h vvvvvvvvvv
+
+template <class _FloatingType>
+struct _Floating_type_traits;
+
+template <>
+struct _Floating_type_traits<float> {
+ static constexpr int32_t _Mantissa_bits = FLT_MANT_DIG;
+ static constexpr int32_t _Exponent_bits = sizeof(float) * CHAR_BIT - FLT_MANT_DIG;
+
+ static constexpr int32_t _Maximum_binary_exponent = FLT_MAX_EXP - 1;
+ static constexpr int32_t _Minimum_binary_exponent = FLT_MIN_EXP - 1;
+
+ static constexpr int32_t _Exponent_bias = 127;
+
+ static constexpr int32_t _Sign_shift = _Exponent_bits + _Mantissa_bits - 1;
+ static constexpr int32_t _Exponent_shift = _Mantissa_bits - 1;
+
+ using _Uint_type = uint32_t;
+
+ static constexpr uint32_t _Exponent_mask = (1u << _Exponent_bits) - 1;
+ static constexpr uint32_t _Normal_mantissa_mask = (1u << _Mantissa_bits) - 1;
+ static constexpr uint32_t _Denormal_mantissa_mask = (1u << (_Mantissa_bits - 1)) - 1;
+ static constexpr uint32_t _Special_nan_mantissa_mask = 1u << (_Mantissa_bits - 2);
+ static constexpr uint32_t _Shifted_sign_mask = 1u << _Sign_shift;
+ static constexpr uint32_t _Shifted_exponent_mask = _Exponent_mask << _Exponent_shift;
+};
+
+template <>
+struct _Floating_type_traits<double> {
+ static constexpr int32_t _Mantissa_bits = DBL_MANT_DIG;
+ static constexpr int32_t _Exponent_bits = sizeof(double) * CHAR_BIT - DBL_MANT_DIG;
+
+ static constexpr int32_t _Maximum_binary_exponent = DBL_MAX_EXP - 1;
+ static constexpr int32_t _Minimum_binary_exponent = DBL_MIN_EXP - 1;
+
+ static constexpr int32_t _Exponent_bias = 1023;
+
+ static constexpr int32_t _Sign_shift = _Exponent_bits + _Mantissa_bits - 1;
+ static constexpr int32_t _Exponent_shift = _Mantissa_bits - 1;
+
+ using _Uint_type = uint64_t;
+
+ static constexpr uint64_t _Exponent_mask = (1ULL << _Exponent_bits) - 1;
+ static constexpr uint64_t _Normal_mantissa_mask = (1ULL << _Mantissa_bits) - 1;
+ static constexpr uint64_t _Denormal_mantissa_mask = (1ULL << (_Mantissa_bits - 1)) - 1;
+ static constexpr uint64_t _Special_nan_mantissa_mask = 1ULL << (_Mantissa_bits - 2);
+ static constexpr uint64_t _Shifted_sign_mask = 1ULL << _Sign_shift;
+ static constexpr uint64_t _Shifted_exponent_mask = _Exponent_mask << _Exponent_shift;
+};
+
+// ^^^^^^^^^^ DERIVED FROM corecrt_internal_fltintrn.h ^^^^^^^^^^
+
+// FUNCTION to_chars (FLOATING-POINT TO STRING)
+template <class _Floating>
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+to_chars_result _Floating_to_chars_hex_precision(
+ char* _First, char* const _Last, const _Floating _Value, int _Precision) noexcept {
+
+ // * Determine the effective _Precision.
+ // * Later, we'll decrement _Precision when printing each hexit after the decimal point.
+
+ // The hexits after the decimal point correspond to the explicitly stored fraction bits.
+ // float explicitly stores 23 fraction bits. 23 / 4 == 5.75, which is 6 hexits.
+ // double explicitly stores 52 fraction bits. 52 / 4 == 13, which is 13 hexits.
+ constexpr int _Full_precision = _IsSame<_Floating, float>::value ? 6 : 13;
+ constexpr int _Adjusted_explicit_bits = _Full_precision * 4;
+
+ if (_Precision < 0) {
+ // C11 7.21.6.1 "The fprintf function"/5: "A negative precision argument is taken as if the precision were
+ // omitted." /8: "if the precision is missing and FLT_RADIX is a power of 2, then the precision is sufficient
+ // for an exact representation of the value"
+ _Precision = _Full_precision;
+ }
+
+ // * Extract the _Ieee_mantissa and _Ieee_exponent.
+ using _Traits = _Floating_type_traits<_Floating>;
+ using _Uint_type = typename _Traits::_Uint_type;
+
+ const _Uint_type _Uint_value = _VSTD::bit_cast<_Uint_type>(_Value);
+ const _Uint_type _Ieee_mantissa = _Uint_value & _Traits::_Denormal_mantissa_mask;
+ const int32_t _Ieee_exponent = static_cast<int32_t>(_Uint_value >> _Traits::_Exponent_shift);
+
+ // * Prepare the _Adjusted_mantissa. This is aligned to hexit boundaries,
+ // * with the implicit bit restored (0 for zero values and subnormal values, 1 for normal values).
+ // * Also calculate the _Unbiased_exponent. This unifies the processing of zero, subnormal, and normal values.
+ _Uint_type _Adjusted_mantissa;
+
+ if constexpr (_IsSame<_Floating, float>::value) {
+ _Adjusted_mantissa = _Ieee_mantissa << 1; // align to hexit boundary (23 isn't divisible by 4)
+ } else {
+ _Adjusted_mantissa = _Ieee_mantissa; // already aligned (52 is divisible by 4)
+ }
+
+ int32_t _Unbiased_exponent;
+
+ if (_Ieee_exponent == 0) { // zero or subnormal
+ // implicit bit is 0
+
+ if (_Ieee_mantissa == 0) { // zero
+ // C11 7.21.6.1 "The fprintf function"/8: "If the value is zero, the exponent is zero."
+ _Unbiased_exponent = 0;
+ } else { // subnormal
+ _Unbiased_exponent = 1 - _Traits::_Exponent_bias;
+ }
+ } else { // normal
+ _Adjusted_mantissa |= _Uint_type{1} << _Adjusted_explicit_bits; // implicit bit is 1
+ _Unbiased_exponent = _Ieee_exponent - _Traits::_Exponent_bias;
+ }
+
+ // _Unbiased_exponent is within [-126, 127] for float, [-1022, 1023] for double.
+
+ // * Decompose _Unbiased_exponent into _Sign_character and _Absolute_exponent.
+ char _Sign_character;
+ uint32_t _Absolute_exponent;
+
+ if (_Unbiased_exponent < 0) {
+ _Sign_character = '-';
+ _Absolute_exponent = static_cast<uint32_t>(-_Unbiased_exponent);
+ } else {
+ _Sign_character = '+';
+ _Absolute_exponent = static_cast<uint32_t>(_Unbiased_exponent);
+ }
+
+ // _Absolute_exponent is within [0, 127] for float, [0, 1023] for double.
+
+ // * Perform a single bounds check.
+ {
+ int32_t _Exponent_length;
+
+ if (_Absolute_exponent < 10) {
+ _Exponent_length = 1;
+ } else if (_Absolute_exponent < 100) {
+ _Exponent_length = 2;
+ } else if constexpr (_IsSame<_Floating, float>::value) {
+ _Exponent_length = 3;
+ } else if (_Absolute_exponent < 1000) {
+ _Exponent_length = 3;
+ } else {
+ _Exponent_length = 4;
+ }
+
+ // _Precision might be enormous; avoid integer overflow by testing it separately.
+ ptrdiff_t _Buffer_size = _Last - _First;
+
+ if (_Buffer_size < _Precision) {
+ return {_Last, errc::value_too_large};
+ }
+
+ _Buffer_size -= _Precision;
+
+ const int32_t _Length_excluding_precision = 1 // leading hexit
+ + static_cast<int32_t>(_Precision > 0) // possible decimal point
+ // excluding `+ _Precision`, hexits after decimal point
+ + 2 // "p+" or "p-"
+ + _Exponent_length; // exponent
+
+ if (_Buffer_size < _Length_excluding_precision) {
+ return {_Last, errc::value_too_large};
+ }
+ }
+
+ // * Perform rounding when we've been asked to omit hexits.
+ if (_Precision < _Full_precision) {
+ // _Precision is within [0, 5] for float, [0, 12] for double.
+
+ // _Dropped_bits is within [4, 24] for float, [4, 52] for double.
+ const int _Dropped_bits = (_Full_precision - _Precision) * 4;
+
+ // Perform rounding by adding an appropriately-shifted bit.
+
+ // This can propagate carries all the way into the leading hexit. Examples:
+ // "0.ff9" rounded to a precision of 2 is "1.00".
+ // "1.ff9" rounded to a precision of 2 is "2.00".
+
+ // Note that the leading hexit participates in the rounding decision. Examples:
+ // "0.8" rounded to a precision of 0 is "0".
+ // "1.8" rounded to a precision of 0 is "2".
+
+ // Reference implementation with suboptimal codegen:
+ // bool _Should_round_up(bool _Lsb_bit, bool _Round_bit, bool _Has_tail_bits) {
+ // // If there are no insignificant set bits, the value is exactly-representable and should not be rounded.
+ // //
+ // // If there are insignificant set bits, we need to round according to round_to_nearest.
+ // // We need to handle two cases: we round up if either [1] the value is slightly greater
+ // // than the midpoint between two exactly-representable values or [2] the value is exactly the midpoint
+ // // between two exactly-representable values and the greater of the two is even (this is "round-to-even").
+ // return _Round_bit && (_Has_tail_bits || _Lsb_bit);
+ //}
+ // const bool _Lsb_bit = (_Adjusted_mantissa & (_Uint_type{1} << _Dropped_bits)) != 0;
+ // const bool _Round_bit = (_Adjusted_mantissa & (_Uint_type{1} << (_Dropped_bits - 1))) != 0;
+ // const bool _Has_tail_bits = (_Adjusted_mantissa & ((_Uint_type{1} << (_Dropped_bits - 1)) - 1)) != 0;
+ // const bool _Should_round = _Should_round_up(_Lsb_bit, _Round_bit, _Has_tail_bits);
+ // _Adjusted_mantissa += _Uint_type{_Should_round} << _Dropped_bits;
+
+ // Example for optimized implementation: Let _Dropped_bits be 8.
+ // Bit index: ...[8]76543210
+ // _Adjusted_mantissa: ...[L]RTTTTTTT (not depicting known details, like hexit alignment)
+ // By focusing on the bit at index _Dropped_bits, we can avoid unnecessary branching and shifting.
+
+ // Bit index: ...[8]76543210
+ // _Lsb_bit: ...[L]RTTTTTTT
+ const _Uint_type _Lsb_bit = _Adjusted_mantissa;
+
+ // Bit index: ...9[8]76543210
+ // _Round_bit: ...L[R]TTTTTTT0
+ const _Uint_type _Round_bit = _Adjusted_mantissa << 1;
+
+ // We can detect (without branching) whether any of the trailing bits are set.
+ // Due to _Should_round below, this computation will be used if and only if R is 1, so we can assume that here.
+ // Bit index: ...9[8]76543210
+ // _Round_bit: ...L[1]TTTTTTT0
+ // _Has_tail_bits: ....[H]........
+
+ // If all of the trailing bits T are 0, then `_Round_bit - 1` will produce 0 for H (due to R being 1).
+ // If any of the trailing bits T are 1, then `_Round_bit - 1` will produce 1 for H (due to R being 1).
+ const _Uint_type _Has_tail_bits = _Round_bit - 1;
+
+ // Finally, we can use _Should_round_up() logic with bitwise-AND and bitwise-OR,
+ // selecting just the bit at index _Dropped_bits. This is the appropriately-shifted bit that we want.
+ const _Uint_type _Should_round = _Round_bit & (_Has_tail_bits | _Lsb_bit) & (_Uint_type{1} << _Dropped_bits);
+
+ // This rounding technique is dedicated to the memory of Peppermint. =^..^=
+ _Adjusted_mantissa += _Should_round;
+ }
+
+ // * Print the leading hexit, then mask it away.
+ {
+ const uint32_t _Nibble = static_cast<uint32_t>(_Adjusted_mantissa >> _Adjusted_explicit_bits);
+ _LIBCPP_ASSERT(_Nibble < 3, "");
+ const char _Leading_hexit = static_cast<char>('0' + _Nibble);
+
+ *_First++ = _Leading_hexit;
+
+ constexpr _Uint_type _Mask = (_Uint_type{1} << _Adjusted_explicit_bits) - 1;
+ _Adjusted_mantissa &= _Mask;
+ }
+
+ // * Print the decimal point and trailing hexits.
+
+ // C11 7.21.6.1 "The fprintf function"/8:
+ // "if the precision is zero and the # flag is not specified, no decimal-point character appears."
+ if (_Precision > 0) {
+ *_First++ = '.';
+
+ int32_t _Number_of_bits_remaining = _Adjusted_explicit_bits; // 24 for float, 52 for double
+
+ for (;;) {
+ _LIBCPP_ASSERT(_Number_of_bits_remaining >= 4, "");
+ _LIBCPP_ASSERT(_Number_of_bits_remaining % 4 == 0, "");
+ _Number_of_bits_remaining -= 4;
+
+ const uint32_t _Nibble = static_cast<uint32_t>(_Adjusted_mantissa >> _Number_of_bits_remaining);
+ _LIBCPP_ASSERT(_Nibble < 16, "");
+ const char _Hexit = __itoa::_Charconv_digits[_Nibble];
+
+ *_First++ = _Hexit;
+
+ // _Precision is the number of hexits that still need to be printed.
+ --_Precision;
+ if (_Precision == 0) {
+ break; // We're completely done with this phase.
+ }
+ // Otherwise, we need to keep printing hexits.
+
+ if (_Number_of_bits_remaining == 0) {
+ // We've finished printing _Adjusted_mantissa, so all remaining hexits are '0'.
+ _VSTD::memset(_First, '0', static_cast<size_t>(_Precision));
+ _First += _Precision;
+ break;
+ }
+
+ // Mask away the hexit that we just printed, then keep looping.
+ // (We skip this when breaking out of the loop above, because _Adjusted_mantissa isn't used later.)
+ const _Uint_type _Mask = (_Uint_type{1} << _Number_of_bits_remaining) - 1;
+ _Adjusted_mantissa &= _Mask;
+ }
+ }
+
+ // * Print the exponent.
+
+ // C11 7.21.6.1 "The fprintf function"/8: "The exponent always contains at least one digit, and only as many more
+ // digits as necessary to represent the decimal exponent of 2."
+
+ // Performance note: We should take advantage of the known ranges of possible exponents.
+
+ *_First++ = 'p';
+ *_First++ = _Sign_character;
+
+ // We've already printed '-' if necessary, so uint32_t _Absolute_exponent avoids testing that again.
+ return _VSTD::to_chars(_First, _Last, _Absolute_exponent);
+}
+
+template <class _Floating>
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+to_chars_result _Floating_to_chars_hex_shortest(
+ char* _First, char* const _Last, const _Floating _Value) noexcept {
+
+ // This prints "1.728p+0" instead of "2.e5p-1".
+ // This prints "0.000002p-126" instead of "1p-149" for float.
+ // This prints "0.0000000000001p-1022" instead of "1p-1074" for double.
+ // This prioritizes being consistent with printf's de facto behavior (and hex-precision's behavior)
+ // over minimizing the number of characters printed.
+
+ using _Traits = _Floating_type_traits<_Floating>;
+ using _Uint_type = typename _Traits::_Uint_type;
+
+ const _Uint_type _Uint_value = _VSTD::bit_cast<_Uint_type>(_Value);
+
+ if (_Uint_value == 0) { // zero detected; write "0p+0" and return
+ // C11 7.21.6.1 "The fprintf function"/8: "If the value is zero, the exponent is zero."
+ // Special-casing zero is necessary because of the exponent.
+ const char* const _Str = "0p+0";
+ const size_t _Len = 4;
+
+ if (_Last - _First < static_cast<ptrdiff_t>(_Len)) {
+ return {_Last, errc::value_too_large};
+ }
+
+ _VSTD::memcpy(_First, _Str, _Len);
+
+ return {_First + _Len, errc{}};
+ }
+
+ const _Uint_type _Ieee_mantissa = _Uint_value & _Traits::_Denormal_mantissa_mask;
+ const int32_t _Ieee_exponent = static_cast<int32_t>(_Uint_value >> _Traits::_Exponent_shift);
+
+ char _Leading_hexit; // implicit bit
+ int32_t _Unbiased_exponent;
+
+ if (_Ieee_exponent == 0) { // subnormal
+ _Leading_hexit = '0';
+ _Unbiased_exponent = 1 - _Traits::_Exponent_bias;
+ } else { // normal
+ _Leading_hexit = '1';
+ _Unbiased_exponent = _Ieee_exponent - _Traits::_Exponent_bias;
+ }
+
+ // Performance note: Consider avoiding per-character bounds checking when there's plenty of space.
+
+ if (_First == _Last) {
+ return {_Last, errc::value_too_large};
+ }
+
+ *_First++ = _Leading_hexit;
+
+ if (_Ieee_mantissa == 0) {
+ // The fraction bits are all 0. Trim them away, including the decimal point.
+ } else {
+ if (_First == _Last) {
+ return {_Last, errc::value_too_large};
+ }
+
+ *_First++ = '.';
+
+ // The hexits after the decimal point correspond to the explicitly stored fraction bits.
+ // float explicitly stores 23 fraction bits. 23 / 4 == 5.75, so we'll print at most 6 hexits.
+ // double explicitly stores 52 fraction bits. 52 / 4 == 13, so we'll print at most 13 hexits.
+ _Uint_type _Adjusted_mantissa;
+ int32_t _Number_of_bits_remaining;
+
+ if constexpr (_IsSame<_Floating, float>::value) {
+ _Adjusted_mantissa = _Ieee_mantissa << 1; // align to hexit boundary (23 isn't divisible by 4)
+ _Number_of_bits_remaining = 24; // 23 fraction bits + 1 alignment bit
+ } else {
+ _Adjusted_mantissa = _Ieee_mantissa; // already aligned (52 is divisible by 4)
+ _Number_of_bits_remaining = 52; // 52 fraction bits
+ }
+
+ // do-while: The condition _Adjusted_mantissa != 0 is initially true - we have nonzero fraction bits and we've
+ // printed the decimal point. Each iteration, we print a hexit, mask it away, and keep looping if we still have
+ // nonzero fraction bits. If there would be trailing '0' hexits, this trims them. If there wouldn't be trailing
+ // '0' hexits, the same condition works (as we print the final hexit and mask it away); we don't need to test
+ // _Number_of_bits_remaining.
+ do {
+ _LIBCPP_ASSERT(_Number_of_bits_remaining >= 4, "");
+ _LIBCPP_ASSERT(_Number_of_bits_remaining % 4 == 0, "");
+ _Number_of_bits_remaining -= 4;
+
+ const uint32_t _Nibble = static_cast<uint32_t>(_Adjusted_mantissa >> _Number_of_bits_remaining);
+ _LIBCPP_ASSERT(_Nibble < 16, "");
+ const char _Hexit = __itoa::_Charconv_digits[_Nibble];
+
+ if (_First == _Last) {
+ return {_Last, errc::value_too_large};
+ }
+
+ *_First++ = _Hexit;
+
+ const _Uint_type _Mask = (_Uint_type{1} << _Number_of_bits_remaining) - 1;
+ _Adjusted_mantissa &= _Mask;
+
+ } while (_Adjusted_mantissa != 0);
+ }
+
+ // C11 7.21.6.1 "The fprintf function"/8: "The exponent always contains at least one digit, and only as many more
+ // digits as necessary to represent the decimal exponent of 2."
+
+ // Performance note: We should take advantage of the known ranges of possible exponents.
+
+ // float: _Unbiased_exponent is within [-126, 127].
+ // double: _Unbiased_exponent is within [-1022, 1023].
+
+ if (_Last - _First < 2) {
+ return {_Last, errc::value_too_large};
+ }
+
+ *_First++ = 'p';
+
+ if (_Unbiased_exponent < 0) {
+ *_First++ = '-';
+ _Unbiased_exponent = -_Unbiased_exponent;
+ } else {
+ *_First++ = '+';
+ }
+
+ // We've already printed '-' if necessary, so static_cast<uint32_t> avoids testing that again.
+ return _VSTD::to_chars(_First, _Last, static_cast<uint32_t>(_Unbiased_exponent));
+}
+
+// For general precision, we can use lookup tables to avoid performing trial formatting.
+
+// For a simple example, imagine counting the number of digits D in an integer, and needing to know
+// whether D is less than 3, equal to 3/4/5/6, or greater than 6. We could use a lookup table:
+// D | Largest integer with D digits
+// 2 | 99
+// 3 | 999
+// 4 | 9'999
+// 5 | 99'999
+// 6 | 999'999
+// 7 | table end
+// Looking up an integer in this table with lower_bound() will work:
+// * Too-small integers, like 7, 70, and 99, will cause lower_bound() to return the D == 2 row. (If all we care
+// about is whether D is less than 3, then it's okay to smash the D == 1 and D == 2 cases together.)
+// * Integers in [100, 999] will cause lower_bound() to return the D == 3 row, and so forth.
+// * Too-large integers, like 1'000'000 and above, will cause lower_bound() to return the end of the table. If we
+// compute D from that index, this will be considered D == 7, which will activate any "greater than 6" logic.
+
+// Floating-point is slightly more complicated.
+
+// The ordinary lookup tables are for X within [-5, 38] for float, and [-5, 308] for double.
+// (-5 absorbs too-negative exponents, outside the P > X >= -4 criterion. 38 and 308 are the maximum exponents.)
+// Due to the P > X condition, we can use a subset of the table for X within [-5, P - 1], suitably clamped.
+
+// When P is small, rounding can affect X. For example:
+// For P == 1, the largest double with X == 0 is: 9.4999999999999982236431605997495353221893310546875
+// For P == 2, the largest double with X == 0 is: 9.949999999999999289457264239899814128875732421875
+// For P == 3, the largest double with X == 0 is: 9.9949999999999992184029906638897955417633056640625
+
+// Exponent adjustment is a concern for P within [1, 7] for float, and [1, 15] for double (determined via
+// brute force). While larger values of P still perform rounding, they can't trigger exponent adjustment.
+// This is because only values with repeated '9' digits can undergo exponent adjustment during rounding,
+// and floating-point granularity limits the number of consecutive '9' digits that can appear.
+
+// So, we need special lookup tables for small values of P.
+// These tables have varying lengths due to the P > X >= -4 criterion. For example:
+// For P == 1, need table entries for X: -5, -4, -3, -2, -1, 0
+// For P == 2, need table entries for X: -5, -4, -3, -2, -1, 0, 1
+// For P == 3, need table entries for X: -5, -4, -3, -2, -1, 0, 1, 2
+// For P == 4, need table entries for X: -5, -4, -3, -2, -1, 0, 1, 2, 3
+
+// We can concatenate these tables for compact storage, using triangular numbers to access them.
+// The table for P begins at index (P - 1) * (P + 10) / 2 with length P + 5.
+
+// For both the ordinary and special lookup tables, after an index I is returned by lower_bound(), X is I - 5.
+
+// We need to special-case the floating-point value 0.0, which is considered to have X == 0.
+// Otherwise, the lookup tables would consider it to have a highly negative X.
+
+// Finally, because we're working with positive floating-point values,
+// representation comparisons behave identically to floating-point comparisons.
+
+// The following code generated the lookup tables for the scientific exponent X. Don't remove this code.
+#if 0
+// cl /EHsc /nologo /W4 /MT /O2 /std:c++17 generate_tables.cpp && generate_tables
+
+#include <algorithm>
+#include <assert.h>
+#include <charconv>
+#include <cmath>
+#include <limits>
+#include <map>
+#include <stdint.h>
+#include <stdio.h>
+#include <system_error>
+#include <type_traits>
+#include <vector>
+using namespace std;
+
+template <typename UInt, typename Pred>
+[[nodiscard]] UInt uint_partition_point(UInt first, const UInt last, Pred pred) {
+ // Find the beginning of the false partition in [first, last).
+ // [first, last) is partitioned when all of the true values occur before all of the false values.
+
+ static_assert(is_unsigned_v<UInt>);
+ assert(first <= last);
+
+ for (UInt n = last - first; n > 0;) {
+ const UInt n2 = n / 2;
+ const UInt mid = first + n2;
+
+ if (pred(mid)) {
+ first = mid + 1;
+ n = n - n2 - 1;
+ } else {
+ n = n2;
+ }
+ }
+
+ return first;
+}
+
+template <typename Floating>
+[[nodiscard]] int scientific_exponent_X(const int P, const Floating flt) {
+ char buf[400]; // more than enough
+
+ // C11 7.21.6.1 "The fprintf function"/8 performs trial formatting with scientific precision P - 1.
+ const auto to_result = to_chars(buf, end(buf), flt, chars_format::scientific, P - 1);
+ assert(to_result.ec == errc{});
+
+ const char* exp_ptr = find(buf, to_result.ptr, 'e');
+ assert(exp_ptr != to_result.ptr);
+
+ ++exp_ptr; // advance past 'e'
+
+ if (*exp_ptr == '+') {
+ ++exp_ptr; // advance past '+' which from_chars() won't parse
+ }
+
+ int X;
+ const auto from_result = from_chars(exp_ptr, to_result.ptr, X);
+ assert(from_result.ec == errc{});
+ return X;
+}
+
+template <typename UInt>
+void print_table(const vector<UInt>& v, const char* const name) {
+ constexpr const char* UIntName = _IsSame<UInt, uint32_t>::value ? "uint32_t" : "uint64_t";
+
+ printf("static constexpr %s %s[%zu] = {\n", UIntName, name, v.size());
+
+ for (const auto& val : v) {
+ if constexpr (_IsSame<UInt, uint32_t>::value) {
+ printf("0x%08Xu,\n", val);
+ } else {
+ printf("0x%016llXu,\n", val);
+ }
+ }
+
+ printf("};\n");
+}
+
+enum class Mode { Tables, Tests };
+
+template <typename Floating>
+void generate_tables(const Mode mode) {
+ using Limits = numeric_limits<Floating>;
+ using UInt = conditional_t<_IsSame<Floating, float>::value, uint32_t, uint64_t>;
+
+ map<int, map<int, UInt>> P_X_LargestValWithX;
+
+ constexpr int MaxP = Limits::max_exponent10 + 1; // MaxP performs no rounding during trial formatting
+
+ for (int P = 1; P <= MaxP; ++P) {
+ for (int X = -5; X < P; ++X) {
+ constexpr Floating first = static_cast<Floating>(9e-5); // well below 9.5e-5, otherwise arbitrary
+ constexpr Floating last = Limits::infinity(); // one bit above Limits::max()
+
+ const UInt val_beyond_X = uint_partition_point(reinterpret_cast<const UInt&>(first),
+ reinterpret_cast<const UInt&>(last),
+ [P, X](const UInt u) { return scientific_exponent_X(P, reinterpret_cast<const Floating&>(u)) <= X; });
+
+ P_X_LargestValWithX[P][X] = val_beyond_X - 1;
+ }
+ }
+
+ constexpr const char* FloatingName = _IsSame<Floating, float>::value ? "float" : "double";
+
+ constexpr int MaxSpecialP = _IsSame<Floating, float>::value ? 7 : 15; // MaxSpecialP is affected by exponent adjustment
+
+ if (mode == Mode::Tables) {
+ printf("template <>\n");
+ printf("struct _General_precision_tables<%s> {\n", FloatingName);
+
+ printf("static constexpr int _Max_special_P = %d;\n", MaxSpecialP);
+
+ vector<UInt> special;
+
+ for (int P = 1; P <= MaxSpecialP; ++P) {
+ for (int X = -5; X < P; ++X) {
+ const UInt val = P_X_LargestValWithX[P][X];
+ special.push_back(val);
+ }
+ }
+
+ print_table(special, "_Special_X_table");
+
+ for (int P = MaxSpecialP + 1; P < MaxP; ++P) {
+ for (int X = -5; X < P; ++X) {
+ const UInt val = P_X_LargestValWithX[P][X];
+ assert(val == P_X_LargestValWithX[MaxP][X]);
+ }
+ }
+
+ printf("static constexpr int _Max_P = %d;\n", MaxP);
+
+ vector<UInt> ordinary;
+
+ for (int X = -5; X < MaxP; ++X) {
+ const UInt val = P_X_LargestValWithX[MaxP][X];
+ ordinary.push_back(val);
+ }
+
+ print_table(ordinary, "_Ordinary_X_table");
+
+ printf("};\n");
+ } else {
+ printf("==========\n");
+ printf("Test cases for %s:\n", FloatingName);
+
+ constexpr int Hexits = _IsSame<Floating, float>::value ? 6 : 13;
+ constexpr const char* Suffix = _IsSame<Floating, float>::value ? "f" : "";
+
+ for (int P = 1; P <= MaxP; ++P) {
+ for (int X = -5; X < P; ++X) {
+ if (P <= MaxSpecialP || P == 25 || P == MaxP || X == P - 1) {
+ const UInt val1 = P_X_LargestValWithX[P][X];
+ const Floating f1 = reinterpret_cast<const Floating&>(val1);
+ const UInt val2 = val1 + 1;
+ const Floating f2 = reinterpret_cast<const Floating&>(val2);
+
+ printf("{%.*a%s, chars_format::general, %d, \"%.*g\"},\n", Hexits, f1, Suffix, P, P, f1);
+ if (isfinite(f2)) {
+ printf("{%.*a%s, chars_format::general, %d, \"%.*g\"},\n", Hexits, f2, Suffix, P, P, f2);
+ }
+ }
+ }
+ }
+ }
+}
+
+int main() {
+ printf("template <class _Floating>\n");
+ printf("struct _General_precision_tables;\n");
+ generate_tables<float>(Mode::Tables);
+ generate_tables<double>(Mode::Tables);
+ generate_tables<float>(Mode::Tests);
+ generate_tables<double>(Mode::Tests);
+}
+#endif // 0
+
+template <class _Floating>
+struct _General_precision_tables;
+
+template <>
+struct _General_precision_tables<float> {
+ static constexpr int _Max_special_P = 7;
+
+ static constexpr uint32_t _Special_X_table[63] = {0x38C73ABCu, 0x3A79096Bu, 0x3C1BA5E3u, 0x3DC28F5Cu, 0x3F733333u,
+ 0x4117FFFFu, 0x38D0AAA7u, 0x3A826AA8u, 0x3C230553u, 0x3DCBC6A7u, 0x3F7EB851u, 0x411F3333u, 0x42C6FFFFu,
+ 0x38D19C3Fu, 0x3A8301A7u, 0x3C23C211u, 0x3DCCB295u, 0x3F7FDF3Bu, 0x411FEB85u, 0x42C7E666u, 0x4479DFFFu,
+ 0x38D1B468u, 0x3A8310C1u, 0x3C23D4F1u, 0x3DCCCA2Du, 0x3F7FFCB9u, 0x411FFDF3u, 0x42C7FD70u, 0x4479FCCCu,
+ 0x461C3DFFu, 0x38D1B6D2u, 0x3A831243u, 0x3C23D6D4u, 0x3DCCCC89u, 0x3F7FFFACu, 0x411FFFCBu, 0x42C7FFBEu,
+ 0x4479FFAEu, 0x461C3FCCu, 0x47C34FBFu, 0x38D1B710u, 0x3A83126Au, 0x3C23D704u, 0x3DCCCCC6u, 0x3F7FFFF7u,
+ 0x411FFFFAu, 0x42C7FFF9u, 0x4479FFF7u, 0x461C3FFAu, 0x47C34FF9u, 0x497423F7u, 0x38D1B716u, 0x3A83126Eu,
+ 0x3C23D709u, 0x3DCCCCCCu, 0x3F7FFFFFu, 0x411FFFFFu, 0x42C7FFFFu, 0x4479FFFFu, 0x461C3FFFu, 0x47C34FFFu,
+ 0x497423FFu, 0x4B18967Fu};
+
+ static constexpr int _Max_P = 39;
+
+ static constexpr uint32_t _Ordinary_X_table[44] = {0x38D1B717u, 0x3A83126Eu, 0x3C23D70Au, 0x3DCCCCCCu, 0x3F7FFFFFu,
+ 0x411FFFFFu, 0x42C7FFFFu, 0x4479FFFFu, 0x461C3FFFu, 0x47C34FFFu, 0x497423FFu, 0x4B18967Fu, 0x4CBEBC1Fu,
+ 0x4E6E6B27u, 0x501502F8u, 0x51BA43B7u, 0x5368D4A5u, 0x551184E7u, 0x56B5E620u, 0x58635FA9u, 0x5A0E1BC9u,
+ 0x5BB1A2BCu, 0x5D5E0B6Bu, 0x5F0AC723u, 0x60AD78EBu, 0x6258D726u, 0x64078678u, 0x65A96816u, 0x6753C21Bu,
+ 0x69045951u, 0x6AA56FA5u, 0x6C4ECB8Fu, 0x6E013F39u, 0x6FA18F07u, 0x7149F2C9u, 0x72FC6F7Cu, 0x749DC5ADu,
+ 0x76453719u, 0x77F684DFu, 0x799A130Bu, 0x7B4097CEu, 0x7CF0BDC2u, 0x7E967699u, 0x7F7FFFFFu};
+};
+
+template <>
+struct _General_precision_tables<double> {
+ static constexpr int _Max_special_P = 15;
+
+ static constexpr uint64_t _Special_X_table[195] = {0x3F18E757928E0C9Du, 0x3F4F212D77318FC5u, 0x3F8374BC6A7EF9DBu,
+ 0x3FB851EB851EB851u, 0x3FEE666666666666u, 0x4022FFFFFFFFFFFFu, 0x3F1A1554FBDAD751u, 0x3F504D551D68C692u,
+ 0x3F8460AA64C2F837u, 0x3FB978D4FDF3B645u, 0x3FEFD70A3D70A3D7u, 0x4023E66666666666u, 0x4058DFFFFFFFFFFFu,
+ 0x3F1A3387ECC8EB96u, 0x3F506034F3FD933Eu, 0x3F84784230FCF80Du, 0x3FB99652BD3C3611u, 0x3FEFFBE76C8B4395u,
+ 0x4023FD70A3D70A3Du, 0x4058FCCCCCCCCCCCu, 0x408F3BFFFFFFFFFFu, 0x3F1A368D04E0BA6Au, 0x3F506218230C7482u,
+ 0x3F847A9E2BCF91A3u, 0x3FB99945B6C3760Bu, 0x3FEFFF972474538Eu, 0x4023FFBE76C8B439u, 0x4058FFAE147AE147u,
+ 0x408F3F9999999999u, 0x40C387BFFFFFFFFFu, 0x3F1A36DA54164F19u, 0x3F506248748DF16Fu, 0x3F847ADA91B16DCBu,
+ 0x3FB99991361DC93Eu, 0x3FEFFFF583A53B8Eu, 0x4023FFF972474538u, 0x4058FFF7CED91687u, 0x408F3FF5C28F5C28u,
+ 0x40C387F999999999u, 0x40F869F7FFFFFFFFu, 0x3F1A36E20F35445Du, 0x3F50624D49814ABAu, 0x3F847AE09BE19D69u,
+ 0x3FB99998C2DA04C3u, 0x3FEFFFFEF39085F4u, 0x4023FFFF583A53B8u, 0x4058FFFF2E48E8A7u, 0x408F3FFEF9DB22D0u,
+ 0x40C387FF5C28F5C2u, 0x40F869FF33333333u, 0x412E847EFFFFFFFFu, 0x3F1A36E2D51EC34Bu, 0x3F50624DC5333A0Eu,
+ 0x3F847AE136800892u, 0x3FB9999984200AB7u, 0x3FEFFFFFE5280D65u, 0x4023FFFFEF39085Fu, 0x4058FFFFEB074A77u,
+ 0x408F3FFFE5C91D14u, 0x40C387FFEF9DB22Du, 0x40F869FFEB851EB8u, 0x412E847FE6666666u, 0x416312CFEFFFFFFFu,
+ 0x3F1A36E2E8E94FFCu, 0x3F50624DD191D1FDu, 0x3F847AE145F6467Du, 0x3FB999999773D81Cu, 0x3FEFFFFFFD50CE23u,
+ 0x4023FFFFFE5280D6u, 0x4058FFFFFDE7210Bu, 0x408F3FFFFD60E94Eu, 0x40C387FFFE5C91D1u, 0x40F869FFFDF3B645u,
+ 0x412E847FFD70A3D7u, 0x416312CFFE666666u, 0x4197D783FDFFFFFFu, 0x3F1A36E2EAE3F7A7u, 0x3F50624DD2CE7AC8u,
+ 0x3F847AE14782197Bu, 0x3FB9999999629FD9u, 0x3FEFFFFFFFBB47D0u, 0x4023FFFFFFD50CE2u, 0x4058FFFFFFCA501Au,
+ 0x408F3FFFFFBCE421u, 0x40C387FFFFD60E94u, 0x40F869FFFFCB923Au, 0x412E847FFFBE76C8u, 0x416312CFFFD70A3Du,
+ 0x4197D783FFCCCCCCu, 0x41CDCD64FFBFFFFFu, 0x3F1A36E2EB16A205u, 0x3F50624DD2EE2543u, 0x3F847AE147A9AE94u,
+ 0x3FB9999999941A39u, 0x3FEFFFFFFFF920C8u, 0x4023FFFFFFFBB47Du, 0x4058FFFFFFFAA19Cu, 0x408F3FFFFFF94A03u,
+ 0x40C387FFFFFBCE42u, 0x40F869FFFFFAC1D2u, 0x412E847FFFF97247u, 0x416312CFFFFBE76Cu, 0x4197D783FFFAE147u,
+ 0x41CDCD64FFF99999u, 0x4202A05F1FFBFFFFu, 0x3F1A36E2EB1BB30Fu, 0x3F50624DD2F14FE9u, 0x3F847AE147ADA3E3u,
+ 0x3FB9999999990CDCu, 0x3FEFFFFFFFFF5014u, 0x4023FFFFFFFF920Cu, 0x4058FFFFFFFF768Fu, 0x408F3FFFFFFF5433u,
+ 0x40C387FFFFFF94A0u, 0x40F869FFFFFF79C8u, 0x412E847FFFFF583Au, 0x416312CFFFFF9724u, 0x4197D783FFFF7CEDu,
+ 0x41CDCD64FFFF5C28u, 0x4202A05F1FFF9999u, 0x42374876E7FF7FFFu, 0x3F1A36E2EB1C34C3u, 0x3F50624DD2F1A0FAu,
+ 0x3F847AE147AE0938u, 0x3FB9999999998B86u, 0x3FEFFFFFFFFFEE68u, 0x4023FFFFFFFFF501u, 0x4058FFFFFFFFF241u,
+ 0x408F3FFFFFFFEED1u, 0x40C387FFFFFFF543u, 0x40F869FFFFFFF294u, 0x412E847FFFFFEF39u, 0x416312CFFFFFF583u,
+ 0x4197D783FFFFF2E4u, 0x41CDCD64FFFFEF9Du, 0x4202A05F1FFFF5C2u, 0x42374876E7FFF333u, 0x426D1A94A1FFEFFFu,
+ 0x3F1A36E2EB1C41BBu, 0x3F50624DD2F1A915u, 0x3F847AE147AE135Au, 0x3FB9999999999831u, 0x3FEFFFFFFFFFFE3Du,
+ 0x4023FFFFFFFFFEE6u, 0x4058FFFFFFFFFEA0u, 0x408F3FFFFFFFFE48u, 0x40C387FFFFFFFEEDu, 0x40F869FFFFFFFEA8u,
+ 0x412E847FFFFFFE52u, 0x416312CFFFFFFEF3u, 0x4197D783FFFFFEB0u, 0x41CDCD64FFFFFE5Cu, 0x4202A05F1FFFFEF9u,
+ 0x42374876E7FFFEB8u, 0x426D1A94A1FFFE66u, 0x42A2309CE53FFEFFu, 0x3F1A36E2EB1C4307u, 0x3F50624DD2F1A9E4u,
+ 0x3F847AE147AE145Eu, 0x3FB9999999999975u, 0x3FEFFFFFFFFFFFD2u, 0x4023FFFFFFFFFFE3u, 0x4058FFFFFFFFFFDCu,
+ 0x408F3FFFFFFFFFD4u, 0x40C387FFFFFFFFE4u, 0x40F869FFFFFFFFDDu, 0x412E847FFFFFFFD5u, 0x416312CFFFFFFFE5u,
+ 0x4197D783FFFFFFDEu, 0x41CDCD64FFFFFFD6u, 0x4202A05F1FFFFFE5u, 0x42374876E7FFFFDFu, 0x426D1A94A1FFFFD7u,
+ 0x42A2309CE53FFFE6u, 0x42D6BCC41E8FFFDFu, 0x3F1A36E2EB1C4328u, 0x3F50624DD2F1A9F9u, 0x3F847AE147AE1477u,
+ 0x3FB9999999999995u, 0x3FEFFFFFFFFFFFFBu, 0x4023FFFFFFFFFFFDu, 0x4058FFFFFFFFFFFCu, 0x408F3FFFFFFFFFFBu,
+ 0x40C387FFFFFFFFFDu, 0x40F869FFFFFFFFFCu, 0x412E847FFFFFFFFBu, 0x416312CFFFFFFFFDu, 0x4197D783FFFFFFFCu,
+ 0x41CDCD64FFFFFFFBu, 0x4202A05F1FFFFFFDu, 0x42374876E7FFFFFCu, 0x426D1A94A1FFFFFBu, 0x42A2309CE53FFFFDu,
+ 0x42D6BCC41E8FFFFCu, 0x430C6BF52633FFFBu};
+
+ static constexpr int _Max_P = 309;
+
+ static constexpr uint64_t _Ordinary_X_table[314] = {0x3F1A36E2EB1C432Cu, 0x3F50624DD2F1A9FBu, 0x3F847AE147AE147Au,
+ 0x3FB9999999999999u, 0x3FEFFFFFFFFFFFFFu, 0x4023FFFFFFFFFFFFu, 0x4058FFFFFFFFFFFFu, 0x408F3FFFFFFFFFFFu,
+ 0x40C387FFFFFFFFFFu, 0x40F869FFFFFFFFFFu, 0x412E847FFFFFFFFFu, 0x416312CFFFFFFFFFu, 0x4197D783FFFFFFFFu,
+ 0x41CDCD64FFFFFFFFu, 0x4202A05F1FFFFFFFu, 0x42374876E7FFFFFFu, 0x426D1A94A1FFFFFFu, 0x42A2309CE53FFFFFu,
+ 0x42D6BCC41E8FFFFFu, 0x430C6BF52633FFFFu, 0x4341C37937E07FFFu, 0x4376345785D89FFFu, 0x43ABC16D674EC7FFu,
+ 0x43E158E460913CFFu, 0x4415AF1D78B58C3Fu, 0x444B1AE4D6E2EF4Fu, 0x4480F0CF064DD591u, 0x44B52D02C7E14AF6u,
+ 0x44EA784379D99DB4u, 0x45208B2A2C280290u, 0x4554ADF4B7320334u, 0x4589D971E4FE8401u, 0x45C027E72F1F1281u,
+ 0x45F431E0FAE6D721u, 0x46293E5939A08CE9u, 0x465F8DEF8808B024u, 0x4693B8B5B5056E16u, 0x46C8A6E32246C99Cu,
+ 0x46FED09BEAD87C03u, 0x4733426172C74D82u, 0x476812F9CF7920E2u, 0x479E17B84357691Bu, 0x47D2CED32A16A1B1u,
+ 0x48078287F49C4A1Du, 0x483D6329F1C35CA4u, 0x48725DFA371A19E6u, 0x48A6F578C4E0A060u, 0x48DCB2D6F618C878u,
+ 0x4911EFC659CF7D4Bu, 0x49466BB7F0435C9Eu, 0x497C06A5EC5433C6u, 0x49B18427B3B4A05Bu, 0x49E5E531A0A1C872u,
+ 0x4A1B5E7E08CA3A8Fu, 0x4A511B0EC57E6499u, 0x4A8561D276DDFDC0u, 0x4ABABA4714957D30u, 0x4AF0B46C6CDD6E3Eu,
+ 0x4B24E1878814C9CDu, 0x4B5A19E96A19FC40u, 0x4B905031E2503DA8u, 0x4BC4643E5AE44D12u, 0x4BF97D4DF19D6057u,
+ 0x4C2FDCA16E04B86Du, 0x4C63E9E4E4C2F344u, 0x4C98E45E1DF3B015u, 0x4CCF1D75A5709C1Au, 0x4D03726987666190u,
+ 0x4D384F03E93FF9F4u, 0x4D6E62C4E38FF872u, 0x4DA2FDBB0E39FB47u, 0x4DD7BD29D1C87A19u, 0x4E0DAC74463A989Fu,
+ 0x4E428BC8ABE49F63u, 0x4E772EBAD6DDC73Cu, 0x4EACFA698C95390Bu, 0x4EE21C81F7DD43A7u, 0x4F16A3A275D49491u,
+ 0x4F4C4C8B1349B9B5u, 0x4F81AFD6EC0E1411u, 0x4FB61BCCA7119915u, 0x4FEBA2BFD0D5FF5Bu, 0x502145B7E285BF98u,
+ 0x50559725DB272F7Fu, 0x508AFCEF51F0FB5Eu, 0x50C0DE1593369D1Bu, 0x50F5159AF8044462u, 0x512A5B01B605557Au,
+ 0x516078E111C3556Cu, 0x5194971956342AC7u, 0x51C9BCDFABC13579u, 0x5200160BCB58C16Cu, 0x52341B8EBE2EF1C7u,
+ 0x526922726DBAAE39u, 0x529F6B0F092959C7u, 0x52D3A2E965B9D81Cu, 0x53088BA3BF284E23u, 0x533EAE8CAEF261ACu,
+ 0x53732D17ED577D0Bu, 0x53A7F85DE8AD5C4Eu, 0x53DDF67562D8B362u, 0x5412BA095DC7701Du, 0x5447688BB5394C25u,
+ 0x547D42AEA2879F2Eu, 0x54B249AD2594C37Cu, 0x54E6DC186EF9F45Cu, 0x551C931E8AB87173u, 0x5551DBF316B346E7u,
+ 0x558652EFDC6018A1u, 0x55BBE7ABD3781ECAu, 0x55F170CB642B133Eu, 0x5625CCFE3D35D80Eu, 0x565B403DCC834E11u,
+ 0x569108269FD210CBu, 0x56C54A3047C694FDu, 0x56FA9CBC59B83A3Du, 0x5730A1F5B8132466u, 0x5764CA732617ED7Fu,
+ 0x5799FD0FEF9DE8DFu, 0x57D03E29F5C2B18Bu, 0x58044DB473335DEEu, 0x583961219000356Au, 0x586FB969F40042C5u,
+ 0x58A3D3E2388029BBu, 0x58D8C8DAC6A0342Au, 0x590EFB1178484134u, 0x59435CEAEB2D28C0u, 0x59783425A5F872F1u,
+ 0x59AE412F0F768FADu, 0x59E2E8BD69AA19CCu, 0x5A17A2ECC414A03Fu, 0x5A4D8BA7F519C84Fu, 0x5A827748F9301D31u,
+ 0x5AB7151B377C247Eu, 0x5AECDA62055B2D9Du, 0x5B22087D4358FC82u, 0x5B568A9C942F3BA3u, 0x5B8C2D43B93B0A8Bu,
+ 0x5BC19C4A53C4E697u, 0x5BF6035CE8B6203Du, 0x5C2B843422E3A84Cu, 0x5C6132A095CE492Fu, 0x5C957F48BB41DB7Bu,
+ 0x5CCADF1AEA12525Au, 0x5D00CB70D24B7378u, 0x5D34FE4D06DE5056u, 0x5D6A3DE04895E46Cu, 0x5DA066AC2D5DAEC3u,
+ 0x5DD4805738B51A74u, 0x5E09A06D06E26112u, 0x5E400444244D7CABu, 0x5E7405552D60DBD6u, 0x5EA906AA78B912CBu,
+ 0x5EDF485516E7577Eu, 0x5F138D352E5096AFu, 0x5F48708279E4BC5Au, 0x5F7E8CA3185DEB71u, 0x5FB317E5EF3AB327u,
+ 0x5FE7DDDF6B095FF0u, 0x601DD55745CBB7ECu, 0x6052A5568B9F52F4u, 0x60874EAC2E8727B1u, 0x60BD22573A28F19Du,
+ 0x60F2357684599702u, 0x6126C2D4256FFCC2u, 0x615C73892ECBFBF3u, 0x6191C835BD3F7D78u, 0x61C63A432C8F5CD6u,
+ 0x61FBC8D3F7B3340Bu, 0x62315D847AD00087u, 0x6265B4E5998400A9u, 0x629B221EFFE500D3u, 0x62D0F5535FEF2084u,
+ 0x630532A837EAE8A5u, 0x633A7F5245E5A2CEu, 0x63708F936BAF85C1u, 0x63A4B378469B6731u, 0x63D9E056584240FDu,
+ 0x64102C35F729689Eu, 0x6444374374F3C2C6u, 0x647945145230B377u, 0x64AF965966BCE055u, 0x64E3BDF7E0360C35u,
+ 0x6518AD75D8438F43u, 0x654ED8D34E547313u, 0x6583478410F4C7ECu, 0x65B819651531F9E7u, 0x65EE1FBE5A7E7861u,
+ 0x6622D3D6F88F0B3Cu, 0x665788CCB6B2CE0Cu, 0x668D6AFFE45F818Fu, 0x66C262DFEEBBB0F9u, 0x66F6FB97EA6A9D37u,
+ 0x672CBA7DE5054485u, 0x6761F48EAF234AD3u, 0x679671B25AEC1D88u, 0x67CC0E1EF1A724EAu, 0x680188D357087712u,
+ 0x6835EB082CCA94D7u, 0x686B65CA37FD3A0Du, 0x68A11F9E62FE4448u, 0x68D56785FBBDD55Au, 0x690AC1677AAD4AB0u,
+ 0x6940B8E0ACAC4EAEu, 0x6974E718D7D7625Au, 0x69AA20DF0DCD3AF0u, 0x69E0548B68A044D6u, 0x6A1469AE42C8560Cu,
+ 0x6A498419D37A6B8Fu, 0x6A7FE52048590672u, 0x6AB3EF342D37A407u, 0x6AE8EB0138858D09u, 0x6B1F25C186A6F04Cu,
+ 0x6B537798F428562Fu, 0x6B88557F31326BBBu, 0x6BBE6ADEFD7F06AAu, 0x6BF302CB5E6F642Au, 0x6C27C37E360B3D35u,
+ 0x6C5DB45DC38E0C82u, 0x6C9290BA9A38C7D1u, 0x6CC734E940C6F9C5u, 0x6CFD022390F8B837u, 0x6D3221563A9B7322u,
+ 0x6D66A9ABC9424FEBu, 0x6D9C5416BB92E3E6u, 0x6DD1B48E353BCE6Fu, 0x6E0621B1C28AC20Bu, 0x6E3BAA1E332D728Eu,
+ 0x6E714A52DFFC6799u, 0x6EA59CE797FB817Fu, 0x6EDB04217DFA61DFu, 0x6F10E294EEBC7D2Bu, 0x6F451B3A2A6B9C76u,
+ 0x6F7A6208B5068394u, 0x6FB07D457124123Cu, 0x6FE49C96CD6D16CBu, 0x7019C3BC80C85C7Eu, 0x70501A55D07D39CFu,
+ 0x708420EB449C8842u, 0x70B9292615C3AA53u, 0x70EF736F9B3494E8u, 0x7123A825C100DD11u, 0x7158922F31411455u,
+ 0x718EB6BAFD91596Bu, 0x71C33234DE7AD7E2u, 0x71F7FEC216198DDBu, 0x722DFE729B9FF152u, 0x7262BF07A143F6D3u,
+ 0x72976EC98994F488u, 0x72CD4A7BEBFA31AAu, 0x73024E8D737C5F0Au, 0x7336E230D05B76CDu, 0x736C9ABD04725480u,
+ 0x73A1E0B622C774D0u, 0x73D658E3AB795204u, 0x740BEF1C9657A685u, 0x74417571DDF6C813u, 0x7475D2CE55747A18u,
+ 0x74AB4781EAD1989Eu, 0x74E10CB132C2FF63u, 0x75154FDD7F73BF3Bu, 0x754AA3D4DF50AF0Au, 0x7580A6650B926D66u,
+ 0x75B4CFFE4E7708C0u, 0x75EA03FDE214CAF0u, 0x7620427EAD4CFED6u, 0x7654531E58A03E8Bu, 0x768967E5EEC84E2Eu,
+ 0x76BFC1DF6A7A61BAu, 0x76F3D92BA28C7D14u, 0x7728CF768B2F9C59u, 0x775F03542DFB8370u, 0x779362149CBD3226u,
+ 0x77C83A99C3EC7EAFu, 0x77FE494034E79E5Bu, 0x7832EDC82110C2F9u, 0x7867A93A2954F3B7u, 0x789D9388B3AA30A5u,
+ 0x78D27C35704A5E67u, 0x79071B42CC5CF601u, 0x793CE2137F743381u, 0x79720D4C2FA8A030u, 0x79A6909F3B92C83Du,
+ 0x79DC34C70A777A4Cu, 0x7A11A0FC668AAC6Fu, 0x7A46093B802D578Bu, 0x7A7B8B8A6038AD6Eu, 0x7AB137367C236C65u,
+ 0x7AE585041B2C477Eu, 0x7B1AE64521F7595Eu, 0x7B50CFEB353A97DAu, 0x7B8503E602893DD1u, 0x7BBA44DF832B8D45u,
+ 0x7BF06B0BB1FB384Bu, 0x7C2485CE9E7A065Eu, 0x7C59A742461887F6u, 0x7C9008896BCF54F9u, 0x7CC40AABC6C32A38u,
+ 0x7CF90D56B873F4C6u, 0x7D2F50AC6690F1F8u, 0x7D63926BC01A973Bu, 0x7D987706B0213D09u, 0x7DCE94C85C298C4Cu,
+ 0x7E031CFD3999F7AFu, 0x7E37E43C8800759Bu, 0x7E6DDD4BAA009302u, 0x7EA2AA4F4A405BE1u, 0x7ED754E31CD072D9u,
+ 0x7F0D2A1BE4048F90u, 0x7F423A516E82D9BAu, 0x7F76C8E5CA239028u, 0x7FAC7B1F3CAC7433u, 0x7FE1CCF385EBC89Fu,
+ 0x7FEFFFFFFFFFFFFFu};
+};
+
+template <class _Floating>
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+to_chars_result _Floating_to_chars_general_precision(
+ char* _First, char* const _Last, const _Floating _Value, int _Precision) noexcept {
+
+ using _Traits = _Floating_type_traits<_Floating>;
+ using _Uint_type = typename _Traits::_Uint_type;
+
+ const _Uint_type _Uint_value = _VSTD::bit_cast<_Uint_type>(_Value);
+
+ if (_Uint_value == 0) { // zero detected; write "0" and return; _Precision is irrelevant due to zero-trimming
+ if (_First == _Last) {
+ return {_Last, errc::value_too_large};
+ }
+
+ *_First++ = '0';
+
+ return {_First, errc{}};
+ }
+
+ // C11 7.21.6.1 "The fprintf function"/5:
+ // "A negative precision argument is taken as if the precision were omitted."
+ // /8: "g,G [...] Let P equal the precision if nonzero, 6 if the precision is omitted,
+ // or 1 if the precision is zero."
+
+ // Performance note: It's possible to rewrite this for branchless codegen,
+ // but profiling will be necessary to determine whether that's faster.
+ if (_Precision < 0) {
+ _Precision = 6;
+ } else if (_Precision == 0) {
+ _Precision = 1;
+ } else if (_Precision < 1'000'000) {
+ // _Precision is ok.
+ } else {
+ // Avoid integer overflow.
+ // Due to general notation's zero-trimming behavior, we can simply clamp _Precision.
+ // This is further clamped below.
+ _Precision = 1'000'000;
+ }
+
+ // _Precision is now the Standard's P.
+
+ // /8: "Then, if a conversion with style E would have an exponent of X:
+ // - if P > X >= -4, the conversion is with style f (or F) and precision P - (X + 1).
+ // - otherwise, the conversion is with style e (or E) and precision P - 1."
+
+ // /8: "Finally, [...] any trailing zeros are removed from the fractional portion of the result
+ // and the decimal-point character is removed if there is no fractional portion remaining."
+
+ using _Tables = _General_precision_tables<_Floating>;
+
+ const _Uint_type* _Table_begin;
+ const _Uint_type* _Table_end;
+
+ if (_Precision <= _Tables::_Max_special_P) {
+ _Table_begin = _Tables::_Special_X_table + (_Precision - 1) * (_Precision + 10) / 2;
+ _Table_end = _Table_begin + _Precision + 5;
+ } else {
+ _Table_begin = _Tables::_Ordinary_X_table;
+ _Table_end = _Table_begin + _VSTD::min(_Precision, _Tables::_Max_P) + 5;
+ }
+
+ // Profiling indicates that linear search is faster than binary search for small tables.
+ // Performance note: lambda captures may have a small performance cost.
+ const _Uint_type* const _Table_lower_bound = [=] {
+ if constexpr (!_IsSame<_Floating, float>::value) {
+ if (_Precision > 155) { // threshold determined via profiling
+ return _VSTD::lower_bound(_Table_begin, _Table_end, _Uint_value, less{});
+ }
+ }
+
+ return _VSTD::find_if(_Table_begin, _Table_end, [=](const _Uint_type _Elem) { return _Uint_value <= _Elem; });
+ }();
+
+ const ptrdiff_t _Table_index = _Table_lower_bound - _Table_begin;
+ const int _Scientific_exponent_X = static_cast<int>(_Table_index - 5);
+ const bool _Use_fixed_notation = _Precision > _Scientific_exponent_X && _Scientific_exponent_X >= -4;
+
+ // Performance note: it might (or might not) be faster to modify Ryu Printf to perform zero-trimming.
+ // Such modifications would involve a fairly complicated state machine (notably, both '0' and '9' digits would
+ // need to be buffered, due to rounding), and that would have performance costs due to increased branching.
+ // Here, we're using a simpler approach: writing into a local buffer, manually zero-trimming, and then copying into
+ // the output range. The necessary buffer size is reasonably small, the zero-trimming logic is simple and fast,
+ // and the final copying is also fast.
+
+ constexpr int _Max_output_length =
+ _IsSame<_Floating, float>::value ? 117 : 773; // cases: 0x1.fffffep-126f and 0x1.fffffffffffffp-1022
+ constexpr int _Max_fixed_precision =
+ _IsSame<_Floating, float>::value ? 37 : 66; // cases: 0x1.fffffep-14f and 0x1.fffffffffffffp-14
+ constexpr int _Max_scientific_precision =
+ _IsSame<_Floating, float>::value ? 111 : 766; // cases: 0x1.fffffep-126f and 0x1.fffffffffffffp-1022
+
+ // Note that _Max_output_length is determined by scientific notation and is more than enough for fixed notation.
+ // 0x1.fffffep+127f is 39 digits, plus 1 for '.', plus _Max_fixed_precision for '0' digits, equals 77.
+ // 0x1.fffffffffffffp+1023 is 309 digits, plus 1 for '.', plus _Max_fixed_precision for '0' digits, equals 376.
+
+ char _Buffer[_Max_output_length];
+ const char* const _Significand_first = _Buffer; // e.g. "1.234"
+ const char* _Significand_last = nullptr;
+ const char* _Exponent_first = nullptr; // e.g. "e-05"
+ const char* _Exponent_last = nullptr;
+ int _Effective_precision; // number of digits printed after the decimal point, before trimming
+
+ // Write into the local buffer.
+ // Clamping _Effective_precision allows _Buffer to be as small as possible, and increases efficiency.
+ if (_Use_fixed_notation) {
+ _Effective_precision = _VSTD::min(_Precision - (_Scientific_exponent_X + 1), _Max_fixed_precision);
+ const to_chars_result _Buf_result =
+ _Floating_to_chars_fixed_precision(_Buffer, _VSTD::end(_Buffer), _Value, _Effective_precision);
+ _LIBCPP_ASSERT(_Buf_result.ec == errc{}, "");
+ _Significand_last = _Buf_result.ptr;
+ } else {
+ _Effective_precision = _VSTD::min(_Precision - 1, _Max_scientific_precision);
+ const to_chars_result _Buf_result =
+ _Floating_to_chars_scientific_precision(_Buffer, _VSTD::end(_Buffer), _Value, _Effective_precision);
+ _LIBCPP_ASSERT(_Buf_result.ec == errc{}, "");
+ _Significand_last = _VSTD::find(_Buffer, _Buf_result.ptr, 'e');
+ _Exponent_first = _Significand_last;
+ _Exponent_last = _Buf_result.ptr;
+ }
+
+ // If we printed a decimal point followed by digits, perform zero-trimming.
+ if (_Effective_precision > 0) {
+ while (_Significand_last[-1] == '0') { // will stop at '.' or a nonzero digit
+ --_Significand_last;
+ }
+
+ if (_Significand_last[-1] == '.') {
+ --_Significand_last;
+ }
+ }
+
+ // Copy the significand to the output range.
+ const ptrdiff_t _Significand_distance = _Significand_last - _Significand_first;
+ if (_Last - _First < _Significand_distance) {
+ return {_Last, errc::value_too_large};
+ }
+ _VSTD::memcpy(_First, _Significand_first, static_cast<size_t>(_Significand_distance));
+ _First += _Significand_distance;
+
+ // Copy the exponent to the output range.
+ if (!_Use_fixed_notation) {
+ const ptrdiff_t _Exponent_distance = _Exponent_last - _Exponent_first;
+ if (_Last - _First < _Exponent_distance) {
+ return {_Last, errc::value_too_large};
+ }
+ _VSTD::memcpy(_First, _Exponent_first, static_cast<size_t>(_Exponent_distance));
+ _First += _Exponent_distance;
+ }
+
+ return {_First, errc{}};
+}
+
+enum class _Floating_to_chars_overload { _Plain, _Format_only, _Format_precision };
+
+template <_Floating_to_chars_overload _Overload, class _Floating>
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+to_chars_result _Floating_to_chars(
+ char* _First, char* const _Last, _Floating _Value, const chars_format _Fmt, const int _Precision) noexcept {
+
+ if constexpr (_Overload == _Floating_to_chars_overload::_Plain) {
+ _LIBCPP_ASSERT(_Fmt == chars_format{}, ""); // plain overload must pass chars_format{} internally
+ } else {
+ _LIBCPP_ASSERT(_Fmt == chars_format::general || _Fmt == chars_format::scientific || _Fmt == chars_format::fixed
+ || _Fmt == chars_format::hex,
+ "invalid format in to_chars()");
+ }
+
+ using _Traits = _Floating_type_traits<_Floating>;
+ using _Uint_type = typename _Traits::_Uint_type;
+
+ _Uint_type _Uint_value = _VSTD::bit_cast<_Uint_type>(_Value);
+
+ const bool _Was_negative = (_Uint_value & _Traits::_Shifted_sign_mask) != 0;
+
+ if (_Was_negative) { // sign bit detected; write minus sign and clear sign bit
+ if (_First == _Last) {
+ return {_Last, errc::value_too_large};
+ }
+
+ *_First++ = '-';
+
+ _Uint_value &= ~_Traits::_Shifted_sign_mask;
+ _Value = _VSTD::bit_cast<_Floating>(_Uint_value);
+ }
+
+ if ((_Uint_value & _Traits::_Shifted_exponent_mask) == _Traits::_Shifted_exponent_mask) {
+ // inf/nan detected; write appropriate string and return
+ const char* _Str;
+ size_t _Len;
+
+ const _Uint_type _Mantissa = _Uint_value & _Traits::_Denormal_mantissa_mask;
+
+ if (_Mantissa == 0) {
+ _Str = "inf";
+ _Len = 3;
+ } else if (_Was_negative && _Mantissa == _Traits::_Special_nan_mantissa_mask) {
+ // When a NaN value has the sign bit set, the quiet bit set, and all other mantissa bits cleared,
+ // the UCRT interprets it to mean "indeterminate", and indicates this by printing "-nan(ind)".
+ _Str = "nan(ind)";
+ _Len = 8;
+ } else if ((_Mantissa & _Traits::_Special_nan_mantissa_mask) != 0) {
+ _Str = "nan";
+ _Len = 3;
+ } else {
+ _Str = "nan(snan)";
+ _Len = 9;
+ }
+
+ if (_Last - _First < static_cast<ptrdiff_t>(_Len)) {
+ return {_Last, errc::value_too_large};
+ }
+
+ _VSTD::memcpy(_First, _Str, _Len);
+
+ return {_First + _Len, errc{}};
+ }
+
+ if constexpr (_Overload == _Floating_to_chars_overload::_Plain) {
+ return _Floating_to_chars_ryu(_First, _Last, _Value, chars_format{});
+ } else if constexpr (_Overload == _Floating_to_chars_overload::_Format_only) {
+ if (_Fmt == chars_format::hex) {
+ return _Floating_to_chars_hex_shortest(_First, _Last, _Value);
+ }
+
+ return _Floating_to_chars_ryu(_First, _Last, _Value, _Fmt);
+ } else if constexpr (_Overload == _Floating_to_chars_overload::_Format_precision) {
+ switch (_Fmt) {
+ case chars_format::scientific:
+ return _Floating_to_chars_scientific_precision(_First, _Last, _Value, _Precision);
+ case chars_format::fixed:
+ return _Floating_to_chars_fixed_precision(_First, _Last, _Value, _Precision);
+ case chars_format::general:
+ return _Floating_to_chars_general_precision(_First, _Last, _Value, _Precision);
+ case chars_format::hex:
+ default: // avoid MSVC warning C4715: not all control paths return a value
+ return _Floating_to_chars_hex_precision(_First, _Last, _Value, _Precision);
+ }
+ }
+}
+
+// clang-format on
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_SRC_INCLUDE_TO_CHARS_FLOATING_POINT_H
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/ios.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/ios.cpp
new file mode 100644
index 0000000000..870406b554
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/ios.cpp
@@ -0,0 +1,443 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <__config>
+#include <__locale>
+#include <algorithm>
+#include <ios>
+#include <limits>
+#include <memory>
+#include <new>
+#include <stdlib.h>
+#include <string>
+
+#include "include/config_elast.h"
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+class _LIBCPP_HIDDEN __iostream_category
+ : public __do_message
+{
+public:
+ virtual const char* name() const noexcept;
+ virtual string message(int ev) const;
+};
+
+const char*
+__iostream_category::name() const noexcept
+{
+ return "iostream";
+}
+
+string
+__iostream_category::message(int ev) const
+{
+ if (ev != static_cast<int>(io_errc::stream)
+#ifdef _LIBCPP_ELAST
+ && ev <= _LIBCPP_ELAST
+#endif // _LIBCPP_ELAST
+ )
+ return __do_message::message(ev);
+ return string("unspecified iostream_category error");
+}
+
+const error_category&
+iostream_category() noexcept
+{
+ static __iostream_category s;
+ return s;
+}
+
+// ios_base::failure
+
+ios_base::failure::failure(const string& msg, const error_code& ec)
+ : system_error(ec, msg)
+{
+}
+
+ios_base::failure::failure(const char* msg, const error_code& ec)
+ : system_error(ec, msg)
+{
+}
+
+ios_base::failure::~failure() throw()
+{
+}
+
+// ios_base locale
+
+const ios_base::fmtflags ios_base::boolalpha;
+const ios_base::fmtflags ios_base::dec;
+const ios_base::fmtflags ios_base::fixed;
+const ios_base::fmtflags ios_base::hex;
+const ios_base::fmtflags ios_base::internal;
+const ios_base::fmtflags ios_base::left;
+const ios_base::fmtflags ios_base::oct;
+const ios_base::fmtflags ios_base::right;
+const ios_base::fmtflags ios_base::scientific;
+const ios_base::fmtflags ios_base::showbase;
+const ios_base::fmtflags ios_base::showpoint;
+const ios_base::fmtflags ios_base::showpos;
+const ios_base::fmtflags ios_base::skipws;
+const ios_base::fmtflags ios_base::unitbuf;
+const ios_base::fmtflags ios_base::uppercase;
+const ios_base::fmtflags ios_base::adjustfield;
+const ios_base::fmtflags ios_base::basefield;
+const ios_base::fmtflags ios_base::floatfield;
+
+const ios_base::iostate ios_base::badbit;
+const ios_base::iostate ios_base::eofbit;
+const ios_base::iostate ios_base::failbit;
+const ios_base::iostate ios_base::goodbit;
+
+const ios_base::openmode ios_base::app;
+const ios_base::openmode ios_base::ate;
+const ios_base::openmode ios_base::binary;
+const ios_base::openmode ios_base::in;
+const ios_base::openmode ios_base::out;
+const ios_base::openmode ios_base::trunc;
+
+void
+ios_base::__call_callbacks(event ev)
+{
+ for (size_t i = __event_size_; i;)
+ {
+ --i;
+ __fn_[i](ev, *this, __index_[i]);
+ }
+}
+
+// locale
+
+locale
+ios_base::imbue(const locale& newloc)
+{
+ static_assert(sizeof(locale) == sizeof(__loc_), "");
+ locale& loc_storage = *reinterpret_cast<locale*>(&__loc_);
+ locale oldloc = loc_storage;
+ loc_storage = newloc;
+ __call_callbacks(imbue_event);
+ return oldloc;
+}
+
+locale
+ios_base::getloc() const
+{
+ const locale& loc_storage = *reinterpret_cast<const locale*>(&__loc_);
+ return loc_storage;
+}
+
+// xalloc
+#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS)
+atomic<int> ios_base::__xindex_{0};
+#else
+int ios_base::__xindex_ = 0;
+#endif
+
+template <typename _Tp>
+static size_t __ios_new_cap(size_t __req_size, size_t __current_cap)
+{ // Precondition: __req_size > __current_cap
+ const size_t mx = std::numeric_limits<size_t>::max() / sizeof(_Tp);
+ if (__req_size < mx/2)
+ return _VSTD::max(2 * __current_cap, __req_size);
+ else
+ return mx;
+}
+
+int
+ios_base::xalloc()
+{
+ return __xindex_++;
+}
+
+long&
+ios_base::iword(int index)
+{
+ size_t req_size = static_cast<size_t>(index)+1;
+ if (req_size > __iarray_cap_)
+ {
+ size_t newcap = __ios_new_cap<long>(req_size, __iarray_cap_);
+ long* iarray = static_cast<long*>(realloc(__iarray_, newcap * sizeof(long)));
+ if (iarray == 0)
+ {
+ setstate(badbit);
+ static long error;
+ error = 0;
+ return error;
+ }
+ __iarray_ = iarray;
+ for (long* p = __iarray_ + __iarray_size_; p < __iarray_ + newcap; ++p)
+ *p = 0;
+ __iarray_cap_ = newcap;
+ }
+ __iarray_size_ = max<size_t>(__iarray_size_, req_size);
+ return __iarray_[index];
+}
+
+void*&
+ios_base::pword(int index)
+{
+ size_t req_size = static_cast<size_t>(index)+1;
+ if (req_size > __parray_cap_)
+ {
+ size_t newcap = __ios_new_cap<void *>(req_size, __iarray_cap_);
+ void** parray = static_cast<void**>(realloc(__parray_, newcap * sizeof(void *)));
+ if (parray == 0)
+ {
+ setstate(badbit);
+ static void* error;
+ error = 0;
+ return error;
+ }
+ __parray_ = parray;
+ for (void** p = __parray_ + __parray_size_; p < __parray_ + newcap; ++p)
+ *p = 0;
+ __parray_cap_ = newcap;
+ }
+ __parray_size_ = max<size_t>(__parray_size_, req_size);
+ return __parray_[index];
+}
+
+// register_callback
+
+void
+ios_base::register_callback(event_callback fn, int index)
+{
+ size_t req_size = __event_size_ + 1;
+ if (req_size > __event_cap_)
+ {
+ size_t newcap = __ios_new_cap<event_callback>(req_size, __event_cap_);
+ event_callback* fns = static_cast<event_callback*>(realloc(__fn_, newcap * sizeof(event_callback)));
+ if (fns == 0)
+ setstate(badbit);
+ __fn_ = fns;
+ int* indxs = static_cast<int *>(realloc(__index_, newcap * sizeof(int)));
+ if (indxs == 0)
+ setstate(badbit);
+ __index_ = indxs;
+ __event_cap_ = newcap;
+ }
+ __fn_[__event_size_] = fn;
+ __index_[__event_size_] = index;
+ ++__event_size_;
+}
+
+ios_base::~ios_base()
+{
+ __call_callbacks(erase_event);
+ locale& loc_storage = *reinterpret_cast<locale*>(&__loc_);
+ loc_storage.~locale();
+ free(__fn_);
+ free(__index_);
+ free(__iarray_);
+ free(__parray_);
+}
+
+// iostate
+
+void
+ios_base::clear(iostate state)
+{
+ if (__rdbuf_)
+ __rdstate_ = state;
+ else
+ __rdstate_ = state | badbit;
+
+ if (((state | (__rdbuf_ ? goodbit : badbit)) & __exceptions_) != 0)
+ __throw_failure("ios_base::clear");
+}
+
+// init
+
+void
+ios_base::init(void* sb)
+{
+ __rdbuf_ = sb;
+ __rdstate_ = __rdbuf_ ? goodbit : badbit;
+ __exceptions_ = goodbit;
+ __fmtflags_ = skipws | dec;
+ __width_ = 0;
+ __precision_ = 6;
+ __fn_ = 0;
+ __index_ = 0;
+ __event_size_ = 0;
+ __event_cap_ = 0;
+ __iarray_ = 0;
+ __iarray_size_ = 0;
+ __iarray_cap_ = 0;
+ __parray_ = 0;
+ __parray_size_ = 0;
+ __parray_cap_ = 0;
+ ::new(&__loc_) locale;
+}
+
+void
+ios_base::copyfmt(const ios_base& rhs)
+{
+ // If we can't acquire the needed resources, throw bad_alloc (can't set badbit)
+ // Don't alter *this until all needed resources are acquired
+ unique_ptr<event_callback, void (*)(void*)> new_callbacks(0, free);
+ unique_ptr<int, void (*)(void*)> new_ints(0, free);
+ unique_ptr<long, void (*)(void*)> new_longs(0, free);
+ unique_ptr<void*, void (*)(void*)> new_pointers(0, free);
+ if (__event_cap_ < rhs.__event_size_)
+ {
+ size_t newesize = sizeof(event_callback) * rhs.__event_size_;
+ new_callbacks.reset(static_cast<event_callback*>(malloc(newesize)));
+ if (!new_callbacks)
+ __throw_bad_alloc();
+
+ size_t newisize = sizeof(int) * rhs.__event_size_;
+ new_ints.reset(static_cast<int *>(malloc(newisize)));
+ if (!new_ints)
+ __throw_bad_alloc();
+ }
+ if (__iarray_cap_ < rhs.__iarray_size_)
+ {
+ size_t newsize = sizeof(long) * rhs.__iarray_size_;
+ new_longs.reset(static_cast<long*>(malloc(newsize)));
+ if (!new_longs)
+ __throw_bad_alloc();
+ }
+ if (__parray_cap_ < rhs.__parray_size_)
+ {
+ size_t newsize = sizeof(void*) * rhs.__parray_size_;
+ new_pointers.reset(static_cast<void**>(malloc(newsize)));
+ if (!new_pointers)
+ __throw_bad_alloc();
+ }
+ // Got everything we need. Copy everything but __rdstate_, __rdbuf_ and __exceptions_
+ __fmtflags_ = rhs.__fmtflags_;
+ __precision_ = rhs.__precision_;
+ __width_ = rhs.__width_;
+ locale& lhs_loc = *reinterpret_cast<locale*>(&__loc_);
+ const locale& rhs_loc = *reinterpret_cast<const locale*>(&rhs.__loc_);
+ lhs_loc = rhs_loc;
+ if (__event_cap_ < rhs.__event_size_)
+ {
+ free(__fn_);
+ __fn_ = new_callbacks.release();
+ free(__index_);
+ __index_ = new_ints.release();
+ __event_cap_ = rhs.__event_size_;
+ }
+ for (__event_size_ = 0; __event_size_ < rhs.__event_size_; ++__event_size_)
+ {
+ __fn_[__event_size_] = rhs.__fn_[__event_size_];
+ __index_[__event_size_] = rhs.__index_[__event_size_];
+ }
+ if (__iarray_cap_ < rhs.__iarray_size_)
+ {
+ free(__iarray_);
+ __iarray_ = new_longs.release();
+ __iarray_cap_ = rhs.__iarray_size_;
+ }
+ for (__iarray_size_ = 0; __iarray_size_ < rhs.__iarray_size_; ++__iarray_size_)
+ __iarray_[__iarray_size_] = rhs.__iarray_[__iarray_size_];
+ if (__parray_cap_ < rhs.__parray_size_)
+ {
+ free(__parray_);
+ __parray_ = new_pointers.release();
+ __parray_cap_ = rhs.__parray_size_;
+ }
+ for (__parray_size_ = 0; __parray_size_ < rhs.__parray_size_; ++__parray_size_)
+ __parray_[__parray_size_] = rhs.__parray_[__parray_size_];
+}
+
+void
+ios_base::move(ios_base& rhs)
+{
+ // *this is uninitialized
+ __fmtflags_ = rhs.__fmtflags_;
+ __precision_ = rhs.__precision_;
+ __width_ = rhs.__width_;
+ __rdstate_ = rhs.__rdstate_;
+ __exceptions_ = rhs.__exceptions_;
+ __rdbuf_ = 0;
+ locale& rhs_loc = *reinterpret_cast<locale*>(&rhs.__loc_);
+ ::new(&__loc_) locale(rhs_loc);
+ __fn_ = rhs.__fn_;
+ rhs.__fn_ = 0;
+ __index_ = rhs.__index_;
+ rhs.__index_ = 0;
+ __event_size_ = rhs.__event_size_;
+ rhs.__event_size_ = 0;
+ __event_cap_ = rhs.__event_cap_;
+ rhs.__event_cap_ = 0;
+ __iarray_ = rhs.__iarray_;
+ rhs.__iarray_ = 0;
+ __iarray_size_ = rhs.__iarray_size_;
+ rhs.__iarray_size_ = 0;
+ __iarray_cap_ = rhs.__iarray_cap_;
+ rhs.__iarray_cap_ = 0;
+ __parray_ = rhs.__parray_;
+ rhs.__parray_ = 0;
+ __parray_size_ = rhs.__parray_size_;
+ rhs.__parray_size_ = 0;
+ __parray_cap_ = rhs.__parray_cap_;
+ rhs.__parray_cap_ = 0;
+}
+
+void
+ios_base::swap(ios_base& rhs) noexcept
+{
+ _VSTD::swap(__fmtflags_, rhs.__fmtflags_);
+ _VSTD::swap(__precision_, rhs.__precision_);
+ _VSTD::swap(__width_, rhs.__width_);
+ _VSTD::swap(__rdstate_, rhs.__rdstate_);
+ _VSTD::swap(__exceptions_, rhs.__exceptions_);
+ locale& lhs_loc = *reinterpret_cast<locale*>(&__loc_);
+ locale& rhs_loc = *reinterpret_cast<locale*>(&rhs.__loc_);
+ _VSTD::swap(lhs_loc, rhs_loc);
+ _VSTD::swap(__fn_, rhs.__fn_);
+ _VSTD::swap(__index_, rhs.__index_);
+ _VSTD::swap(__event_size_, rhs.__event_size_);
+ _VSTD::swap(__event_cap_, rhs.__event_cap_);
+ _VSTD::swap(__iarray_, rhs.__iarray_);
+ _VSTD::swap(__iarray_size_, rhs.__iarray_size_);
+ _VSTD::swap(__iarray_cap_, rhs.__iarray_cap_);
+ _VSTD::swap(__parray_, rhs.__parray_);
+ _VSTD::swap(__parray_size_, rhs.__parray_size_);
+ _VSTD::swap(__parray_cap_, rhs.__parray_cap_);
+}
+
+void
+ios_base::__set_badbit_and_consider_rethrow()
+{
+ __rdstate_ |= badbit;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ if (__exceptions_ & badbit)
+ throw;
+#endif // _LIBCPP_NO_EXCEPTIONS
+}
+
+void
+ios_base::__set_failbit_and_consider_rethrow()
+{
+ __rdstate_ |= failbit;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ if (__exceptions_ & failbit)
+ throw;
+#endif // _LIBCPP_NO_EXCEPTIONS
+}
+
+bool
+ios_base::sync_with_stdio(bool sync)
+{
+ static bool previous_state = true;
+ bool r = previous_state;
+ previous_state = sync;
+ return r;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/ios.instantiations.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/ios.instantiations.cpp
new file mode 100644
index 0000000000..2ff7057fa6
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/ios.instantiations.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <__config>
+#include <fstream>
+#include <ios>
+#include <istream>
+#include <ostream>
+#include <sstream>
+#include <streambuf>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// Original explicit instantiations provided in the library
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ios<char>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_streambuf<char>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_istream<char>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ostream<char>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_iostream<char>;
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ios<wchar_t>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_streambuf<wchar_t>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_istream<wchar_t>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ostream<wchar_t>;
+#endif
+
+// Additional instantiations added later. Whether programs rely on these being
+// available is protected by _LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1.
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_stringbuf<char>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_stringstream<char>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ostringstream<char>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_istringstream<char>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ifstream<char>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ofstream<char>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_filebuf<char>;
+
+// Add more here if needed...
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/iostream.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/iostream.cpp
new file mode 100644
index 0000000000..79dbd9a52b
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/iostream.cpp
@@ -0,0 +1,204 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <__locale>
+#include <__std_stream>
+#include <new>
+#include <string>
+
+#define _str(s) #s
+#define str(s) _str(s)
+#define _LIBCPP_ABI_NAMESPACE_STR str(_LIBCPP_ABI_NAMESPACE)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(__clang__)
+_ALIGNAS_TYPE (istream) char _cin [sizeof(istream)];
+_LIBCPP_FUNC_VIS istream& cin = *reinterpret_cast<istream*>(_cin);
+#else
+_ALIGNAS_TYPE (istream) _LIBCPP_FUNC_VIS char cin[sizeof(istream)]
+#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
+__asm__("?cin@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_istream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR "@std@@@12@A")
+#endif
+;
+#endif
+_ALIGNAS_TYPE (__stdinbuf<char> ) static char __cin[sizeof(__stdinbuf <char>)];
+static mbstate_t mb_cin;
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(__clang__)
+_ALIGNAS_TYPE (wistream) char _wcin [sizeof(wistream)];
+_LIBCPP_FUNC_VIS wistream& wcin = *reinterpret_cast<wistream*>(_wcin);
+#else
+_ALIGNAS_TYPE (wistream) _LIBCPP_FUNC_VIS char wcin[sizeof(wistream)]
+#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
+__asm__("?wcin@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_istream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR "@std@@@12@A")
+#endif
+;
+#endif
+_ALIGNAS_TYPE (__stdinbuf<wchar_t> ) static char __wcin[sizeof(__stdinbuf <wchar_t>)];
+static mbstate_t mb_wcin;
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(__clang__)
+_ALIGNAS_TYPE (ostream) char _cout[sizeof(ostream)];
+_LIBCPP_FUNC_VIS ostream& cout = *reinterpret_cast<ostream*>(_cout);
+#else
+_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char cout[sizeof(ostream)]
+#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
+__asm__("?cout@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR "@std@@@12@A")
+#endif
+;
+#endif
+_ALIGNAS_TYPE (__stdoutbuf<char>) static char __cout[sizeof(__stdoutbuf<char>)];
+static mbstate_t mb_cout;
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(__clang__)
+_ALIGNAS_TYPE (wostream) char _wcout[sizeof(wostream)];
+_LIBCPP_FUNC_VIS wostream& wcout = *reinterpret_cast<wostream*>(_wcout);
+#else
+_ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wcout[sizeof(wostream)]
+#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
+__asm__("?wcout@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR "@std@@@12@A")
+#endif
+;
+#endif
+_ALIGNAS_TYPE (__stdoutbuf<wchar_t>) static char __wcout[sizeof(__stdoutbuf<wchar_t>)];
+static mbstate_t mb_wcout;
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(__clang__)
+_ALIGNAS_TYPE (ostream) char _cerr[sizeof(ostream)];
+_LIBCPP_FUNC_VIS ostream& cerr = *reinterpret_cast<ostream*>(_cerr);
+#else
+_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char cerr[sizeof(ostream)]
+#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
+__asm__("?cerr@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR "@std@@@12@A")
+#endif
+;
+#endif
+_ALIGNAS_TYPE (__stdoutbuf<char>) static char __cerr[sizeof(__stdoutbuf<char>)];
+static mbstate_t mb_cerr;
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(__clang__)
+_ALIGNAS_TYPE (wostream) char _wcerr[sizeof(wostream)];
+_LIBCPP_FUNC_VIS wostream& wcerr = *reinterpret_cast<wostream*>(_wcerr);
+#else
+_ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wcerr[sizeof(wostream)]
+#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
+__asm__("?wcerr@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR "@std@@@12@A")
+#endif
+;
+#endif
+_ALIGNAS_TYPE (__stdoutbuf<wchar_t>) static char __wcerr[sizeof(__stdoutbuf<wchar_t>)];
+static mbstate_t mb_wcerr;
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(__clang__)
+_ALIGNAS_TYPE (ostream) char _clog[sizeof(ostream)];
+_LIBCPP_FUNC_VIS ostream& clog = *reinterpret_cast<ostream*>(_clog);
+#else
+_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char clog[sizeof(ostream)]
+#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
+__asm__("?clog@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR "@std@@@12@A")
+#endif
+;
+#endif
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(__clang__)
+_ALIGNAS_TYPE (wostream) char _wclog[sizeof(wostream)];
+_LIBCPP_FUNC_VIS wostream& wclog = *reinterpret_cast<wostream*>(_wclog);
+#else
+_ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wclog[sizeof(wostream)]
+#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
+__asm__("?wclog@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR "@std@@@12@A")
+#endif
+;
+#endif
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+// Pretend we're inside a system header so the compiler doesn't flag the use of the init_priority
+// attribute with a value that's reserved for the implementation (we're the implementation).
+#include "iostream_init.h"
+
+// On Windows the TLS storage for locales needs to be initialized before we create
+// the standard streams, otherwise it may not be alive during program termination
+// when we flush the streams.
+static void force_locale_initialization() {
+#if defined(_LIBCPP_MSVCRT_LIKE)
+ static bool once = []() {
+ auto loc = newlocale(LC_ALL_MASK, "C", 0);
+ {
+ __libcpp_locale_guard g(loc); // forces initialization of locale TLS
+ ((void)g);
+ }
+ freelocale(loc);
+ return true;
+ }();
+ ((void)once);
+#endif
+}
+
+class DoIOSInit {
+public:
+ DoIOSInit();
+ ~DoIOSInit();
+};
+
+DoIOSInit::DoIOSInit()
+{
+ force_locale_initialization();
+
+ istream* cin_ptr = ::new(&cin) istream(::new(__cin) __stdinbuf <char>(stdin, &mb_cin));
+ ostream* cout_ptr = ::new(&cout) ostream(::new(__cout) __stdoutbuf<char>(stdout, &mb_cout));
+ ostream* cerr_ptr = ::new(&cerr) ostream(::new(__cerr) __stdoutbuf<char>(stderr, &mb_cerr));
+ ::new(&clog) ostream(cerr_ptr->rdbuf());
+ cin_ptr->tie(cout_ptr);
+ _VSTD::unitbuf(*cerr_ptr);
+ cerr_ptr->tie(cout_ptr);
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ wistream* wcin_ptr = ::new(&wcin) wistream(::new(__wcin) __stdinbuf <wchar_t>(stdin, &mb_wcin));
+ wostream* wcout_ptr = ::new(&wcout) wostream(::new(__wcout) __stdoutbuf<wchar_t>(stdout, &mb_wcout));
+ wostream* wcerr_ptr = ::new(&wcerr) wostream(::new(__wcerr) __stdoutbuf<wchar_t>(stderr, &mb_wcerr));
+ ::new(&wclog) wostream(wcerr_ptr->rdbuf());
+
+ wcin_ptr->tie(wcout_ptr);
+ _VSTD::unitbuf(*wcerr_ptr);
+ wcerr_ptr->tie(wcout_ptr);
+#endif
+}
+
+DoIOSInit::~DoIOSInit()
+{
+ ostream* cout_ptr = reinterpret_cast<ostream*>(&cout);
+ cout_ptr->flush();
+ ostream* clog_ptr = reinterpret_cast<ostream*>(&clog);
+ clog_ptr->flush();
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ wostream* wcout_ptr = reinterpret_cast<wostream*>(&wcout);
+ wcout_ptr->flush();
+ wostream* wclog_ptr = reinterpret_cast<wostream*>(&wclog);
+ wclog_ptr->flush();
+#endif
+}
+
+ios_base::Init::Init()
+{
+ static DoIOSInit init_the_streams; // gets initialized once
+}
+
+ios_base::Init::~Init()
+{
+}
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/iostream_init.h b/contrib/libs/cxxsupp/libcxxmsvc/src/iostream_init.h
new file mode 100644
index 0000000000..7d1bb5c2d7
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/iostream_init.h
@@ -0,0 +1,2 @@
+#pragma GCC system_header
+_LIBCPP_HIDDEN ios_base::Init __start_std_streams _LIBCPP_INIT_PRIORITY_MAX;
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/legacy_pointer_safety.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/legacy_pointer_safety.cpp
new file mode 100644
index 0000000000..5d2b04c121
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/legacy_pointer_safety.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <__config>
+#include <memory>
+
+// Support for garbage collection was removed in C++23 by https://wg21.link/P2186R2. Libc++ implements
+// that removal as an extension in all Standard versions. However, we still define the functions that
+// were once part of the library's ABI for backwards compatibility.
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+_LIBCPP_FUNC_VIS void declare_reachable(void*) {}
+_LIBCPP_FUNC_VIS void declare_no_pointers(char*, size_t) {}
+_LIBCPP_FUNC_VIS void undeclare_no_pointers(char*, size_t) {}
+_LIBCPP_FUNC_VIS void* __undeclare_reachable(void* p) { return p; }
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/locale.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/locale.cpp
new file mode 100644
index 0000000000..fc95dad600
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/locale.cpp
@@ -0,0 +1,6613 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// On Solaris, we need to define something to make the C99 parts of localeconv
+// visible.
+#ifdef __sun__
+#define _LCONV_C99
+#endif
+
+#include <__utility/unreachable.h>
+#include <algorithm>
+#include <clocale>
+#include <codecvt>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <locale>
+#include <string>
+#include <type_traits>
+#include <typeinfo>
+#include <vector>
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# include <cwctype>
+#endif
+
+#if defined(_AIX)
+# include <sys/localedef.h> // for __lc_ctype_ptr
+#endif
+
+#if defined(_LIBCPP_MSVCRT)
+# define _CTYPE_DISABLE_MACROS
+#endif
+
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
+# include "__support/win32/locale_win32.h"
+#elif !defined(__BIONIC__) && !defined(__NuttX__)
+# include <langinfo.h>
+#endif
+
+#include "atomic"
+#include "include/sso_allocator.h"
+
+// On Linux, wint_t and wchar_t have different signed-ness, and this causes
+// lots of noise in the build log, but no bugs that I know of.
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wsign-conversion")
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+struct __libcpp_unique_locale {
+ __libcpp_unique_locale(const char* nm) : __loc_(newlocale(LC_ALL_MASK, nm, 0)) {}
+
+ ~__libcpp_unique_locale() {
+ if (__loc_)
+ freelocale(__loc_);
+ }
+
+ explicit operator bool() const { return __loc_; }
+
+ locale_t& get() { return __loc_; }
+
+ locale_t __loc_;
+private:
+ __libcpp_unique_locale(__libcpp_unique_locale const&);
+ __libcpp_unique_locale& operator=(__libcpp_unique_locale const&);
+};
+
+#ifdef __cloc_defined
+locale_t __cloc() {
+ // In theory this could create a race condition. In practice
+ // the race condition is non-fatal since it will just create
+ // a little resource leak. Better approach would be appreciated.
+ static locale_t result = newlocale(LC_ALL_MASK, "C", 0);
+ return result;
+}
+#endif // __cloc_defined
+
+namespace {
+
+struct release
+{
+ void operator()(locale::facet* p) {p->__release_shared();}
+};
+
+template <class T, class ...Args>
+T& make(Args ...args)
+{
+ static typename aligned_storage<sizeof(T)>::type buf;
+ auto *obj = ::new (&buf) T(args...);
+ return *obj;
+}
+
+template <typename T, size_t N>
+inline
+_LIBCPP_CONSTEXPR
+size_t
+countof(const T (&)[N])
+{
+ return N;
+}
+
+template <typename T>
+inline
+_LIBCPP_CONSTEXPR
+size_t
+countof(const T * const begin, const T * const end)
+{
+ return static_cast<size_t>(end - begin);
+}
+
+_LIBCPP_NORETURN static void __throw_runtime_error(const string &msg)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw runtime_error(msg);
+#else
+ (void)msg;
+ _VSTD::abort();
+#endif
+}
+
+}
+
+const locale::category locale::none;
+const locale::category locale::collate;
+const locale::category locale::ctype;
+const locale::category locale::monetary;
+const locale::category locale::numeric;
+const locale::category locale::time;
+const locale::category locale::messages;
+const locale::category locale::all;
+
+class _LIBCPP_HIDDEN locale::__imp
+ : public facet
+{
+ enum {N = 30};
+ vector<facet*, __sso_allocator<facet*, N> > facets_;
+ string name_;
+public:
+ explicit __imp(size_t refs = 0);
+ explicit __imp(const string& name, size_t refs = 0);
+ __imp(const __imp&);
+ __imp(const __imp&, const string&, locale::category c);
+ __imp(const __imp& other, const __imp& one, locale::category c);
+ __imp(const __imp&, facet* f, long id);
+ ~__imp();
+
+ const string& name() const {return name_;}
+ bool has_facet(long id) const
+ {return static_cast<size_t>(id) < facets_.size() && facets_[static_cast<size_t>(id)];}
+ const locale::facet* use_facet(long id) const;
+
+ static const locale& make_classic();
+ static locale& make_global();
+private:
+ void install(facet* f, long id);
+ template <class F> void install(F* f) {install(f, f->id.__get());}
+ template <class F> void install_from(const __imp& other);
+};
+
+locale::__imp::__imp(size_t refs)
+ : facet(refs),
+ facets_(N),
+ name_("C")
+{
+ facets_.clear();
+ install(&make<_VSTD::collate<char> >(1u));
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install(&make<_VSTD::collate<wchar_t> >(1u));
+#endif
+ install(&make<_VSTD::ctype<char> >(nullptr, false, 1u));
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install(&make<_VSTD::ctype<wchar_t> >(1u));
+#endif
+ install(&make<codecvt<char, char, mbstate_t> >(1u));
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install(&make<codecvt<wchar_t, char, mbstate_t> >(1u));
+#endif
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+ install(&make<codecvt<char16_t, char, mbstate_t> >(1u));
+ install(&make<codecvt<char32_t, char, mbstate_t> >(1u));
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
+ install(&make<codecvt<char16_t, char8_t, mbstate_t> >(1u));
+ install(&make<codecvt<char32_t, char8_t, mbstate_t> >(1u));
+#endif
+ install(&make<numpunct<char> >(1u));
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install(&make<numpunct<wchar_t> >(1u));
+#endif
+ install(&make<num_get<char> >(1u));
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install(&make<num_get<wchar_t> >(1u));
+#endif
+ install(&make<num_put<char> >(1u));
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install(&make<num_put<wchar_t> >(1u));
+#endif
+ install(&make<moneypunct<char, false> >(1u));
+ install(&make<moneypunct<char, true> >(1u));
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install(&make<moneypunct<wchar_t, false> >(1u));
+ install(&make<moneypunct<wchar_t, true> >(1u));
+#endif
+ install(&make<money_get<char> >(1u));
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install(&make<money_get<wchar_t> >(1u));
+#endif
+ install(&make<money_put<char> >(1u));
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install(&make<money_put<wchar_t> >(1u));
+#endif
+ install(&make<time_get<char> >(1u));
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install(&make<time_get<wchar_t> >(1u));
+#endif
+ install(&make<time_put<char> >(1u));
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install(&make<time_put<wchar_t> >(1u));
+#endif
+ install(&make<_VSTD::messages<char> >(1u));
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install(&make<_VSTD::messages<wchar_t> >(1u));
+#endif
+}
+
+locale::__imp::__imp(const string& name, size_t refs)
+ : facet(refs),
+ facets_(N),
+ name_(name)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ facets_ = locale::classic().__locale_->facets_;
+ for (unsigned i = 0; i < facets_.size(); ++i)
+ if (facets_[i])
+ facets_[i]->__add_shared();
+ install(new collate_byname<char>(name_));
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install(new collate_byname<wchar_t>(name_));
+#endif
+ install(new ctype_byname<char>(name_));
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install(new ctype_byname<wchar_t>(name_));
+#endif
+ install(new codecvt_byname<char, char, mbstate_t>(name_));
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install(new codecvt_byname<wchar_t, char, mbstate_t>(name_));
+#endif
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+ install(new codecvt_byname<char16_t, char, mbstate_t>(name_));
+ install(new codecvt_byname<char32_t, char, mbstate_t>(name_));
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
+ install(new codecvt_byname<char16_t, char8_t, mbstate_t>(name_));
+ install(new codecvt_byname<char32_t, char8_t, mbstate_t>(name_));
+#endif
+ install(new numpunct_byname<char>(name_));
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install(new numpunct_byname<wchar_t>(name_));
+#endif
+ install(new moneypunct_byname<char, false>(name_));
+ install(new moneypunct_byname<char, true>(name_));
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install(new moneypunct_byname<wchar_t, false>(name_));
+ install(new moneypunct_byname<wchar_t, true>(name_));
+#endif
+ install(new time_get_byname<char>(name_));
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install(new time_get_byname<wchar_t>(name_));
+#endif
+ install(new time_put_byname<char>(name_));
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install(new time_put_byname<wchar_t>(name_));
+#endif
+ install(new messages_byname<char>(name_));
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install(new messages_byname<wchar_t>(name_));
+#endif
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ for (unsigned i = 0; i < facets_.size(); ++i)
+ if (facets_[i])
+ facets_[i]->__release_shared();
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+}
+
+locale::__imp::__imp(const __imp& other)
+ : facets_(max<size_t>(N, other.facets_.size())),
+ name_(other.name_)
+{
+ facets_ = other.facets_;
+ for (unsigned i = 0; i < facets_.size(); ++i)
+ if (facets_[i])
+ facets_[i]->__add_shared();
+}
+
+locale::__imp::__imp(const __imp& other, const string& name, locale::category c)
+ : facets_(N),
+ name_("*")
+{
+ facets_ = other.facets_;
+ for (unsigned i = 0; i < facets_.size(); ++i)
+ if (facets_[i])
+ facets_[i]->__add_shared();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ if (c & locale::collate)
+ {
+ install(new collate_byname<char>(name));
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install(new collate_byname<wchar_t>(name));
+#endif
+ }
+ if (c & locale::ctype)
+ {
+ install(new ctype_byname<char>(name));
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install(new ctype_byname<wchar_t>(name));
+#endif
+ install(new codecvt_byname<char, char, mbstate_t>(name));
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install(new codecvt_byname<wchar_t, char, mbstate_t>(name));
+#endif
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+ install(new codecvt_byname<char16_t, char, mbstate_t>(name));
+ install(new codecvt_byname<char32_t, char, mbstate_t>(name));
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
+ install(new codecvt_byname<char16_t, char8_t, mbstate_t>(name));
+ install(new codecvt_byname<char32_t, char8_t, mbstate_t>(name));
+#endif
+ }
+ if (c & locale::monetary)
+ {
+ install(new moneypunct_byname<char, false>(name));
+ install(new moneypunct_byname<char, true>(name));
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install(new moneypunct_byname<wchar_t, false>(name));
+ install(new moneypunct_byname<wchar_t, true>(name));
+#endif
+ }
+ if (c & locale::numeric)
+ {
+ install(new numpunct_byname<char>(name));
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install(new numpunct_byname<wchar_t>(name));
+#endif
+ }
+ if (c & locale::time)
+ {
+ install(new time_get_byname<char>(name));
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install(new time_get_byname<wchar_t>(name));
+#endif
+ install(new time_put_byname<char>(name));
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install(new time_put_byname<wchar_t>(name));
+#endif
+ }
+ if (c & locale::messages)
+ {
+ install(new messages_byname<char>(name));
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install(new messages_byname<wchar_t>(name));
+#endif
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ for (unsigned i = 0; i < facets_.size(); ++i)
+ if (facets_[i])
+ facets_[i]->__release_shared();
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+}
+
+template<class F>
+inline
+void
+locale::__imp::install_from(const locale::__imp& one)
+{
+ long id = F::id.__get();
+ install(const_cast<F*>(static_cast<const F*>(one.use_facet(id))), id);
+}
+
+locale::__imp::__imp(const __imp& other, const __imp& one, locale::category c)
+ : facets_(N),
+ name_("*")
+{
+ facets_ = other.facets_;
+ for (unsigned i = 0; i < facets_.size(); ++i)
+ if (facets_[i])
+ facets_[i]->__add_shared();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ if (c & locale::collate)
+ {
+ install_from<_VSTD::collate<char> >(one);
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install_from<_VSTD::collate<wchar_t> >(one);
+#endif
+ }
+ if (c & locale::ctype)
+ {
+ install_from<_VSTD::ctype<char> >(one);
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install_from<_VSTD::ctype<wchar_t> >(one);
+#endif
+ install_from<_VSTD::codecvt<char, char, mbstate_t> >(one);
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+ install_from<_VSTD::codecvt<char16_t, char, mbstate_t> >(one);
+ install_from<_VSTD::codecvt<char32_t, char, mbstate_t> >(one);
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
+ install_from<_VSTD::codecvt<char16_t, char8_t, mbstate_t> >(one);
+ install_from<_VSTD::codecvt<char32_t, char8_t, mbstate_t> >(one);
+#endif
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install_from<_VSTD::codecvt<wchar_t, char, mbstate_t> >(one);
+#endif
+ }
+ if (c & locale::monetary)
+ {
+ install_from<moneypunct<char, false> >(one);
+ install_from<moneypunct<char, true> >(one);
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install_from<moneypunct<wchar_t, false> >(one);
+ install_from<moneypunct<wchar_t, true> >(one);
+#endif
+ install_from<money_get<char> >(one);
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install_from<money_get<wchar_t> >(one);
+#endif
+ install_from<money_put<char> >(one);
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install_from<money_put<wchar_t> >(one);
+#endif
+ }
+ if (c & locale::numeric)
+ {
+ install_from<numpunct<char> >(one);
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install_from<numpunct<wchar_t> >(one);
+#endif
+ install_from<num_get<char> >(one);
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install_from<num_get<wchar_t> >(one);
+#endif
+ install_from<num_put<char> >(one);
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install_from<num_put<wchar_t> >(one);
+#endif
+ }
+ if (c & locale::time)
+ {
+ install_from<time_get<char> >(one);
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install_from<time_get<wchar_t> >(one);
+#endif
+ install_from<time_put<char> >(one);
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install_from<time_put<wchar_t> >(one);
+#endif
+ }
+ if (c & locale::messages)
+ {
+ install_from<_VSTD::messages<char> >(one);
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ install_from<_VSTD::messages<wchar_t> >(one);
+#endif
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ for (unsigned i = 0; i < facets_.size(); ++i)
+ if (facets_[i])
+ facets_[i]->__release_shared();
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+}
+
+locale::__imp::__imp(const __imp& other, facet* f, long id)
+ : facets_(max<size_t>(N, other.facets_.size()+1)),
+ name_("*")
+{
+ f->__add_shared();
+ unique_ptr<facet, release> hold(f);
+ facets_ = other.facets_;
+ for (unsigned i = 0; i < other.facets_.size(); ++i)
+ if (facets_[i])
+ facets_[i]->__add_shared();
+ install(hold.get(), id);
+}
+
+locale::__imp::~__imp()
+{
+ for (unsigned i = 0; i < facets_.size(); ++i)
+ if (facets_[i])
+ facets_[i]->__release_shared();
+}
+
+void
+locale::__imp::install(facet* f, long id)
+{
+ f->__add_shared();
+ unique_ptr<facet, release> hold(f);
+ if (static_cast<size_t>(id) >= facets_.size())
+ facets_.resize(static_cast<size_t>(id+1));
+ if (facets_[static_cast<size_t>(id)])
+ facets_[static_cast<size_t>(id)]->__release_shared();
+ facets_[static_cast<size_t>(id)] = hold.release();
+}
+
+const locale::facet*
+locale::__imp::use_facet(long id) const
+{
+ if (!has_facet(id))
+ __throw_bad_cast();
+ return facets_[static_cast<size_t>(id)];
+}
+
+// locale
+
+const locale&
+locale::__imp::make_classic()
+{
+ // only one thread can get in here and it only gets in once
+ static aligned_storage<sizeof(locale)>::type buf;
+ locale* c = reinterpret_cast<locale*>(&buf);
+ c->__locale_ = &make<__imp>(1u);
+ return *c;
+}
+
+const locale&
+locale::classic()
+{
+ static const locale& c = __imp::make_classic();
+ return c;
+}
+
+locale&
+locale::__imp::make_global()
+{
+ // only one thread can get in here and it only gets in once
+ static aligned_storage<sizeof(locale)>::type buf;
+ auto *obj = ::new (&buf) locale(locale::classic());
+ return *obj;
+}
+
+locale&
+locale::__global()
+{
+ static locale& g = __imp::make_global();
+ return g;
+}
+
+locale::locale() noexcept
+ : __locale_(__global().__locale_)
+{
+ __locale_->__add_shared();
+}
+
+locale::locale(const locale& l) noexcept
+ : __locale_(l.__locale_)
+{
+ __locale_->__add_shared();
+}
+
+locale::~locale()
+{
+ __locale_->__release_shared();
+}
+
+const locale&
+locale::operator=(const locale& other) noexcept
+{
+ other.__locale_->__add_shared();
+ __locale_->__release_shared();
+ __locale_ = other.__locale_;
+ return *this;
+}
+
+locale::locale(const char* name)
+ : __locale_(name ? new __imp(name)
+ : (__throw_runtime_error("locale constructed with null"), nullptr))
+{
+ __locale_->__add_shared();
+}
+
+locale::locale(const string& name)
+ : __locale_(new __imp(name))
+{
+ __locale_->__add_shared();
+}
+
+locale::locale(const locale& other, const char* name, category c)
+ : __locale_(name ? new __imp(*other.__locale_, name, c)
+ : (__throw_runtime_error("locale constructed with null"), nullptr))
+{
+ __locale_->__add_shared();
+}
+
+locale::locale(const locale& other, const string& name, category c)
+ : __locale_(new __imp(*other.__locale_, name, c))
+{
+ __locale_->__add_shared();
+}
+
+locale::locale(const locale& other, const locale& one, category c)
+ : __locale_(new __imp(*other.__locale_, *one.__locale_, c))
+{
+ __locale_->__add_shared();
+}
+
+string
+locale::name() const
+{
+ return __locale_->name();
+}
+
+void
+locale::__install_ctor(const locale& other, facet* f, long id)
+{
+ if (f)
+ __locale_ = new __imp(*other.__locale_, f, id);
+ else
+ __locale_ = other.__locale_;
+ __locale_->__add_shared();
+}
+
+locale
+locale::global(const locale& loc)
+{
+ locale& g = __global();
+ locale r = g;
+ g = loc;
+ if (g.name() != "*")
+ setlocale(LC_ALL, g.name().c_str());
+ return r;
+}
+
+bool
+locale::has_facet(id& x) const
+{
+ return __locale_->has_facet(x.__get());
+}
+
+const locale::facet*
+locale::use_facet(id& x) const
+{
+ return __locale_->use_facet(x.__get());
+}
+
+bool
+locale::operator==(const locale& y) const
+{
+ return (__locale_ == y.__locale_)
+ || (__locale_->name() != "*" && __locale_->name() == y.__locale_->name());
+}
+
+// locale::facet
+
+locale::facet::~facet()
+{
+}
+
+void
+locale::facet::__on_zero_shared() noexcept
+{
+ delete this;
+}
+
+// locale::id
+
+namespace
+{
+
+class __fake_bind
+{
+ locale::id* id_;
+ void (locale::id::* pmf_)();
+public:
+ __fake_bind(void (locale::id::* pmf)(), locale::id* id)
+ : id_(id), pmf_(pmf) {}
+
+ void operator()() const
+ {
+ (id_->*pmf_)();
+ }
+};
+
+}
+
+int32_t locale::id::__next_id;
+
+long
+locale::id::__get()
+{
+ int32_t result = __id_.load(std::memory_order_acquire);
+ if (result == 0) {
+ static std::mutex m;
+ std::lock_guard<std::mutex> guard(m);
+ result = __id_.load(std::memory_order_acquire);
+ if (result == 0) {
+ result = ++__next_id;
+ __id_.store(result, std::memory_order_release);
+ }
+ }
+ return result - 1;
+}
+
+// template <> class collate_byname<char>
+
+collate_byname<char>::collate_byname(const char* n, size_t refs)
+ : collate<char>(refs),
+ __l(newlocale(LC_ALL_MASK, n, 0))
+{
+ if (__l == 0)
+ __throw_runtime_error("collate_byname<char>::collate_byname"
+ " failed to construct for " + string(n));
+}
+
+collate_byname<char>::collate_byname(const string& name, size_t refs)
+ : collate<char>(refs),
+ __l(newlocale(LC_ALL_MASK, name.c_str(), 0))
+{
+ if (__l == 0)
+ __throw_runtime_error("collate_byname<char>::collate_byname"
+ " failed to construct for " + name);
+}
+
+collate_byname<char>::~collate_byname()
+{
+ freelocale(__l);
+}
+
+int
+collate_byname<char>::do_compare(const char_type* __lo1, const char_type* __hi1,
+ const char_type* __lo2, const char_type* __hi2) const
+{
+ string_type lhs(__lo1, __hi1);
+ string_type rhs(__lo2, __hi2);
+ int r = strcoll_l(lhs.c_str(), rhs.c_str(), __l);
+ if (r < 0)
+ return -1;
+ if (r > 0)
+ return 1;
+ return r;
+}
+
+collate_byname<char>::string_type
+collate_byname<char>::do_transform(const char_type* lo, const char_type* hi) const
+{
+ const string_type in(lo, hi);
+ string_type out(strxfrm_l(0, in.c_str(), 0, __l), char());
+ strxfrm_l(const_cast<char*>(out.c_str()), in.c_str(), out.size()+1, __l);
+ return out;
+}
+
+// template <> class collate_byname<wchar_t>
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+collate_byname<wchar_t>::collate_byname(const char* n, size_t refs)
+ : collate<wchar_t>(refs),
+ __l(newlocale(LC_ALL_MASK, n, 0))
+{
+ if (__l == 0)
+ __throw_runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)"
+ " failed to construct for " + string(n));
+}
+
+collate_byname<wchar_t>::collate_byname(const string& name, size_t refs)
+ : collate<wchar_t>(refs),
+ __l(newlocale(LC_ALL_MASK, name.c_str(), 0))
+{
+ if (__l == 0)
+ __throw_runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)"
+ " failed to construct for " + name);
+}
+
+collate_byname<wchar_t>::~collate_byname()
+{
+ freelocale(__l);
+}
+
+int
+collate_byname<wchar_t>::do_compare(const char_type* __lo1, const char_type* __hi1,
+ const char_type* __lo2, const char_type* __hi2) const
+{
+ string_type lhs(__lo1, __hi1);
+ string_type rhs(__lo2, __hi2);
+ int r = wcscoll_l(lhs.c_str(), rhs.c_str(), __l);
+ if (r < 0)
+ return -1;
+ if (r > 0)
+ return 1;
+ return r;
+}
+
+collate_byname<wchar_t>::string_type
+collate_byname<wchar_t>::do_transform(const char_type* lo, const char_type* hi) const
+{
+ const string_type in(lo, hi);
+ string_type out(wcsxfrm_l(0, in.c_str(), 0, __l), wchar_t());
+ wcsxfrm_l(const_cast<wchar_t*>(out.c_str()), in.c_str(), out.size()+1, __l);
+ return out;
+}
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+const ctype_base::mask ctype_base::space;
+const ctype_base::mask ctype_base::print;
+const ctype_base::mask ctype_base::cntrl;
+const ctype_base::mask ctype_base::upper;
+const ctype_base::mask ctype_base::lower;
+const ctype_base::mask ctype_base::alpha;
+const ctype_base::mask ctype_base::digit;
+const ctype_base::mask ctype_base::punct;
+const ctype_base::mask ctype_base::xdigit;
+const ctype_base::mask ctype_base::blank;
+const ctype_base::mask ctype_base::alnum;
+const ctype_base::mask ctype_base::graph;
+
+// template <> class ctype<wchar_t>;
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+locale::id ctype<wchar_t>::id;
+
+ctype<wchar_t>::~ctype()
+{
+}
+
+bool
+ctype<wchar_t>::do_is(mask m, char_type c) const
+{
+ return isascii(c) ? (ctype<char>::classic_table()[c] & m) != 0 : false;
+}
+
+const wchar_t*
+ctype<wchar_t>::do_is(const char_type* low, const char_type* high, mask* vec) const
+{
+ for (; low != high; ++low, ++vec)
+ *vec = static_cast<mask>(isascii(*low) ?
+ ctype<char>::classic_table()[*low] : 0);
+ return low;
+}
+
+const wchar_t*
+ctype<wchar_t>::do_scan_is(mask m, const char_type* low, const char_type* high) const
+{
+ for (; low != high; ++low)
+ if (isascii(*low) && (ctype<char>::classic_table()[*low] & m))
+ break;
+ return low;
+}
+
+const wchar_t*
+ctype<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type* high) const
+{
+ for (; low != high; ++low)
+ if (!(isascii(*low) && (ctype<char>::classic_table()[*low] & m)))
+ break;
+ return low;
+}
+
+wchar_t
+ctype<wchar_t>::do_toupper(char_type c) const
+{
+#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
+ return isascii(c) ? _DefaultRuneLocale.__mapupper[c] : c;
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \
+ defined(__NetBSD__) || defined(__MVS__)
+ return isascii(c) ? ctype<char>::__classic_upper_table()[c] : c;
+#else
+ return (isascii(c) && iswlower_l(c, _LIBCPP_GET_C_LOCALE)) ? c-L'a'+L'A' : c;
+#endif
+}
+
+const wchar_t*
+ctype<wchar_t>::do_toupper(char_type* low, const char_type* high) const
+{
+ for (; low != high; ++low)
+#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
+ *low = isascii(*low) ? _DefaultRuneLocale.__mapupper[*low] : *low;
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \
+ defined(__NetBSD__) || defined(__MVS__)
+ *low = isascii(*low) ? ctype<char>::__classic_upper_table()[*low]
+ : *low;
+#else
+ *low = (isascii(*low) && islower_l(*low, _LIBCPP_GET_C_LOCALE)) ? (*low-L'a'+L'A') : *low;
+#endif
+ return low;
+}
+
+wchar_t
+ctype<wchar_t>::do_tolower(char_type c) const
+{
+#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
+ return isascii(c) ? _DefaultRuneLocale.__maplower[c] : c;
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \
+ defined(__NetBSD__) || defined(__MVS__)
+ return isascii(c) ? ctype<char>::__classic_lower_table()[c] : c;
+#else
+ return (isascii(c) && isupper_l(c, _LIBCPP_GET_C_LOCALE)) ? c-L'A'+'a' : c;
+#endif
+}
+
+const wchar_t*
+ctype<wchar_t>::do_tolower(char_type* low, const char_type* high) const
+{
+ for (; low != high; ++low)
+#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
+ *low = isascii(*low) ? _DefaultRuneLocale.__maplower[*low] : *low;
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \
+ defined(__NetBSD__) || defined(__MVS__)
+ *low = isascii(*low) ? ctype<char>::__classic_lower_table()[*low]
+ : *low;
+#else
+ *low = (isascii(*low) && isupper_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low-L'A'+L'a' : *low;
+#endif
+ return low;
+}
+
+wchar_t
+ctype<wchar_t>::do_widen(char c) const
+{
+ return c;
+}
+
+const char*
+ctype<wchar_t>::do_widen(const char* low, const char* high, char_type* dest) const
+{
+ for (; low != high; ++low, ++dest)
+ *dest = *low;
+ return low;
+}
+
+char
+ctype<wchar_t>::do_narrow(char_type c, char dfault) const
+{
+ if (isascii(c))
+ return static_cast<char>(c);
+ return dfault;
+}
+
+const wchar_t*
+ctype<wchar_t>::do_narrow(const char_type* low, const char_type* high, char dfault, char* dest) const
+{
+ for (; low != high; ++low, ++dest)
+ if (isascii(*low))
+ *dest = static_cast<char>(*low);
+ else
+ *dest = dfault;
+ return low;
+}
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+// template <> class ctype<char>;
+
+locale::id ctype<char>::id;
+
+const size_t ctype<char>::table_size;
+
+ctype<char>::ctype(const mask* tab, bool del, size_t refs)
+ : locale::facet(refs),
+ __tab_(tab),
+ __del_(del)
+{
+ if (__tab_ == 0)
+ __tab_ = classic_table();
+}
+
+ctype<char>::~ctype()
+{
+ if (__tab_ && __del_)
+ delete [] __tab_;
+}
+
+char
+ctype<char>::do_toupper(char_type c) const
+{
+#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
+ return isascii(c) ?
+ static_cast<char>(_DefaultRuneLocale.__mapupper[static_cast<ptrdiff_t>(c)]) : c;
+#elif defined(__NetBSD__)
+ return static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(c)]);
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__)
+ return isascii(c) ?
+ static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(c)]) : c;
+#else
+ return (isascii(c) && islower_l(c, _LIBCPP_GET_C_LOCALE)) ? c-'a'+'A' : c;
+#endif
+}
+
+const char*
+ctype<char>::do_toupper(char_type* low, const char_type* high) const
+{
+ for (; low != high; ++low)
+#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
+ *low = isascii(*low) ?
+ static_cast<char>(_DefaultRuneLocale.__mapupper[static_cast<ptrdiff_t>(*low)]) : *low;
+#elif defined(__NetBSD__)
+ *low = static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(*low)]);
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__)
+ *low = isascii(*low) ?
+ static_cast<char>(__classic_upper_table()[static_cast<size_t>(*low)]) : *low;
+#else
+ *low = (isascii(*low) && islower_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low-'a'+'A' : *low;
+#endif
+ return low;
+}
+
+char
+ctype<char>::do_tolower(char_type c) const
+{
+#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
+ return isascii(c) ?
+ static_cast<char>(_DefaultRuneLocale.__maplower[static_cast<ptrdiff_t>(c)]) : c;
+#elif defined(__NetBSD__)
+ return static_cast<char>(__classic_lower_table()[static_cast<unsigned char>(c)]);
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__)
+ return isascii(c) ?
+ static_cast<char>(__classic_lower_table()[static_cast<size_t>(c)]) : c;
+#else
+ return (isascii(c) && isupper_l(c, _LIBCPP_GET_C_LOCALE)) ? c-'A'+'a' : c;
+#endif
+}
+
+const char*
+ctype<char>::do_tolower(char_type* low, const char_type* high) const
+{
+ for (; low != high; ++low)
+#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
+ *low = isascii(*low) ? static_cast<char>(_DefaultRuneLocale.__maplower[static_cast<ptrdiff_t>(*low)]) : *low;
+#elif defined(__NetBSD__)
+ *low = static_cast<char>(__classic_lower_table()[static_cast<unsigned char>(*low)]);
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__)
+ *low = isascii(*low) ? static_cast<char>(__classic_lower_table()[static_cast<size_t>(*low)]) : *low;
+#else
+ *low = (isascii(*low) && isupper_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low-'A'+'a' : *low;
+#endif
+ return low;
+}
+
+char
+ctype<char>::do_widen(char c) const
+{
+ return c;
+}
+
+const char*
+ctype<char>::do_widen(const char* low, const char* high, char_type* dest) const
+{
+ for (; low != high; ++low, ++dest)
+ *dest = *low;
+ return low;
+}
+
+char
+ctype<char>::do_narrow(char_type c, char dfault) const
+{
+ if (isascii(c))
+ return static_cast<char>(c);
+ return dfault;
+}
+
+const char*
+ctype<char>::do_narrow(const char_type* low, const char_type* high, char dfault, char* dest) const
+{
+ for (; low != high; ++low, ++dest)
+ if (isascii(*low))
+ *dest = *low;
+ else
+ *dest = dfault;
+ return low;
+}
+
+#if defined(__EMSCRIPTEN__)
+extern "C" const unsigned short ** __ctype_b_loc();
+extern "C" const int ** __ctype_tolower_loc();
+extern "C" const int ** __ctype_toupper_loc();
+#endif
+
+#if defined(__ANDROID__)
+// See src/support/android/android_locale.cpp
+extern "C" const unsigned short* const _ctype_android;
+#endif
+
+#ifdef _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
+const ctype<char>::mask*
+ctype<char>::classic_table() noexcept
+{
+ static _LIBCPP_CONSTEXPR const ctype<char>::mask builtin_table[table_size] = {
+ cntrl, cntrl,
+ cntrl, cntrl,
+ cntrl, cntrl,
+ cntrl, cntrl,
+ cntrl, cntrl | space | blank,
+ cntrl | space, cntrl | space,
+ cntrl | space, cntrl | space,
+ cntrl, cntrl,
+ cntrl, cntrl,
+ cntrl, cntrl,
+ cntrl, cntrl,
+ cntrl, cntrl,
+ cntrl, cntrl,
+ cntrl, cntrl,
+ cntrl, cntrl,
+ cntrl, cntrl,
+ space | blank | print, punct | print,
+ punct | print, punct | print,
+ punct | print, punct | print,
+ punct | print, punct | print,
+ punct | print, punct | print,
+ punct | print, punct | print,
+ punct | print, punct | print,
+ punct | print, punct | print,
+ digit | print | xdigit, digit | print | xdigit,
+ digit | print | xdigit, digit | print | xdigit,
+ digit | print | xdigit, digit | print | xdigit,
+ digit | print | xdigit, digit | print | xdigit,
+ digit | print | xdigit, digit | print | xdigit,
+ punct | print, punct | print,
+ punct | print, punct | print,
+ punct | print, punct | print,
+ punct | print, upper | xdigit | print | alpha,
+ upper | xdigit | print | alpha, upper | xdigit | print | alpha,
+ upper | xdigit | print | alpha, upper | xdigit | print | alpha,
+ upper | xdigit | print | alpha, upper | print | alpha,
+ upper | print | alpha, upper | print | alpha,
+ upper | print | alpha, upper | print | alpha,
+ upper | print | alpha, upper | print | alpha,
+ upper | print | alpha, upper | print | alpha,
+ upper | print | alpha, upper | print | alpha,
+ upper | print | alpha, upper | print | alpha,
+ upper | print | alpha, upper | print | alpha,
+ upper | print | alpha, upper | print | alpha,
+ upper | print | alpha, upper | print | alpha,
+ upper | print | alpha, punct | print,
+ punct | print, punct | print,
+ punct | print, punct | print,
+ punct | print, lower | xdigit | print | alpha,
+ lower | xdigit | print | alpha, lower | xdigit | print | alpha,
+ lower | xdigit | print | alpha, lower | xdigit | print | alpha,
+ lower | xdigit | print | alpha, lower | print | alpha,
+ lower | print | alpha, lower | print | alpha,
+ lower | print | alpha, lower | print | alpha,
+ lower | print | alpha, lower | print | alpha,
+ lower | print | alpha, lower | print | alpha,
+ lower | print | alpha, lower | print | alpha,
+ lower | print | alpha, lower | print | alpha,
+ lower | print | alpha, lower | print | alpha,
+ lower | print | alpha, lower | print | alpha,
+ lower | print | alpha, lower | print | alpha,
+ lower | print | alpha, punct | print,
+ punct | print, punct | print,
+ punct | print, cntrl,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ };
+ return builtin_table;
+}
+#else
+const ctype<char>::mask*
+ctype<char>::classic_table() noexcept
+{
+#if defined(__APPLE__) || defined(__FreeBSD__)
+ return _DefaultRuneLocale.__runetype;
+#elif defined(__NetBSD__)
+ return _C_ctype_tab_ + 1;
+#elif defined(__GLIBC__)
+ return _LIBCPP_GET_C_LOCALE->__ctype_b;
+#elif defined(__sun__)
+ return __ctype_mask;
+#elif defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
+ return __pctype_func();
+#elif defined(__EMSCRIPTEN__)
+ return *__ctype_b_loc();
+#elif defined(_NEWLIB_VERSION)
+ // Newlib has a 257-entry table in ctype_.c, where (char)0 starts at [1].
+ return _ctype_ + 1;
+#elif defined(__ANDROID__)
+ return _ctype_android;
+#elif defined(_AIX)
+ return (const unsigned int *)__lc_ctype_ptr->obj->mask;
+#elif defined(__MVS__)
+# if defined(__NATIVE_ASCII_F)
+ return const_cast<const ctype<char>::mask*> (__OBJ_DATA(__lc_ctype_a)->mask);
+# else
+ return const_cast<const ctype<char>::mask*> (__ctypec);
+# endif
+#else
+ // Platform not supported: abort so the person doing the port knows what to
+ // fix
+# warning ctype<char>::classic_table() is not implemented
+ printf("ctype<char>::classic_table() is not implemented\n");
+ abort();
+ return NULL;
+#endif
+}
+#endif
+
+#if defined(__GLIBC__)
+const int*
+ctype<char>::__classic_lower_table() noexcept
+{
+ return _LIBCPP_GET_C_LOCALE->__ctype_tolower;
+}
+
+const int*
+ctype<char>::__classic_upper_table() noexcept
+{
+ return _LIBCPP_GET_C_LOCALE->__ctype_toupper;
+}
+#elif defined(__NetBSD__)
+const short*
+ctype<char>::__classic_lower_table() noexcept
+{
+ return _C_tolower_tab_ + 1;
+}
+
+const short*
+ctype<char>::__classic_upper_table() noexcept
+{
+ return _C_toupper_tab_ + 1;
+}
+
+#elif defined(__EMSCRIPTEN__)
+const int*
+ctype<char>::__classic_lower_table() noexcept
+{
+ return *__ctype_tolower_loc();
+}
+
+const int*
+ctype<char>::__classic_upper_table() noexcept
+{
+ return *__ctype_toupper_loc();
+}
+#elif defined(__MVS__)
+const unsigned short*
+ctype<char>::__classic_lower_table() _NOEXCEPT
+{
+# if defined(__NATIVE_ASCII_F)
+ return const_cast<const unsigned short*>(__OBJ_DATA(__lc_ctype_a)->lower);
+# else
+ return const_cast<const unsigned short*>(__ctype + __TOLOWER_INDEX);
+# endif
+}
+const unsigned short *
+ctype<char>::__classic_upper_table() _NOEXCEPT
+{
+# if defined(__NATIVE_ASCII_F)
+ return const_cast<const unsigned short*>(__OBJ_DATA(__lc_ctype_a)->upper);
+# else
+ return const_cast<const unsigned short*>(__ctype + __TOUPPER_INDEX);
+# endif
+}
+#endif // __GLIBC__ || __NETBSD__ || __EMSCRIPTEN__ || __MVS__
+
+// template <> class ctype_byname<char>
+
+ctype_byname<char>::ctype_byname(const char* name, size_t refs)
+ : ctype<char>(0, false, refs),
+ __l(newlocale(LC_ALL_MASK, name, 0))
+{
+ if (__l == 0)
+ __throw_runtime_error("ctype_byname<char>::ctype_byname"
+ " failed to construct for " + string(name));
+}
+
+ctype_byname<char>::ctype_byname(const string& name, size_t refs)
+ : ctype<char>(0, false, refs),
+ __l(newlocale(LC_ALL_MASK, name.c_str(), 0))
+{
+ if (__l == 0)
+ __throw_runtime_error("ctype_byname<char>::ctype_byname"
+ " failed to construct for " + name);
+}
+
+ctype_byname<char>::~ctype_byname()
+{
+ freelocale(__l);
+}
+
+char
+ctype_byname<char>::do_toupper(char_type c) const
+{
+ return static_cast<char>(toupper_l(static_cast<unsigned char>(c), __l));
+}
+
+const char*
+ctype_byname<char>::do_toupper(char_type* low, const char_type* high) const
+{
+ for (; low != high; ++low)
+ *low = static_cast<char>(toupper_l(static_cast<unsigned char>(*low), __l));
+ return low;
+}
+
+char
+ctype_byname<char>::do_tolower(char_type c) const
+{
+ return static_cast<char>(tolower_l(static_cast<unsigned char>(c), __l));
+}
+
+const char*
+ctype_byname<char>::do_tolower(char_type* low, const char_type* high) const
+{
+ for (; low != high; ++low)
+ *low = static_cast<char>(tolower_l(static_cast<unsigned char>(*low), __l));
+ return low;
+}
+
+// template <> class ctype_byname<wchar_t>
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ctype_byname<wchar_t>::ctype_byname(const char* name, size_t refs)
+ : ctype<wchar_t>(refs),
+ __l(newlocale(LC_ALL_MASK, name, 0))
+{
+ if (__l == 0)
+ __throw_runtime_error("ctype_byname<wchar_t>::ctype_byname"
+ " failed to construct for " + string(name));
+}
+
+ctype_byname<wchar_t>::ctype_byname(const string& name, size_t refs)
+ : ctype<wchar_t>(refs),
+ __l(newlocale(LC_ALL_MASK, name.c_str(), 0))
+{
+ if (__l == 0)
+ __throw_runtime_error("ctype_byname<wchar_t>::ctype_byname"
+ " failed to construct for " + name);
+}
+
+ctype_byname<wchar_t>::~ctype_byname()
+{
+ freelocale(__l);
+}
+
+bool
+ctype_byname<wchar_t>::do_is(mask m, char_type c) const
+{
+#ifdef _LIBCPP_WCTYPE_IS_MASK
+ return static_cast<bool>(iswctype_l(c, m, __l));
+#else
+ bool result = false;
+ wint_t ch = static_cast<wint_t>(c);
+ if ((m & space) == space) result |= (iswspace_l(ch, __l) != 0);
+ if ((m & print) == print) result |= (iswprint_l(ch, __l) != 0);
+ if ((m & cntrl) == cntrl) result |= (iswcntrl_l(ch, __l) != 0);
+ if ((m & upper) == upper) result |= (iswupper_l(ch, __l) != 0);
+ if ((m & lower) == lower) result |= (iswlower_l(ch, __l) != 0);
+ if ((m & alpha) == alpha) result |= (iswalpha_l(ch, __l) != 0);
+ if ((m & digit) == digit) result |= (iswdigit_l(ch, __l) != 0);
+ if ((m & punct) == punct) result |= (iswpunct_l(ch, __l) != 0);
+ if ((m & xdigit) == xdigit) result |= (iswxdigit_l(ch, __l) != 0);
+ if ((m & blank) == blank) result |= (iswblank_l(ch, __l) != 0);
+ return result;
+#endif
+}
+
+const wchar_t*
+ctype_byname<wchar_t>::do_is(const char_type* low, const char_type* high, mask* vec) const
+{
+ for (; low != high; ++low, ++vec)
+ {
+ if (isascii(*low))
+ *vec = static_cast<mask>(ctype<char>::classic_table()[*low]);
+ else
+ {
+ *vec = 0;
+ wint_t ch = static_cast<wint_t>(*low);
+ if (iswspace_l(ch, __l))
+ *vec |= space;
+#ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
+ if (iswprint_l(ch, __l))
+ *vec |= print;
+#endif
+ if (iswcntrl_l(ch, __l))
+ *vec |= cntrl;
+ if (iswupper_l(ch, __l))
+ *vec |= upper;
+ if (iswlower_l(ch, __l))
+ *vec |= lower;
+#ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
+ if (iswalpha_l(ch, __l))
+ *vec |= alpha;
+#endif
+ if (iswdigit_l(ch, __l))
+ *vec |= digit;
+ if (iswpunct_l(ch, __l))
+ *vec |= punct;
+#ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT
+ if (iswxdigit_l(ch, __l))
+ *vec |= xdigit;
+#endif
+#if !defined(__sun__)
+ if (iswblank_l(ch, __l))
+ *vec |= blank;
+#endif
+ }
+ }
+ return low;
+}
+
+const wchar_t*
+ctype_byname<wchar_t>::do_scan_is(mask m, const char_type* low, const char_type* high) const
+{
+ for (; low != high; ++low)
+ {
+#ifdef _LIBCPP_WCTYPE_IS_MASK
+ if (iswctype_l(*low, m, __l))
+ break;
+#else
+ wint_t ch = static_cast<wint_t>(*low);
+ if ((m & space) == space && iswspace_l(ch, __l)) break;
+ if ((m & print) == print && iswprint_l(ch, __l)) break;
+ if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l)) break;
+ if ((m & upper) == upper && iswupper_l(ch, __l)) break;
+ if ((m & lower) == lower && iswlower_l(ch, __l)) break;
+ if ((m & alpha) == alpha && iswalpha_l(ch, __l)) break;
+ if ((m & digit) == digit && iswdigit_l(ch, __l)) break;
+ if ((m & punct) == punct && iswpunct_l(ch, __l)) break;
+ if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l)) break;
+ if ((m & blank) == blank && iswblank_l(ch, __l)) break;
+#endif
+ }
+ return low;
+}
+
+const wchar_t*
+ctype_byname<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type* high) const
+{
+ for (; low != high; ++low)
+ {
+#ifdef _LIBCPP_WCTYPE_IS_MASK
+ if (!iswctype_l(*low, m, __l))
+ break;
+#else
+ wint_t ch = static_cast<wint_t>(*low);
+ if ((m & space) == space && iswspace_l(ch, __l)) continue;
+ if ((m & print) == print && iswprint_l(ch, __l)) continue;
+ if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l)) continue;
+ if ((m & upper) == upper && iswupper_l(ch, __l)) continue;
+ if ((m & lower) == lower && iswlower_l(ch, __l)) continue;
+ if ((m & alpha) == alpha && iswalpha_l(ch, __l)) continue;
+ if ((m & digit) == digit && iswdigit_l(ch, __l)) continue;
+ if ((m & punct) == punct && iswpunct_l(ch, __l)) continue;
+ if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l)) continue;
+ if ((m & blank) == blank && iswblank_l(ch, __l)) continue;
+ break;
+#endif
+ }
+ return low;
+}
+
+wchar_t
+ctype_byname<wchar_t>::do_toupper(char_type c) const
+{
+ return towupper_l(c, __l);
+}
+
+const wchar_t*
+ctype_byname<wchar_t>::do_toupper(char_type* low, const char_type* high) const
+{
+ for (; low != high; ++low)
+ *low = towupper_l(*low, __l);
+ return low;
+}
+
+wchar_t
+ctype_byname<wchar_t>::do_tolower(char_type c) const
+{
+ return towlower_l(c, __l);
+}
+
+const wchar_t*
+ctype_byname<wchar_t>::do_tolower(char_type* low, const char_type* high) const
+{
+ for (; low != high; ++low)
+ *low = towlower_l(*low, __l);
+ return low;
+}
+
+wchar_t
+ctype_byname<wchar_t>::do_widen(char c) const
+{
+ return __libcpp_btowc_l(c, __l);
+}
+
+const char*
+ctype_byname<wchar_t>::do_widen(const char* low, const char* high, char_type* dest) const
+{
+ for (; low != high; ++low, ++dest)
+ *dest = __libcpp_btowc_l(*low, __l);
+ return low;
+}
+
+char
+ctype_byname<wchar_t>::do_narrow(char_type c, char dfault) const
+{
+ int r = __libcpp_wctob_l(c, __l);
+ return r != static_cast<int>(WEOF) ? static_cast<char>(r) : dfault;
+}
+
+const wchar_t*
+ctype_byname<wchar_t>::do_narrow(const char_type* low, const char_type* high, char dfault, char* dest) const
+{
+ for (; low != high; ++low, ++dest)
+ {
+ int r = __libcpp_wctob_l(*low, __l);
+ *dest = r != static_cast<int>(WEOF) ? static_cast<char>(r) : dfault;
+ }
+ return low;
+}
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+// template <> class codecvt<char, char, mbstate_t>
+
+locale::id codecvt<char, char, mbstate_t>::id;
+
+codecvt<char, char, mbstate_t>::~codecvt()
+{
+}
+
+codecvt<char, char, mbstate_t>::result
+codecvt<char, char, mbstate_t>::do_out(state_type&,
+ const intern_type* frm, const intern_type*, const intern_type*& frm_nxt,
+ extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+ frm_nxt = frm;
+ to_nxt = to;
+ return noconv;
+}
+
+codecvt<char, char, mbstate_t>::result
+codecvt<char, char, mbstate_t>::do_in(state_type&,
+ const extern_type* frm, const extern_type*, const extern_type*& frm_nxt,
+ intern_type* to, intern_type*, intern_type*& to_nxt) const
+{
+ frm_nxt = frm;
+ to_nxt = to;
+ return noconv;
+}
+
+codecvt<char, char, mbstate_t>::result
+codecvt<char, char, mbstate_t>::do_unshift(state_type&,
+ extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+ to_nxt = to;
+ return noconv;
+}
+
+int
+codecvt<char, char, mbstate_t>::do_encoding() const noexcept
+{
+ return 1;
+}
+
+bool
+codecvt<char, char, mbstate_t>::do_always_noconv() const noexcept
+{
+ return true;
+}
+
+int
+codecvt<char, char, mbstate_t>::do_length(state_type&,
+ const extern_type* frm, const extern_type* end, size_t mx) const
+{
+ return static_cast<int>(min<size_t>(mx, static_cast<size_t>(end-frm)));
+}
+
+int
+codecvt<char, char, mbstate_t>::do_max_length() const noexcept
+{
+ return 1;
+}
+
+// template <> class codecvt<wchar_t, char, mbstate_t>
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+locale::id codecvt<wchar_t, char, mbstate_t>::id;
+
+codecvt<wchar_t, char, mbstate_t>::codecvt(size_t refs)
+ : locale::facet(refs),
+ __l(_LIBCPP_GET_C_LOCALE)
+{
+}
+
+codecvt<wchar_t, char, mbstate_t>::codecvt(const char* nm, size_t refs)
+ : locale::facet(refs),
+ __l(newlocale(LC_ALL_MASK, nm, 0))
+{
+ if (__l == 0)
+ __throw_runtime_error("codecvt_byname<wchar_t, char, mbstate_t>::codecvt_byname"
+ " failed to construct for " + string(nm));
+}
+
+codecvt<wchar_t, char, mbstate_t>::~codecvt()
+{
+ if (__l != _LIBCPP_GET_C_LOCALE)
+ freelocale(__l);
+}
+
+codecvt<wchar_t, char, mbstate_t>::result
+codecvt<wchar_t, char, mbstate_t>::do_out(state_type& st,
+ const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+ extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+ // look for first internal null in frm
+ const intern_type* fend = frm;
+ for (; fend != frm_end; ++fend)
+ if (*fend == 0)
+ break;
+ // loop over all null-terminated sequences in frm
+ to_nxt = to;
+ for (frm_nxt = frm; frm != frm_end && to != to_end; frm = frm_nxt, to = to_nxt)
+ {
+ // save state in case it is needed to recover to_nxt on error
+ mbstate_t save_state = st;
+ size_t n = __libcpp_wcsnrtombs_l(to, &frm_nxt, static_cast<size_t>(fend-frm),
+ static_cast<size_t>(to_end-to), &st, __l);
+ if (n == size_t(-1))
+ {
+ // need to recover to_nxt
+ for (to_nxt = to; frm != frm_nxt; ++frm)
+ {
+ n = __libcpp_wcrtomb_l(to_nxt, *frm, &save_state, __l);
+ if (n == size_t(-1))
+ break;
+ to_nxt += n;
+ }
+ frm_nxt = frm;
+ return error;
+ }
+ if (n == 0)
+ return partial;
+ to_nxt += n;
+ if (to_nxt == to_end)
+ break;
+ if (fend != frm_end) // set up next null terminated sequence
+ {
+ // Try to write the terminating null
+ extern_type tmp[MB_LEN_MAX];
+ n = __libcpp_wcrtomb_l(tmp, intern_type(), &st, __l);
+ if (n == size_t(-1)) // on error
+ return error;
+ if (n > static_cast<size_t>(to_end-to_nxt)) // is there room?
+ return partial;
+ for (extern_type* p = tmp; n; --n) // write it
+ *to_nxt++ = *p++;
+ ++frm_nxt;
+ // look for next null in frm
+ for (fend = frm_nxt; fend != frm_end; ++fend)
+ if (*fend == 0)
+ break;
+ }
+ }
+ return frm_nxt == frm_end ? ok : partial;
+}
+
+codecvt<wchar_t, char, mbstate_t>::result
+codecvt<wchar_t, char, mbstate_t>::do_in(state_type& st,
+ const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+ intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+ // look for first internal null in frm
+ const extern_type* fend = frm;
+ for (; fend != frm_end; ++fend)
+ if (*fend == 0)
+ break;
+ // loop over all null-terminated sequences in frm
+ to_nxt = to;
+ for (frm_nxt = frm; frm != frm_end && to != to_end; frm = frm_nxt, to = to_nxt)
+ {
+ // save state in case it is needed to recover to_nxt on error
+ mbstate_t save_state = st;
+ size_t n = __libcpp_mbsnrtowcs_l(to, &frm_nxt, static_cast<size_t>(fend-frm),
+ static_cast<size_t>(to_end-to), &st, __l);
+ if (n == size_t(-1))
+ {
+ // need to recover to_nxt
+ for (to_nxt = to; frm != frm_nxt; ++to_nxt)
+ {
+ n = __libcpp_mbrtowc_l(to_nxt, frm, static_cast<size_t>(fend-frm),
+ &save_state, __l);
+ switch (n)
+ {
+ case 0:
+ ++frm;
+ break;
+ case size_t(-1):
+ frm_nxt = frm;
+ return error;
+ case size_t(-2):
+ frm_nxt = frm;
+ return partial;
+ default:
+ frm += n;
+ break;
+ }
+ }
+ frm_nxt = frm;
+ return frm_nxt == frm_end ? ok : partial;
+ }
+ if (n == size_t(-1))
+ return error;
+ to_nxt += n;
+ if (to_nxt == to_end)
+ break;
+ if (fend != frm_end) // set up next null terminated sequence
+ {
+ // Try to write the terminating null
+ n = __libcpp_mbrtowc_l(to_nxt, frm_nxt, 1, &st, __l);
+ if (n != 0) // on error
+ return error;
+ ++to_nxt;
+ ++frm_nxt;
+ // look for next null in frm
+ for (fend = frm_nxt; fend != frm_end; ++fend)
+ if (*fend == 0)
+ break;
+ }
+ }
+ return frm_nxt == frm_end ? ok : partial;
+}
+
+codecvt<wchar_t, char, mbstate_t>::result
+codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type& st,
+ extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+ to_nxt = to;
+ extern_type tmp[MB_LEN_MAX];
+ size_t n = __libcpp_wcrtomb_l(tmp, intern_type(), &st, __l);
+ if (n == size_t(-1) || n == 0) // on error
+ return error;
+ --n;
+ if (n > static_cast<size_t>(to_end-to_nxt)) // is there room?
+ return partial;
+ for (extern_type* p = tmp; n; --n) // write it
+ *to_nxt++ = *p++;
+ return ok;
+}
+
+int
+codecvt<wchar_t, char, mbstate_t>::do_encoding() const noexcept
+{
+ if (__libcpp_mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l) != 0)
+ return -1;
+
+ // stateless encoding
+ if (__l == 0 || __libcpp_mb_cur_max_l(__l) == 1) // there are no known constant length encodings
+ return 1; // which take more than 1 char to form a wchar_t
+ return 0;
+}
+
+bool
+codecvt<wchar_t, char, mbstate_t>::do_always_noconv() const noexcept
+{
+ return false;
+}
+
+int
+codecvt<wchar_t, char, mbstate_t>::do_length(state_type& st,
+ const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+ int nbytes = 0;
+ for (size_t nwchar_t = 0; nwchar_t < mx && frm != frm_end; ++nwchar_t)
+ {
+ size_t n = __libcpp_mbrlen_l(frm, static_cast<size_t>(frm_end-frm), &st, __l);
+ switch (n)
+ {
+ case 0:
+ ++nbytes;
+ ++frm;
+ break;
+ case size_t(-1):
+ case size_t(-2):
+ return nbytes;
+ default:
+ nbytes += n;
+ frm += n;
+ break;
+ }
+ }
+ return nbytes;
+}
+
+int
+codecvt<wchar_t, char, mbstate_t>::do_max_length() const noexcept
+{
+ return __l == 0 ? 1 : static_cast<int>(__libcpp_mb_cur_max_l(__l));
+}
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+// Valid UTF ranges
+// UTF-32 UTF-16 UTF-8 # of code points
+// first second first second third fourth
+// 000000 - 00007F 0000 - 007F 00 - 7F 127
+// 000080 - 0007FF 0080 - 07FF C2 - DF, 80 - BF 1920
+// 000800 - 000FFF 0800 - 0FFF E0 - E0, A0 - BF, 80 - BF 2048
+// 001000 - 00CFFF 1000 - CFFF E1 - EC, 80 - BF, 80 - BF 49152
+// 00D000 - 00D7FF D000 - D7FF ED - ED, 80 - 9F, 80 - BF 2048
+// 00D800 - 00DFFF invalid
+// 00E000 - 00FFFF E000 - FFFF EE - EF, 80 - BF, 80 - BF 8192
+// 010000 - 03FFFF D800 - D8BF, DC00 - DFFF F0 - F0, 90 - BF, 80 - BF, 80 - BF 196608
+// 040000 - 0FFFFF D8C0 - DBBF, DC00 - DFFF F1 - F3, 80 - BF, 80 - BF, 80 - BF 786432
+// 100000 - 10FFFF DBC0 - DBFF, DC00 - DFFF F4 - F4, 80 - 8F, 80 - BF, 80 - BF 65536
+
+static
+codecvt_base::result
+utf16_to_utf8(const uint16_t* frm, const uint16_t* frm_end, const uint16_t*& frm_nxt,
+ uint8_t* to, uint8_t* to_end, uint8_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & generate_header)
+ {
+ if (to_end-to_nxt < 3)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xEF);
+ *to_nxt++ = static_cast<uint8_t>(0xBB);
+ *to_nxt++ = static_cast<uint8_t>(0xBF);
+ }
+ for (; frm_nxt < frm_end; ++frm_nxt)
+ {
+ uint16_t wc1 = *frm_nxt;
+ if (wc1 > Maxcode)
+ return codecvt_base::error;
+ if (wc1 < 0x0080)
+ {
+ if (to_end-to_nxt < 1)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(wc1);
+ }
+ else if (wc1 < 0x0800)
+ {
+ if (to_end-to_nxt < 2)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xC0 | (wc1 >> 6));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | (wc1 & 0x03F));
+ }
+ else if (wc1 < 0xD800)
+ {
+ if (to_end-to_nxt < 3)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xE0 | (wc1 >> 12));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc1 & 0x0FC0) >> 6));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | (wc1 & 0x003F));
+ }
+ else if (wc1 < 0xDC00)
+ {
+ if (frm_end-frm_nxt < 2)
+ return codecvt_base::partial;
+ uint16_t wc2 = frm_nxt[1];
+ if ((wc2 & 0xFC00) != 0xDC00)
+ return codecvt_base::error;
+ if (to_end-to_nxt < 4)
+ return codecvt_base::partial;
+ if (((((wc1 & 0x03C0UL) >> 6) + 1) << 16) +
+ ((wc1 & 0x003FUL) << 10) + (wc2 & 0x03FF) > Maxcode)
+ return codecvt_base::error;
+ ++frm_nxt;
+ uint8_t z = ((wc1 & 0x03C0) >> 6) + 1;
+ *to_nxt++ = static_cast<uint8_t>(0xF0 | (z >> 2));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | ((z & 0x03) << 4) | ((wc1 & 0x003C) >> 2));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc1 & 0x0003) << 4) | ((wc2 & 0x03C0) >> 6));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | (wc2 & 0x003F));
+ }
+ else if (wc1 < 0xE000)
+ {
+ return codecvt_base::error;
+ }
+ else
+ {
+ if (to_end-to_nxt < 3)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xE0 | (wc1 >> 12));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc1 & 0x0FC0) >> 6));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | (wc1 & 0x003F));
+ }
+ }
+ return codecvt_base::ok;
+}
+
+static
+codecvt_base::result
+utf16_to_utf8(const uint32_t* frm, const uint32_t* frm_end, const uint32_t*& frm_nxt,
+ uint8_t* to, uint8_t* to_end, uint8_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & generate_header)
+ {
+ if (to_end-to_nxt < 3)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xEF);
+ *to_nxt++ = static_cast<uint8_t>(0xBB);
+ *to_nxt++ = static_cast<uint8_t>(0xBF);
+ }
+ for (; frm_nxt < frm_end; ++frm_nxt)
+ {
+ uint16_t wc1 = static_cast<uint16_t>(*frm_nxt);
+ if (wc1 > Maxcode)
+ return codecvt_base::error;
+ if (wc1 < 0x0080)
+ {
+ if (to_end-to_nxt < 1)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(wc1);
+ }
+ else if (wc1 < 0x0800)
+ {
+ if (to_end-to_nxt < 2)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xC0 | (wc1 >> 6));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | (wc1 & 0x03F));
+ }
+ else if (wc1 < 0xD800)
+ {
+ if (to_end-to_nxt < 3)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xE0 | (wc1 >> 12));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc1 & 0x0FC0) >> 6));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | (wc1 & 0x003F));
+ }
+ else if (wc1 < 0xDC00)
+ {
+ if (frm_end-frm_nxt < 2)
+ return codecvt_base::partial;
+ uint16_t wc2 = static_cast<uint16_t>(frm_nxt[1]);
+ if ((wc2 & 0xFC00) != 0xDC00)
+ return codecvt_base::error;
+ if (to_end-to_nxt < 4)
+ return codecvt_base::partial;
+ if (((((wc1 & 0x03C0UL) >> 6) + 1) << 16) +
+ ((wc1 & 0x003FUL) << 10) + (wc2 & 0x03FF) > Maxcode)
+ return codecvt_base::error;
+ ++frm_nxt;
+ uint8_t z = ((wc1 & 0x03C0) >> 6) + 1;
+ *to_nxt++ = static_cast<uint8_t>(0xF0 | (z >> 2));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | ((z & 0x03) << 4) | ((wc1 & 0x003C) >> 2));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc1 & 0x0003) << 4) | ((wc2 & 0x03C0) >> 6));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | (wc2 & 0x003F));
+ }
+ else if (wc1 < 0xE000)
+ {
+ return codecvt_base::error;
+ }
+ else
+ {
+ if (to_end-to_nxt < 3)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xE0 | (wc1 >> 12));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc1 & 0x0FC0) >> 6));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | (wc1 & 0x003F));
+ }
+ }
+ return codecvt_base::ok;
+}
+
+static
+codecvt_base::result
+utf8_to_utf16(const uint8_t* frm, const uint8_t* frm_end, const uint8_t*& frm_nxt,
+ uint16_t* to, uint16_t* to_end, uint16_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & consume_header)
+ {
+ if (frm_end-frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB &&
+ frm_nxt[2] == 0xBF)
+ frm_nxt += 3;
+ }
+ for (; frm_nxt < frm_end && to_nxt < to_end; ++to_nxt)
+ {
+ uint8_t c1 = *frm_nxt;
+ if (c1 > Maxcode)
+ return codecvt_base::error;
+ if (c1 < 0x80)
+ {
+ *to_nxt = static_cast<uint16_t>(c1);
+ ++frm_nxt;
+ }
+ else if (c1 < 0xC2)
+ {
+ return codecvt_base::error;
+ }
+ else if (c1 < 0xE0)
+ {
+ if (frm_end-frm_nxt < 2)
+ return codecvt_base::partial;
+ uint8_t c2 = frm_nxt[1];
+ if ((c2 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ uint16_t t = static_cast<uint16_t>(((c1 & 0x1F) << 6) | (c2 & 0x3F));
+ if (t > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = t;
+ frm_nxt += 2;
+ }
+ else if (c1 < 0xF0)
+ {
+ if (frm_end-frm_nxt < 3)
+ return codecvt_base::partial;
+ uint8_t c2 = frm_nxt[1];
+ uint8_t c3 = frm_nxt[2];
+ switch (c1)
+ {
+ case 0xE0:
+ if ((c2 & 0xE0) != 0xA0)
+ return codecvt_base::error;
+ break;
+ case 0xED:
+ if ((c2 & 0xE0) != 0x80)
+ return codecvt_base::error;
+ break;
+ default:
+ if ((c2 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ break;
+ }
+ if ((c3 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ uint16_t t = static_cast<uint16_t>(((c1 & 0x0F) << 12)
+ | ((c2 & 0x3F) << 6)
+ | (c3 & 0x3F));
+ if (t > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = t;
+ frm_nxt += 3;
+ }
+ else if (c1 < 0xF5)
+ {
+ if (frm_end-frm_nxt < 4)
+ return codecvt_base::partial;
+ uint8_t c2 = frm_nxt[1];
+ uint8_t c3 = frm_nxt[2];
+ uint8_t c4 = frm_nxt[3];
+ switch (c1)
+ {
+ case 0xF0:
+ if (!(0x90 <= c2 && c2 <= 0xBF))
+ return codecvt_base::error;
+ break;
+ case 0xF4:
+ if ((c2 & 0xF0) != 0x80)
+ return codecvt_base::error;
+ break;
+ default:
+ if ((c2 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ break;
+ }
+ if ((c3 & 0xC0) != 0x80 || (c4 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ if (to_end-to_nxt < 2)
+ return codecvt_base::partial;
+ if ((((c1 & 7UL) << 18) +
+ ((c2 & 0x3FUL) << 12) +
+ ((c3 & 0x3FUL) << 6) + (c4 & 0x3F)) > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = static_cast<uint16_t>(
+ 0xD800
+ | (((((c1 & 0x07) << 2) | ((c2 & 0x30) >> 4)) - 1) << 6)
+ | ((c2 & 0x0F) << 2)
+ | ((c3 & 0x30) >> 4));
+ *++to_nxt = static_cast<uint16_t>(
+ 0xDC00
+ | ((c3 & 0x0F) << 6)
+ | (c4 & 0x3F));
+ frm_nxt += 4;
+ }
+ else
+ {
+ return codecvt_base::error;
+ }
+ }
+ return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
+}
+
+static
+codecvt_base::result
+utf8_to_utf16(const uint8_t* frm, const uint8_t* frm_end, const uint8_t*& frm_nxt,
+ uint32_t* to, uint32_t* to_end, uint32_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & consume_header)
+ {
+ if (frm_end-frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB &&
+ frm_nxt[2] == 0xBF)
+ frm_nxt += 3;
+ }
+ for (; frm_nxt < frm_end && to_nxt < to_end; ++to_nxt)
+ {
+ uint8_t c1 = *frm_nxt;
+ if (c1 > Maxcode)
+ return codecvt_base::error;
+ if (c1 < 0x80)
+ {
+ *to_nxt = static_cast<uint32_t>(c1);
+ ++frm_nxt;
+ }
+ else if (c1 < 0xC2)
+ {
+ return codecvt_base::error;
+ }
+ else if (c1 < 0xE0)
+ {
+ if (frm_end-frm_nxt < 2)
+ return codecvt_base::partial;
+ uint8_t c2 = frm_nxt[1];
+ if ((c2 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ uint16_t t = static_cast<uint16_t>(((c1 & 0x1F) << 6) | (c2 & 0x3F));
+ if (t > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = static_cast<uint32_t>(t);
+ frm_nxt += 2;
+ }
+ else if (c1 < 0xF0)
+ {
+ if (frm_end-frm_nxt < 3)
+ return codecvt_base::partial;
+ uint8_t c2 = frm_nxt[1];
+ uint8_t c3 = frm_nxt[2];
+ switch (c1)
+ {
+ case 0xE0:
+ if ((c2 & 0xE0) != 0xA0)
+ return codecvt_base::error;
+ break;
+ case 0xED:
+ if ((c2 & 0xE0) != 0x80)
+ return codecvt_base::error;
+ break;
+ default:
+ if ((c2 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ break;
+ }
+ if ((c3 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ uint16_t t = static_cast<uint16_t>(((c1 & 0x0F) << 12)
+ | ((c2 & 0x3F) << 6)
+ | (c3 & 0x3F));
+ if (t > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = static_cast<uint32_t>(t);
+ frm_nxt += 3;
+ }
+ else if (c1 < 0xF5)
+ {
+ if (frm_end-frm_nxt < 4)
+ return codecvt_base::partial;
+ uint8_t c2 = frm_nxt[1];
+ uint8_t c3 = frm_nxt[2];
+ uint8_t c4 = frm_nxt[3];
+ switch (c1)
+ {
+ case 0xF0:
+ if (!(0x90 <= c2 && c2 <= 0xBF))
+ return codecvt_base::error;
+ break;
+ case 0xF4:
+ if ((c2 & 0xF0) != 0x80)
+ return codecvt_base::error;
+ break;
+ default:
+ if ((c2 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ break;
+ }
+ if ((c3 & 0xC0) != 0x80 || (c4 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ if (to_end-to_nxt < 2)
+ return codecvt_base::partial;
+ if ((((c1 & 7UL) << 18) +
+ ((c2 & 0x3FUL) << 12) +
+ ((c3 & 0x3FUL) << 6) + (c4 & 0x3F)) > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = static_cast<uint32_t>(
+ 0xD800
+ | (((((c1 & 0x07) << 2) | ((c2 & 0x30) >> 4)) - 1) << 6)
+ | ((c2 & 0x0F) << 2)
+ | ((c3 & 0x30) >> 4));
+ *++to_nxt = static_cast<uint32_t>(
+ 0xDC00
+ | ((c3 & 0x0F) << 6)
+ | (c4 & 0x3F));
+ frm_nxt += 4;
+ }
+ else
+ {
+ return codecvt_base::error;
+ }
+ }
+ return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
+}
+
+static
+int
+utf8_to_utf16_length(const uint8_t* frm, const uint8_t* frm_end,
+ size_t mx, unsigned long Maxcode = 0x10FFFF,
+ codecvt_mode mode = codecvt_mode(0))
+{
+ const uint8_t* frm_nxt = frm;
+ if (mode & consume_header)
+ {
+ if (frm_end-frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB &&
+ frm_nxt[2] == 0xBF)
+ frm_nxt += 3;
+ }
+ for (size_t nchar16_t = 0; frm_nxt < frm_end && nchar16_t < mx; ++nchar16_t)
+ {
+ uint8_t c1 = *frm_nxt;
+ if (c1 > Maxcode)
+ break;
+ if (c1 < 0x80)
+ {
+ ++frm_nxt;
+ }
+ else if (c1 < 0xC2)
+ {
+ break;
+ }
+ else if (c1 < 0xE0)
+ {
+ if ((frm_end-frm_nxt < 2) || (frm_nxt[1] & 0xC0) != 0x80)
+ break;
+ uint16_t t = static_cast<uint16_t>(((c1 & 0x1F) << 6) | (frm_nxt[1] & 0x3F));
+ if (t > Maxcode)
+ break;
+ frm_nxt += 2;
+ }
+ else if (c1 < 0xF0)
+ {
+ if (frm_end-frm_nxt < 3)
+ break;
+ uint8_t c2 = frm_nxt[1];
+ uint8_t c3 = frm_nxt[2];
+ switch (c1)
+ {
+ case 0xE0:
+ if ((c2 & 0xE0) != 0xA0)
+ return static_cast<int>(frm_nxt - frm);
+ break;
+ case 0xED:
+ if ((c2 & 0xE0) != 0x80)
+ return static_cast<int>(frm_nxt - frm);
+ break;
+ default:
+ if ((c2 & 0xC0) != 0x80)
+ return static_cast<int>(frm_nxt - frm);
+ break;
+ }
+ if ((c3 & 0xC0) != 0x80)
+ break;
+ if ((((c1 & 0x0Fu) << 12) | ((c2 & 0x3Fu) << 6) | (c3 & 0x3Fu)) > Maxcode)
+ break;
+ frm_nxt += 3;
+ }
+ else if (c1 < 0xF5)
+ {
+ if (frm_end-frm_nxt < 4 || mx-nchar16_t < 2)
+ break;
+ uint8_t c2 = frm_nxt[1];
+ uint8_t c3 = frm_nxt[2];
+ uint8_t c4 = frm_nxt[3];
+ switch (c1)
+ {
+ case 0xF0:
+ if (!(0x90 <= c2 && c2 <= 0xBF))
+ return static_cast<int>(frm_nxt - frm);
+ break;
+ case 0xF4:
+ if ((c2 & 0xF0) != 0x80)
+ return static_cast<int>(frm_nxt - frm);
+ break;
+ default:
+ if ((c2 & 0xC0) != 0x80)
+ return static_cast<int>(frm_nxt - frm);
+ break;
+ }
+ if ((c3 & 0xC0) != 0x80 || (c4 & 0xC0) != 0x80)
+ break;
+ if ((((c1 & 7UL) << 18) +
+ ((c2 & 0x3FUL) << 12) +
+ ((c3 & 0x3FUL) << 6) + (c4 & 0x3F)) > Maxcode)
+ break;
+ ++nchar16_t;
+ frm_nxt += 4;
+ }
+ else
+ {
+ break;
+ }
+ }
+ return static_cast<int>(frm_nxt - frm);
+}
+
+static
+codecvt_base::result
+ucs4_to_utf8(const uint32_t* frm, const uint32_t* frm_end, const uint32_t*& frm_nxt,
+ uint8_t* to, uint8_t* to_end, uint8_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & generate_header)
+ {
+ if (to_end-to_nxt < 3)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xEF);
+ *to_nxt++ = static_cast<uint8_t>(0xBB);
+ *to_nxt++ = static_cast<uint8_t>(0xBF);
+ }
+ for (; frm_nxt < frm_end; ++frm_nxt)
+ {
+ uint32_t wc = *frm_nxt;
+ if ((wc & 0xFFFFF800) == 0x00D800 || wc > Maxcode)
+ return codecvt_base::error;
+ if (wc < 0x000080)
+ {
+ if (to_end-to_nxt < 1)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(wc);
+ }
+ else if (wc < 0x000800)
+ {
+ if (to_end-to_nxt < 2)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xC0 | (wc >> 6));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | (wc & 0x03F));
+ }
+ else if (wc < 0x010000)
+ {
+ if (to_end-to_nxt < 3)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xE0 | (wc >> 12));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc & 0x0FC0) >> 6));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | (wc & 0x003F));
+ }
+ else // if (wc < 0x110000)
+ {
+ if (to_end-to_nxt < 4)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xF0 | (wc >> 18));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc & 0x03F000) >> 12));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc & 0x000FC0) >> 6));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | (wc & 0x00003F));
+ }
+ }
+ return codecvt_base::ok;
+}
+
+static
+codecvt_base::result
+utf8_to_ucs4(const uint8_t* frm, const uint8_t* frm_end, const uint8_t*& frm_nxt,
+ uint32_t* to, uint32_t* to_end, uint32_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & consume_header)
+ {
+ if (frm_end-frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB &&
+ frm_nxt[2] == 0xBF)
+ frm_nxt += 3;
+ }
+ for (; frm_nxt < frm_end && to_nxt < to_end; ++to_nxt)
+ {
+ uint8_t c1 = static_cast<uint8_t>(*frm_nxt);
+ if (c1 < 0x80)
+ {
+ if (c1 > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = static_cast<uint32_t>(c1);
+ ++frm_nxt;
+ }
+ else if (c1 < 0xC2)
+ {
+ return codecvt_base::error;
+ }
+ else if (c1 < 0xE0)
+ {
+ if (frm_end-frm_nxt < 2)
+ return codecvt_base::partial;
+ uint8_t c2 = frm_nxt[1];
+ if ((c2 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ uint32_t t = static_cast<uint32_t>(((c1 & 0x1F) << 6)
+ | (c2 & 0x3F));
+ if (t > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = t;
+ frm_nxt += 2;
+ }
+ else if (c1 < 0xF0)
+ {
+ if (frm_end-frm_nxt < 3)
+ return codecvt_base::partial;
+ uint8_t c2 = frm_nxt[1];
+ uint8_t c3 = frm_nxt[2];
+ switch (c1)
+ {
+ case 0xE0:
+ if ((c2 & 0xE0) != 0xA0)
+ return codecvt_base::error;
+ break;
+ case 0xED:
+ if ((c2 & 0xE0) != 0x80)
+ return codecvt_base::error;
+ break;
+ default:
+ if ((c2 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ break;
+ }
+ if ((c3 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ uint32_t t = static_cast<uint32_t>(((c1 & 0x0F) << 12)
+ | ((c2 & 0x3F) << 6)
+ | (c3 & 0x3F));
+ if (t > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = t;
+ frm_nxt += 3;
+ }
+ else if (c1 < 0xF5)
+ {
+ if (frm_end-frm_nxt < 4)
+ return codecvt_base::partial;
+ uint8_t c2 = frm_nxt[1];
+ uint8_t c3 = frm_nxt[2];
+ uint8_t c4 = frm_nxt[3];
+ switch (c1)
+ {
+ case 0xF0:
+ if (!(0x90 <= c2 && c2 <= 0xBF))
+ return codecvt_base::error;
+ break;
+ case 0xF4:
+ if ((c2 & 0xF0) != 0x80)
+ return codecvt_base::error;
+ break;
+ default:
+ if ((c2 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ break;
+ }
+ if ((c3 & 0xC0) != 0x80 || (c4 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ uint32_t t = static_cast<uint32_t>(((c1 & 0x07) << 18)
+ | ((c2 & 0x3F) << 12)
+ | ((c3 & 0x3F) << 6)
+ | (c4 & 0x3F));
+ if (t > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = t;
+ frm_nxt += 4;
+ }
+ else
+ {
+ return codecvt_base::error;
+ }
+ }
+ return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
+}
+
+static
+int
+utf8_to_ucs4_length(const uint8_t* frm, const uint8_t* frm_end,
+ size_t mx, unsigned long Maxcode = 0x10FFFF,
+ codecvt_mode mode = codecvt_mode(0))
+{
+ const uint8_t* frm_nxt = frm;
+ if (mode & consume_header)
+ {
+ if (frm_end-frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB &&
+ frm_nxt[2] == 0xBF)
+ frm_nxt += 3;
+ }
+ for (size_t nchar32_t = 0; frm_nxt < frm_end && nchar32_t < mx; ++nchar32_t)
+ {
+ uint8_t c1 = static_cast<uint8_t>(*frm_nxt);
+ if (c1 < 0x80)
+ {
+ if (c1 > Maxcode)
+ break;
+ ++frm_nxt;
+ }
+ else if (c1 < 0xC2)
+ {
+ break;
+ }
+ else if (c1 < 0xE0)
+ {
+ if ((frm_end-frm_nxt < 2) || ((frm_nxt[1] & 0xC0) != 0x80))
+ break;
+ if ((((c1 & 0x1Fu) << 6) | (frm_nxt[1] & 0x3Fu)) > Maxcode)
+ break;
+ frm_nxt += 2;
+ }
+ else if (c1 < 0xF0)
+ {
+ if (frm_end-frm_nxt < 3)
+ break;
+ uint8_t c2 = frm_nxt[1];
+ uint8_t c3 = frm_nxt[2];
+ switch (c1)
+ {
+ case 0xE0:
+ if ((c2 & 0xE0) != 0xA0)
+ return static_cast<int>(frm_nxt - frm);
+ break;
+ case 0xED:
+ if ((c2 & 0xE0) != 0x80)
+ return static_cast<int>(frm_nxt - frm);
+ break;
+ default:
+ if ((c2 & 0xC0) != 0x80)
+ return static_cast<int>(frm_nxt - frm);
+ break;
+ }
+ if ((c3 & 0xC0) != 0x80)
+ break;
+ if ((((c1 & 0x0Fu) << 12) | ((c2 & 0x3Fu) << 6) | (c3 & 0x3Fu)) > Maxcode)
+ break;
+ frm_nxt += 3;
+ }
+ else if (c1 < 0xF5)
+ {
+ if (frm_end-frm_nxt < 4)
+ break;
+ uint8_t c2 = frm_nxt[1];
+ uint8_t c3 = frm_nxt[2];
+ uint8_t c4 = frm_nxt[3];
+ switch (c1)
+ {
+ case 0xF0:
+ if (!(0x90 <= c2 && c2 <= 0xBF))
+ return static_cast<int>(frm_nxt - frm);
+ break;
+ case 0xF4:
+ if ((c2 & 0xF0) != 0x80)
+ return static_cast<int>(frm_nxt - frm);
+ break;
+ default:
+ if ((c2 & 0xC0) != 0x80)
+ return static_cast<int>(frm_nxt - frm);
+ break;
+ }
+ if ((c3 & 0xC0) != 0x80 || (c4 & 0xC0) != 0x80)
+ break;
+ if ((((c1 & 0x07u) << 18) | ((c2 & 0x3Fu) << 12) |
+ ((c3 & 0x3Fu) << 6) | (c4 & 0x3Fu)) > Maxcode)
+ break;
+ frm_nxt += 4;
+ }
+ else
+ {
+ break;
+ }
+ }
+ return static_cast<int>(frm_nxt - frm);
+}
+
+static
+codecvt_base::result
+ucs2_to_utf8(const uint16_t* frm, const uint16_t* frm_end, const uint16_t*& frm_nxt,
+ uint8_t* to, uint8_t* to_end, uint8_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & generate_header)
+ {
+ if (to_end-to_nxt < 3)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xEF);
+ *to_nxt++ = static_cast<uint8_t>(0xBB);
+ *to_nxt++ = static_cast<uint8_t>(0xBF);
+ }
+ for (; frm_nxt < frm_end; ++frm_nxt)
+ {
+ uint16_t wc = *frm_nxt;
+ if ((wc & 0xF800) == 0xD800 || wc > Maxcode)
+ return codecvt_base::error;
+ if (wc < 0x0080)
+ {
+ if (to_end-to_nxt < 1)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(wc);
+ }
+ else if (wc < 0x0800)
+ {
+ if (to_end-to_nxt < 2)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xC0 | (wc >> 6));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | (wc & 0x03F));
+ }
+ else // if (wc <= 0xFFFF)
+ {
+ if (to_end-to_nxt < 3)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xE0 | (wc >> 12));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc & 0x0FC0) >> 6));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | (wc & 0x003F));
+ }
+ }
+ return codecvt_base::ok;
+}
+
+static
+codecvt_base::result
+utf8_to_ucs2(const uint8_t* frm, const uint8_t* frm_end, const uint8_t*& frm_nxt,
+ uint16_t* to, uint16_t* to_end, uint16_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & consume_header)
+ {
+ if (frm_end-frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB &&
+ frm_nxt[2] == 0xBF)
+ frm_nxt += 3;
+ }
+ for (; frm_nxt < frm_end && to_nxt < to_end; ++to_nxt)
+ {
+ uint8_t c1 = static_cast<uint8_t>(*frm_nxt);
+ if (c1 < 0x80)
+ {
+ if (c1 > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = static_cast<uint16_t>(c1);
+ ++frm_nxt;
+ }
+ else if (c1 < 0xC2)
+ {
+ return codecvt_base::error;
+ }
+ else if (c1 < 0xE0)
+ {
+ if (frm_end-frm_nxt < 2)
+ return codecvt_base::partial;
+ uint8_t c2 = frm_nxt[1];
+ if ((c2 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ uint16_t t = static_cast<uint16_t>(((c1 & 0x1F) << 6)
+ | (c2 & 0x3F));
+ if (t > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = t;
+ frm_nxt += 2;
+ }
+ else if (c1 < 0xF0)
+ {
+ if (frm_end-frm_nxt < 3)
+ return codecvt_base::partial;
+ uint8_t c2 = frm_nxt[1];
+ uint8_t c3 = frm_nxt[2];
+ switch (c1)
+ {
+ case 0xE0:
+ if ((c2 & 0xE0) != 0xA0)
+ return codecvt_base::error;
+ break;
+ case 0xED:
+ if ((c2 & 0xE0) != 0x80)
+ return codecvt_base::error;
+ break;
+ default:
+ if ((c2 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ break;
+ }
+ if ((c3 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ uint16_t t = static_cast<uint16_t>(((c1 & 0x0F) << 12)
+ | ((c2 & 0x3F) << 6)
+ | (c3 & 0x3F));
+ if (t > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = t;
+ frm_nxt += 3;
+ }
+ else
+ {
+ return codecvt_base::error;
+ }
+ }
+ return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
+}
+
+static
+int
+utf8_to_ucs2_length(const uint8_t* frm, const uint8_t* frm_end,
+ size_t mx, unsigned long Maxcode = 0x10FFFF,
+ codecvt_mode mode = codecvt_mode(0))
+{
+ const uint8_t* frm_nxt = frm;
+ if (mode & consume_header)
+ {
+ if (frm_end-frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB &&
+ frm_nxt[2] == 0xBF)
+ frm_nxt += 3;
+ }
+ for (size_t nchar32_t = 0; frm_nxt < frm_end && nchar32_t < mx; ++nchar32_t)
+ {
+ uint8_t c1 = static_cast<uint8_t>(*frm_nxt);
+ if (c1 < 0x80)
+ {
+ if (c1 > Maxcode)
+ break;
+ ++frm_nxt;
+ }
+ else if (c1 < 0xC2)
+ {
+ break;
+ }
+ else if (c1 < 0xE0)
+ {
+ if ((frm_end-frm_nxt < 2) || ((frm_nxt[1] & 0xC0) != 0x80))
+ break;
+ if ((((c1 & 0x1Fu) << 6) | (frm_nxt[1] & 0x3Fu)) > Maxcode)
+ break;
+ frm_nxt += 2;
+ }
+ else if (c1 < 0xF0)
+ {
+ if (frm_end-frm_nxt < 3)
+ break;
+ uint8_t c2 = frm_nxt[1];
+ uint8_t c3 = frm_nxt[2];
+ switch (c1)
+ {
+ case 0xE0:
+ if ((c2 & 0xE0) != 0xA0)
+ return static_cast<int>(frm_nxt - frm);
+ break;
+ case 0xED:
+ if ((c2 & 0xE0) != 0x80)
+ return static_cast<int>(frm_nxt - frm);
+ break;
+ default:
+ if ((c2 & 0xC0) != 0x80)
+ return static_cast<int>(frm_nxt - frm);
+ break;
+ }
+ if ((c3 & 0xC0) != 0x80)
+ break;
+ if ((((c1 & 0x0Fu) << 12) | ((c2 & 0x3Fu) << 6) | (c3 & 0x3Fu)) > Maxcode)
+ break;
+ frm_nxt += 3;
+ }
+ else
+ {
+ break;
+ }
+ }
+ return static_cast<int>(frm_nxt - frm);
+}
+
+static
+codecvt_base::result
+ucs4_to_utf16be(const uint32_t* frm, const uint32_t* frm_end, const uint32_t*& frm_nxt,
+ uint8_t* to, uint8_t* to_end, uint8_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & generate_header)
+ {
+ if (to_end-to_nxt < 2)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xFE);
+ *to_nxt++ = static_cast<uint8_t>(0xFF);
+ }
+ for (; frm_nxt < frm_end; ++frm_nxt)
+ {
+ uint32_t wc = *frm_nxt;
+ if ((wc & 0xFFFFF800) == 0x00D800 || wc > Maxcode)
+ return codecvt_base::error;
+ if (wc < 0x010000)
+ {
+ if (to_end-to_nxt < 2)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(wc >> 8);
+ *to_nxt++ = static_cast<uint8_t>(wc);
+ }
+ else
+ {
+ if (to_end-to_nxt < 4)
+ return codecvt_base::partial;
+ uint16_t t = static_cast<uint16_t>(
+ 0xD800
+ | ((((wc & 0x1F0000) >> 16) - 1) << 6)
+ | ((wc & 0x00FC00) >> 10));
+ *to_nxt++ = static_cast<uint8_t>(t >> 8);
+ *to_nxt++ = static_cast<uint8_t>(t);
+ t = static_cast<uint16_t>(0xDC00 | (wc & 0x03FF));
+ *to_nxt++ = static_cast<uint8_t>(t >> 8);
+ *to_nxt++ = static_cast<uint8_t>(t);
+ }
+ }
+ return codecvt_base::ok;
+}
+
+static
+codecvt_base::result
+utf16be_to_ucs4(const uint8_t* frm, const uint8_t* frm_end, const uint8_t*& frm_nxt,
+ uint32_t* to, uint32_t* to_end, uint32_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & consume_header)
+ {
+ if (frm_end-frm_nxt >= 2 && frm_nxt[0] == 0xFE && frm_nxt[1] == 0xFF)
+ frm_nxt += 2;
+ }
+ for (; frm_nxt < frm_end - 1 && to_nxt < to_end; ++to_nxt)
+ {
+ uint16_t c1 = static_cast<uint16_t>(frm_nxt[0] << 8 | frm_nxt[1]);
+ if ((c1 & 0xFC00) == 0xDC00)
+ return codecvt_base::error;
+ if ((c1 & 0xFC00) != 0xD800)
+ {
+ if (c1 > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = static_cast<uint32_t>(c1);
+ frm_nxt += 2;
+ }
+ else
+ {
+ if (frm_end-frm_nxt < 4)
+ return codecvt_base::partial;
+ uint16_t c2 = static_cast<uint16_t>(frm_nxt[2] << 8 | frm_nxt[3]);
+ if ((c2 & 0xFC00) != 0xDC00)
+ return codecvt_base::error;
+ uint32_t t = static_cast<uint32_t>(
+ ((((c1 & 0x03C0) >> 6) + 1) << 16)
+ | ((c1 & 0x003F) << 10)
+ | (c2 & 0x03FF));
+ if (t > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = t;
+ frm_nxt += 4;
+ }
+ }
+ return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
+}
+
+static
+int
+utf16be_to_ucs4_length(const uint8_t* frm, const uint8_t* frm_end,
+ size_t mx, unsigned long Maxcode = 0x10FFFF,
+ codecvt_mode mode = codecvt_mode(0))
+{
+ const uint8_t* frm_nxt = frm;
+ if (mode & consume_header)
+ {
+ if (frm_end-frm_nxt >= 2 && frm_nxt[0] == 0xFE && frm_nxt[1] == 0xFF)
+ frm_nxt += 2;
+ }
+ for (size_t nchar32_t = 0; frm_nxt < frm_end - 1 && nchar32_t < mx; ++nchar32_t)
+ {
+ uint16_t c1 = static_cast<uint16_t>(frm_nxt[0] << 8 | frm_nxt[1]);
+ if ((c1 & 0xFC00) == 0xDC00)
+ break;
+ if ((c1 & 0xFC00) != 0xD800)
+ {
+ if (c1 > Maxcode)
+ break;
+ frm_nxt += 2;
+ }
+ else
+ {
+ if (frm_end-frm_nxt < 4)
+ break;
+ uint16_t c2 = static_cast<uint16_t>(frm_nxt[2] << 8 | frm_nxt[3]);
+ if ((c2 & 0xFC00) != 0xDC00)
+ break;
+ uint32_t t = static_cast<uint32_t>(
+ ((((c1 & 0x03C0) >> 6) + 1) << 16)
+ | ((c1 & 0x003F) << 10)
+ | (c2 & 0x03FF));
+ if (t > Maxcode)
+ break;
+ frm_nxt += 4;
+ }
+ }
+ return static_cast<int>(frm_nxt - frm);
+}
+
+static
+codecvt_base::result
+ucs4_to_utf16le(const uint32_t* frm, const uint32_t* frm_end, const uint32_t*& frm_nxt,
+ uint8_t* to, uint8_t* to_end, uint8_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & generate_header)
+ {
+ if (to_end - to_nxt < 2)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xFF);
+ *to_nxt++ = static_cast<uint8_t>(0xFE);
+ }
+ for (; frm_nxt < frm_end; ++frm_nxt)
+ {
+ uint32_t wc = *frm_nxt;
+ if ((wc & 0xFFFFF800) == 0x00D800 || wc > Maxcode)
+ return codecvt_base::error;
+ if (wc < 0x010000)
+ {
+ if (to_end-to_nxt < 2)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(wc);
+ *to_nxt++ = static_cast<uint8_t>(wc >> 8);
+ }
+ else
+ {
+ if (to_end-to_nxt < 4)
+ return codecvt_base::partial;
+ uint16_t t = static_cast<uint16_t>(
+ 0xD800
+ | ((((wc & 0x1F0000) >> 16) - 1) << 6)
+ | ((wc & 0x00FC00) >> 10));
+ *to_nxt++ = static_cast<uint8_t>(t);
+ *to_nxt++ = static_cast<uint8_t>(t >> 8);
+ t = static_cast<uint16_t>(0xDC00 | (wc & 0x03FF));
+ *to_nxt++ = static_cast<uint8_t>(t);
+ *to_nxt++ = static_cast<uint8_t>(t >> 8);
+ }
+ }
+ return codecvt_base::ok;
+}
+
+static
+codecvt_base::result
+utf16le_to_ucs4(const uint8_t* frm, const uint8_t* frm_end, const uint8_t*& frm_nxt,
+ uint32_t* to, uint32_t* to_end, uint32_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & consume_header)
+ {
+ if (frm_end-frm_nxt >= 2 && frm_nxt[0] == 0xFF && frm_nxt[1] == 0xFE)
+ frm_nxt += 2;
+ }
+ for (; frm_nxt < frm_end - 1 && to_nxt < to_end; ++to_nxt)
+ {
+ uint16_t c1 = static_cast<uint16_t>(frm_nxt[1] << 8 | frm_nxt[0]);
+ if ((c1 & 0xFC00) == 0xDC00)
+ return codecvt_base::error;
+ if ((c1 & 0xFC00) != 0xD800)
+ {
+ if (c1 > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = static_cast<uint32_t>(c1);
+ frm_nxt += 2;
+ }
+ else
+ {
+ if (frm_end-frm_nxt < 4)
+ return codecvt_base::partial;
+ uint16_t c2 = static_cast<uint16_t>(frm_nxt[3] << 8 | frm_nxt[2]);
+ if ((c2 & 0xFC00) != 0xDC00)
+ return codecvt_base::error;
+ uint32_t t = static_cast<uint32_t>(
+ ((((c1 & 0x03C0) >> 6) + 1) << 16)
+ | ((c1 & 0x003F) << 10)
+ | (c2 & 0x03FF));
+ if (t > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = t;
+ frm_nxt += 4;
+ }
+ }
+ return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
+}
+
+static
+int
+utf16le_to_ucs4_length(const uint8_t* frm, const uint8_t* frm_end,
+ size_t mx, unsigned long Maxcode = 0x10FFFF,
+ codecvt_mode mode = codecvt_mode(0))
+{
+ const uint8_t* frm_nxt = frm;
+ if (mode & consume_header)
+ {
+ if (frm_end-frm_nxt >= 2 && frm_nxt[0] == 0xFF && frm_nxt[1] == 0xFE)
+ frm_nxt += 2;
+ }
+ for (size_t nchar32_t = 0; frm_nxt < frm_end - 1 && nchar32_t < mx; ++nchar32_t)
+ {
+ uint16_t c1 = static_cast<uint16_t>(frm_nxt[1] << 8 | frm_nxt[0]);
+ if ((c1 & 0xFC00) == 0xDC00)
+ break;
+ if ((c1 & 0xFC00) != 0xD800)
+ {
+ if (c1 > Maxcode)
+ break;
+ frm_nxt += 2;
+ }
+ else
+ {
+ if (frm_end-frm_nxt < 4)
+ break;
+ uint16_t c2 = static_cast<uint16_t>(frm_nxt[3] << 8 | frm_nxt[2]);
+ if ((c2 & 0xFC00) != 0xDC00)
+ break;
+ uint32_t t = static_cast<uint32_t>(
+ ((((c1 & 0x03C0) >> 6) + 1) << 16)
+ | ((c1 & 0x003F) << 10)
+ | (c2 & 0x03FF));
+ if (t > Maxcode)
+ break;
+ frm_nxt += 4;
+ }
+ }
+ return static_cast<int>(frm_nxt - frm);
+}
+
+static
+codecvt_base::result
+ucs2_to_utf16be(const uint16_t* frm, const uint16_t* frm_end, const uint16_t*& frm_nxt,
+ uint8_t* to, uint8_t* to_end, uint8_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & generate_header)
+ {
+ if (to_end-to_nxt < 2)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xFE);
+ *to_nxt++ = static_cast<uint8_t>(0xFF);
+ }
+ for (; frm_nxt < frm_end; ++frm_nxt)
+ {
+ uint16_t wc = *frm_nxt;
+ if ((wc & 0xF800) == 0xD800 || wc > Maxcode)
+ return codecvt_base::error;
+ if (to_end-to_nxt < 2)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(wc >> 8);
+ *to_nxt++ = static_cast<uint8_t>(wc);
+ }
+ return codecvt_base::ok;
+}
+
+static
+codecvt_base::result
+utf16be_to_ucs2(const uint8_t* frm, const uint8_t* frm_end, const uint8_t*& frm_nxt,
+ uint16_t* to, uint16_t* to_end, uint16_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & consume_header)
+ {
+ if (frm_end-frm_nxt >= 2 && frm_nxt[0] == 0xFE && frm_nxt[1] == 0xFF)
+ frm_nxt += 2;
+ }
+ for (; frm_nxt < frm_end - 1 && to_nxt < to_end; ++to_nxt)
+ {
+ uint16_t c1 = static_cast<uint16_t>(frm_nxt[0] << 8 | frm_nxt[1]);
+ if ((c1 & 0xF800) == 0xD800 || c1 > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = c1;
+ frm_nxt += 2;
+ }
+ return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
+}
+
+static
+int
+utf16be_to_ucs2_length(const uint8_t* frm, const uint8_t* frm_end,
+ size_t mx, unsigned long Maxcode = 0x10FFFF,
+ codecvt_mode mode = codecvt_mode(0))
+{
+ const uint8_t* frm_nxt = frm;
+ if (mode & consume_header)
+ {
+ if (frm_end-frm_nxt >= 2 && frm_nxt[0] == 0xFE && frm_nxt[1] == 0xFF)
+ frm_nxt += 2;
+ }
+ for (size_t nchar16_t = 0; frm_nxt < frm_end - 1 && nchar16_t < mx; ++nchar16_t)
+ {
+ uint16_t c1 = static_cast<uint16_t>(frm_nxt[0] << 8 | frm_nxt[1]);
+ if ((c1 & 0xF800) == 0xD800 || c1 > Maxcode)
+ break;
+ frm_nxt += 2;
+ }
+ return static_cast<int>(frm_nxt - frm);
+}
+
+static
+codecvt_base::result
+ucs2_to_utf16le(const uint16_t* frm, const uint16_t* frm_end, const uint16_t*& frm_nxt,
+ uint8_t* to, uint8_t* to_end, uint8_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & generate_header)
+ {
+ if (to_end-to_nxt < 2)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xFF);
+ *to_nxt++ = static_cast<uint8_t>(0xFE);
+ }
+ for (; frm_nxt < frm_end; ++frm_nxt)
+ {
+ uint16_t wc = *frm_nxt;
+ if ((wc & 0xF800) == 0xD800 || wc > Maxcode)
+ return codecvt_base::error;
+ if (to_end-to_nxt < 2)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(wc);
+ *to_nxt++ = static_cast<uint8_t>(wc >> 8);
+ }
+ return codecvt_base::ok;
+}
+
+static
+codecvt_base::result
+utf16le_to_ucs2(const uint8_t* frm, const uint8_t* frm_end, const uint8_t*& frm_nxt,
+ uint16_t* to, uint16_t* to_end, uint16_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & consume_header)
+ {
+ if (frm_end-frm_nxt >= 2 && frm_nxt[0] == 0xFF && frm_nxt[1] == 0xFE)
+ frm_nxt += 2;
+ }
+ for (; frm_nxt < frm_end - 1 && to_nxt < to_end; ++to_nxt)
+ {
+ uint16_t c1 = static_cast<uint16_t>(frm_nxt[1] << 8 | frm_nxt[0]);
+ if ((c1 & 0xF800) == 0xD800 || c1 > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = c1;
+ frm_nxt += 2;
+ }
+ return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
+}
+
+static
+int
+utf16le_to_ucs2_length(const uint8_t* frm, const uint8_t* frm_end,
+ size_t mx, unsigned long Maxcode = 0x10FFFF,
+ codecvt_mode mode = codecvt_mode(0))
+{
+ const uint8_t* frm_nxt = frm;
+ frm_nxt = frm;
+ if (mode & consume_header)
+ {
+ if (frm_end-frm_nxt >= 2 && frm_nxt[0] == 0xFF && frm_nxt[1] == 0xFE)
+ frm_nxt += 2;
+ }
+ for (size_t nchar16_t = 0; frm_nxt < frm_end - 1 && nchar16_t < mx; ++nchar16_t)
+ {
+ uint16_t c1 = static_cast<uint16_t>(frm_nxt[1] << 8 | frm_nxt[0]);
+ if ((c1 & 0xF800) == 0xD800 || c1 > Maxcode)
+ break;
+ frm_nxt += 2;
+ }
+ return static_cast<int>(frm_nxt - frm);
+}
+
+// template <> class codecvt<char16_t, char, mbstate_t>
+
+locale::id codecvt<char16_t, char, mbstate_t>::id;
+
+codecvt<char16_t, char, mbstate_t>::~codecvt()
+{
+}
+
+codecvt<char16_t, char, mbstate_t>::result
+codecvt<char16_t, char, mbstate_t>::do_out(state_type&,
+ const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+ extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+ const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
+ const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
+ const uint16_t* _frm_nxt = _frm;
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
+ result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+codecvt<char16_t, char, mbstate_t>::result
+codecvt<char16_t, char, mbstate_t>::do_in(state_type&,
+ const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+ intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
+ uint16_t* _to = reinterpret_cast<uint16_t*>(to);
+ uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
+ uint16_t* _to_nxt = _to;
+ result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+codecvt<char16_t, char, mbstate_t>::result
+codecvt<char16_t, char, mbstate_t>::do_unshift(state_type&,
+ extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+ to_nxt = to;
+ return noconv;
+}
+
+int
+codecvt<char16_t, char, mbstate_t>::do_encoding() const noexcept
+{
+ return 0;
+}
+
+bool
+codecvt<char16_t, char, mbstate_t>::do_always_noconv() const noexcept
+{
+ return false;
+}
+
+int
+codecvt<char16_t, char, mbstate_t>::do_length(state_type&,
+ const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ return utf8_to_utf16_length(_frm, _frm_end, mx);
+}
+
+int
+codecvt<char16_t, char, mbstate_t>::do_max_length() const noexcept
+{
+ return 4;
+}
+
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
+
+// template <> class codecvt<char16_t, char8_t, mbstate_t>
+
+locale::id codecvt<char16_t, char8_t, mbstate_t>::id;
+
+codecvt<char16_t, char8_t, mbstate_t>::~codecvt()
+{
+}
+
+codecvt<char16_t, char8_t, mbstate_t>::result
+codecvt<char16_t, char8_t, mbstate_t>::do_out(state_type&,
+ const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+ extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+ const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
+ const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
+ const uint16_t* _frm_nxt = _frm;
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
+ result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+codecvt<char16_t, char8_t, mbstate_t>::result
+codecvt<char16_t, char8_t, mbstate_t>::do_in(state_type&,
+ const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+ intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
+ uint16_t* _to = reinterpret_cast<uint16_t*>(to);
+ uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
+ uint16_t* _to_nxt = _to;
+ result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+codecvt<char16_t, char8_t, mbstate_t>::result
+codecvt<char16_t, char8_t, mbstate_t>::do_unshift(state_type&,
+ extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+ to_nxt = to;
+ return noconv;
+}
+
+int
+codecvt<char16_t, char8_t, mbstate_t>::do_encoding() const noexcept
+{
+ return 0;
+}
+
+bool
+codecvt<char16_t, char8_t, mbstate_t>::do_always_noconv() const noexcept
+{
+ return false;
+}
+
+int
+codecvt<char16_t, char8_t, mbstate_t>::do_length(state_type&,
+ const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ return utf8_to_utf16_length(_frm, _frm_end, mx);
+}
+
+int
+codecvt<char16_t, char8_t, mbstate_t>::do_max_length() const noexcept
+{
+ return 4;
+}
+
+#endif
+
+// template <> class codecvt<char32_t, char, mbstate_t>
+
+locale::id codecvt<char32_t, char, mbstate_t>::id;
+
+codecvt<char32_t, char, mbstate_t>::~codecvt()
+{
+}
+
+codecvt<char32_t, char, mbstate_t>::result
+codecvt<char32_t, char, mbstate_t>::do_out(state_type&,
+ const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+ extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+ const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
+ const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
+ const uint32_t* _frm_nxt = _frm;
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
+ result r = ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+codecvt<char32_t, char, mbstate_t>::result
+codecvt<char32_t, char, mbstate_t>::do_in(state_type&,
+ const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+ intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
+ uint32_t* _to = reinterpret_cast<uint32_t*>(to);
+ uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
+ uint32_t* _to_nxt = _to;
+ result r = utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+codecvt<char32_t, char, mbstate_t>::result
+codecvt<char32_t, char, mbstate_t>::do_unshift(state_type&,
+ extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+ to_nxt = to;
+ return noconv;
+}
+
+int
+codecvt<char32_t, char, mbstate_t>::do_encoding() const noexcept
+{
+ return 0;
+}
+
+bool
+codecvt<char32_t, char, mbstate_t>::do_always_noconv() const noexcept
+{
+ return false;
+}
+
+int
+codecvt<char32_t, char, mbstate_t>::do_length(state_type&,
+ const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ return utf8_to_ucs4_length(_frm, _frm_end, mx);
+}
+
+int
+codecvt<char32_t, char, mbstate_t>::do_max_length() const noexcept
+{
+ return 4;
+}
+
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
+
+// template <> class codecvt<char32_t, char8_t, mbstate_t>
+
+locale::id codecvt<char32_t, char8_t, mbstate_t>::id;
+
+codecvt<char32_t, char8_t, mbstate_t>::~codecvt()
+{
+}
+
+codecvt<char32_t, char8_t, mbstate_t>::result
+codecvt<char32_t, char8_t, mbstate_t>::do_out(state_type&,
+ const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+ extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+ const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
+ const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
+ const uint32_t* _frm_nxt = _frm;
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
+ result r = ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+codecvt<char32_t, char8_t, mbstate_t>::result
+codecvt<char32_t, char8_t, mbstate_t>::do_in(state_type&,
+ const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+ intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
+ uint32_t* _to = reinterpret_cast<uint32_t*>(to);
+ uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
+ uint32_t* _to_nxt = _to;
+ result r = utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+codecvt<char32_t, char8_t, mbstate_t>::result
+codecvt<char32_t, char8_t, mbstate_t>::do_unshift(state_type&,
+ extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+ to_nxt = to;
+ return noconv;
+}
+
+int
+codecvt<char32_t, char8_t, mbstate_t>::do_encoding() const noexcept
+{
+ return 0;
+}
+
+bool
+codecvt<char32_t, char8_t, mbstate_t>::do_always_noconv() const noexcept
+{
+ return false;
+}
+
+int
+codecvt<char32_t, char8_t, mbstate_t>::do_length(state_type&,
+ const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ return utf8_to_ucs4_length(_frm, _frm_end, mx);
+}
+
+int
+codecvt<char32_t, char8_t, mbstate_t>::do_max_length() const noexcept
+{
+ return 4;
+}
+
+#endif
+
+// __codecvt_utf8<wchar_t>
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+__codecvt_utf8<wchar_t>::result
+__codecvt_utf8<wchar_t>::do_out(state_type&,
+ const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+ extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+#if defined(_LIBCPP_SHORT_WCHAR)
+ const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
+ const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
+ const uint16_t* _frm_nxt = _frm;
+#else
+ const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
+ const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
+ const uint32_t* _frm_nxt = _frm;
+#endif
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
+#if defined(_LIBCPP_SHORT_WCHAR)
+ result r = ucs2_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+#else
+ result r = ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+#endif
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf8<wchar_t>::result
+__codecvt_utf8<wchar_t>::do_in(state_type&,
+ const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+ intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
+#if defined(_LIBCPP_SHORT_WCHAR)
+ uint16_t* _to = reinterpret_cast<uint16_t*>(to);
+ uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
+ uint16_t* _to_nxt = _to;
+ result r = utf8_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+#else
+ uint32_t* _to = reinterpret_cast<uint32_t*>(to);
+ uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
+ uint32_t* _to_nxt = _to;
+ result r = utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+#endif
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf8<wchar_t>::result
+__codecvt_utf8<wchar_t>::do_unshift(state_type&,
+ extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+ to_nxt = to;
+ return noconv;
+}
+
+int
+__codecvt_utf8<wchar_t>::do_encoding() const noexcept
+{
+ return 0;
+}
+
+bool
+__codecvt_utf8<wchar_t>::do_always_noconv() const noexcept
+{
+ return false;
+}
+
+int
+__codecvt_utf8<wchar_t>::do_length(state_type&,
+ const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+#if defined(_LIBCPP_SHORT_WCHAR)
+ return utf8_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+#else
+ return utf8_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+#endif
+}
+
+int
+__codecvt_utf8<wchar_t>::do_max_length() const noexcept
+{
+#if defined(_LIBCPP_SHORT_WCHAR)
+ if (_Mode_ & consume_header)
+ return 6;
+ return 3;
+#else
+ if (_Mode_ & consume_header)
+ return 7;
+ return 4;
+#endif
+}
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+// __codecvt_utf8<char16_t>
+
+__codecvt_utf8<char16_t>::result
+__codecvt_utf8<char16_t>::do_out(state_type&,
+ const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+ extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+ const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
+ const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
+ const uint16_t* _frm_nxt = _frm;
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
+ result r = ucs2_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf8<char16_t>::result
+__codecvt_utf8<char16_t>::do_in(state_type&,
+ const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+ intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
+ uint16_t* _to = reinterpret_cast<uint16_t*>(to);
+ uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
+ uint16_t* _to_nxt = _to;
+ result r = utf8_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf8<char16_t>::result
+__codecvt_utf8<char16_t>::do_unshift(state_type&,
+ extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+ to_nxt = to;
+ return noconv;
+}
+
+int
+__codecvt_utf8<char16_t>::do_encoding() const noexcept
+{
+ return 0;
+}
+
+bool
+__codecvt_utf8<char16_t>::do_always_noconv() const noexcept
+{
+ return false;
+}
+
+int
+__codecvt_utf8<char16_t>::do_length(state_type&,
+ const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ return utf8_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+}
+
+int
+__codecvt_utf8<char16_t>::do_max_length() const noexcept
+{
+ if (_Mode_ & consume_header)
+ return 6;
+ return 3;
+}
+
+// __codecvt_utf8<char32_t>
+
+__codecvt_utf8<char32_t>::result
+__codecvt_utf8<char32_t>::do_out(state_type&,
+ const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+ extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+ const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
+ const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
+ const uint32_t* _frm_nxt = _frm;
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
+ result r = ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf8<char32_t>::result
+__codecvt_utf8<char32_t>::do_in(state_type&,
+ const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+ intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
+ uint32_t* _to = reinterpret_cast<uint32_t*>(to);
+ uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
+ uint32_t* _to_nxt = _to;
+ result r = utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf8<char32_t>::result
+__codecvt_utf8<char32_t>::do_unshift(state_type&,
+ extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+ to_nxt = to;
+ return noconv;
+}
+
+int
+__codecvt_utf8<char32_t>::do_encoding() const noexcept
+{
+ return 0;
+}
+
+bool
+__codecvt_utf8<char32_t>::do_always_noconv() const noexcept
+{
+ return false;
+}
+
+int
+__codecvt_utf8<char32_t>::do_length(state_type&,
+ const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ return utf8_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+}
+
+int
+__codecvt_utf8<char32_t>::do_max_length() const noexcept
+{
+ if (_Mode_ & consume_header)
+ return 7;
+ return 4;
+}
+
+// __codecvt_utf16<wchar_t, false>
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+__codecvt_utf16<wchar_t, false>::result
+__codecvt_utf16<wchar_t, false>::do_out(state_type&,
+ const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+ extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+#if defined(_LIBCPP_SHORT_WCHAR)
+ const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
+ const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
+ const uint16_t* _frm_nxt = _frm;
+#else
+ const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
+ const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
+ const uint32_t* _frm_nxt = _frm;
+#endif
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
+#if defined(_LIBCPP_SHORT_WCHAR)
+ result r = ucs2_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+#else
+ result r = ucs4_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+#endif
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf16<wchar_t, false>::result
+__codecvt_utf16<wchar_t, false>::do_in(state_type&,
+ const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+ intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
+#if defined(_LIBCPP_SHORT_WCHAR)
+ uint16_t* _to = reinterpret_cast<uint16_t*>(to);
+ uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
+ uint16_t* _to_nxt = _to;
+ result r = utf16be_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+#else
+ uint32_t* _to = reinterpret_cast<uint32_t*>(to);
+ uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
+ uint32_t* _to_nxt = _to;
+ result r = utf16be_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+#endif
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf16<wchar_t, false>::result
+__codecvt_utf16<wchar_t, false>::do_unshift(state_type&,
+ extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+ to_nxt = to;
+ return noconv;
+}
+
+int
+__codecvt_utf16<wchar_t, false>::do_encoding() const noexcept
+{
+ return 0;
+}
+
+bool
+__codecvt_utf16<wchar_t, false>::do_always_noconv() const noexcept
+{
+ return false;
+}
+
+int
+__codecvt_utf16<wchar_t, false>::do_length(state_type&,
+ const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+#if defined(_LIBCPP_SHORT_WCHAR)
+ return utf16be_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+#else
+ return utf16be_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+#endif
+}
+
+int
+__codecvt_utf16<wchar_t, false>::do_max_length() const noexcept
+{
+#if defined(_LIBCPP_SHORT_WCHAR)
+ if (_Mode_ & consume_header)
+ return 4;
+ return 2;
+#else
+ if (_Mode_ & consume_header)
+ return 6;
+ return 4;
+#endif
+}
+
+// __codecvt_utf16<wchar_t, true>
+
+__codecvt_utf16<wchar_t, true>::result
+__codecvt_utf16<wchar_t, true>::do_out(state_type&,
+ const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+ extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+#if defined(_LIBCPP_SHORT_WCHAR)
+ const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
+ const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
+ const uint16_t* _frm_nxt = _frm;
+#else
+ const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
+ const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
+ const uint32_t* _frm_nxt = _frm;
+#endif
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
+#if defined(_LIBCPP_SHORT_WCHAR)
+ result r = ucs2_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+#else
+ result r = ucs4_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+#endif
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf16<wchar_t, true>::result
+__codecvt_utf16<wchar_t, true>::do_in(state_type&,
+ const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+ intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
+#if defined(_LIBCPP_SHORT_WCHAR)
+ uint16_t* _to = reinterpret_cast<uint16_t*>(to);
+ uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
+ uint16_t* _to_nxt = _to;
+ result r = utf16le_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+#else
+ uint32_t* _to = reinterpret_cast<uint32_t*>(to);
+ uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
+ uint32_t* _to_nxt = _to;
+ result r = utf16le_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+#endif
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf16<wchar_t, true>::result
+__codecvt_utf16<wchar_t, true>::do_unshift(state_type&,
+ extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+ to_nxt = to;
+ return noconv;
+}
+
+int
+__codecvt_utf16<wchar_t, true>::do_encoding() const noexcept
+{
+ return 0;
+}
+
+bool
+__codecvt_utf16<wchar_t, true>::do_always_noconv() const noexcept
+{
+ return false;
+}
+
+int
+__codecvt_utf16<wchar_t, true>::do_length(state_type&,
+ const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+#if defined(_LIBCPP_SHORT_WCHAR)
+ return utf16le_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+#else
+ return utf16le_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+#endif
+}
+
+int
+__codecvt_utf16<wchar_t, true>::do_max_length() const noexcept
+{
+#if defined(_LIBCPP_SHORT_WCHAR)
+ if (_Mode_ & consume_header)
+ return 4;
+ return 2;
+#else
+ if (_Mode_ & consume_header)
+ return 6;
+ return 4;
+#endif
+}
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+// __codecvt_utf16<char16_t, false>
+
+__codecvt_utf16<char16_t, false>::result
+__codecvt_utf16<char16_t, false>::do_out(state_type&,
+ const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+ extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+ const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
+ const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
+ const uint16_t* _frm_nxt = _frm;
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
+ result r = ucs2_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf16<char16_t, false>::result
+__codecvt_utf16<char16_t, false>::do_in(state_type&,
+ const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+ intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
+ uint16_t* _to = reinterpret_cast<uint16_t*>(to);
+ uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
+ uint16_t* _to_nxt = _to;
+ result r = utf16be_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf16<char16_t, false>::result
+__codecvt_utf16<char16_t, false>::do_unshift(state_type&,
+ extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+ to_nxt = to;
+ return noconv;
+}
+
+int
+__codecvt_utf16<char16_t, false>::do_encoding() const noexcept
+{
+ return 0;
+}
+
+bool
+__codecvt_utf16<char16_t, false>::do_always_noconv() const noexcept
+{
+ return false;
+}
+
+int
+__codecvt_utf16<char16_t, false>::do_length(state_type&,
+ const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ return utf16be_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+}
+
+int
+__codecvt_utf16<char16_t, false>::do_max_length() const noexcept
+{
+ if (_Mode_ & consume_header)
+ return 4;
+ return 2;
+}
+
+// __codecvt_utf16<char16_t, true>
+
+__codecvt_utf16<char16_t, true>::result
+__codecvt_utf16<char16_t, true>::do_out(state_type&,
+ const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+ extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+ const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
+ const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
+ const uint16_t* _frm_nxt = _frm;
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
+ result r = ucs2_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf16<char16_t, true>::result
+__codecvt_utf16<char16_t, true>::do_in(state_type&,
+ const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+ intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
+ uint16_t* _to = reinterpret_cast<uint16_t*>(to);
+ uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
+ uint16_t* _to_nxt = _to;
+ result r = utf16le_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf16<char16_t, true>::result
+__codecvt_utf16<char16_t, true>::do_unshift(state_type&,
+ extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+ to_nxt = to;
+ return noconv;
+}
+
+int
+__codecvt_utf16<char16_t, true>::do_encoding() const noexcept
+{
+ return 0;
+}
+
+bool
+__codecvt_utf16<char16_t, true>::do_always_noconv() const noexcept
+{
+ return false;
+}
+
+int
+__codecvt_utf16<char16_t, true>::do_length(state_type&,
+ const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ return utf16le_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+}
+
+int
+__codecvt_utf16<char16_t, true>::do_max_length() const noexcept
+{
+ if (_Mode_ & consume_header)
+ return 4;
+ return 2;
+}
+
+// __codecvt_utf16<char32_t, false>
+
+__codecvt_utf16<char32_t, false>::result
+__codecvt_utf16<char32_t, false>::do_out(state_type&,
+ const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+ extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+ const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
+ const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
+ const uint32_t* _frm_nxt = _frm;
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
+ result r = ucs4_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf16<char32_t, false>::result
+__codecvt_utf16<char32_t, false>::do_in(state_type&,
+ const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+ intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
+ uint32_t* _to = reinterpret_cast<uint32_t*>(to);
+ uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
+ uint32_t* _to_nxt = _to;
+ result r = utf16be_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf16<char32_t, false>::result
+__codecvt_utf16<char32_t, false>::do_unshift(state_type&,
+ extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+ to_nxt = to;
+ return noconv;
+}
+
+int
+__codecvt_utf16<char32_t, false>::do_encoding() const noexcept
+{
+ return 0;
+}
+
+bool
+__codecvt_utf16<char32_t, false>::do_always_noconv() const noexcept
+{
+ return false;
+}
+
+int
+__codecvt_utf16<char32_t, false>::do_length(state_type&,
+ const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ return utf16be_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+}
+
+int
+__codecvt_utf16<char32_t, false>::do_max_length() const noexcept
+{
+ if (_Mode_ & consume_header)
+ return 6;
+ return 4;
+}
+
+// __codecvt_utf16<char32_t, true>
+
+__codecvt_utf16<char32_t, true>::result
+__codecvt_utf16<char32_t, true>::do_out(state_type&,
+ const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+ extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+#if defined(_LIBCPP_SHORT_WCHAR)
+ const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
+ const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
+ const uint16_t* _frm_nxt = _frm;
+#else
+ const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
+ const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
+ const uint32_t* _frm_nxt = _frm;
+#endif
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
+#if defined(_LIBCPP_SHORT_WCHAR)
+ result r = ucs2_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+#else
+ result r = ucs4_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+#endif
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf16<char32_t, true>::result
+__codecvt_utf16<char32_t, true>::do_in(state_type&,
+ const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+ intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
+ uint32_t* _to = reinterpret_cast<uint32_t*>(to);
+ uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
+ uint32_t* _to_nxt = _to;
+ result r = utf16le_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf16<char32_t, true>::result
+__codecvt_utf16<char32_t, true>::do_unshift(state_type&,
+ extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+ to_nxt = to;
+ return noconv;
+}
+
+int
+__codecvt_utf16<char32_t, true>::do_encoding() const noexcept
+{
+ return 0;
+}
+
+bool
+__codecvt_utf16<char32_t, true>::do_always_noconv() const noexcept
+{
+ return false;
+}
+
+int
+__codecvt_utf16<char32_t, true>::do_length(state_type&,
+ const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ return utf16le_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+}
+
+int
+__codecvt_utf16<char32_t, true>::do_max_length() const noexcept
+{
+ if (_Mode_ & consume_header)
+ return 6;
+ return 4;
+}
+
+// __codecvt_utf8_utf16<wchar_t>
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+__codecvt_utf8_utf16<wchar_t>::result
+__codecvt_utf8_utf16<wchar_t>::do_out(state_type&,
+ const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+ extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+#ifdef _WIN32
+ const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
+ const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
+ const uint16_t* _frm_nxt = _frm;
+#else
+ const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
+ const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
+ const uint32_t* _frm_nxt = _frm;
+#endif
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
+ result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf8_utf16<wchar_t>::result
+__codecvt_utf8_utf16<wchar_t>::do_in(state_type&,
+ const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+ intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
+#ifdef _WIN32
+ uint16_t* _to = reinterpret_cast<uint16_t*>(to);
+ uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
+ uint16_t* _to_nxt = _to;
+#else
+ uint32_t* _to = reinterpret_cast<uint32_t*>(to);
+ uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
+ uint32_t* _to_nxt = _to;
+#endif
+ result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf8_utf16<wchar_t>::result
+__codecvt_utf8_utf16<wchar_t>::do_unshift(state_type&,
+ extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+ to_nxt = to;
+ return noconv;
+}
+
+int
+__codecvt_utf8_utf16<wchar_t>::do_encoding() const noexcept
+{
+ return 0;
+}
+
+bool
+__codecvt_utf8_utf16<wchar_t>::do_always_noconv() const noexcept
+{
+ return false;
+}
+
+int
+__codecvt_utf8_utf16<wchar_t>::do_length(state_type&,
+ const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ return utf8_to_utf16_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+}
+
+int
+__codecvt_utf8_utf16<wchar_t>::do_max_length() const noexcept
+{
+ if (_Mode_ & consume_header)
+ return 7;
+ return 4;
+}
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+// __codecvt_utf8_utf16<char16_t>
+
+__codecvt_utf8_utf16<char16_t>::result
+__codecvt_utf8_utf16<char16_t>::do_out(state_type&,
+ const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+ extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+ const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
+ const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
+ const uint16_t* _frm_nxt = _frm;
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
+ result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf8_utf16<char16_t>::result
+__codecvt_utf8_utf16<char16_t>::do_in(state_type&,
+ const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+ intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
+ uint16_t* _to = reinterpret_cast<uint16_t*>(to);
+ uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
+ uint16_t* _to_nxt = _to;
+ result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf8_utf16<char16_t>::result
+__codecvt_utf8_utf16<char16_t>::do_unshift(state_type&,
+ extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+ to_nxt = to;
+ return noconv;
+}
+
+int
+__codecvt_utf8_utf16<char16_t>::do_encoding() const noexcept
+{
+ return 0;
+}
+
+bool
+__codecvt_utf8_utf16<char16_t>::do_always_noconv() const noexcept
+{
+ return false;
+}
+
+int
+__codecvt_utf8_utf16<char16_t>::do_length(state_type&,
+ const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ return utf8_to_utf16_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+}
+
+int
+__codecvt_utf8_utf16<char16_t>::do_max_length() const noexcept
+{
+ if (_Mode_ & consume_header)
+ return 7;
+ return 4;
+}
+
+// __codecvt_utf8_utf16<char32_t>
+
+__codecvt_utf8_utf16<char32_t>::result
+__codecvt_utf8_utf16<char32_t>::do_out(state_type&,
+ const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+ extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+ const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
+ const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
+ const uint32_t* _frm_nxt = _frm;
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
+ result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf8_utf16<char32_t>::result
+__codecvt_utf8_utf16<char32_t>::do_in(state_type&,
+ const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+ intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
+#if defined(_LIBCPP_SHORT_WCHAR)
+ uint16_t* _to = reinterpret_cast<uint16_t*>(to);
+ uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
+ uint16_t* _to_nxt = _to;
+#else
+ uint32_t* _to = reinterpret_cast<uint32_t*>(to);
+ uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
+ uint32_t* _to_nxt = _to;
+#endif
+ result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf8_utf16<char32_t>::result
+__codecvt_utf8_utf16<char32_t>::do_unshift(state_type&,
+ extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+ to_nxt = to;
+ return noconv;
+}
+
+int
+__codecvt_utf8_utf16<char32_t>::do_encoding() const noexcept
+{
+ return 0;
+}
+
+bool
+__codecvt_utf8_utf16<char32_t>::do_always_noconv() const noexcept
+{
+ return false;
+}
+
+int
+__codecvt_utf8_utf16<char32_t>::do_length(state_type&,
+ const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ return utf8_to_utf16_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+}
+
+int
+__codecvt_utf8_utf16<char32_t>::do_max_length() const noexcept
+{
+ if (_Mode_ & consume_header)
+ return 7;
+ return 4;
+}
+
+// __narrow_to_utf8<16>
+
+__narrow_to_utf8<16>::~__narrow_to_utf8()
+{
+}
+
+// __narrow_to_utf8<32>
+
+__narrow_to_utf8<32>::~__narrow_to_utf8()
+{
+}
+
+// __widen_from_utf8<16>
+
+__widen_from_utf8<16>::~__widen_from_utf8()
+{
+}
+
+// __widen_from_utf8<32>
+
+__widen_from_utf8<32>::~__widen_from_utf8()
+{
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+static bool checked_string_to_wchar_convert(wchar_t& dest,
+ const char* ptr,
+ locale_t loc) {
+ if (*ptr == '\0')
+ return false;
+ mbstate_t mb = {};
+ wchar_t out;
+ size_t ret = __libcpp_mbrtowc_l(&out, ptr, strlen(ptr), &mb, loc);
+ if (ret == static_cast<size_t>(-1) || ret == static_cast<size_t>(-2)) {
+ return false;
+ }
+ dest = out;
+ return true;
+}
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+#ifdef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+static bool is_narrow_non_breaking_space(const char* ptr) {
+ // https://www.fileformat.info/info/unicode/char/202f/index.htm
+ return ptr[0] == '\xe2' && ptr[1] == '\x80' && ptr[2] == '\xaf';
+}
+
+static bool is_non_breaking_space(const char* ptr) {
+ // https://www.fileformat.info/info/unicode/char/0a/index.htm
+ return ptr[0] == '\xc2' && ptr[1] == '\xa0';
+}
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+static bool checked_string_to_char_convert(char& dest,
+ const char* ptr,
+ locale_t __loc) {
+ if (*ptr == '\0')
+ return false;
+ if (!ptr[1]) {
+ dest = *ptr;
+ return true;
+ }
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ // First convert the MBS into a wide char then attempt to narrow it using
+ // wctob_l.
+ wchar_t wout;
+ if (!checked_string_to_wchar_convert(wout, ptr, __loc))
+ return false;
+ int res;
+ if ((res = __libcpp_wctob_l(wout, __loc)) != char_traits<char>::eof()) {
+ dest = res;
+ return true;
+ }
+ // FIXME: Work around specific multibyte sequences that we can reasonably
+ // translate into a different single byte.
+ switch (wout) {
+ case L'\u202F': // narrow non-breaking space
+ case L'\u00A0': // non-breaking space
+ dest = ' ';
+ return true;
+ default:
+ return false;
+ }
+#else // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ // FIXME: Work around specific multibyte sequences that we can reasonably
+ // translate into a different single byte.
+ if (is_narrow_non_breaking_space(ptr) || is_non_breaking_space(ptr)) {
+ dest = ' ';
+ return true;
+ }
+
+ return false;
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ __libcpp_unreachable();
+}
+
+
+// numpunct<char> && numpunct<wchar_t>
+
+locale::id numpunct< char >::id;
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+locale::id numpunct<wchar_t>::id;
+#endif
+
+numpunct<char>::numpunct(size_t refs)
+ : locale::facet(refs),
+ __decimal_point_('.'),
+ __thousands_sep_(',')
+{
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+numpunct<wchar_t>::numpunct(size_t refs)
+ : locale::facet(refs),
+ __decimal_point_(L'.'),
+ __thousands_sep_(L',')
+{
+}
+#endif
+
+numpunct<char>::~numpunct()
+{
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+numpunct<wchar_t>::~numpunct()
+{
+}
+#endif
+
+ char numpunct< char >::do_decimal_point() const {return __decimal_point_;}
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+wchar_t numpunct<wchar_t>::do_decimal_point() const {return __decimal_point_;}
+#endif
+
+ char numpunct< char >::do_thousands_sep() const {return __thousands_sep_;}
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+wchar_t numpunct<wchar_t>::do_thousands_sep() const {return __thousands_sep_;}
+#endif
+
+string numpunct< char >::do_grouping() const {return __grouping_;}
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+string numpunct<wchar_t>::do_grouping() const {return __grouping_;}
+#endif
+
+ string numpunct< char >::do_truename() const {return "true";}
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+wstring numpunct<wchar_t>::do_truename() const {return L"true";}
+#endif
+
+ string numpunct< char >::do_falsename() const {return "false";}
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+wstring numpunct<wchar_t>::do_falsename() const {return L"false";}
+#endif
+
+// numpunct_byname<char>
+
+numpunct_byname<char>::numpunct_byname(const char* nm, size_t refs)
+ : numpunct<char>(refs)
+{
+ __init(nm);
+}
+
+numpunct_byname<char>::numpunct_byname(const string& nm, size_t refs)
+ : numpunct<char>(refs)
+{
+ __init(nm.c_str());
+}
+
+numpunct_byname<char>::~numpunct_byname()
+{
+}
+
+void
+numpunct_byname<char>::__init(const char* nm)
+{
+ typedef numpunct<char> base;
+ if (strcmp(nm, "C") != 0)
+ {
+ __libcpp_unique_locale loc(nm);
+ if (!loc)
+ __throw_runtime_error("numpunct_byname<char>::numpunct_byname"
+ " failed to construct for " + string(nm));
+
+ lconv* lc = __libcpp_localeconv_l(loc.get());
+ if (!checked_string_to_char_convert(__decimal_point_, lc->decimal_point,
+ loc.get()))
+ __decimal_point_ = base::do_decimal_point();
+ if (!checked_string_to_char_convert(__thousands_sep_, lc->thousands_sep,
+ loc.get()))
+ __thousands_sep_ = base::do_thousands_sep();
+ __grouping_ = lc->grouping;
+ // localization for truename and falsename is not available
+ }
+}
+
+// numpunct_byname<wchar_t>
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+numpunct_byname<wchar_t>::numpunct_byname(const char* nm, size_t refs)
+ : numpunct<wchar_t>(refs)
+{
+ __init(nm);
+}
+
+numpunct_byname<wchar_t>::numpunct_byname(const string& nm, size_t refs)
+ : numpunct<wchar_t>(refs)
+{
+ __init(nm.c_str());
+}
+
+numpunct_byname<wchar_t>::~numpunct_byname()
+{
+}
+
+void
+numpunct_byname<wchar_t>::__init(const char* nm)
+{
+ if (strcmp(nm, "C") != 0)
+ {
+ __libcpp_unique_locale loc(nm);
+ if (!loc)
+ __throw_runtime_error("numpunct_byname<wchar_t>::numpunct_byname"
+ " failed to construct for " + string(nm));
+
+ lconv* lc = __libcpp_localeconv_l(loc.get());
+ checked_string_to_wchar_convert(__decimal_point_, lc->decimal_point,
+ loc.get());
+ checked_string_to_wchar_convert(__thousands_sep_, lc->thousands_sep,
+ loc.get());
+ __grouping_ = lc->grouping;
+ // localization for truename and falsename is not available
+ }
+}
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+// num_get helpers
+
+int
+__num_get_base::__get_base(ios_base& iob)
+{
+ ios_base::fmtflags __basefield = iob.flags() & ios_base::basefield;
+ if (__basefield == ios_base::oct)
+ return 8;
+ else if (__basefield == ios_base::hex)
+ return 16;
+ else if (__basefield == 0)
+ return 0;
+ return 10;
+}
+
+const char __num_get_base::__src[33] = "0123456789abcdefABCDEFxX+-pPiInN";
+
+void
+__check_grouping(const string& __grouping, unsigned* __g, unsigned* __g_end,
+ ios_base::iostate& __err)
+{
+// if the grouping pattern is empty _or_ there are no grouping bits, then do nothing
+// we always have at least a single entry in [__g, __g_end); the end of the input sequence
+ if (__grouping.size() != 0 && __g_end - __g > 1)
+ {
+ reverse(__g, __g_end);
+ const char* __ig = __grouping.data();
+ const char* __eg = __ig + __grouping.size();
+ for (unsigned* __r = __g; __r < __g_end-1; ++__r)
+ {
+ if (0 < *__ig && *__ig < numeric_limits<char>::max())
+ {
+ if (static_cast<unsigned>(*__ig) != *__r)
+ {
+ __err = ios_base::failbit;
+ return;
+ }
+ }
+ if (__eg - __ig > 1)
+ ++__ig;
+ }
+ if (0 < *__ig && *__ig < numeric_limits<char>::max())
+ {
+ if (static_cast<unsigned>(*__ig) < __g_end[-1] || __g_end[-1] == 0)
+ __err = ios_base::failbit;
+ }
+ }
+}
+
+void
+__num_put_base::__format_int(char* __fmtp, const char* __len, bool __signd,
+ ios_base::fmtflags __flags)
+{
+ if ((__flags & ios_base::showpos) &&
+ (__flags & ios_base::basefield) != ios_base::oct &&
+ (__flags & ios_base::basefield) != ios_base::hex &&
+ __signd)
+ *__fmtp++ = '+';
+ if (__flags & ios_base::showbase)
+ *__fmtp++ = '#';
+ while(*__len)
+ *__fmtp++ = *__len++;
+ if ((__flags & ios_base::basefield) == ios_base::oct)
+ *__fmtp = 'o';
+ else if ((__flags & ios_base::basefield) == ios_base::hex)
+ {
+ if (__flags & ios_base::uppercase)
+ *__fmtp = 'X';
+ else
+ *__fmtp = 'x';
+ }
+ else if (__signd)
+ *__fmtp = 'd';
+ else
+ *__fmtp = 'u';
+}
+
+bool
+__num_put_base::__format_float(char* __fmtp, const char* __len,
+ ios_base::fmtflags __flags)
+{
+ bool specify_precision = true;
+ if (__flags & ios_base::showpos)
+ *__fmtp++ = '+';
+ if (__flags & ios_base::showpoint)
+ *__fmtp++ = '#';
+ ios_base::fmtflags floatfield = __flags & ios_base::floatfield;
+ bool uppercase = (__flags & ios_base::uppercase) != 0;
+ if (floatfield == (ios_base::fixed | ios_base::scientific))
+ specify_precision = false;
+ else
+ {
+ *__fmtp++ = '.';
+ *__fmtp++ = '*';
+ }
+ while(*__len)
+ *__fmtp++ = *__len++;
+ if (floatfield == ios_base::fixed)
+ {
+ if (uppercase)
+ *__fmtp = 'F';
+ else
+ *__fmtp = 'f';
+ }
+ else if (floatfield == ios_base::scientific)
+ {
+ if (uppercase)
+ *__fmtp = 'E';
+ else
+ *__fmtp = 'e';
+ }
+ else if (floatfield == (ios_base::fixed | ios_base::scientific))
+ {
+ if (uppercase)
+ *__fmtp = 'A';
+ else
+ *__fmtp = 'a';
+ }
+ else
+ {
+ if (uppercase)
+ *__fmtp = 'G';
+ else
+ *__fmtp = 'g';
+ }
+ return specify_precision;
+}
+
+char*
+__num_put_base::__identify_padding(char* __nb, char* __ne,
+ const ios_base& __iob)
+{
+ switch (__iob.flags() & ios_base::adjustfield)
+ {
+ case ios_base::internal:
+ if (__nb[0] == '-' || __nb[0] == '+')
+ return __nb+1;
+ if (__ne - __nb >= 2 && __nb[0] == '0'
+ && (__nb[1] == 'x' || __nb[1] == 'X'))
+ return __nb+2;
+ break;
+ case ios_base::left:
+ return __ne;
+ case ios_base::right:
+ default:
+ break;
+ }
+ return __nb;
+}
+
+// time_get
+
+static
+string*
+init_weeks()
+{
+ static string weeks[14];
+ weeks[0] = "Sunday";
+ weeks[1] = "Monday";
+ weeks[2] = "Tuesday";
+ weeks[3] = "Wednesday";
+ weeks[4] = "Thursday";
+ weeks[5] = "Friday";
+ weeks[6] = "Saturday";
+ weeks[7] = "Sun";
+ weeks[8] = "Mon";
+ weeks[9] = "Tue";
+ weeks[10] = "Wed";
+ weeks[11] = "Thu";
+ weeks[12] = "Fri";
+ weeks[13] = "Sat";
+ return weeks;
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+static
+wstring*
+init_wweeks()
+{
+ static wstring weeks[14];
+ weeks[0] = L"Sunday";
+ weeks[1] = L"Monday";
+ weeks[2] = L"Tuesday";
+ weeks[3] = L"Wednesday";
+ weeks[4] = L"Thursday";
+ weeks[5] = L"Friday";
+ weeks[6] = L"Saturday";
+ weeks[7] = L"Sun";
+ weeks[8] = L"Mon";
+ weeks[9] = L"Tue";
+ weeks[10] = L"Wed";
+ weeks[11] = L"Thu";
+ weeks[12] = L"Fri";
+ weeks[13] = L"Sat";
+ return weeks;
+}
+#endif
+
+template <>
+const string*
+__time_get_c_storage<char>::__weeks() const
+{
+ static const string* weeks = init_weeks();
+ return weeks;
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+const wstring*
+__time_get_c_storage<wchar_t>::__weeks() const
+{
+ static const wstring* weeks = init_wweeks();
+ return weeks;
+}
+#endif
+
+static
+string*
+init_months()
+{
+ static string months[24];
+ months[0] = "January";
+ months[1] = "February";
+ months[2] = "March";
+ months[3] = "April";
+ months[4] = "May";
+ months[5] = "June";
+ months[6] = "July";
+ months[7] = "August";
+ months[8] = "September";
+ months[9] = "October";
+ months[10] = "November";
+ months[11] = "December";
+ months[12] = "Jan";
+ months[13] = "Feb";
+ months[14] = "Mar";
+ months[15] = "Apr";
+ months[16] = "May";
+ months[17] = "Jun";
+ months[18] = "Jul";
+ months[19] = "Aug";
+ months[20] = "Sep";
+ months[21] = "Oct";
+ months[22] = "Nov";
+ months[23] = "Dec";
+ return months;
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+static
+wstring*
+init_wmonths()
+{
+ static wstring months[24];
+ months[0] = L"January";
+ months[1] = L"February";
+ months[2] = L"March";
+ months[3] = L"April";
+ months[4] = L"May";
+ months[5] = L"June";
+ months[6] = L"July";
+ months[7] = L"August";
+ months[8] = L"September";
+ months[9] = L"October";
+ months[10] = L"November";
+ months[11] = L"December";
+ months[12] = L"Jan";
+ months[13] = L"Feb";
+ months[14] = L"Mar";
+ months[15] = L"Apr";
+ months[16] = L"May";
+ months[17] = L"Jun";
+ months[18] = L"Jul";
+ months[19] = L"Aug";
+ months[20] = L"Sep";
+ months[21] = L"Oct";
+ months[22] = L"Nov";
+ months[23] = L"Dec";
+ return months;
+}
+#endif
+
+template <>
+const string*
+__time_get_c_storage<char>::__months() const
+{
+ static const string* months = init_months();
+ return months;
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+const wstring*
+__time_get_c_storage<wchar_t>::__months() const
+{
+ static const wstring* months = init_wmonths();
+ return months;
+}
+#endif
+
+static
+string*
+init_am_pm()
+{
+ static string am_pm[2];
+ am_pm[0] = "AM";
+ am_pm[1] = "PM";
+ return am_pm;
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+static
+wstring*
+init_wam_pm()
+{
+ static wstring am_pm[2];
+ am_pm[0] = L"AM";
+ am_pm[1] = L"PM";
+ return am_pm;
+}
+#endif
+
+template <>
+const string*
+__time_get_c_storage<char>::__am_pm() const
+{
+ static const string* am_pm = init_am_pm();
+ return am_pm;
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+const wstring*
+__time_get_c_storage<wchar_t>::__am_pm() const
+{
+ static const wstring* am_pm = init_wam_pm();
+ return am_pm;
+}
+#endif
+
+template <>
+const string&
+__time_get_c_storage<char>::__x() const
+{
+ static string s("%m/%d/%y");
+ return s;
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+const wstring&
+__time_get_c_storage<wchar_t>::__x() const
+{
+ static wstring s(L"%m/%d/%y");
+ return s;
+}
+#endif
+
+template <>
+const string&
+__time_get_c_storage<char>::__X() const
+{
+ static string s("%H:%M:%S");
+ return s;
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+const wstring&
+__time_get_c_storage<wchar_t>::__X() const
+{
+ static wstring s(L"%H:%M:%S");
+ return s;
+}
+#endif
+
+template <>
+const string&
+__time_get_c_storage<char>::__c() const
+{
+ static string s("%a %b %d %H:%M:%S %Y");
+ return s;
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+const wstring&
+__time_get_c_storage<wchar_t>::__c() const
+{
+ static wstring s(L"%a %b %d %H:%M:%S %Y");
+ return s;
+}
+#endif
+
+template <>
+const string&
+__time_get_c_storage<char>::__r() const
+{
+ static string s("%I:%M:%S %p");
+ return s;
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+const wstring&
+__time_get_c_storage<wchar_t>::__r() const
+{
+ static wstring s(L"%I:%M:%S %p");
+ return s;
+}
+#endif
+
+// time_get_byname
+
+__time_get::__time_get(const char* nm)
+ : __loc_(newlocale(LC_ALL_MASK, nm, 0))
+{
+ if (__loc_ == 0)
+ __throw_runtime_error("time_get_byname"
+ " failed to construct for " + string(nm));
+}
+
+__time_get::__time_get(const string& nm)
+ : __loc_(newlocale(LC_ALL_MASK, nm.c_str(), 0))
+{
+ if (__loc_ == 0)
+ __throw_runtime_error("time_get_byname"
+ " failed to construct for " + nm);
+}
+
+__time_get::~__time_get()
+{
+ freelocale(__loc_);
+}
+
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")
+
+template <>
+string
+__time_get_storage<char>::__analyze(char fmt, const ctype<char>& ct)
+{
+ tm t = {0};
+ t.tm_sec = 59;
+ t.tm_min = 55;
+ t.tm_hour = 23;
+ t.tm_mday = 31;
+ t.tm_mon = 11;
+ t.tm_year = 161;
+ t.tm_wday = 6;
+ t.tm_yday = 364;
+ t.tm_isdst = -1;
+ char buf[100];
+ char f[3] = {0};
+ f[0] = '%';
+ f[1] = fmt;
+ size_t n = strftime_l(buf, countof(buf), f, &t, __loc_);
+ char* bb = buf;
+ char* be = buf + n;
+ string result;
+ while (bb != be)
+ {
+ if (ct.is(ctype_base::space, *bb))
+ {
+ result.push_back(' ');
+ for (++bb; bb != be && ct.is(ctype_base::space, *bb); ++bb)
+ ;
+ continue;
+ }
+ char* w = bb;
+ ios_base::iostate err = ios_base::goodbit;
+ ptrdiff_t i = __scan_keyword(w, be, this->__weeks_, this->__weeks_+14,
+ ct, err, false)
+ - this->__weeks_;
+ if (i < 14)
+ {
+ result.push_back('%');
+ if (i < 7)
+ result.push_back('A');
+ else
+ result.push_back('a');
+ bb = w;
+ continue;
+ }
+ w = bb;
+ i = __scan_keyword(w, be, this->__months_, this->__months_+24,
+ ct, err, false)
+ - this->__months_;
+ if (i < 24)
+ {
+ result.push_back('%');
+ if (i < 12)
+ result.push_back('B');
+ else
+ result.push_back('b');
+ if (fmt == 'x' && ct.is(ctype_base::digit, this->__months_[i][0]))
+ result.back() = 'm';
+ bb = w;
+ continue;
+ }
+ if (this->__am_pm_[0].size() + this->__am_pm_[1].size() > 0)
+ {
+ w = bb;
+ i = __scan_keyword(w, be, this->__am_pm_, this->__am_pm_+2,
+ ct, err, false) - this->__am_pm_;
+ if (i < 2)
+ {
+ result.push_back('%');
+ result.push_back('p');
+ bb = w;
+ continue;
+ }
+ }
+ w = bb;
+ if (ct.is(ctype_base::digit, *bb))
+ {
+ switch(__get_up_to_n_digits(bb, be, err, ct, 4))
+ {
+ case 6:
+ result.push_back('%');
+ result.push_back('w');
+ break;
+ case 7:
+ result.push_back('%');
+ result.push_back('u');
+ break;
+ case 11:
+ result.push_back('%');
+ result.push_back('I');
+ break;
+ case 12:
+ result.push_back('%');
+ result.push_back('m');
+ break;
+ case 23:
+ result.push_back('%');
+ result.push_back('H');
+ break;
+ case 31:
+ result.push_back('%');
+ result.push_back('d');
+ break;
+ case 55:
+ result.push_back('%');
+ result.push_back('M');
+ break;
+ case 59:
+ result.push_back('%');
+ result.push_back('S');
+ break;
+ case 61:
+ result.push_back('%');
+ result.push_back('y');
+ break;
+ case 364:
+ result.push_back('%');
+ result.push_back('j');
+ break;
+ case 2061:
+ result.push_back('%');
+ result.push_back('Y');
+ break;
+ default:
+ for (; w != bb; ++w)
+ result.push_back(*w);
+ break;
+ }
+ continue;
+ }
+ if (*bb == '%')
+ {
+ result.push_back('%');
+ result.push_back('%');
+ ++bb;
+ continue;
+ }
+ result.push_back(*bb);
+ ++bb;
+ }
+ return result;
+}
+
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-braces")
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+wstring
+__time_get_storage<wchar_t>::__analyze(char fmt, const ctype<wchar_t>& ct)
+{
+ tm t = {0};
+ t.tm_sec = 59;
+ t.tm_min = 55;
+ t.tm_hour = 23;
+ t.tm_mday = 31;
+ t.tm_mon = 11;
+ t.tm_year = 161;
+ t.tm_wday = 6;
+ t.tm_yday = 364;
+ t.tm_isdst = -1;
+ char buf[100];
+ char f[3] = {0};
+ f[0] = '%';
+ f[1] = fmt;
+ strftime_l(buf, countof(buf), f, &t, __loc_);
+ wchar_t wbuf[100];
+ wchar_t* wbb = wbuf;
+ mbstate_t mb = {0};
+ const char* bb = buf;
+ size_t j = __libcpp_mbsrtowcs_l( wbb, &bb, countof(wbuf), &mb, __loc_);
+ if (j == size_t(-1))
+ __throw_runtime_error("locale not supported");
+ wchar_t* wbe = wbb + j;
+ wstring result;
+ while (wbb != wbe)
+ {
+ if (ct.is(ctype_base::space, *wbb))
+ {
+ result.push_back(L' ');
+ for (++wbb; wbb != wbe && ct.is(ctype_base::space, *wbb); ++wbb)
+ ;
+ continue;
+ }
+ wchar_t* w = wbb;
+ ios_base::iostate err = ios_base::goodbit;
+ ptrdiff_t i = __scan_keyword(w, wbe, this->__weeks_, this->__weeks_+14,
+ ct, err, false)
+ - this->__weeks_;
+ if (i < 14)
+ {
+ result.push_back(L'%');
+ if (i < 7)
+ result.push_back(L'A');
+ else
+ result.push_back(L'a');
+ wbb = w;
+ continue;
+ }
+ w = wbb;
+ i = __scan_keyword(w, wbe, this->__months_, this->__months_+24,
+ ct, err, false)
+ - this->__months_;
+ if (i < 24)
+ {
+ result.push_back(L'%');
+ if (i < 12)
+ result.push_back(L'B');
+ else
+ result.push_back(L'b');
+ if (fmt == 'x' && ct.is(ctype_base::digit, this->__months_[i][0]))
+ result.back() = L'm';
+ wbb = w;
+ continue;
+ }
+ if (this->__am_pm_[0].size() + this->__am_pm_[1].size() > 0)
+ {
+ w = wbb;
+ i = __scan_keyword(w, wbe, this->__am_pm_, this->__am_pm_+2,
+ ct, err, false) - this->__am_pm_;
+ if (i < 2)
+ {
+ result.push_back(L'%');
+ result.push_back(L'p');
+ wbb = w;
+ continue;
+ }
+ }
+ w = wbb;
+ if (ct.is(ctype_base::digit, *wbb))
+ {
+ switch(__get_up_to_n_digits(wbb, wbe, err, ct, 4))
+ {
+ case 6:
+ result.push_back(L'%');
+ result.push_back(L'w');
+ break;
+ case 7:
+ result.push_back(L'%');
+ result.push_back(L'u');
+ break;
+ case 11:
+ result.push_back(L'%');
+ result.push_back(L'I');
+ break;
+ case 12:
+ result.push_back(L'%');
+ result.push_back(L'm');
+ break;
+ case 23:
+ result.push_back(L'%');
+ result.push_back(L'H');
+ break;
+ case 31:
+ result.push_back(L'%');
+ result.push_back(L'd');
+ break;
+ case 55:
+ result.push_back(L'%');
+ result.push_back(L'M');
+ break;
+ case 59:
+ result.push_back(L'%');
+ result.push_back(L'S');
+ break;
+ case 61:
+ result.push_back(L'%');
+ result.push_back(L'y');
+ break;
+ case 364:
+ result.push_back(L'%');
+ result.push_back(L'j');
+ break;
+ case 2061:
+ result.push_back(L'%');
+ result.push_back(L'Y');
+ break;
+ default:
+ for (; w != wbb; ++w)
+ result.push_back(*w);
+ break;
+ }
+ continue;
+ }
+ if (ct.narrow(*wbb, 0) == '%')
+ {
+ result.push_back(L'%');
+ result.push_back(L'%');
+ ++wbb;
+ continue;
+ }
+ result.push_back(*wbb);
+ ++wbb;
+ }
+ return result;
+}
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+template <>
+void
+__time_get_storage<char>::init(const ctype<char>& ct)
+{
+ tm t = {0};
+ char buf[100];
+ // __weeks_
+ for (int i = 0; i < 7; ++i)
+ {
+ t.tm_wday = i;
+ strftime_l(buf, countof(buf), "%A", &t, __loc_);
+ __weeks_[i] = buf;
+ strftime_l(buf, countof(buf), "%a", &t, __loc_);
+ __weeks_[i+7] = buf;
+ }
+ // __months_
+ for (int i = 0; i < 12; ++i)
+ {
+ t.tm_mon = i;
+ strftime_l(buf, countof(buf), "%B", &t, __loc_);
+ __months_[i] = buf;
+ strftime_l(buf, countof(buf), "%b", &t, __loc_);
+ __months_[i+12] = buf;
+ }
+ // __am_pm_
+ t.tm_hour = 1;
+ strftime_l(buf, countof(buf), "%p", &t, __loc_);
+ __am_pm_[0] = buf;
+ t.tm_hour = 13;
+ strftime_l(buf, countof(buf), "%p", &t, __loc_);
+ __am_pm_[1] = buf;
+ __c_ = __analyze('c', ct);
+ __r_ = __analyze('r', ct);
+ __x_ = __analyze('x', ct);
+ __X_ = __analyze('X', ct);
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+void
+__time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)
+{
+ tm t = {0};
+ char buf[100];
+ wchar_t wbuf[100];
+ wchar_t* wbe;
+ mbstate_t mb = {0};
+ // __weeks_
+ for (int i = 0; i < 7; ++i)
+ {
+ t.tm_wday = i;
+ strftime_l(buf, countof(buf), "%A", &t, __loc_);
+ mb = mbstate_t();
+ const char* bb = buf;
+ size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
+ if (j == size_t(-1) || j == 0)
+ __throw_runtime_error("locale not supported");
+ wbe = wbuf + j;
+ __weeks_[i].assign(wbuf, wbe);
+ strftime_l(buf, countof(buf), "%a", &t, __loc_);
+ mb = mbstate_t();
+ bb = buf;
+ j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
+ if (j == size_t(-1) || j == 0)
+ __throw_runtime_error("locale not supported");
+ wbe = wbuf + j;
+ __weeks_[i+7].assign(wbuf, wbe);
+ }
+ // __months_
+ for (int i = 0; i < 12; ++i)
+ {
+ t.tm_mon = i;
+ strftime_l(buf, countof(buf), "%B", &t, __loc_);
+ mb = mbstate_t();
+ const char* bb = buf;
+ size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
+ if (j == size_t(-1) || j == 0)
+ __throw_runtime_error("locale not supported");
+ wbe = wbuf + j;
+ __months_[i].assign(wbuf, wbe);
+ strftime_l(buf, countof(buf), "%b", &t, __loc_);
+ mb = mbstate_t();
+ bb = buf;
+ j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
+ if (j == size_t(-1) || j == 0)
+ __throw_runtime_error("locale not supported");
+ wbe = wbuf + j;
+ __months_[i+12].assign(wbuf, wbe);
+ }
+ // __am_pm_
+ t.tm_hour = 1;
+ strftime_l(buf, countof(buf), "%p", &t, __loc_);
+ mb = mbstate_t();
+ const char* bb = buf;
+ size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
+ if (j == size_t(-1))
+ __throw_runtime_error("locale not supported");
+ wbe = wbuf + j;
+ __am_pm_[0].assign(wbuf, wbe);
+ t.tm_hour = 13;
+ strftime_l(buf, countof(buf), "%p", &t, __loc_);
+ mb = mbstate_t();
+ bb = buf;
+ j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
+ if (j == size_t(-1))
+ __throw_runtime_error("locale not supported");
+ wbe = wbuf + j;
+ __am_pm_[1].assign(wbuf, wbe);
+ __c_ = __analyze('c', ct);
+ __r_ = __analyze('r', ct);
+ __x_ = __analyze('x', ct);
+ __X_ = __analyze('X', ct);
+}
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+template <class CharT>
+struct _LIBCPP_HIDDEN __time_get_temp
+ : public ctype_byname<CharT>
+{
+ explicit __time_get_temp(const char* nm)
+ : ctype_byname<CharT>(nm, 1) {}
+ explicit __time_get_temp(const string& nm)
+ : ctype_byname<CharT>(nm, 1) {}
+};
+
+template <>
+__time_get_storage<char>::__time_get_storage(const char* __nm)
+ : __time_get(__nm)
+{
+ const __time_get_temp<char> ct(__nm);
+ init(ct);
+}
+
+template <>
+__time_get_storage<char>::__time_get_storage(const string& __nm)
+ : __time_get(__nm)
+{
+ const __time_get_temp<char> ct(__nm);
+ init(ct);
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+__time_get_storage<wchar_t>::__time_get_storage(const char* __nm)
+ : __time_get(__nm)
+{
+ const __time_get_temp<wchar_t> ct(__nm);
+ init(ct);
+}
+
+template <>
+__time_get_storage<wchar_t>::__time_get_storage(const string& __nm)
+ : __time_get(__nm)
+{
+ const __time_get_temp<wchar_t> ct(__nm);
+ init(ct);
+}
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+template <>
+time_base::dateorder
+__time_get_storage<char>::__do_date_order() const
+{
+ unsigned i;
+ for (i = 0; i < __x_.size(); ++i)
+ if (__x_[i] == '%')
+ break;
+ ++i;
+ switch (__x_[i])
+ {
+ case 'y':
+ case 'Y':
+ for (++i; i < __x_.size(); ++i)
+ if (__x_[i] == '%')
+ break;
+ if (i == __x_.size())
+ break;
+ ++i;
+ switch (__x_[i])
+ {
+ case 'm':
+ for (++i; i < __x_.size(); ++i)
+ if (__x_[i] == '%')
+ break;
+ if (i == __x_.size())
+ break;
+ ++i;
+ if (__x_[i] == 'd')
+ return time_base::ymd;
+ break;
+ case 'd':
+ for (++i; i < __x_.size(); ++i)
+ if (__x_[i] == '%')
+ break;
+ if (i == __x_.size())
+ break;
+ ++i;
+ if (__x_[i] == 'm')
+ return time_base::ydm;
+ break;
+ }
+ break;
+ case 'm':
+ for (++i; i < __x_.size(); ++i)
+ if (__x_[i] == '%')
+ break;
+ if (i == __x_.size())
+ break;
+ ++i;
+ if (__x_[i] == 'd')
+ {
+ for (++i; i < __x_.size(); ++i)
+ if (__x_[i] == '%')
+ break;
+ if (i == __x_.size())
+ break;
+ ++i;
+ if (__x_[i] == 'y' || __x_[i] == 'Y')
+ return time_base::mdy;
+ break;
+ }
+ break;
+ case 'd':
+ for (++i; i < __x_.size(); ++i)
+ if (__x_[i] == '%')
+ break;
+ if (i == __x_.size())
+ break;
+ ++i;
+ if (__x_[i] == 'm')
+ {
+ for (++i; i < __x_.size(); ++i)
+ if (__x_[i] == '%')
+ break;
+ if (i == __x_.size())
+ break;
+ ++i;
+ if (__x_[i] == 'y' || __x_[i] == 'Y')
+ return time_base::dmy;
+ break;
+ }
+ break;
+ }
+ return time_base::no_order;
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+time_base::dateorder
+__time_get_storage<wchar_t>::__do_date_order() const
+{
+ unsigned i;
+ for (i = 0; i < __x_.size(); ++i)
+ if (__x_[i] == L'%')
+ break;
+ ++i;
+ switch (__x_[i])
+ {
+ case L'y':
+ case L'Y':
+ for (++i; i < __x_.size(); ++i)
+ if (__x_[i] == L'%')
+ break;
+ if (i == __x_.size())
+ break;
+ ++i;
+ switch (__x_[i])
+ {
+ case L'm':
+ for (++i; i < __x_.size(); ++i)
+ if (__x_[i] == L'%')
+ break;
+ if (i == __x_.size())
+ break;
+ ++i;
+ if (__x_[i] == L'd')
+ return time_base::ymd;
+ break;
+ case L'd':
+ for (++i; i < __x_.size(); ++i)
+ if (__x_[i] == L'%')
+ break;
+ if (i == __x_.size())
+ break;
+ ++i;
+ if (__x_[i] == L'm')
+ return time_base::ydm;
+ break;
+ }
+ break;
+ case L'm':
+ for (++i; i < __x_.size(); ++i)
+ if (__x_[i] == L'%')
+ break;
+ if (i == __x_.size())
+ break;
+ ++i;
+ if (__x_[i] == L'd')
+ {
+ for (++i; i < __x_.size(); ++i)
+ if (__x_[i] == L'%')
+ break;
+ if (i == __x_.size())
+ break;
+ ++i;
+ if (__x_[i] == L'y' || __x_[i] == L'Y')
+ return time_base::mdy;
+ break;
+ }
+ break;
+ case L'd':
+ for (++i; i < __x_.size(); ++i)
+ if (__x_[i] == L'%')
+ break;
+ if (i == __x_.size())
+ break;
+ ++i;
+ if (__x_[i] == L'm')
+ {
+ for (++i; i < __x_.size(); ++i)
+ if (__x_[i] == L'%')
+ break;
+ if (i == __x_.size())
+ break;
+ ++i;
+ if (__x_[i] == L'y' || __x_[i] == L'Y')
+ return time_base::dmy;
+ break;
+ }
+ break;
+ }
+ return time_base::no_order;
+}
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+// time_put
+
+__time_put::__time_put(const char* nm)
+ : __loc_(newlocale(LC_ALL_MASK, nm, 0))
+{
+ if (__loc_ == 0)
+ __throw_runtime_error("time_put_byname"
+ " failed to construct for " + string(nm));
+}
+
+__time_put::__time_put(const string& nm)
+ : __loc_(newlocale(LC_ALL_MASK, nm.c_str(), 0))
+{
+ if (__loc_ == 0)
+ __throw_runtime_error("time_put_byname"
+ " failed to construct for " + nm);
+}
+
+__time_put::~__time_put()
+{
+ if (__loc_ != _LIBCPP_GET_C_LOCALE)
+ freelocale(__loc_);
+}
+
+void
+__time_put::__do_put(char* __nb, char*& __ne, const tm* __tm,
+ char __fmt, char __mod) const
+{
+ char fmt[] = {'%', __fmt, __mod, 0};
+ if (__mod != 0)
+ swap(fmt[1], fmt[2]);
+ size_t n = strftime_l(__nb, countof(__nb, __ne), fmt, __tm, __loc_);
+ __ne = __nb + n;
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+void
+__time_put::__do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm,
+ char __fmt, char __mod) const
+{
+ char __nar[100];
+ char* __ne = __nar + 100;
+ __do_put(__nar, __ne, __tm, __fmt, __mod);
+ mbstate_t mb = {0};
+ const char* __nb = __nar;
+ size_t j = __libcpp_mbsrtowcs_l(__wb, &__nb, countof(__wb, __we), &mb, __loc_);
+ if (j == size_t(-1))
+ __throw_runtime_error("locale not supported");
+ __we = __wb + j;
+}
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+// moneypunct_byname
+
+template <class charT>
+static
+void
+__init_pat(money_base::pattern& pat, basic_string<charT>& __curr_symbol_,
+ bool intl, char cs_precedes, char sep_by_space, char sign_posn,
+ charT space_char)
+{
+ const char sign = static_cast<char>(money_base::sign);
+ const char space = static_cast<char>(money_base::space);
+ const char none = static_cast<char>(money_base::none);
+ const char symbol = static_cast<char>(money_base::symbol);
+ const char value = static_cast<char>(money_base::value);
+ const bool symbol_contains_sep = intl && __curr_symbol_.size() == 4;
+
+ // Comments on case branches reflect 'C11 7.11.2.1 The localeconv
+ // function'. "Space between sign and symbol or value" means that
+ // if the sign is adjacent to the symbol, there's a space between
+ // them, and otherwise there's a space between the sign and value.
+ //
+ // C11's localeconv specifies that the fourth character of an
+ // international curr_symbol is used to separate the sign and
+ // value when sep_by_space says to do so. C++ can't represent
+ // that, so we just use a space. When sep_by_space says to
+ // separate the symbol and value-or-sign with a space, we rearrange the
+ // curr_symbol to put its spacing character on the correct side of
+ // the symbol.
+ //
+ // We also need to avoid adding an extra space between the sign
+ // and value when the currency symbol is suppressed (by not
+ // setting showbase). We match glibc's strfmon by interpreting
+ // sep_by_space==1 as "omit the space when the currency symbol is
+ // absent".
+ //
+ // Users who want to get this right should use ICU instead.
+
+ switch (cs_precedes)
+ {
+ case 0: // value before curr_symbol
+ if (symbol_contains_sep) {
+ // Move the separator to before the symbol, to place it
+ // between the value and symbol.
+ rotate(__curr_symbol_.begin(), __curr_symbol_.begin() + 3,
+ __curr_symbol_.end());
+ }
+ switch (sign_posn)
+ {
+ case 0: // Parentheses surround the quantity and currency symbol.
+ pat.field[0] = sign;
+ pat.field[1] = value;
+ pat.field[2] = none; // Any space appears in the symbol.
+ pat.field[3] = symbol;
+ switch (sep_by_space)
+ {
+ case 0: // No space separates the currency symbol and value.
+ // This case may have changed between C99 and C11;
+ // assume the currency symbol matches the intention.
+ case 2: // Space between sign and currency or value.
+ // The "sign" is two parentheses, so no space here either.
+ return;
+ case 1: // Space between currency-and-sign or currency and value.
+ if (!symbol_contains_sep) {
+ // We insert the space into the symbol instead of
+ // setting pat.field[2]=space so that when
+ // showbase is not set, the space goes away too.
+ __curr_symbol_.insert((size_t)0, 1, space_char);
+ }
+ return;
+ default:
+ break;
+ }
+ break;
+ case 1: // The sign string precedes the quantity and currency symbol.
+ pat.field[0] = sign;
+ pat.field[3] = symbol;
+ switch (sep_by_space)
+ {
+ case 0: // No space separates the currency symbol and value.
+ pat.field[1] = value;
+ pat.field[2] = none;
+ return;
+ case 1: // Space between currency-and-sign or currency and value.
+ pat.field[1] = value;
+ pat.field[2] = none;
+ if (!symbol_contains_sep) {
+ // We insert the space into the symbol instead of
+ // setting pat.field[2]=space so that when
+ // showbase is not set, the space goes away too.
+ __curr_symbol_.insert((size_t)0, 1, space_char);
+ }
+ return;
+ case 2: // Space between sign and currency or value.
+ pat.field[1] = space;
+ pat.field[2] = value;
+ if (symbol_contains_sep) {
+ // Remove the separator from the symbol, since it
+ // has already appeared after the sign.
+ __curr_symbol_.erase(__curr_symbol_.begin());
+ }
+ return;
+ default:
+ break;
+ }
+ break;
+ case 2: // The sign string succeeds the quantity and currency symbol.
+ pat.field[0] = value;
+ pat.field[3] = sign;
+ switch (sep_by_space)
+ {
+ case 0: // No space separates the currency symbol and value.
+ pat.field[1] = none;
+ pat.field[2] = symbol;
+ return;
+ case 1: // Space between currency-and-sign or currency and value.
+ if (!symbol_contains_sep) {
+ // We insert the space into the symbol instead of
+ // setting pat.field[1]=space so that when
+ // showbase is not set, the space goes away too.
+ __curr_symbol_.insert((size_t)0, 1, space_char);
+ }
+ pat.field[1] = none;
+ pat.field[2] = symbol;
+ return;
+ case 2: // Space between sign and currency or value.
+ pat.field[1] = symbol;
+ pat.field[2] = space;
+ if (symbol_contains_sep) {
+ // Remove the separator from the symbol, since it
+ // should not be removed if showbase is absent.
+ __curr_symbol_.erase(__curr_symbol_.begin());
+ }
+ return;
+ default:
+ break;
+ }
+ break;
+ case 3: // The sign string immediately precedes the currency symbol.
+ pat.field[0] = value;
+ pat.field[3] = symbol;
+ switch (sep_by_space)
+ {
+ case 0: // No space separates the currency symbol and value.
+ pat.field[1] = none;
+ pat.field[2] = sign;
+ return;
+ case 1: // Space between currency-and-sign or currency and value.
+ pat.field[1] = space;
+ pat.field[2] = sign;
+ if (symbol_contains_sep) {
+ // Remove the separator from the symbol, since it
+ // has already appeared before the sign.
+ __curr_symbol_.erase(__curr_symbol_.begin());
+ }
+ return;
+ case 2: // Space between sign and currency or value.
+ pat.field[1] = sign;
+ pat.field[2] = none;
+ if (!symbol_contains_sep) {
+ // We insert the space into the symbol instead of
+ // setting pat.field[2]=space so that when
+ // showbase is not set, the space goes away too.
+ __curr_symbol_.insert((size_t)0, 1, space_char);
+ }
+ return;
+ default:
+ break;
+ }
+ break;
+ case 4: // The sign string immediately succeeds the currency symbol.
+ pat.field[0] = value;
+ pat.field[3] = sign;
+ switch (sep_by_space)
+ {
+ case 0: // No space separates the currency symbol and value.
+ pat.field[1] = none;
+ pat.field[2] = symbol;
+ return;
+ case 1: // Space between currency-and-sign or currency and value.
+ pat.field[1] = none;
+ pat.field[2] = symbol;
+ if (!symbol_contains_sep) {
+ // We insert the space into the symbol instead of
+ // setting pat.field[1]=space so that when
+ // showbase is not set, the space goes away too.
+ __curr_symbol_.insert((size_t)0, 1, space_char);
+ }
+ return;
+ case 2: // Space between sign and currency or value.
+ pat.field[1] = symbol;
+ pat.field[2] = space;
+ if (symbol_contains_sep) {
+ // Remove the separator from the symbol, since it
+ // should not disappear when showbase is absent.
+ __curr_symbol_.erase(__curr_symbol_.begin());
+ }
+ return;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ break;
+ case 1: // curr_symbol before value
+ switch (sign_posn)
+ {
+ case 0: // Parentheses surround the quantity and currency symbol.
+ pat.field[0] = sign;
+ pat.field[1] = symbol;
+ pat.field[2] = none; // Any space appears in the symbol.
+ pat.field[3] = value;
+ switch (sep_by_space)
+ {
+ case 0: // No space separates the currency symbol and value.
+ // This case may have changed between C99 and C11;
+ // assume the currency symbol matches the intention.
+ case 2: // Space between sign and currency or value.
+ // The "sign" is two parentheses, so no space here either.
+ return;
+ case 1: // Space between currency-and-sign or currency and value.
+ if (!symbol_contains_sep) {
+ // We insert the space into the symbol instead of
+ // setting pat.field[2]=space so that when
+ // showbase is not set, the space goes away too.
+ __curr_symbol_.insert((size_t)0, 1, space_char);
+ }
+ return;
+ default:
+ break;
+ }
+ break;
+ case 1: // The sign string precedes the quantity and currency symbol.
+ pat.field[0] = sign;
+ pat.field[3] = value;
+ switch (sep_by_space)
+ {
+ case 0: // No space separates the currency symbol and value.
+ pat.field[1] = symbol;
+ pat.field[2] = none;
+ return;
+ case 1: // Space between currency-and-sign or currency and value.
+ pat.field[1] = symbol;
+ pat.field[2] = none;
+ if (!symbol_contains_sep) {
+ // We insert the space into the symbol instead of
+ // setting pat.field[2]=space so that when
+ // showbase is not set, the space goes away too.
+ __curr_symbol_.push_back(space_char);
+ }
+ return;
+ case 2: // Space between sign and currency or value.
+ pat.field[1] = space;
+ pat.field[2] = symbol;
+ if (symbol_contains_sep) {
+ // Remove the separator from the symbol, since it
+ // has already appeared after the sign.
+ __curr_symbol_.pop_back();
+ }
+ return;
+ default:
+ break;
+ }
+ break;
+ case 2: // The sign string succeeds the quantity and currency symbol.
+ pat.field[0] = symbol;
+ pat.field[3] = sign;
+ switch (sep_by_space)
+ {
+ case 0: // No space separates the currency symbol and value.
+ pat.field[1] = none;
+ pat.field[2] = value;
+ return;
+ case 1: // Space between currency-and-sign or currency and value.
+ pat.field[1] = none;
+ pat.field[2] = value;
+ if (!symbol_contains_sep) {
+ // We insert the space into the symbol instead of
+ // setting pat.field[1]=space so that when
+ // showbase is not set, the space goes away too.
+ __curr_symbol_.push_back(space_char);
+ }
+ return;
+ case 2: // Space between sign and currency or value.
+ pat.field[1] = value;
+ pat.field[2] = space;
+ if (symbol_contains_sep) {
+ // Remove the separator from the symbol, since it
+ // will appear before the sign.
+ __curr_symbol_.pop_back();
+ }
+ return;
+ default:
+ break;
+ }
+ break;
+ case 3: // The sign string immediately precedes the currency symbol.
+ pat.field[0] = sign;
+ pat.field[3] = value;
+ switch (sep_by_space)
+ {
+ case 0: // No space separates the currency symbol and value.
+ pat.field[1] = symbol;
+ pat.field[2] = none;
+ return;
+ case 1: // Space between currency-and-sign or currency and value.
+ pat.field[1] = symbol;
+ pat.field[2] = none;
+ if (!symbol_contains_sep) {
+ // We insert the space into the symbol instead of
+ // setting pat.field[2]=space so that when
+ // showbase is not set, the space goes away too.
+ __curr_symbol_.push_back(space_char);
+ }
+ return;
+ case 2: // Space between sign and currency or value.
+ pat.field[1] = space;
+ pat.field[2] = symbol;
+ if (symbol_contains_sep) {
+ // Remove the separator from the symbol, since it
+ // has already appeared after the sign.
+ __curr_symbol_.pop_back();
+ }
+ return;
+ default:
+ break;
+ }
+ break;
+ case 4: // The sign string immediately succeeds the currency symbol.
+ pat.field[0] = symbol;
+ pat.field[3] = value;
+ switch (sep_by_space)
+ {
+ case 0: // No space separates the currency symbol and value.
+ pat.field[1] = sign;
+ pat.field[2] = none;
+ return;
+ case 1: // Space between currency-and-sign or currency and value.
+ pat.field[1] = sign;
+ pat.field[2] = space;
+ if (symbol_contains_sep) {
+ // Remove the separator from the symbol, since it
+ // should not disappear when showbase is absent.
+ __curr_symbol_.pop_back();
+ }
+ return;
+ case 2: // Space between sign and currency or value.
+ pat.field[1] = none;
+ pat.field[2] = sign;
+ if (!symbol_contains_sep) {
+ // We insert the space into the symbol instead of
+ // setting pat.field[1]=space so that when
+ // showbase is not set, the space goes away too.
+ __curr_symbol_.push_back(space_char);
+ }
+ return;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ pat.field[0] = symbol;
+ pat.field[1] = sign;
+ pat.field[2] = none;
+ pat.field[3] = value;
+}
+
+template<>
+void
+moneypunct_byname<char, false>::init(const char* nm)
+{
+ typedef moneypunct<char, false> base;
+ __libcpp_unique_locale loc(nm);
+ if (!loc)
+ __throw_runtime_error("moneypunct_byname"
+ " failed to construct for " + string(nm));
+
+ lconv* lc = __libcpp_localeconv_l(loc.get());
+ if (!checked_string_to_char_convert(__decimal_point_,
+ lc->mon_decimal_point,
+ loc.get()))
+ __decimal_point_ = base::do_decimal_point();
+ if (!checked_string_to_char_convert(__thousands_sep_,
+ lc->mon_thousands_sep,
+ loc.get()))
+ __thousands_sep_ = base::do_thousands_sep();
+
+ __grouping_ = lc->mon_grouping;
+ __curr_symbol_ = lc->currency_symbol;
+ if (lc->frac_digits != CHAR_MAX)
+ __frac_digits_ = lc->frac_digits;
+ else
+ __frac_digits_ = base::do_frac_digits();
+ if (lc->p_sign_posn == 0)
+ __positive_sign_ = "()";
+ else
+ __positive_sign_ = lc->positive_sign;
+ if (lc->n_sign_posn == 0)
+ __negative_sign_ = "()";
+ else
+ __negative_sign_ = lc->negative_sign;
+ // Assume the positive and negative formats will want spaces in
+ // the same places in curr_symbol since there's no way to
+ // represent anything else.
+ string_type __dummy_curr_symbol = __curr_symbol_;
+ __init_pat(__pos_format_, __dummy_curr_symbol, false,
+ lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn, ' ');
+ __init_pat(__neg_format_, __curr_symbol_, false,
+ lc->n_cs_precedes, lc->n_sep_by_space, lc->n_sign_posn, ' ');
+}
+
+template<>
+void
+moneypunct_byname<char, true>::init(const char* nm)
+{
+ typedef moneypunct<char, true> base;
+ __libcpp_unique_locale loc(nm);
+ if (!loc)
+ __throw_runtime_error("moneypunct_byname"
+ " failed to construct for " + string(nm));
+
+ lconv* lc = __libcpp_localeconv_l(loc.get());
+ if (!checked_string_to_char_convert(__decimal_point_,
+ lc->mon_decimal_point,
+ loc.get()))
+ __decimal_point_ = base::do_decimal_point();
+ if (!checked_string_to_char_convert(__thousands_sep_,
+ lc->mon_thousands_sep,
+ loc.get()))
+ __thousands_sep_ = base::do_thousands_sep();
+ __grouping_ = lc->mon_grouping;
+ __curr_symbol_ = lc->int_curr_symbol;
+ if (lc->int_frac_digits != CHAR_MAX)
+ __frac_digits_ = lc->int_frac_digits;
+ else
+ __frac_digits_ = base::do_frac_digits();
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
+ if (lc->p_sign_posn == 0)
+#else // _LIBCPP_MSVCRT
+ if (lc->int_p_sign_posn == 0)
+#endif // !_LIBCPP_MSVCRT
+ __positive_sign_ = "()";
+ else
+ __positive_sign_ = lc->positive_sign;
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
+ if(lc->n_sign_posn == 0)
+#else // _LIBCPP_MSVCRT
+ if (lc->int_n_sign_posn == 0)
+#endif // !_LIBCPP_MSVCRT
+ __negative_sign_ = "()";
+ else
+ __negative_sign_ = lc->negative_sign;
+ // Assume the positive and negative formats will want spaces in
+ // the same places in curr_symbol since there's no way to
+ // represent anything else.
+ string_type __dummy_curr_symbol = __curr_symbol_;
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
+ __init_pat(__pos_format_, __dummy_curr_symbol, true,
+ lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn, ' ');
+ __init_pat(__neg_format_, __curr_symbol_, true,
+ lc->n_cs_precedes, lc->n_sep_by_space, lc->n_sign_posn, ' ');
+#else // _LIBCPP_MSVCRT
+ __init_pat(__pos_format_, __dummy_curr_symbol, true,
+ lc->int_p_cs_precedes, lc->int_p_sep_by_space,
+ lc->int_p_sign_posn, ' ');
+ __init_pat(__neg_format_, __curr_symbol_, true,
+ lc->int_n_cs_precedes, lc->int_n_sep_by_space,
+ lc->int_n_sign_posn, ' ');
+#endif // !_LIBCPP_MSVCRT
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template<>
+void
+moneypunct_byname<wchar_t, false>::init(const char* nm)
+{
+ typedef moneypunct<wchar_t, false> base;
+ __libcpp_unique_locale loc(nm);
+ if (!loc)
+ __throw_runtime_error("moneypunct_byname"
+ " failed to construct for " + string(nm));
+ lconv* lc = __libcpp_localeconv_l(loc.get());
+ if (!checked_string_to_wchar_convert(__decimal_point_,
+ lc->mon_decimal_point,
+ loc.get()))
+ __decimal_point_ = base::do_decimal_point();
+ if (!checked_string_to_wchar_convert(__thousands_sep_,
+ lc->mon_thousands_sep,
+ loc.get()))
+ __thousands_sep_ = base::do_thousands_sep();
+ __grouping_ = lc->mon_grouping;
+ wchar_t wbuf[100];
+ mbstate_t mb = {0};
+ const char* bb = lc->currency_symbol;
+ size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
+ if (j == size_t(-1))
+ __throw_runtime_error("locale not supported");
+ wchar_t* wbe = wbuf + j;
+ __curr_symbol_.assign(wbuf, wbe);
+ if (lc->frac_digits != CHAR_MAX)
+ __frac_digits_ = lc->frac_digits;
+ else
+ __frac_digits_ = base::do_frac_digits();
+ if (lc->p_sign_posn == 0)
+ __positive_sign_ = L"()";
+ else
+ {
+ mb = mbstate_t();
+ bb = lc->positive_sign;
+ j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
+ if (j == size_t(-1))
+ __throw_runtime_error("locale not supported");
+ wbe = wbuf + j;
+ __positive_sign_.assign(wbuf, wbe);
+ }
+ if (lc->n_sign_posn == 0)
+ __negative_sign_ = L"()";
+ else
+ {
+ mb = mbstate_t();
+ bb = lc->negative_sign;
+ j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
+ if (j == size_t(-1))
+ __throw_runtime_error("locale not supported");
+ wbe = wbuf + j;
+ __negative_sign_.assign(wbuf, wbe);
+ }
+ // Assume the positive and negative formats will want spaces in
+ // the same places in curr_symbol since there's no way to
+ // represent anything else.
+ string_type __dummy_curr_symbol = __curr_symbol_;
+ __init_pat(__pos_format_, __dummy_curr_symbol, false,
+ lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn, L' ');
+ __init_pat(__neg_format_, __curr_symbol_, false,
+ lc->n_cs_precedes, lc->n_sep_by_space, lc->n_sign_posn, L' ');
+}
+
+template<>
+void
+moneypunct_byname<wchar_t, true>::init(const char* nm)
+{
+ typedef moneypunct<wchar_t, true> base;
+ __libcpp_unique_locale loc(nm);
+ if (!loc)
+ __throw_runtime_error("moneypunct_byname"
+ " failed to construct for " + string(nm));
+
+ lconv* lc = __libcpp_localeconv_l(loc.get());
+ if (!checked_string_to_wchar_convert(__decimal_point_,
+ lc->mon_decimal_point,
+ loc.get()))
+ __decimal_point_ = base::do_decimal_point();
+ if (!checked_string_to_wchar_convert(__thousands_sep_,
+ lc->mon_thousands_sep,
+ loc.get()))
+ __thousands_sep_ = base::do_thousands_sep();
+ __grouping_ = lc->mon_grouping;
+ wchar_t wbuf[100];
+ mbstate_t mb = {0};
+ const char* bb = lc->int_curr_symbol;
+ size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
+ if (j == size_t(-1))
+ __throw_runtime_error("locale not supported");
+ wchar_t* wbe = wbuf + j;
+ __curr_symbol_.assign(wbuf, wbe);
+ if (lc->int_frac_digits != CHAR_MAX)
+ __frac_digits_ = lc->int_frac_digits;
+ else
+ __frac_digits_ = base::do_frac_digits();
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
+ if (lc->p_sign_posn == 0)
+#else // _LIBCPP_MSVCRT
+ if (lc->int_p_sign_posn == 0)
+#endif // !_LIBCPP_MSVCRT
+ __positive_sign_ = L"()";
+ else
+ {
+ mb = mbstate_t();
+ bb = lc->positive_sign;
+ j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
+ if (j == size_t(-1))
+ __throw_runtime_error("locale not supported");
+ wbe = wbuf + j;
+ __positive_sign_.assign(wbuf, wbe);
+ }
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
+ if (lc->n_sign_posn == 0)
+#else // _LIBCPP_MSVCRT
+ if (lc->int_n_sign_posn == 0)
+#endif // !_LIBCPP_MSVCRT
+ __negative_sign_ = L"()";
+ else
+ {
+ mb = mbstate_t();
+ bb = lc->negative_sign;
+ j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
+ if (j == size_t(-1))
+ __throw_runtime_error("locale not supported");
+ wbe = wbuf + j;
+ __negative_sign_.assign(wbuf, wbe);
+ }
+ // Assume the positive and negative formats will want spaces in
+ // the same places in curr_symbol since there's no way to
+ // represent anything else.
+ string_type __dummy_curr_symbol = __curr_symbol_;
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
+ __init_pat(__pos_format_, __dummy_curr_symbol, true,
+ lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn, L' ');
+ __init_pat(__neg_format_, __curr_symbol_, true,
+ lc->n_cs_precedes, lc->n_sep_by_space, lc->n_sign_posn, L' ');
+#else // _LIBCPP_MSVCRT
+ __init_pat(__pos_format_, __dummy_curr_symbol, true,
+ lc->int_p_cs_precedes, lc->int_p_sep_by_space,
+ lc->int_p_sign_posn, L' ');
+ __init_pat(__neg_format_, __curr_symbol_, true,
+ lc->int_n_cs_precedes, lc->int_n_sep_by_space,
+ lc->int_n_sign_posn, L' ');
+#endif // !_LIBCPP_MSVCRT
+}
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+void __do_nothing(void*) {}
+
+void __throw_runtime_error(const char* msg)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw runtime_error(msg);
+#else
+ (void)msg;
+ _VSTD::abort();
+#endif
+}
+
+ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS collate<char>;
+_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS collate<wchar_t>;)
+
+ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS num_get<char>;
+_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS num_get<wchar_t>;)
+
+ template struct _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __num_get<char>;
+_LIBCPP_IF_WIDE_CHARACTERS(template struct _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __num_get<wchar_t>;)
+
+ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS num_put<char>;
+_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS num_put<wchar_t>;)
+
+ template struct _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __num_put<char>;
+_LIBCPP_IF_WIDE_CHARACTERS(template struct _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __num_put<wchar_t>;)
+
+ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_get<char>;
+_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_get<wchar_t>;)
+
+ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_get_byname<char>;
+_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_get_byname<wchar_t>;)
+
+ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_put<char>;
+_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_put<wchar_t>;)
+
+ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_put_byname<char>;
+_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_put_byname<wchar_t>;)
+
+ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct<char, false>;
+ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct<char, true>;
+_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct<wchar_t, false>;)
+_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct<wchar_t, true>;)
+
+ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct_byname<char, false>;
+ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct_byname<char, true>;
+_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct_byname<wchar_t, false>;)
+_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct_byname<wchar_t, true>;)
+
+ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS money_get<char>;
+_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS money_get<wchar_t>;)
+
+ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __money_get<char>;
+_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __money_get<wchar_t>;)
+
+ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS money_put<char>;
+_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS money_put<wchar_t>;)
+
+ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __money_put<char>;
+_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __money_put<wchar_t>;)
+
+ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS messages<char>;
+_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS messages<wchar_t>;)
+
+ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS messages_byname<char>;
+_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS messages_byname<wchar_t>;)
+
+ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char, char, mbstate_t>;
+_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<wchar_t, char, mbstate_t>;)
+template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char16_t, char, mbstate_t>;
+template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char32_t, char, mbstate_t>;
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char16_t, char8_t, mbstate_t>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char32_t, char8_t, mbstate_t>;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/memory.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/memory.cpp
new file mode 100644
index 0000000000..e4933881bf
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/memory.cpp
@@ -0,0 +1,238 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <memory>
+
+#ifndef _LIBCPP_HAS_NO_THREADS
+# include <mutex>
+# include <thread>
+# if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
+# pragma comment(lib, "pthread")
+# endif
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#include <atomic>
+#else
+#include "include/atomic_support.h"
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+const allocator_arg_t allocator_arg = allocator_arg_t();
+
+bad_weak_ptr::~bad_weak_ptr() noexcept {}
+
+const char*
+bad_weak_ptr::what() const noexcept
+{
+ return "bad_weak_ptr";
+}
+
+__shared_count::~__shared_count()
+{
+}
+
+__shared_weak_count::~__shared_weak_count()
+{
+}
+
+#if defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS)
+void
+__shared_count::__add_shared() noexcept
+{
+#ifdef _LIBCPP_HAS_NO_THREADS
+ __libcpp_atomic_refcount_increment(__shared_owners_);
+#else
+ ++__shared_owners_;
+#endif
+}
+
+bool
+__shared_count::__release_shared() noexcept
+{
+#ifdef _LIBCPP_HAS_NO_THREADS
+ if (__libcpp_atomic_refcount_decrement(__shared_owners_) == -1)
+#else
+ if (--__shared_owners_ == -1)
+#endif
+ {
+ __on_zero_shared();
+ return true;
+ }
+ return false;
+}
+
+void
+__shared_weak_count::__add_shared() noexcept
+{
+ __shared_count::__add_shared();
+}
+
+void
+__shared_weak_count::__add_weak() noexcept
+{
+#ifdef _LIBCPP_HAS_NO_THREADS
+ __libcpp_atomic_refcount_increment(__shared_weak_owners_);
+#else
+ ++__shared_weak_owners_;
+#endif
+}
+
+void
+__shared_weak_count::__release_shared() noexcept
+{
+ if (__shared_count::__release_shared())
+ __release_weak();
+}
+
+#endif // _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
+
+void
+__shared_weak_count::__release_weak() noexcept
+{
+ // NOTE: The acquire load here is an optimization of the very
+ // common case where a shared pointer is being destructed while
+ // having no other contended references.
+ //
+ // BENEFIT: We avoid expensive atomic stores like XADD and STREX
+ // in a common case. Those instructions are slow and do nasty
+ // things to caches.
+ //
+ // IS THIS SAFE? Yes. During weak destruction, if we see that we
+ // are the last reference, we know that no-one else is accessing
+ // us. If someone were accessing us, then they would be doing so
+ // while the last shared / weak_ptr was being destructed, and
+ // that's undefined anyway.
+ //
+ // If we see anything other than a 0, then we have possible
+ // contention, and need to use an atomicrmw primitive.
+ // The same arguments don't apply for increment, where it is legal
+ // (though inadvisable) to share shared_ptr references between
+ // threads, and have them all get copied at once. The argument
+ // also doesn't apply for __release_shared, because an outstanding
+ // weak_ptr::lock() could read / modify the shared count.
+#ifdef _LIBCPP_HAS_NO_THREADS
+ if (__libcpp_atomic_load(&__shared_weak_owners_, _AO_Acquire) == 0)
+#else
+ if (__shared_weak_owners_.load(memory_order_acquire) == 0)
+#endif
+ {
+ // no need to do this store, because we are about
+ // to destroy everything.
+ //__libcpp_atomic_store(&__shared_weak_owners_, -1, _AO_Release);
+ __on_zero_shared_weak();
+ }
+#ifdef _LIBCPP_HAS_NO_THREADS
+ else if (__libcpp_atomic_refcount_decrement(__shared_weak_owners_) == -1)
+#else
+ else if (--__shared_weak_owners_ == -1)
+#endif
+ __on_zero_shared_weak();
+}
+
+__shared_weak_count*
+__shared_weak_count::lock() noexcept
+{
+#ifdef _LIBCPP_HAS_NO_THREADS
+ long object_owners = __libcpp_atomic_load(&__shared_owners_);
+#else
+ long object_owners = __shared_owners_.load();
+#endif
+ while (object_owners != -1)
+ {
+#ifdef _LIBCPP_HAS_NO_THREADS
+ if (__libcpp_atomic_compare_exchange(&__shared_owners_,
+ &object_owners,
+ object_owners+1))
+#else
+ if (__shared_owners_.compare_exchange_weak(object_owners, object_owners+1))
+#endif
+ return this;
+ }
+ return nullptr;
+}
+
+const void*
+__shared_weak_count::__get_deleter(const type_info&) const noexcept
+{
+ return nullptr;
+}
+
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+
+static constexpr std::size_t __sp_mut_count = 16;
+static _LIBCPP_CONSTINIT __libcpp_mutex_t mut_back[__sp_mut_count] =
+{
+ _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
+ _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
+ _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
+ _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER
+};
+
+_LIBCPP_CONSTEXPR __sp_mut::__sp_mut(void* p) noexcept
+ : __lx(p)
+{
+}
+
+void
+__sp_mut::lock() noexcept
+{
+ auto m = static_cast<__libcpp_mutex_t*>(__lx);
+ unsigned count = 0;
+ while (!__libcpp_mutex_trylock(m))
+ {
+ if (++count > 16)
+ {
+ __libcpp_mutex_lock(m);
+ break;
+ }
+ this_thread::yield();
+ }
+}
+
+void
+__sp_mut::unlock() noexcept
+{
+ __libcpp_mutex_unlock(static_cast<__libcpp_mutex_t*>(__lx));
+}
+
+__sp_mut&
+__get_sp_mut(const void* p)
+{
+ static _LIBCPP_CONSTINIT __sp_mut muts[__sp_mut_count] = {
+ &mut_back[ 0], &mut_back[ 1], &mut_back[ 2], &mut_back[ 3],
+ &mut_back[ 4], &mut_back[ 5], &mut_back[ 6], &mut_back[ 7],
+ &mut_back[ 8], &mut_back[ 9], &mut_back[10], &mut_back[11],
+ &mut_back[12], &mut_back[13], &mut_back[14], &mut_back[15]
+ };
+ return muts[hash<const void*>()(p) & (__sp_mut_count-1)];
+}
+
+#endif // !defined(_LIBCPP_HAS_NO_THREADS)
+
+void*
+align(size_t alignment, size_t size, void*& ptr, size_t& space)
+{
+ void* r = nullptr;
+ if (size <= space)
+ {
+ char* p1 = static_cast<char*>(ptr);
+ char* p2 = reinterpret_cast<char*>(reinterpret_cast<size_t>(p1 + (alignment - 1)) & -alignment);
+ size_t d = static_cast<size_t>(p2 - p1);
+ if (d <= space - size)
+ {
+ r = p2;
+ ptr = r;
+ space -= d;
+ }
+ }
+ return r;
+}
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/mutex.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/mutex.cpp
new file mode 100644
index 0000000000..c247225e31
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/mutex.cpp
@@ -0,0 +1,286 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <__assert>
+#include <limits>
+#include <mutex>
+#include <system_error>
+
+#if !defined(_LIBCPP_ABI_MICROSOFT)
+#include "include/atomic_support.h"
+#endif
+
+#ifndef _LIBCPP_HAS_NO_THREADS
+# if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
+# pragma comment(lib, "pthread")
+# endif
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifndef _LIBCPP_HAS_NO_THREADS
+
+const defer_lock_t defer_lock{};
+const try_to_lock_t try_to_lock{};
+const adopt_lock_t adopt_lock{};
+
+// ~mutex is defined elsewhere
+
+void
+mutex::lock()
+{
+ int ec = __libcpp_mutex_lock(&__m_);
+ if (ec)
+ __throw_system_error(ec, "mutex lock failed");
+}
+
+bool
+mutex::try_lock() noexcept
+{
+ return __libcpp_mutex_trylock(&__m_);
+}
+
+void
+mutex::unlock() noexcept
+{
+ int ec = __libcpp_mutex_unlock(&__m_);
+ (void)ec;
+ _LIBCPP_ASSERT(ec == 0, "call to mutex::unlock failed");
+}
+
+// recursive_mutex
+
+recursive_mutex::recursive_mutex()
+{
+ int ec = __libcpp_recursive_mutex_init(&__m_);
+ if (ec)
+ __throw_system_error(ec, "recursive_mutex constructor failed");
+}
+
+recursive_mutex::~recursive_mutex()
+{
+ int e = __libcpp_recursive_mutex_destroy(&__m_);
+ (void)e;
+ _LIBCPP_ASSERT(e == 0, "call to ~recursive_mutex() failed");
+}
+
+void
+recursive_mutex::lock()
+{
+ int ec = __libcpp_recursive_mutex_lock(&__m_);
+ if (ec)
+ __throw_system_error(ec, "recursive_mutex lock failed");
+}
+
+void
+recursive_mutex::unlock() noexcept
+{
+ int e = __libcpp_recursive_mutex_unlock(&__m_);
+ (void)e;
+ _LIBCPP_ASSERT(e == 0, "call to recursive_mutex::unlock() failed");
+}
+
+bool
+recursive_mutex::try_lock() noexcept
+{
+ return __libcpp_recursive_mutex_trylock(&__m_);
+}
+
+// timed_mutex
+
+timed_mutex::timed_mutex()
+ : __locked_(false)
+{
+}
+
+timed_mutex::~timed_mutex()
+{
+ lock_guard<mutex> _(__m_);
+}
+
+void
+timed_mutex::lock()
+{
+ unique_lock<mutex> lk(__m_);
+ while (__locked_)
+ __cv_.wait(lk);
+ __locked_ = true;
+}
+
+bool
+timed_mutex::try_lock() noexcept
+{
+ unique_lock<mutex> lk(__m_, try_to_lock);
+ if (lk.owns_lock() && !__locked_)
+ {
+ __locked_ = true;
+ return true;
+ }
+ return false;
+}
+
+void
+timed_mutex::unlock() noexcept
+{
+ lock_guard<mutex> _(__m_);
+ __locked_ = false;
+ __cv_.notify_one();
+}
+
+// recursive_timed_mutex
+
+recursive_timed_mutex::recursive_timed_mutex()
+ : __count_(0),
+ __id_{}
+{
+}
+
+recursive_timed_mutex::~recursive_timed_mutex()
+{
+ lock_guard<mutex> _(__m_);
+}
+
+void
+recursive_timed_mutex::lock()
+{
+ __thread_id id = this_thread::get_id();
+ unique_lock<mutex> lk(__m_);
+ if (id ==__id_)
+ {
+ if (__count_ == numeric_limits<size_t>::max())
+ __throw_system_error(EAGAIN, "recursive_timed_mutex lock limit reached");
+ ++__count_;
+ return;
+ }
+ while (__count_ != 0)
+ __cv_.wait(lk);
+ __count_ = 1;
+ __id_ = id;
+}
+
+bool
+recursive_timed_mutex::try_lock() noexcept
+{
+ __thread_id id = this_thread::get_id();
+ unique_lock<mutex> lk(__m_, try_to_lock);
+ if (lk.owns_lock() && (__count_ == 0 || id == __id_))
+ {
+ if (__count_ == numeric_limits<size_t>::max())
+ return false;
+ ++__count_;
+ __id_ = id;
+ return true;
+ }
+ return false;
+}
+
+void
+recursive_timed_mutex::unlock() noexcept
+{
+ unique_lock<mutex> lk(__m_);
+ if (--__count_ == 0)
+ {
+ __id_.__reset();
+ lk.unlock();
+ __cv_.notify_one();
+ }
+}
+
+#endif // !_LIBCPP_HAS_NO_THREADS
+
+// If dispatch_once_f ever handles C++ exceptions, and if one can get to it
+// without illegal macros (unexpected macros not beginning with _UpperCase or
+// __lowercase), and if it stops spinning waiting threads, then call_once should
+// call into dispatch_once_f instead of here. Relevant radar this code needs to
+// keep in sync with: 7741191.
+
+#ifndef _LIBCPP_HAS_NO_THREADS
+static _LIBCPP_CONSTINIT __libcpp_mutex_t mut = _LIBCPP_MUTEX_INITIALIZER;
+static _LIBCPP_CONSTINIT __libcpp_condvar_t cv = _LIBCPP_CONDVAR_INITIALIZER;
+#endif
+
+#ifdef _LIBCPP_ABI_MICROSOFT
+void __call_once(volatile std::atomic<once_flag::_State_type>& flag, void* arg,
+ void (*func)(void*))
+#else
+void __call_once(volatile once_flag::_State_type& flag, void* arg,
+ void (*func)(void*))
+#endif
+{
+#if defined(_LIBCPP_HAS_NO_THREADS)
+ if (flag == 0)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ flag = 1;
+ func(arg);
+ flag = ~once_flag::_State_type(0);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ flag = 0;
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ }
+#else // !_LIBCPP_HAS_NO_THREADS
+ __libcpp_mutex_lock(&mut);
+ while (flag == 1)
+ __libcpp_condvar_wait(&cv, &mut);
+ if (flag == 0)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+#ifdef _LIBCPP_ABI_MICROSOFT
+ flag.store(once_flag::_State_type(1));
+#else
+ __libcpp_relaxed_store(&flag, once_flag::_State_type(1));
+#endif
+ __libcpp_mutex_unlock(&mut);
+ func(arg);
+ __libcpp_mutex_lock(&mut);
+#ifdef _LIBCPP_ABI_MICROSOFT
+ flag.store(~once_flag::_State_type(0), memory_order_release);
+#else
+ __libcpp_atomic_store(&flag, ~once_flag::_State_type(0),
+ _AO_Release);
+#endif
+ __libcpp_mutex_unlock(&mut);
+ __libcpp_condvar_broadcast(&cv);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __libcpp_mutex_lock(&mut);
+#ifdef _LIBCPP_ABI_MICROSOFT
+ flag.store(once_flag::_State_type(0), memory_order_relaxed);
+#else
+ __libcpp_relaxed_store(&flag, once_flag::_State_type(0));
+#endif
+ __libcpp_mutex_unlock(&mut);
+ __libcpp_condvar_broadcast(&cv);
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ }
+ else
+ __libcpp_mutex_unlock(&mut);
+#endif // !_LIBCPP_HAS_NO_THREADS
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/mutex_destructor.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/mutex_destructor.cpp
new file mode 100644
index 0000000000..6850b6e6f4
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/mutex_destructor.cpp
@@ -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
+//
+//===----------------------------------------------------------------------===//
+
+// Define ~mutex.
+//
+// On some platforms ~mutex has been made trivial and the definition is only
+// provided for ABI compatibility.
+//
+// In order to avoid ODR violations within libc++ itself, we need to ensure
+// that *nothing* sees the non-trivial mutex declaration. For this reason
+// we re-declare the entire class in this file instead of using
+// _LIBCPP_BUILDING_LIBRARY to change the definition in the headers.
+
+#include <__config>
+#include <__threading_support>
+
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+# if _LIBCPP_ABI_VERSION == 1 || !defined(_LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION)
+# define NEEDS_MUTEX_DESTRUCTOR
+# endif
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifdef NEEDS_MUTEX_DESTRUCTOR
+class _LIBCPP_TYPE_VIS mutex
+{
+ __libcpp_mutex_t __m_ = _LIBCPP_MUTEX_INITIALIZER;
+
+public:
+ _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
+ constexpr mutex() = default;
+ mutex(const mutex&) = delete;
+ mutex& operator=(const mutex&) = delete;
+ ~mutex() noexcept;
+};
+
+
+mutex::~mutex() noexcept
+{
+ __libcpp_mutex_destroy(&__m_);
+}
+
+#endif // !_LIBCPP_HAS_NO_THREADS
+_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/new.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/new.cpp
new file mode 100644
index 0000000000..937e860337
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/new.cpp
@@ -0,0 +1,300 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <new>
+#include <stdlib.h>
+
+#if defined(_LIBCPP_ABI_MICROSOFT)
+# if !defined(_LIBCPP_ABI_VCRUNTIME)
+# include "support/runtime/new_handler_fallback.ipp"
+# endif
+#elif defined(LIBCXX_BUILDING_LIBCXXABI)
+# include <cxxabi.h>
+#elif defined(LIBCXX_BUILDING_LIBCXXRT)
+# include <cxxabi.h>
+# include "support/runtime/new_handler_fallback.ipp"
+#elif defined(__GLIBCXX__)
+ // nothing to do
+#else
+# include "support/runtime/new_handler_fallback.ipp"
+#endif
+
+namespace std
+{
+
+#ifndef __GLIBCXX__
+const nothrow_t nothrow{};
+#endif
+
+#ifndef LIBSTDCXX
+
+void
+__throw_bad_alloc()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw bad_alloc();
+#else
+ _VSTD::abort();
+#endif
+}
+
+#endif // !LIBSTDCXX
+
+} // std
+
+#if !defined(__GLIBCXX__) && \
+ !defined(_LIBCPP_ABI_VCRUNTIME) && \
+ !defined(_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS)
+
+// Implement all new and delete operators as weak definitions
+// in this shared library, so that they can be overridden by programs
+// that define non-weak copies of the functions.
+
+_LIBCPP_WEAK
+void *
+operator new(std::size_t size) _THROW_BAD_ALLOC
+{
+ if (size == 0)
+ size = 1;
+ void* p;
+ while ((p = ::malloc(size)) == nullptr)
+ {
+ // If malloc fails and there is a new_handler,
+ // call it to try free up memory.
+ std::new_handler nh = std::get_new_handler();
+ if (nh)
+ nh();
+ else
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw std::bad_alloc();
+#else
+#ifdef __EMSCRIPTEN__
+ // Abort here so that when exceptions are disabled, we do not just
+ // return 0 when malloc returns 0.
+ // We could also do this with set_new_handler, but that adds a
+ // global constructor and a table entry, overhead that we can avoid
+ // by doing it this way.
+ abort();
+#else
+ break;
+#endif
+#endif
+ }
+ return p;
+}
+
+_LIBCPP_WEAK
+void*
+operator new(size_t size, const std::nothrow_t&) noexcept
+{
+ void* p = nullptr;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ p = ::operator new(size);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ return p;
+}
+
+_LIBCPP_WEAK
+void*
+operator new[](size_t size) _THROW_BAD_ALLOC
+{
+ return ::operator new(size);
+}
+
+_LIBCPP_WEAK
+void*
+operator new[](size_t size, const std::nothrow_t&) noexcept
+{
+ void* p = nullptr;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ p = ::operator new[](size);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ return p;
+}
+
+_LIBCPP_WEAK
+void
+operator delete(void* ptr) noexcept
+{
+ ::free(ptr);
+}
+
+_LIBCPP_WEAK
+void
+operator delete(void* ptr, const std::nothrow_t&) noexcept
+{
+ ::operator delete(ptr);
+}
+
+_LIBCPP_WEAK
+void
+operator delete(void* ptr, size_t) noexcept
+{
+ ::operator delete(ptr);
+}
+
+_LIBCPP_WEAK
+void
+operator delete[] (void* ptr) noexcept
+{
+ ::operator delete(ptr);
+}
+
+_LIBCPP_WEAK
+void
+operator delete[] (void* ptr, const std::nothrow_t&) noexcept
+{
+ ::operator delete[](ptr);
+}
+
+_LIBCPP_WEAK
+void
+operator delete[] (void* ptr, size_t) noexcept
+{
+ ::operator delete[](ptr);
+}
+
+#if !defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION)
+
+_LIBCPP_WEAK
+void *
+operator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC
+{
+ if (size == 0)
+ size = 1;
+ if (static_cast<size_t>(alignment) < sizeof(void*))
+ alignment = std::align_val_t(sizeof(void*));
+
+ // Try allocating memory. If allocation fails and there is a new_handler,
+ // call it to try free up memory, and try again until it succeeds, or until
+ // the new_handler decides to terminate.
+ //
+ // If allocation fails and there is no new_handler, we throw bad_alloc
+ // (or return nullptr if exceptions are disabled).
+ void* p;
+ while ((p = std::__libcpp_aligned_alloc(static_cast<std::size_t>(alignment), size)) == nullptr)
+ {
+ std::new_handler nh = std::get_new_handler();
+ if (nh)
+ nh();
+ else {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw std::bad_alloc();
+#else
+ break;
+#endif
+ }
+ }
+ return p;
+}
+
+_LIBCPP_WEAK
+void*
+operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept
+{
+ void* p = nullptr;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ p = ::operator new(size, alignment);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ return p;
+}
+
+_LIBCPP_WEAK
+void*
+operator new[](size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC
+{
+ return ::operator new(size, alignment);
+}
+
+_LIBCPP_WEAK
+void*
+operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept
+{
+ void* p = nullptr;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ p = ::operator new[](size, alignment);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+ return p;
+}
+
+_LIBCPP_WEAK
+void
+operator delete(void* ptr, std::align_val_t) noexcept
+{
+ std::__libcpp_aligned_free(ptr);
+}
+
+_LIBCPP_WEAK
+void
+operator delete(void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept
+{
+ ::operator delete(ptr, alignment);
+}
+
+_LIBCPP_WEAK
+void
+operator delete(void* ptr, size_t, std::align_val_t alignment) noexcept
+{
+ ::operator delete(ptr, alignment);
+}
+
+_LIBCPP_WEAK
+void
+operator delete[] (void* ptr, std::align_val_t alignment) noexcept
+{
+ ::operator delete(ptr, alignment);
+}
+
+_LIBCPP_WEAK
+void
+operator delete[] (void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept
+{
+ ::operator delete[](ptr, alignment);
+}
+
+_LIBCPP_WEAK
+void
+operator delete[] (void* ptr, size_t, std::align_val_t alignment) noexcept
+{
+ ::operator delete[](ptr, alignment);
+}
+
+#endif // !_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
+#endif // !__GLIBCXX__ && !_LIBCPP_ABI_VCRUNTIME && !_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/optional.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/optional.cpp
new file mode 100644
index 0000000000..e9573bfa30
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/optional.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <__availability>
+#include <optional>
+
+namespace std
+{
+
+bad_optional_access::~bad_optional_access() noexcept = default;
+
+const char* bad_optional_access::what() const noexcept {
+ return "bad_optional_access";
+ }
+
+} // std
+
+
+#include <experimental/__config>
+
+// Preserve std::experimental::bad_optional_access for ABI compatibility
+// Even though it no longer exists in a header file
+_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL
+
+class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optional_access
+ : public std::logic_error
+{
+public:
+ bad_optional_access() : std::logic_error("Bad optional Access") {}
+
+// Get the key function ~bad_optional_access() into the dylib
+ virtual ~bad_optional_access() noexcept;
+};
+
+bad_optional_access::~bad_optional_access() noexcept = default;
+
+_LIBCPP_END_NAMESPACE_EXPERIMENTAL
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/random.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/random.cpp
new file mode 100644
index 0000000000..466b015772
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/random.cpp
@@ -0,0 +1,220 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <__config>
+
+#if defined(_LIBCPP_USING_WIN32_RANDOM)
+ // Must be defined before including stdlib.h to enable rand_s().
+# define _CRT_RAND_S
+#endif // defined(_LIBCPP_USING_WIN32_RANDOM)
+
+#include <limits>
+#include <random>
+#include <system_error>
+
+#if defined(__sun__)
+# define rename solaris_headers_are_broken
+#endif // defined(__sun__)
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#if defined(_LIBCPP_USING_GETENTROPY)
+# include <sys/random.h>
+#elif defined(_LIBCPP_USING_DEV_RANDOM)
+# include <fcntl.h>
+# include <unistd.h>
+# if __has_include(<sys/ioctl.h>) && __has_include(<linux/random.h>)
+# include <sys/ioctl.h>
+# include <linux/random.h>
+# endif
+#elif defined(_LIBCPP_USING_NACL_RANDOM)
+# include <nacl/nacl_random.h>
+#elif defined(_LIBCPP_USING_FUCHSIA_CPRNG)
+# include <zircon/syscalls.h>
+#endif
+
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if defined(_LIBCPP_USING_GETENTROPY)
+
+random_device::random_device(const string& __token)
+{
+ if (__token != "/dev/urandom")
+ __throw_system_error(ENOENT, ("random device not supported " + __token).c_str());
+}
+
+random_device::~random_device()
+{
+}
+
+unsigned
+random_device::operator()()
+{
+ unsigned r;
+ size_t n = sizeof(r);
+ int err = getentropy(&r, n);
+ if (err)
+ __throw_system_error(errno, "random_device getentropy failed");
+ return r;
+}
+
+#elif defined(_LIBCPP_USING_ARC4_RANDOM)
+
+random_device::random_device(const string&)
+{
+}
+
+random_device::~random_device()
+{
+}
+
+unsigned
+random_device::operator()()
+{
+ return arc4random();
+}
+
+#elif defined(_LIBCPP_USING_DEV_RANDOM)
+
+random_device::random_device(const string& __token)
+ : __f_(open(__token.c_str(), O_RDONLY))
+{
+ if (__f_ < 0)
+ __throw_system_error(errno, ("random_device failed to open " + __token).c_str());
+}
+
+random_device::~random_device()
+{
+ close(__f_);
+}
+
+unsigned
+random_device::operator()()
+{
+ unsigned r;
+ size_t n = sizeof(r);
+ char* p = reinterpret_cast<char*>(&r);
+ while (n > 0)
+ {
+ ssize_t s = read(__f_, p, n);
+ if (s == 0)
+ __throw_system_error(ENODATA, "random_device got EOF");
+ if (s == -1)
+ {
+ if (errno != EINTR)
+ __throw_system_error(errno, "random_device got an unexpected error");
+ continue;
+ }
+ n -= static_cast<size_t>(s);
+ p += static_cast<size_t>(s);
+ }
+ return r;
+}
+
+#elif defined(_LIBCPP_USING_NACL_RANDOM)
+
+random_device::random_device(const string& __token)
+{
+ if (__token != "/dev/urandom")
+ __throw_system_error(ENOENT, ("random device not supported " + __token).c_str());
+ int error = nacl_secure_random_init();
+ if (error)
+ __throw_system_error(error, ("random device failed to open " + __token).c_str());
+}
+
+random_device::~random_device()
+{
+}
+
+unsigned
+random_device::operator()()
+{
+ unsigned r;
+ size_t n = sizeof(r);
+ size_t bytes_written;
+ int error = nacl_secure_random(&r, n, &bytes_written);
+ if (error != 0)
+ __throw_system_error(error, "random_device failed getting bytes");
+ else if (bytes_written != n)
+ __throw_runtime_error("random_device failed to obtain enough bytes");
+ return r;
+}
+
+#elif defined(_LIBCPP_USING_WIN32_RANDOM)
+
+random_device::random_device(const string& __token)
+{
+ if (__token != "/dev/urandom")
+ __throw_system_error(ENOENT, ("random device not supported " + __token).c_str());
+}
+
+random_device::~random_device()
+{
+}
+
+unsigned
+random_device::operator()()
+{
+ unsigned r;
+ errno_t err = rand_s(&r);
+ if (err)
+ __throw_system_error(err, "random_device rand_s failed.");
+ return r;
+}
+
+#elif defined(_LIBCPP_USING_FUCHSIA_CPRNG)
+
+random_device::random_device(const string& __token) {
+ if (__token != "/dev/urandom")
+ __throw_system_error(ENOENT, ("random device not supported " + __token).c_str());
+}
+
+random_device::~random_device() {}
+
+unsigned random_device::operator()() {
+ // Implicitly link against the vDSO system call ABI without
+ // requiring the final link to specify -lzircon explicitly when
+ // statically linking libc++.
+# pragma comment(lib, "zircon")
+
+ // The system call cannot fail. It returns only when the bits are ready.
+ unsigned r;
+ _zx_cprng_draw(&r, sizeof(r));
+ return r;
+}
+
+#else
+#error "Random device not implemented for this architecture"
+#endif
+
+double
+random_device::entropy() const noexcept
+{
+#if defined(_LIBCPP_USING_DEV_RANDOM) && defined(RNDGETENTCNT)
+ int ent;
+ if (::ioctl(__f_, RNDGETENTCNT, &ent) < 0)
+ return 0;
+
+ if (ent < 0)
+ return 0;
+
+ if (ent > std::numeric_limits<result_type>::digits)
+ return std::numeric_limits<result_type>::digits;
+
+ return ent;
+#elif defined(__OpenBSD__) || defined(_LIBCPP_USING_FUCHSIA_CPRNG)
+ return std::numeric_limits<result_type>::digits;
+#else
+ return 0;
+#endif
+}
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/random_shuffle.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/random_shuffle.cpp
new file mode 100644
index 0000000000..a673035b48
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/random_shuffle.cpp
@@ -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
+//
+//===----------------------------------------------------------------------===//
+
+#include <algorithm>
+#include <random>
+
+#ifndef _LIBCPP_HAS_NO_THREADS
+# include <mutex>
+# if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
+# pragma comment(lib, "pthread")
+# endif
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifndef _LIBCPP_HAS_NO_THREADS
+static _LIBCPP_CONSTINIT __libcpp_mutex_t __rs_mut = _LIBCPP_MUTEX_INITIALIZER;
+#endif
+unsigned __rs_default::__c_ = 0;
+
+__rs_default::__rs_default()
+{
+#ifndef _LIBCPP_HAS_NO_THREADS
+ __libcpp_mutex_lock(&__rs_mut);
+#endif
+ __c_ = 1;
+}
+
+__rs_default::__rs_default(const __rs_default&)
+{
+ ++__c_;
+}
+
+__rs_default::~__rs_default()
+{
+#ifndef _LIBCPP_HAS_NO_THREADS
+ if (--__c_ == 0)
+ __libcpp_mutex_unlock(&__rs_mut);
+#else
+ --__c_;
+#endif
+}
+
+__rs_default::result_type
+__rs_default::operator()()
+{
+ static mt19937 __rs_g;
+ return __rs_g();
+}
+
+__rs_default
+__rs_get()
+{
+ return __rs_default();
+}
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/regex.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/regex.cpp
new file mode 100644
index 0000000000..e53d324186
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/regex.cpp
@@ -0,0 +1,436 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <algorithm>
+#include <iterator>
+#include <regex>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+static
+const char*
+make_error_type_string(regex_constants::error_type ecode)
+{
+ switch (ecode)
+ {
+ case regex_constants::error_collate:
+ return "The expression contained an invalid collating element name.";
+ case regex_constants::error_ctype:
+ return "The expression contained an invalid character class name.";
+ case regex_constants::error_escape:
+ return "The expression contained an invalid escaped character, or a "
+ "trailing escape.";
+ case regex_constants::error_backref:
+ return "The expression contained an invalid back reference.";
+ case regex_constants::error_brack:
+ return "The expression contained mismatched [ and ].";
+ case regex_constants::error_paren:
+ return "The expression contained mismatched ( and ).";
+ case regex_constants::error_brace:
+ return "The expression contained mismatched { and }.";
+ case regex_constants::error_badbrace:
+ return "The expression contained an invalid range in a {} expression.";
+ case regex_constants::error_range:
+ return "The expression contained an invalid character range, "
+ "such as [b-a] in most encodings.";
+ case regex_constants::error_space:
+ return "There was insufficient memory to convert the expression into "
+ "a finite state machine.";
+ case regex_constants::error_badrepeat:
+ return "One of *?+{ was not preceded by a valid regular expression.";
+ case regex_constants::error_complexity:
+ return "The complexity of an attempted match against a regular "
+ "expression exceeded a pre-set level.";
+ case regex_constants::error_stack:
+ return "There was insufficient memory to determine whether the regular "
+ "expression could match the specified character sequence.";
+ case regex_constants::__re_err_grammar:
+ return "An invalid regex grammar has been requested.";
+ case regex_constants::__re_err_empty:
+ return "An empty regex is not allowed in the POSIX grammar.";
+ case regex_constants::__re_err_parse:
+ return "The parser did not consume the entire regular expression.";
+ default:
+ break;
+ }
+ return "Unknown error type";
+}
+
+regex_error::regex_error(regex_constants::error_type ecode)
+ : runtime_error(make_error_type_string(ecode)),
+ __code_(ecode)
+{}
+
+regex_error::~regex_error() throw() {}
+
+namespace {
+
+struct collationnames
+{
+ const char* elem_;
+ char char_;
+};
+
+#if defined(__MVS__) && !defined(__NATIVE_ASCII_F)
+// EBCDIC IBM-1047
+// Sorted via the EBCDIC collating sequence
+const collationnames collatenames[] =
+{
+ {"a", 0x81},
+ {"alert", 0x2f},
+ {"ampersand", 0x50},
+ {"apostrophe", 0x7d},
+ {"asterisk", 0x5c},
+ {"b", 0x82},
+ {"backslash", 0xe0},
+ {"backspace", 0x16},
+ {"c", 0x83},
+ {"carriage-return", 0xd},
+ {"circumflex", 0x5f},
+ {"circumflex-accent", 0x5f},
+ {"colon", 0x7a},
+ {"comma", 0x6b},
+ {"commercial-at", 0x7c},
+ {"d", 0x84},
+ {"dollar-sign", 0x5b},
+ {"e", 0x85},
+ {"eight", 0xf8},
+ {"equals-sign", 0x7e},
+ {"exclamation-mark", 0x5a},
+ {"f", 0x86},
+ {"five", 0xf5},
+ {"form-feed", 0xc},
+ {"four", 0xf4},
+ {"full-stop", 0x4b},
+ {"g", 0x87},
+ {"grave-accent", 0x79},
+ {"greater-than-sign", 0x6e},
+ {"h", 0x88},
+ {"hyphen", 0x60},
+ {"hyphen-minus", 0x60},
+ {"i", 0x89},
+ {"j", 0x91},
+ {"k", 0x92},
+ {"l", 0x93},
+ {"left-brace", 0xc0},
+ {"left-curly-bracket", 0xc0},
+ {"left-parenthesis", 0x4d},
+ {"left-square-bracket", 0xad},
+ {"less-than-sign", 0x4c},
+ {"low-line", 0x6d},
+ {"m", 0x94},
+ {"n", 0x95},
+ {"newline", 0x15},
+ {"nine", 0xf9},
+ {"number-sign", 0x7b},
+ {"o", 0x96},
+ {"one", 0xf1},
+ {"p", 0x97},
+ {"percent-sign", 0x6c},
+ {"period", 0x4b},
+ {"plus-sign", 0x4e},
+ {"q", 0x98},
+ {"question-mark", 0x6f},
+ {"quotation-mark", 0x7f},
+ {"r", 0x99},
+ {"reverse-solidus", 0xe0},
+ {"right-brace", 0xd0},
+ {"right-curly-bracket", 0xd0},
+ {"right-parenthesis", 0x5d},
+ {"right-square-bracket", 0xbd},
+ {"s", 0xa2},
+ {"semicolon", 0x5e},
+ {"seven", 0xf7},
+ {"six", 0xf6},
+ {"slash", 0x61},
+ {"solidus", 0x61},
+ {"space", 0x40},
+ {"t", 0xa3},
+ {"tab", 0x5},
+ {"three", 0xf3},
+ {"tilde", 0xa1},
+ {"two", 0xf2},
+ {"u", 0xa4},
+ {"underscore", 0x6d},
+ {"v", 0xa5},
+ {"vertical-line", 0x4f},
+ {"vertical-tab", 0xb},
+ {"w", 0xa6},
+ {"x", 0xa7},
+ {"y", 0xa8},
+ {"z", 0xa9},
+ {"zero", 0xf0},
+ {"A", 0xc1},
+ {"B", 0xc2},
+ {"C", 0xc3},
+ {"D", 0xc4},
+ {"E", 0xc5},
+ {"F", 0xc6},
+ {"G", 0xc7},
+ {"H", 0xc8},
+ {"I", 0xc9},
+ {"J", 0xd1},
+ {"K", 0xd2},
+ {"L", 0xd3},
+ {"M", 0xd4},
+ {"N", 0xd5},
+ {"NUL", 0},
+ {"O", 0xd6},
+ {"P", 0xd7},
+ {"Q", 0xd8},
+ {"R", 0xd9},
+ {"S", 0xe2},
+ {"T", 0xe3},
+ {"U", 0xe4},
+ {"V", 0xe5},
+ {"W", 0xe6},
+ {"X", 0xe7},
+ {"Y", 0xe8},
+ {"Z", 0xe9}
+};
+#else
+// ASCII
+const collationnames collatenames[] =
+{
+ {"A", 0x41},
+ {"B", 0x42},
+ {"C", 0x43},
+ {"D", 0x44},
+ {"E", 0x45},
+ {"F", 0x46},
+ {"G", 0x47},
+ {"H", 0x48},
+ {"I", 0x49},
+ {"J", 0x4a},
+ {"K", 0x4b},
+ {"L", 0x4c},
+ {"M", 0x4d},
+ {"N", 0x4e},
+ {"NUL", 0x00},
+ {"O", 0x4f},
+ {"P", 0x50},
+ {"Q", 0x51},
+ {"R", 0x52},
+ {"S", 0x53},
+ {"T", 0x54},
+ {"U", 0x55},
+ {"V", 0x56},
+ {"W", 0x57},
+ {"X", 0x58},
+ {"Y", 0x59},
+ {"Z", 0x5a},
+ {"a", 0x61},
+ {"alert", 0x07},
+ {"ampersand", 0x26},
+ {"apostrophe", 0x27},
+ {"asterisk", 0x2a},
+ {"b", 0x62},
+ {"backslash", 0x5c},
+ {"backspace", 0x08},
+ {"c", 0x63},
+ {"carriage-return", 0x0d},
+ {"circumflex", 0x5e},
+ {"circumflex-accent", 0x5e},
+ {"colon", 0x3a},
+ {"comma", 0x2c},
+ {"commercial-at", 0x40},
+ {"d", 0x64},
+ {"dollar-sign", 0x24},
+ {"e", 0x65},
+ {"eight", 0x38},
+ {"equals-sign", 0x3d},
+ {"exclamation-mark", 0x21},
+ {"f", 0x66},
+ {"five", 0x35},
+ {"form-feed", 0x0c},
+ {"four", 0x34},
+ {"full-stop", 0x2e},
+ {"g", 0x67},
+ {"grave-accent", 0x60},
+ {"greater-than-sign", 0x3e},
+ {"h", 0x68},
+ {"hyphen", 0x2d},
+ {"hyphen-minus", 0x2d},
+ {"i", 0x69},
+ {"j", 0x6a},
+ {"k", 0x6b},
+ {"l", 0x6c},
+ {"left-brace", 0x7b},
+ {"left-curly-bracket", 0x7b},
+ {"left-parenthesis", 0x28},
+ {"left-square-bracket", 0x5b},
+ {"less-than-sign", 0x3c},
+ {"low-line", 0x5f},
+ {"m", 0x6d},
+ {"n", 0x6e},
+ {"newline", 0x0a},
+ {"nine", 0x39},
+ {"number-sign", 0x23},
+ {"o", 0x6f},
+ {"one", 0x31},
+ {"p", 0x70},
+ {"percent-sign", 0x25},
+ {"period", 0x2e},
+ {"plus-sign", 0x2b},
+ {"q", 0x71},
+ {"question-mark", 0x3f},
+ {"quotation-mark", 0x22},
+ {"r", 0x72},
+ {"reverse-solidus", 0x5c},
+ {"right-brace", 0x7d},
+ {"right-curly-bracket", 0x7d},
+ {"right-parenthesis", 0x29},
+ {"right-square-bracket", 0x5d},
+ {"s", 0x73},
+ {"semicolon", 0x3b},
+ {"seven", 0x37},
+ {"six", 0x36},
+ {"slash", 0x2f},
+ {"solidus", 0x2f},
+ {"space", 0x20},
+ {"t", 0x74},
+ {"tab", 0x09},
+ {"three", 0x33},
+ {"tilde", 0x7e},
+ {"two", 0x32},
+ {"u", 0x75},
+ {"underscore", 0x5f},
+ {"v", 0x76},
+ {"vertical-line", 0x7c},
+ {"vertical-tab", 0x0b},
+ {"w", 0x77},
+ {"x", 0x78},
+ {"y", 0x79},
+ {"z", 0x7a},
+ {"zero", 0x30}
+};
+#endif
+
+struct classnames
+{
+ const char* elem_;
+ regex_traits<char>::char_class_type mask_;
+};
+
+const classnames ClassNames[] =
+{
+ {"alnum", ctype_base::alnum},
+ {"alpha", ctype_base::alpha},
+ {"blank", ctype_base::blank},
+ {"cntrl", ctype_base::cntrl},
+ {"d", ctype_base::digit},
+ {"digit", ctype_base::digit},
+ {"graph", ctype_base::graph},
+ {"lower", ctype_base::lower},
+ {"print", ctype_base::print},
+ {"punct", ctype_base::punct},
+ {"s", ctype_base::space},
+ {"space", ctype_base::space},
+ {"upper", ctype_base::upper},
+ {"w", regex_traits<char>::__regex_word},
+ {"xdigit", ctype_base::xdigit}
+};
+
+struct use_strcmp
+{
+ bool operator()(const collationnames& x, const char* y)
+ {return strcmp(x.elem_, y) < 0;}
+ bool operator()(const classnames& x, const char* y)
+ {return strcmp(x.elem_, y) < 0;}
+};
+
+}
+
+string
+__get_collation_name(const char* s)
+{
+ const collationnames* i =
+ _VSTD::lower_bound(begin(collatenames), end(collatenames), s, use_strcmp());
+ string r;
+ if (i != end(collatenames) && strcmp(s, i->elem_) == 0)
+ r = char(i->char_);
+ return r;
+}
+
+regex_traits<char>::char_class_type
+__get_classname(const char* s, bool __icase)
+{
+ const classnames* i =
+ _VSTD::lower_bound(begin(ClassNames), end(ClassNames), s, use_strcmp());
+ regex_traits<char>::char_class_type r = 0;
+ if (i != end(ClassNames) && strcmp(s, i->elem_) == 0)
+ {
+ r = i->mask_;
+ if (r == regex_traits<char>::__regex_word)
+ r |= ctype_base::alnum | ctype_base::upper | ctype_base::lower;
+ else if (__icase)
+ {
+ if (r & (ctype_base::lower | ctype_base::upper))
+ r |= ctype_base::alpha;
+ }
+ }
+ return r;
+}
+
+template <>
+void
+__match_any_but_newline<char>::__exec(__state& __s) const
+{
+ if (__s.__current_ != __s.__last_)
+ {
+ switch (*__s.__current_)
+ {
+ case '\r':
+ case '\n':
+ __s.__do_ = __state::__reject;
+ __s.__node_ = nullptr;
+ break;
+ default:
+ __s.__do_ = __state::__accept_and_consume;
+ ++__s.__current_;
+ __s.__node_ = this->first();
+ break;
+ }
+ }
+ else
+ {
+ __s.__do_ = __state::__reject;
+ __s.__node_ = nullptr;
+ }
+}
+
+template <>
+void
+__match_any_but_newline<wchar_t>::__exec(__state& __s) const
+{
+ if (__s.__current_ != __s.__last_)
+ {
+ switch (*__s.__current_)
+ {
+ case '\r':
+ case '\n':
+ case 0x2028:
+ case 0x2029:
+ __s.__do_ = __state::__reject;
+ __s.__node_ = nullptr;
+ break;
+ default:
+ __s.__do_ = __state::__accept_and_consume;
+ ++__s.__current_;
+ __s.__node_ = this->first();
+ break;
+ }
+ }
+ else
+ {
+ __s.__do_ = __state::__reject;
+ __s.__node_ = nullptr;
+ }
+}
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/ryu/README.txt b/contrib/libs/cxxsupp/libcxxmsvc/src/ryu/README.txt
new file mode 100644
index 0000000000..e3d17469d4
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/ryu/README.txt
@@ -0,0 +1,11 @@
+The code in this directory is based on Ulf Adams's work. The upstream for the
+code is:
+
+https://github.com/ulfjack/ryu/tree/59661c3/ryu
+
+The code has been adapted by Stephan T. Lavavej of Microsoft for usage in
+std::to_chars. This code has been contributed by Microsoft for inclusion in
+libc++.
+
+The code in this directory has a different coding style than other parts to
+minimize the number of changes by both upstream sources.
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/ryu/d2fixed.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/ryu/d2fixed.cpp
new file mode 100644
index 0000000000..c1a1f6cf9e
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/ryu/d2fixed.cpp
@@ -0,0 +1,670 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (c) Microsoft Corporation.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+// Copyright 2018 Ulf Adams
+// Copyright (c) Microsoft Corporation. All rights reserved.
+
+// Boost Software License - Version 1.0 - August 17th, 2003
+
+// Permission is hereby granted, free of charge, to any person or organization
+// obtaining a copy of the software and accompanying documentation covered by
+// this license (the "Software") to use, reproduce, display, distribute,
+// execute, and transmit the Software, and to prepare derivative works of the
+// Software, and to permit third-parties to whom the Software is furnished to
+// do so, all subject to the following:
+
+// The copyright notices in the Software and this entire statement, including
+// the above license grant, this restriction and the following disclaimer,
+// must be included in all copies of the Software, in whole or in part, and
+// all derivative works of the Software, unless such copies or derivative
+// works are solely in the form of machine-executable object code generated by
+// a source language processor.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+// Avoid formatting to keep the changes with the original code minimal.
+// clang-format off
+
+#include <__assert>
+#include <__config>
+#include <charconv>
+#include <cstring>
+#include <system_error>
+
+#include "include/ryu/common.h"
+#include "include/ryu/d2fixed.h"
+#include "include/ryu/d2fixed_full_table.h"
+#include "include/ryu/d2s.h"
+#include "include/ryu/d2s_intrinsics.h"
+#include "include/ryu/digit_table.h"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+inline constexpr int __POW10_ADDITIONAL_BITS = 120;
+
+#ifdef _LIBCPP_INTRINSIC128
+// Returns the low 64 bits of the high 128 bits of the 256-bit product of a and b.
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __umul256_hi128_lo64(
+ const uint64_t __aHi, const uint64_t __aLo, const uint64_t __bHi, const uint64_t __bLo) {
+ uint64_t __b00Hi;
+ const uint64_t __b00Lo = __ryu_umul128(__aLo, __bLo, &__b00Hi);
+ uint64_t __b01Hi;
+ const uint64_t __b01Lo = __ryu_umul128(__aLo, __bHi, &__b01Hi);
+ uint64_t __b10Hi;
+ const uint64_t __b10Lo = __ryu_umul128(__aHi, __bLo, &__b10Hi);
+ uint64_t __b11Hi;
+ const uint64_t __b11Lo = __ryu_umul128(__aHi, __bHi, &__b11Hi);
+ (void) __b00Lo; // unused
+ (void) __b11Hi; // unused
+ const uint64_t __temp1Lo = __b10Lo + __b00Hi;
+ const uint64_t __temp1Hi = __b10Hi + (__temp1Lo < __b10Lo);
+ const uint64_t __temp2Lo = __b01Lo + __temp1Lo;
+ const uint64_t __temp2Hi = __b01Hi + (__temp2Lo < __b01Lo);
+ return __b11Lo + __temp1Hi + __temp2Hi;
+}
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __uint128_mod1e9(const uint64_t __vHi, const uint64_t __vLo) {
+ // After multiplying, we're going to shift right by 29, then truncate to uint32_t.
+ // This means that we need only 29 + 32 = 61 bits, so we can truncate to uint64_t before shifting.
+ const uint64_t __multiplied = __umul256_hi128_lo64(__vHi, __vLo, 0x89705F4136B4A597u, 0x31680A88F8953031u);
+
+ // For uint32_t truncation, see the __mod1e9() comment in d2s_intrinsics.h.
+ const uint32_t __shifted = static_cast<uint32_t>(__multiplied >> 29);
+
+ return static_cast<uint32_t>(__vLo) - 1000000000 * __shifted;
+}
+#endif // ^^^ intrinsics available ^^^
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __mulShift_mod1e9(const uint64_t __m, const uint64_t* const __mul, const int32_t __j) {
+ uint64_t __high0; // 64
+ const uint64_t __low0 = __ryu_umul128(__m, __mul[0], &__high0); // 0
+ uint64_t __high1; // 128
+ const uint64_t __low1 = __ryu_umul128(__m, __mul[1], &__high1); // 64
+ uint64_t __high2; // 192
+ const uint64_t __low2 = __ryu_umul128(__m, __mul[2], &__high2); // 128
+ const uint64_t __s0low = __low0; // 0
+ (void) __s0low; // unused
+ const uint64_t __s0high = __low1 + __high0; // 64
+ const uint32_t __c1 = __s0high < __low1;
+ const uint64_t __s1low = __low2 + __high1 + __c1; // 128
+ const uint32_t __c2 = __s1low < __low2; // __high1 + __c1 can't overflow, so compare against __low2
+ const uint64_t __s1high = __high2 + __c2; // 192
+ _LIBCPP_ASSERT(__j >= 128, "");
+ _LIBCPP_ASSERT(__j <= 180, "");
+#ifdef _LIBCPP_INTRINSIC128
+ const uint32_t __dist = static_cast<uint32_t>(__j - 128); // __dist: [0, 52]
+ const uint64_t __shiftedhigh = __s1high >> __dist;
+ const uint64_t __shiftedlow = __ryu_shiftright128(__s1low, __s1high, __dist);
+ return __uint128_mod1e9(__shiftedhigh, __shiftedlow);
+#else // ^^^ intrinsics available ^^^ / vvv intrinsics unavailable vvv
+ if (__j < 160) { // __j: [128, 160)
+ const uint64_t __r0 = __mod1e9(__s1high);
+ const uint64_t __r1 = __mod1e9((__r0 << 32) | (__s1low >> 32));
+ const uint64_t __r2 = ((__r1 << 32) | (__s1low & 0xffffffff));
+ return __mod1e9(__r2 >> (__j - 128));
+ } else { // __j: [160, 192)
+ const uint64_t __r0 = __mod1e9(__s1high);
+ const uint64_t __r1 = ((__r0 << 32) | (__s1low >> 32));
+ return __mod1e9(__r1 >> (__j - 160));
+ }
+#endif // ^^^ intrinsics unavailable ^^^
+}
+
+void __append_n_digits(const uint32_t __olength, uint32_t __digits, char* const __result) {
+ uint32_t __i = 0;
+ while (__digits >= 10000) {
+#ifdef __clang__ // TRANSITION, LLVM-38217
+ const uint32_t __c = __digits - 10000 * (__digits / 10000);
+#else
+ const uint32_t __c = __digits % 10000;
+#endif
+ __digits /= 10000;
+ const uint32_t __c0 = (__c % 100) << 1;
+ const uint32_t __c1 = (__c / 100) << 1;
+ _VSTD::memcpy(__result + __olength - __i - 2, __DIGIT_TABLE + __c0, 2);
+ _VSTD::memcpy(__result + __olength - __i - 4, __DIGIT_TABLE + __c1, 2);
+ __i += 4;
+ }
+ if (__digits >= 100) {
+ const uint32_t __c = (__digits % 100) << 1;
+ __digits /= 100;
+ _VSTD::memcpy(__result + __olength - __i - 2, __DIGIT_TABLE + __c, 2);
+ __i += 2;
+ }
+ if (__digits >= 10) {
+ const uint32_t __c = __digits << 1;
+ _VSTD::memcpy(__result + __olength - __i - 2, __DIGIT_TABLE + __c, 2);
+ } else {
+ __result[0] = static_cast<char>('0' + __digits);
+ }
+}
+
+_LIBCPP_HIDE_FROM_ABI inline void __append_d_digits(const uint32_t __olength, uint32_t __digits, char* const __result) {
+ uint32_t __i = 0;
+ while (__digits >= 10000) {
+#ifdef __clang__ // TRANSITION, LLVM-38217
+ const uint32_t __c = __digits - 10000 * (__digits / 10000);
+#else
+ const uint32_t __c = __digits % 10000;
+#endif
+ __digits /= 10000;
+ const uint32_t __c0 = (__c % 100) << 1;
+ const uint32_t __c1 = (__c / 100) << 1;
+ _VSTD::memcpy(__result + __olength + 1 - __i - 2, __DIGIT_TABLE + __c0, 2);
+ _VSTD::memcpy(__result + __olength + 1 - __i - 4, __DIGIT_TABLE + __c1, 2);
+ __i += 4;
+ }
+ if (__digits >= 100) {
+ const uint32_t __c = (__digits % 100) << 1;
+ __digits /= 100;
+ _VSTD::memcpy(__result + __olength + 1 - __i - 2, __DIGIT_TABLE + __c, 2);
+ __i += 2;
+ }
+ if (__digits >= 10) {
+ const uint32_t __c = __digits << 1;
+ __result[2] = __DIGIT_TABLE[__c + 1];
+ __result[1] = '.';
+ __result[0] = __DIGIT_TABLE[__c];
+ } else {
+ __result[1] = '.';
+ __result[0] = static_cast<char>('0' + __digits);
+ }
+}
+
+_LIBCPP_HIDE_FROM_ABI inline void __append_c_digits(const uint32_t __count, uint32_t __digits, char* const __result) {
+ uint32_t __i = 0;
+ for (; __i < __count - 1; __i += 2) {
+ const uint32_t __c = (__digits % 100) << 1;
+ __digits /= 100;
+ _VSTD::memcpy(__result + __count - __i - 2, __DIGIT_TABLE + __c, 2);
+ }
+ if (__i < __count) {
+ const char __c = static_cast<char>('0' + (__digits % 10));
+ __result[__count - __i - 1] = __c;
+ }
+}
+
+void __append_nine_digits(uint32_t __digits, char* const __result) {
+ if (__digits == 0) {
+ _VSTD::memset(__result, '0', 9);
+ return;
+ }
+
+ for (uint32_t __i = 0; __i < 5; __i += 4) {
+#ifdef __clang__ // TRANSITION, LLVM-38217
+ const uint32_t __c = __digits - 10000 * (__digits / 10000);
+#else
+ const uint32_t __c = __digits % 10000;
+#endif
+ __digits /= 10000;
+ const uint32_t __c0 = (__c % 100) << 1;
+ const uint32_t __c1 = (__c / 100) << 1;
+ _VSTD::memcpy(__result + 7 - __i, __DIGIT_TABLE + __c0, 2);
+ _VSTD::memcpy(__result + 5 - __i, __DIGIT_TABLE + __c1, 2);
+ }
+ __result[0] = static_cast<char>('0' + __digits);
+}
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __indexForExponent(const uint32_t __e) {
+ return (__e + 15) / 16;
+}
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __pow10BitsForIndex(const uint32_t __idx) {
+ return 16 * __idx + __POW10_ADDITIONAL_BITS;
+}
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __lengthForIndex(const uint32_t __idx) {
+ // +1 for ceil, +16 for mantissa, +8 to round up when dividing by 9
+ return (__log10Pow2(16 * static_cast<int32_t>(__idx)) + 1 + 16 + 8) / 9;
+}
+
+[[nodiscard]] to_chars_result __d2fixed_buffered_n(char* _First, char* const _Last, const double __d,
+ const uint32_t __precision) {
+ char* const _Original_first = _First;
+
+ const uint64_t __bits = __double_to_bits(__d);
+
+ // Case distinction; exit early for the easy cases.
+ if (__bits == 0) {
+ const int32_t _Total_zero_length = 1 // leading zero
+ + static_cast<int32_t>(__precision != 0) // possible decimal point
+ + static_cast<int32_t>(__precision); // zeroes after decimal point
+
+ if (_Last - _First < _Total_zero_length) {
+ return { _Last, errc::value_too_large };
+ }
+
+ *_First++ = '0';
+ if (__precision > 0) {
+ *_First++ = '.';
+ _VSTD::memset(_First, '0', __precision);
+ _First += __precision;
+ }
+ return { _First, errc{} };
+ }
+
+ // Decode __bits into mantissa and exponent.
+ const uint64_t __ieeeMantissa = __bits & ((1ull << __DOUBLE_MANTISSA_BITS) - 1);
+ const uint32_t __ieeeExponent = static_cast<uint32_t>(__bits >> __DOUBLE_MANTISSA_BITS);
+
+ int32_t __e2;
+ uint64_t __m2;
+ if (__ieeeExponent == 0) {
+ __e2 = 1 - __DOUBLE_BIAS - __DOUBLE_MANTISSA_BITS;
+ __m2 = __ieeeMantissa;
+ } else {
+ __e2 = static_cast<int32_t>(__ieeeExponent) - __DOUBLE_BIAS - __DOUBLE_MANTISSA_BITS;
+ __m2 = (1ull << __DOUBLE_MANTISSA_BITS) | __ieeeMantissa;
+ }
+
+ bool __nonzero = false;
+ if (__e2 >= -52) {
+ const uint32_t __idx = __e2 < 0 ? 0 : __indexForExponent(static_cast<uint32_t>(__e2));
+ const uint32_t __p10bits = __pow10BitsForIndex(__idx);
+ const int32_t __len = static_cast<int32_t>(__lengthForIndex(__idx));
+ for (int32_t __i = __len - 1; __i >= 0; --__i) {
+ const uint32_t __j = __p10bits - __e2;
+ // Temporary: __j is usually around 128, and by shifting a bit, we push it to 128 or above, which is
+ // a slightly faster code path in __mulShift_mod1e9. Instead, we can just increase the multipliers.
+ const uint32_t __digits = __mulShift_mod1e9(__m2 << 8, __POW10_SPLIT[__POW10_OFFSET[__idx] + __i],
+ static_cast<int32_t>(__j + 8));
+ if (__nonzero) {
+ if (_Last - _First < 9) {
+ return { _Last, errc::value_too_large };
+ }
+ __append_nine_digits(__digits, _First);
+ _First += 9;
+ } else if (__digits != 0) {
+ const uint32_t __olength = __decimalLength9(__digits);
+ if (_Last - _First < static_cast<ptrdiff_t>(__olength)) {
+ return { _Last, errc::value_too_large };
+ }
+ __append_n_digits(__olength, __digits, _First);
+ _First += __olength;
+ __nonzero = true;
+ }
+ }
+ }
+ if (!__nonzero) {
+ if (_First == _Last) {
+ return { _Last, errc::value_too_large };
+ }
+ *_First++ = '0';
+ }
+ if (__precision > 0) {
+ if (_First == _Last) {
+ return { _Last, errc::value_too_large };
+ }
+ *_First++ = '.';
+ }
+ if (__e2 < 0) {
+ const int32_t __idx = -__e2 / 16;
+ const uint32_t __blocks = __precision / 9 + 1;
+ // 0 = don't round up; 1 = round up unconditionally; 2 = round up if odd.
+ int __roundUp = 0;
+ uint32_t __i = 0;
+ if (__blocks <= __MIN_BLOCK_2[__idx]) {
+ __i = __blocks;
+ if (_Last - _First < static_cast<ptrdiff_t>(__precision)) {
+ return { _Last, errc::value_too_large };
+ }
+ _VSTD::memset(_First, '0', __precision);
+ _First += __precision;
+ } else if (__i < __MIN_BLOCK_2[__idx]) {
+ __i = __MIN_BLOCK_2[__idx];
+ if (_Last - _First < static_cast<ptrdiff_t>(9 * __i)) {
+ return { _Last, errc::value_too_large };
+ }
+ _VSTD::memset(_First, '0', 9 * __i);
+ _First += 9 * __i;
+ }
+ for (; __i < __blocks; ++__i) {
+ const int32_t __j = __ADDITIONAL_BITS_2 + (-__e2 - 16 * __idx);
+ const uint32_t __p = __POW10_OFFSET_2[__idx] + __i - __MIN_BLOCK_2[__idx];
+ if (__p >= __POW10_OFFSET_2[__idx + 1]) {
+ // If the remaining digits are all 0, then we might as well use memset.
+ // No rounding required in this case.
+ const uint32_t __fill = __precision - 9 * __i;
+ if (_Last - _First < static_cast<ptrdiff_t>(__fill)) {
+ return { _Last, errc::value_too_large };
+ }
+ _VSTD::memset(_First, '0', __fill);
+ _First += __fill;
+ break;
+ }
+ // Temporary: __j is usually around 128, and by shifting a bit, we push it to 128 or above, which is
+ // a slightly faster code path in __mulShift_mod1e9. Instead, we can just increase the multipliers.
+ uint32_t __digits = __mulShift_mod1e9(__m2 << 8, __POW10_SPLIT_2[__p], __j + 8);
+ if (__i < __blocks - 1) {
+ if (_Last - _First < 9) {
+ return { _Last, errc::value_too_large };
+ }
+ __append_nine_digits(__digits, _First);
+ _First += 9;
+ } else {
+ const uint32_t __maximum = __precision - 9 * __i;
+ uint32_t __lastDigit = 0;
+ for (uint32_t __k = 0; __k < 9 - __maximum; ++__k) {
+ __lastDigit = __digits % 10;
+ __digits /= 10;
+ }
+ if (__lastDigit != 5) {
+ __roundUp = __lastDigit > 5;
+ } else {
+ // Is m * 10^(additionalDigits + 1) / 2^(-__e2) integer?
+ const int32_t __requiredTwos = -__e2 - static_cast<int32_t>(__precision) - 1;
+ const bool __trailingZeros = __requiredTwos <= 0
+ || (__requiredTwos < 60 && __multipleOfPowerOf2(__m2, static_cast<uint32_t>(__requiredTwos)));
+ __roundUp = __trailingZeros ? 2 : 1;
+ }
+ if (__maximum > 0) {
+ if (_Last - _First < static_cast<ptrdiff_t>(__maximum)) {
+ return { _Last, errc::value_too_large };
+ }
+ __append_c_digits(__maximum, __digits, _First);
+ _First += __maximum;
+ }
+ break;
+ }
+ }
+ if (__roundUp != 0) {
+ char* _Round = _First;
+ char* _Dot = _Last;
+ while (true) {
+ if (_Round == _Original_first) {
+ _Round[0] = '1';
+ if (_Dot != _Last) {
+ _Dot[0] = '0';
+ _Dot[1] = '.';
+ }
+ if (_First == _Last) {
+ return { _Last, errc::value_too_large };
+ }
+ *_First++ = '0';
+ break;
+ }
+ --_Round;
+ const char __c = _Round[0];
+ if (__c == '.') {
+ _Dot = _Round;
+ } else if (__c == '9') {
+ _Round[0] = '0';
+ __roundUp = 1;
+ } else {
+ if (__roundUp == 1 || __c % 2 != 0) {
+ _Round[0] = __c + 1;
+ }
+ break;
+ }
+ }
+ }
+ } else {
+ if (_Last - _First < static_cast<ptrdiff_t>(__precision)) {
+ return { _Last, errc::value_too_large };
+ }
+ _VSTD::memset(_First, '0', __precision);
+ _First += __precision;
+ }
+ return { _First, errc{} };
+}
+
+[[nodiscard]] to_chars_result __d2exp_buffered_n(char* _First, char* const _Last, const double __d,
+ uint32_t __precision) {
+ char* const _Original_first = _First;
+
+ const uint64_t __bits = __double_to_bits(__d);
+
+ // Case distinction; exit early for the easy cases.
+ if (__bits == 0) {
+ const int32_t _Total_zero_length = 1 // leading zero
+ + static_cast<int32_t>(__precision != 0) // possible decimal point
+ + static_cast<int32_t>(__precision) // zeroes after decimal point
+ + 4; // "e+00"
+ if (_Last - _First < _Total_zero_length) {
+ return { _Last, errc::value_too_large };
+ }
+ *_First++ = '0';
+ if (__precision > 0) {
+ *_First++ = '.';
+ _VSTD::memset(_First, '0', __precision);
+ _First += __precision;
+ }
+ _VSTD::memcpy(_First, "e+00", 4);
+ _First += 4;
+ return { _First, errc{} };
+ }
+
+ // Decode __bits into mantissa and exponent.
+ const uint64_t __ieeeMantissa = __bits & ((1ull << __DOUBLE_MANTISSA_BITS) - 1);
+ const uint32_t __ieeeExponent = static_cast<uint32_t>(__bits >> __DOUBLE_MANTISSA_BITS);
+
+ int32_t __e2;
+ uint64_t __m2;
+ if (__ieeeExponent == 0) {
+ __e2 = 1 - __DOUBLE_BIAS - __DOUBLE_MANTISSA_BITS;
+ __m2 = __ieeeMantissa;
+ } else {
+ __e2 = static_cast<int32_t>(__ieeeExponent) - __DOUBLE_BIAS - __DOUBLE_MANTISSA_BITS;
+ __m2 = (1ull << __DOUBLE_MANTISSA_BITS) | __ieeeMantissa;
+ }
+
+ const bool __printDecimalPoint = __precision > 0;
+ ++__precision;
+ uint32_t __digits = 0;
+ uint32_t __printedDigits = 0;
+ uint32_t __availableDigits = 0;
+ int32_t __exp = 0;
+ if (__e2 >= -52) {
+ const uint32_t __idx = __e2 < 0 ? 0 : __indexForExponent(static_cast<uint32_t>(__e2));
+ const uint32_t __p10bits = __pow10BitsForIndex(__idx);
+ const int32_t __len = static_cast<int32_t>(__lengthForIndex(__idx));
+ for (int32_t __i = __len - 1; __i >= 0; --__i) {
+ const uint32_t __j = __p10bits - __e2;
+ // Temporary: __j is usually around 128, and by shifting a bit, we push it to 128 or above, which is
+ // a slightly faster code path in __mulShift_mod1e9. Instead, we can just increase the multipliers.
+ __digits = __mulShift_mod1e9(__m2 << 8, __POW10_SPLIT[__POW10_OFFSET[__idx] + __i],
+ static_cast<int32_t>(__j + 8));
+ if (__printedDigits != 0) {
+ if (__printedDigits + 9 > __precision) {
+ __availableDigits = 9;
+ break;
+ }
+ if (_Last - _First < 9) {
+ return { _Last, errc::value_too_large };
+ }
+ __append_nine_digits(__digits, _First);
+ _First += 9;
+ __printedDigits += 9;
+ } else if (__digits != 0) {
+ __availableDigits = __decimalLength9(__digits);
+ __exp = __i * 9 + static_cast<int32_t>(__availableDigits) - 1;
+ if (__availableDigits > __precision) {
+ break;
+ }
+ if (__printDecimalPoint) {
+ if (_Last - _First < static_cast<ptrdiff_t>(__availableDigits + 1)) {
+ return { _Last, errc::value_too_large };
+ }
+ __append_d_digits(__availableDigits, __digits, _First);
+ _First += __availableDigits + 1; // +1 for decimal point
+ } else {
+ if (_First == _Last) {
+ return { _Last, errc::value_too_large };
+ }
+ *_First++ = static_cast<char>('0' + __digits);
+ }
+ __printedDigits = __availableDigits;
+ __availableDigits = 0;
+ }
+ }
+ }
+
+ if (__e2 < 0 && __availableDigits == 0) {
+ const int32_t __idx = -__e2 / 16;
+ for (int32_t __i = __MIN_BLOCK_2[__idx]; __i < 200; ++__i) {
+ const int32_t __j = __ADDITIONAL_BITS_2 + (-__e2 - 16 * __idx);
+ const uint32_t __p = __POW10_OFFSET_2[__idx] + static_cast<uint32_t>(__i) - __MIN_BLOCK_2[__idx];
+ // Temporary: __j is usually around 128, and by shifting a bit, we push it to 128 or above, which is
+ // a slightly faster code path in __mulShift_mod1e9. Instead, we can just increase the multipliers.
+ __digits = (__p >= __POW10_OFFSET_2[__idx + 1]) ? 0 : __mulShift_mod1e9(__m2 << 8, __POW10_SPLIT_2[__p], __j + 8);
+ if (__printedDigits != 0) {
+ if (__printedDigits + 9 > __precision) {
+ __availableDigits = 9;
+ break;
+ }
+ if (_Last - _First < 9) {
+ return { _Last, errc::value_too_large };
+ }
+ __append_nine_digits(__digits, _First);
+ _First += 9;
+ __printedDigits += 9;
+ } else if (__digits != 0) {
+ __availableDigits = __decimalLength9(__digits);
+ __exp = -(__i + 1) * 9 + static_cast<int32_t>(__availableDigits) - 1;
+ if (__availableDigits > __precision) {
+ break;
+ }
+ if (__printDecimalPoint) {
+ if (_Last - _First < static_cast<ptrdiff_t>(__availableDigits + 1)) {
+ return { _Last, errc::value_too_large };
+ }
+ __append_d_digits(__availableDigits, __digits, _First);
+ _First += __availableDigits + 1; // +1 for decimal point
+ } else {
+ if (_First == _Last) {
+ return { _Last, errc::value_too_large };
+ }
+ *_First++ = static_cast<char>('0' + __digits);
+ }
+ __printedDigits = __availableDigits;
+ __availableDigits = 0;
+ }
+ }
+ }
+
+ const uint32_t __maximum = __precision - __printedDigits;
+ if (__availableDigits == 0) {
+ __digits = 0;
+ }
+ uint32_t __lastDigit = 0;
+ if (__availableDigits > __maximum) {
+ for (uint32_t __k = 0; __k < __availableDigits - __maximum; ++__k) {
+ __lastDigit = __digits % 10;
+ __digits /= 10;
+ }
+ }
+ // 0 = don't round up; 1 = round up unconditionally; 2 = round up if odd.
+ int __roundUp = 0;
+ if (__lastDigit != 5) {
+ __roundUp = __lastDigit > 5;
+ } else {
+ // Is m * 2^__e2 * 10^(__precision + 1 - __exp) integer?
+ // __precision was already increased by 1, so we don't need to write + 1 here.
+ const int32_t __rexp = static_cast<int32_t>(__precision) - __exp;
+ const int32_t __requiredTwos = -__e2 - __rexp;
+ bool __trailingZeros = __requiredTwos <= 0
+ || (__requiredTwos < 60 && __multipleOfPowerOf2(__m2, static_cast<uint32_t>(__requiredTwos)));
+ if (__rexp < 0) {
+ const int32_t __requiredFives = -__rexp;
+ __trailingZeros = __trailingZeros && __multipleOfPowerOf5(__m2, static_cast<uint32_t>(__requiredFives));
+ }
+ __roundUp = __trailingZeros ? 2 : 1;
+ }
+ if (__printedDigits != 0) {
+ if (_Last - _First < static_cast<ptrdiff_t>(__maximum)) {
+ return { _Last, errc::value_too_large };
+ }
+ if (__digits == 0) {
+ _VSTD::memset(_First, '0', __maximum);
+ } else {
+ __append_c_digits(__maximum, __digits, _First);
+ }
+ _First += __maximum;
+ } else {
+ if (__printDecimalPoint) {
+ if (_Last - _First < static_cast<ptrdiff_t>(__maximum + 1)) {
+ return { _Last, errc::value_too_large };
+ }
+ __append_d_digits(__maximum, __digits, _First);
+ _First += __maximum + 1; // +1 for decimal point
+ } else {
+ if (_First == _Last) {
+ return { _Last, errc::value_too_large };
+ }
+ *_First++ = static_cast<char>('0' + __digits);
+ }
+ }
+ if (__roundUp != 0) {
+ char* _Round = _First;
+ while (true) {
+ if (_Round == _Original_first) {
+ _Round[0] = '1';
+ ++__exp;
+ break;
+ }
+ --_Round;
+ const char __c = _Round[0];
+ if (__c == '.') {
+ // Keep going.
+ } else if (__c == '9') {
+ _Round[0] = '0';
+ __roundUp = 1;
+ } else {
+ if (__roundUp == 1 || __c % 2 != 0) {
+ _Round[0] = __c + 1;
+ }
+ break;
+ }
+ }
+ }
+
+ char _Sign_character;
+
+ if (__exp < 0) {
+ _Sign_character = '-';
+ __exp = -__exp;
+ } else {
+ _Sign_character = '+';
+ }
+
+ const int _Exponent_part_length = __exp >= 100
+ ? 5 // "e+NNN"
+ : 4; // "e+NN"
+
+ if (_Last - _First < _Exponent_part_length) {
+ return { _Last, errc::value_too_large };
+ }
+
+ *_First++ = 'e';
+ *_First++ = _Sign_character;
+
+ if (__exp >= 100) {
+ const int32_t __c = __exp % 10;
+ _VSTD::memcpy(_First, __DIGIT_TABLE + 2 * (__exp / 10), 2);
+ _First[2] = static_cast<char>('0' + __c);
+ _First += 3;
+ } else {
+ _VSTD::memcpy(_First, __DIGIT_TABLE + 2 * __exp, 2);
+ _First += 2;
+ }
+
+ return { _First, errc{} };
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+// clang-format on
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/ryu/d2s.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/ryu/d2s.cpp
new file mode 100644
index 0000000000..245c2eb590
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/ryu/d2s.cpp
@@ -0,0 +1,783 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (c) Microsoft Corporation.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+// Copyright 2018 Ulf Adams
+// Copyright (c) Microsoft Corporation. All rights reserved.
+
+// Boost Software License - Version 1.0 - August 17th, 2003
+
+// Permission is hereby granted, free of charge, to any person or organization
+// obtaining a copy of the software and accompanying documentation covered by
+// this license (the "Software") to use, reproduce, display, distribute,
+// execute, and transmit the Software, and to prepare derivative works of the
+// Software, and to permit third-parties to whom the Software is furnished to
+// do so, all subject to the following:
+
+// The copyright notices in the Software and this entire statement, including
+// the above license grant, this restriction and the following disclaimer,
+// must be included in all copies of the Software, in whole or in part, and
+// all derivative works of the Software, unless such copies or derivative
+// works are solely in the form of machine-executable object code generated by
+// a source language processor.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+// Avoid formatting to keep the changes with the original code minimal.
+// clang-format off
+
+#include <__assert>
+#include <__config>
+#include <charconv>
+
+#include "include/ryu/common.h"
+#include "include/ryu/d2fixed.h"
+#include "include/ryu/d2s.h"
+#include "include/ryu/d2s_full_table.h"
+#include "include/ryu/d2s_intrinsics.h"
+#include "include/ryu/digit_table.h"
+#include "include/ryu/ryu.h"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// We need a 64x128-bit multiplication and a subsequent 128-bit shift.
+// Multiplication:
+// The 64-bit factor is variable and passed in, the 128-bit factor comes
+// from a lookup table. We know that the 64-bit factor only has 55
+// significant bits (i.e., the 9 topmost bits are zeros). The 128-bit
+// factor only has 124 significant bits (i.e., the 4 topmost bits are
+// zeros).
+// Shift:
+// In principle, the multiplication result requires 55 + 124 = 179 bits to
+// represent. However, we then shift this value to the right by __j, which is
+// at least __j >= 115, so the result is guaranteed to fit into 179 - 115 = 64
+// bits. This means that we only need the topmost 64 significant bits of
+// the 64x128-bit multiplication.
+//
+// There are several ways to do this:
+// 1. Best case: the compiler exposes a 128-bit type.
+// We perform two 64x64-bit multiplications, add the higher 64 bits of the
+// lower result to the higher result, and shift by __j - 64 bits.
+//
+// We explicitly cast from 64-bit to 128-bit, so the compiler can tell
+// that these are only 64-bit inputs, and can map these to the best
+// possible sequence of assembly instructions.
+// x64 machines happen to have matching assembly instructions for
+// 64x64-bit multiplications and 128-bit shifts.
+//
+// 2. Second best case: the compiler exposes intrinsics for the x64 assembly
+// instructions mentioned in 1.
+//
+// 3. We only have 64x64 bit instructions that return the lower 64 bits of
+// the result, i.e., we have to use plain C.
+// Our inputs are less than the full width, so we have three options:
+// a. Ignore this fact and just implement the intrinsics manually.
+// b. Split both into 31-bit pieces, which guarantees no internal overflow,
+// but requires extra work upfront (unless we change the lookup table).
+// c. Split only the first factor into 31-bit pieces, which also guarantees
+// no internal overflow, but requires extra work since the intermediate
+// results are not perfectly aligned.
+#ifdef _LIBCPP_INTRINSIC128
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __mulShift(const uint64_t __m, const uint64_t* const __mul, const int32_t __j) {
+ // __m is maximum 55 bits
+ uint64_t __high1; // 128
+ const uint64_t __low1 = __ryu_umul128(__m, __mul[1], &__high1); // 64
+ uint64_t __high0; // 64
+ (void) __ryu_umul128(__m, __mul[0], &__high0); // 0
+ const uint64_t __sum = __high0 + __low1;
+ if (__sum < __high0) {
+ ++__high1; // overflow into __high1
+ }
+ return __ryu_shiftright128(__sum, __high1, static_cast<uint32_t>(__j - 64));
+}
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __mulShiftAll(const uint64_t __m, const uint64_t* const __mul, const int32_t __j,
+ uint64_t* const __vp, uint64_t* const __vm, const uint32_t __mmShift) {
+ *__vp = __mulShift(4 * __m + 2, __mul, __j);
+ *__vm = __mulShift(4 * __m - 1 - __mmShift, __mul, __j);
+ return __mulShift(4 * __m, __mul, __j);
+}
+
+#else // ^^^ intrinsics available ^^^ / vvv intrinsics unavailable vvv
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline _LIBCPP_ALWAYS_INLINE uint64_t __mulShiftAll(uint64_t __m, const uint64_t* const __mul, const int32_t __j,
+ uint64_t* const __vp, uint64_t* const __vm, const uint32_t __mmShift) { // TRANSITION, VSO-634761
+ __m <<= 1;
+ // __m is maximum 55 bits
+ uint64_t __tmp;
+ const uint64_t __lo = __ryu_umul128(__m, __mul[0], &__tmp);
+ uint64_t __hi;
+ const uint64_t __mid = __tmp + __ryu_umul128(__m, __mul[1], &__hi);
+ __hi += __mid < __tmp; // overflow into __hi
+
+ const uint64_t __lo2 = __lo + __mul[0];
+ const uint64_t __mid2 = __mid + __mul[1] + (__lo2 < __lo);
+ const uint64_t __hi2 = __hi + (__mid2 < __mid);
+ *__vp = __ryu_shiftright128(__mid2, __hi2, static_cast<uint32_t>(__j - 64 - 1));
+
+ if (__mmShift == 1) {
+ const uint64_t __lo3 = __lo - __mul[0];
+ const uint64_t __mid3 = __mid - __mul[1] - (__lo3 > __lo);
+ const uint64_t __hi3 = __hi - (__mid3 > __mid);
+ *__vm = __ryu_shiftright128(__mid3, __hi3, static_cast<uint32_t>(__j - 64 - 1));
+ } else {
+ const uint64_t __lo3 = __lo + __lo;
+ const uint64_t __mid3 = __mid + __mid + (__lo3 < __lo);
+ const uint64_t __hi3 = __hi + __hi + (__mid3 < __mid);
+ const uint64_t __lo4 = __lo3 - __mul[0];
+ const uint64_t __mid4 = __mid3 - __mul[1] - (__lo4 > __lo3);
+ const uint64_t __hi4 = __hi3 - (__mid4 > __mid3);
+ *__vm = __ryu_shiftright128(__mid4, __hi4, static_cast<uint32_t>(__j - 64));
+ }
+
+ return __ryu_shiftright128(__mid, __hi, static_cast<uint32_t>(__j - 64 - 1));
+}
+
+#endif // ^^^ intrinsics unavailable ^^^
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __decimalLength17(const uint64_t __v) {
+ // This is slightly faster than a loop.
+ // The average output length is 16.38 digits, so we check high-to-low.
+ // Function precondition: __v is not an 18, 19, or 20-digit number.
+ // (17 digits are sufficient for round-tripping.)
+ _LIBCPP_ASSERT(__v < 100000000000000000u, "");
+ if (__v >= 10000000000000000u) { return 17; }
+ if (__v >= 1000000000000000u) { return 16; }
+ if (__v >= 100000000000000u) { return 15; }
+ if (__v >= 10000000000000u) { return 14; }
+ if (__v >= 1000000000000u) { return 13; }
+ if (__v >= 100000000000u) { return 12; }
+ if (__v >= 10000000000u) { return 11; }
+ if (__v >= 1000000000u) { return 10; }
+ if (__v >= 100000000u) { return 9; }
+ if (__v >= 10000000u) { return 8; }
+ if (__v >= 1000000u) { return 7; }
+ if (__v >= 100000u) { return 6; }
+ if (__v >= 10000u) { return 5; }
+ if (__v >= 1000u) { return 4; }
+ if (__v >= 100u) { return 3; }
+ if (__v >= 10u) { return 2; }
+ return 1;
+}
+
+// A floating decimal representing m * 10^e.
+struct __floating_decimal_64 {
+ uint64_t __mantissa;
+ int32_t __exponent;
+};
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline __floating_decimal_64 __d2d(const uint64_t __ieeeMantissa, const uint32_t __ieeeExponent) {
+ int32_t __e2;
+ uint64_t __m2;
+ if (__ieeeExponent == 0) {
+ // We subtract 2 so that the bounds computation has 2 additional bits.
+ __e2 = 1 - __DOUBLE_BIAS - __DOUBLE_MANTISSA_BITS - 2;
+ __m2 = __ieeeMantissa;
+ } else {
+ __e2 = static_cast<int32_t>(__ieeeExponent) - __DOUBLE_BIAS - __DOUBLE_MANTISSA_BITS - 2;
+ __m2 = (1ull << __DOUBLE_MANTISSA_BITS) | __ieeeMantissa;
+ }
+ const bool __even = (__m2 & 1) == 0;
+ const bool __acceptBounds = __even;
+
+ // Step 2: Determine the interval of valid decimal representations.
+ const uint64_t __mv = 4 * __m2;
+ // Implicit bool -> int conversion. True is 1, false is 0.
+ const uint32_t __mmShift = __ieeeMantissa != 0 || __ieeeExponent <= 1;
+ // We would compute __mp and __mm like this:
+ // uint64_t __mp = 4 * __m2 + 2;
+ // uint64_t __mm = __mv - 1 - __mmShift;
+
+ // Step 3: Convert to a decimal power base using 128-bit arithmetic.
+ uint64_t __vr, __vp, __vm;
+ int32_t __e10;
+ bool __vmIsTrailingZeros = false;
+ bool __vrIsTrailingZeros = false;
+ if (__e2 >= 0) {
+ // I tried special-casing __q == 0, but there was no effect on performance.
+ // This expression is slightly faster than max(0, __log10Pow2(__e2) - 1).
+ const uint32_t __q = __log10Pow2(__e2) - (__e2 > 3);
+ __e10 = static_cast<int32_t>(__q);
+ const int32_t __k = __DOUBLE_POW5_INV_BITCOUNT + __pow5bits(static_cast<int32_t>(__q)) - 1;
+ const int32_t __i = -__e2 + static_cast<int32_t>(__q) + __k;
+ __vr = __mulShiftAll(__m2, __DOUBLE_POW5_INV_SPLIT[__q], __i, &__vp, &__vm, __mmShift);
+ if (__q <= 21) {
+ // This should use __q <= 22, but I think 21 is also safe. Smaller values
+ // may still be safe, but it's more difficult to reason about them.
+ // Only one of __mp, __mv, and __mm can be a multiple of 5, if any.
+ const uint32_t __mvMod5 = static_cast<uint32_t>(__mv) - 5 * static_cast<uint32_t>(__div5(__mv));
+ if (__mvMod5 == 0) {
+ __vrIsTrailingZeros = __multipleOfPowerOf5(__mv, __q);
+ } else if (__acceptBounds) {
+ // Same as min(__e2 + (~__mm & 1), __pow5Factor(__mm)) >= __q
+ // <=> __e2 + (~__mm & 1) >= __q && __pow5Factor(__mm) >= __q
+ // <=> true && __pow5Factor(__mm) >= __q, since __e2 >= __q.
+ __vmIsTrailingZeros = __multipleOfPowerOf5(__mv - 1 - __mmShift, __q);
+ } else {
+ // Same as min(__e2 + 1, __pow5Factor(__mp)) >= __q.
+ __vp -= __multipleOfPowerOf5(__mv + 2, __q);
+ }
+ }
+ } else {
+ // This expression is slightly faster than max(0, __log10Pow5(-__e2) - 1).
+ const uint32_t __q = __log10Pow5(-__e2) - (-__e2 > 1);
+ __e10 = static_cast<int32_t>(__q) + __e2;
+ const int32_t __i = -__e2 - static_cast<int32_t>(__q);
+ const int32_t __k = __pow5bits(__i) - __DOUBLE_POW5_BITCOUNT;
+ const int32_t __j = static_cast<int32_t>(__q) - __k;
+ __vr = __mulShiftAll(__m2, __DOUBLE_POW5_SPLIT[__i], __j, &__vp, &__vm, __mmShift);
+ if (__q <= 1) {
+ // {__vr,__vp,__vm} is trailing zeros if {__mv,__mp,__mm} has at least __q trailing 0 bits.
+ // __mv = 4 * __m2, so it always has at least two trailing 0 bits.
+ __vrIsTrailingZeros = true;
+ if (__acceptBounds) {
+ // __mm = __mv - 1 - __mmShift, so it has 1 trailing 0 bit iff __mmShift == 1.
+ __vmIsTrailingZeros = __mmShift == 1;
+ } else {
+ // __mp = __mv + 2, so it always has at least one trailing 0 bit.
+ --__vp;
+ }
+ } else if (__q < 63) { // TRANSITION(ulfjack): Use a tighter bound here.
+ // We need to compute min(ntz(__mv), __pow5Factor(__mv) - __e2) >= __q - 1
+ // <=> ntz(__mv) >= __q - 1 && __pow5Factor(__mv) - __e2 >= __q - 1
+ // <=> ntz(__mv) >= __q - 1 (__e2 is negative and -__e2 >= __q)
+ // <=> (__mv & ((1 << (__q - 1)) - 1)) == 0
+ // We also need to make sure that the left shift does not overflow.
+ __vrIsTrailingZeros = __multipleOfPowerOf2(__mv, __q - 1);
+ }
+ }
+
+ // Step 4: Find the shortest decimal representation in the interval of valid representations.
+ int32_t __removed = 0;
+ uint8_t __lastRemovedDigit = 0;
+ uint64_t _Output;
+ // On average, we remove ~2 digits.
+ if (__vmIsTrailingZeros || __vrIsTrailingZeros) {
+ // General case, which happens rarely (~0.7%).
+ for (;;) {
+ const uint64_t __vpDiv10 = __div10(__vp);
+ const uint64_t __vmDiv10 = __div10(__vm);
+ if (__vpDiv10 <= __vmDiv10) {
+ break;
+ }
+ const uint32_t __vmMod10 = static_cast<uint32_t>(__vm) - 10 * static_cast<uint32_t>(__vmDiv10);
+ const uint64_t __vrDiv10 = __div10(__vr);
+ const uint32_t __vrMod10 = static_cast<uint32_t>(__vr) - 10 * static_cast<uint32_t>(__vrDiv10);
+ __vmIsTrailingZeros &= __vmMod10 == 0;
+ __vrIsTrailingZeros &= __lastRemovedDigit == 0;
+ __lastRemovedDigit = static_cast<uint8_t>(__vrMod10);
+ __vr = __vrDiv10;
+ __vp = __vpDiv10;
+ __vm = __vmDiv10;
+ ++__removed;
+ }
+ if (__vmIsTrailingZeros) {
+ for (;;) {
+ const uint64_t __vmDiv10 = __div10(__vm);
+ const uint32_t __vmMod10 = static_cast<uint32_t>(__vm) - 10 * static_cast<uint32_t>(__vmDiv10);
+ if (__vmMod10 != 0) {
+ break;
+ }
+ const uint64_t __vpDiv10 = __div10(__vp);
+ const uint64_t __vrDiv10 = __div10(__vr);
+ const uint32_t __vrMod10 = static_cast<uint32_t>(__vr) - 10 * static_cast<uint32_t>(__vrDiv10);
+ __vrIsTrailingZeros &= __lastRemovedDigit == 0;
+ __lastRemovedDigit = static_cast<uint8_t>(__vrMod10);
+ __vr = __vrDiv10;
+ __vp = __vpDiv10;
+ __vm = __vmDiv10;
+ ++__removed;
+ }
+ }
+ if (__vrIsTrailingZeros && __lastRemovedDigit == 5 && __vr % 2 == 0) {
+ // Round even if the exact number is .....50..0.
+ __lastRemovedDigit = 4;
+ }
+ // We need to take __vr + 1 if __vr is outside bounds or we need to round up.
+ _Output = __vr + ((__vr == __vm && (!__acceptBounds || !__vmIsTrailingZeros)) || __lastRemovedDigit >= 5);
+ } else {
+ // Specialized for the common case (~99.3%). Percentages below are relative to this.
+ bool __roundUp = false;
+ const uint64_t __vpDiv100 = __div100(__vp);
+ const uint64_t __vmDiv100 = __div100(__vm);
+ if (__vpDiv100 > __vmDiv100) { // Optimization: remove two digits at a time (~86.2%).
+ const uint64_t __vrDiv100 = __div100(__vr);
+ const uint32_t __vrMod100 = static_cast<uint32_t>(__vr) - 100 * static_cast<uint32_t>(__vrDiv100);
+ __roundUp = __vrMod100 >= 50;
+ __vr = __vrDiv100;
+ __vp = __vpDiv100;
+ __vm = __vmDiv100;
+ __removed += 2;
+ }
+ // Loop iterations below (approximately), without optimization above:
+ // 0: 0.03%, 1: 13.8%, 2: 70.6%, 3: 14.0%, 4: 1.40%, 5: 0.14%, 6+: 0.02%
+ // Loop iterations below (approximately), with optimization above:
+ // 0: 70.6%, 1: 27.8%, 2: 1.40%, 3: 0.14%, 4+: 0.02%
+ for (;;) {
+ const uint64_t __vpDiv10 = __div10(__vp);
+ const uint64_t __vmDiv10 = __div10(__vm);
+ if (__vpDiv10 <= __vmDiv10) {
+ break;
+ }
+ const uint64_t __vrDiv10 = __div10(__vr);
+ const uint32_t __vrMod10 = static_cast<uint32_t>(__vr) - 10 * static_cast<uint32_t>(__vrDiv10);
+ __roundUp = __vrMod10 >= 5;
+ __vr = __vrDiv10;
+ __vp = __vpDiv10;
+ __vm = __vmDiv10;
+ ++__removed;
+ }
+ // We need to take __vr + 1 if __vr is outside bounds or we need to round up.
+ _Output = __vr + (__vr == __vm || __roundUp);
+ }
+ const int32_t __exp = __e10 + __removed;
+
+ __floating_decimal_64 __fd;
+ __fd.__exponent = __exp;
+ __fd.__mantissa = _Output;
+ return __fd;
+}
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline to_chars_result __to_chars(char* const _First, char* const _Last, const __floating_decimal_64 __v,
+ chars_format _Fmt, const double __f) {
+ // Step 5: Print the decimal representation.
+ uint64_t _Output = __v.__mantissa;
+ int32_t _Ryu_exponent = __v.__exponent;
+ const uint32_t __olength = __decimalLength17(_Output);
+ int32_t _Scientific_exponent = _Ryu_exponent + static_cast<int32_t>(__olength) - 1;
+
+ if (_Fmt == chars_format{}) {
+ int32_t _Lower;
+ int32_t _Upper;
+
+ if (__olength == 1) {
+ // Value | Fixed | Scientific
+ // 1e-3 | "0.001" | "1e-03"
+ // 1e4 | "10000" | "1e+04"
+ _Lower = -3;
+ _Upper = 4;
+ } else {
+ // Value | Fixed | Scientific
+ // 1234e-7 | "0.0001234" | "1.234e-04"
+ // 1234e5 | "123400000" | "1.234e+08"
+ _Lower = -static_cast<int32_t>(__olength + 3);
+ _Upper = 5;
+ }
+
+ if (_Lower <= _Ryu_exponent && _Ryu_exponent <= _Upper) {
+ _Fmt = chars_format::fixed;
+ } else {
+ _Fmt = chars_format::scientific;
+ }
+ } else if (_Fmt == chars_format::general) {
+ // C11 7.21.6.1 "The fprintf function"/8:
+ // "Let P equal [...] 6 if the precision is omitted [...].
+ // Then, if a conversion with style E would have an exponent of X:
+ // - if P > X >= -4, the conversion is with style f [...].
+ // - otherwise, the conversion is with style e [...]."
+ if (-4 <= _Scientific_exponent && _Scientific_exponent < 6) {
+ _Fmt = chars_format::fixed;
+ } else {
+ _Fmt = chars_format::scientific;
+ }
+ }
+
+ if (_Fmt == chars_format::fixed) {
+ // Example: _Output == 1729, __olength == 4
+
+ // _Ryu_exponent | Printed | _Whole_digits | _Total_fixed_length | Notes
+ // --------------|----------|---------------|----------------------|---------------------------------------
+ // 2 | 172900 | 6 | _Whole_digits | Ryu can't be used for printing
+ // 1 | 17290 | 5 | (sometimes adjusted) | when the trimmed digits are nonzero.
+ // --------------|----------|---------------|----------------------|---------------------------------------
+ // 0 | 1729 | 4 | _Whole_digits | Unified length cases.
+ // --------------|----------|---------------|----------------------|---------------------------------------
+ // -1 | 172.9 | 3 | __olength + 1 | This case can't happen for
+ // -2 | 17.29 | 2 | | __olength == 1, but no additional
+ // -3 | 1.729 | 1 | | code is needed to avoid it.
+ // --------------|----------|---------------|----------------------|---------------------------------------
+ // -4 | 0.1729 | 0 | 2 - _Ryu_exponent | C11 7.21.6.1 "The fprintf function"/8:
+ // -5 | 0.01729 | -1 | | "If a decimal-point character appears,
+ // -6 | 0.001729 | -2 | | at least one digit appears before it."
+
+ const int32_t _Whole_digits = static_cast<int32_t>(__olength) + _Ryu_exponent;
+
+ uint32_t _Total_fixed_length;
+ if (_Ryu_exponent >= 0) { // cases "172900" and "1729"
+ _Total_fixed_length = static_cast<uint32_t>(_Whole_digits);
+ if (_Output == 1) {
+ // Rounding can affect the number of digits.
+ // For example, 1e23 is exactly "99999999999999991611392" which is 23 digits instead of 24.
+ // We can use a lookup table to detect this and adjust the total length.
+ static constexpr uint8_t _Adjustment[309] = {
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,0,1,0,1,1,1,0,1,1,1,0,0,0,0,0,
+ 1,1,0,0,1,0,1,1,1,0,0,0,0,1,1,1,1,0,0,0,1,1,1,1,0,0,0,1,1,1,1,0,1,0,1,0,1,1,0,0,0,0,1,1,1,
+ 1,0,0,0,0,0,0,0,1,1,0,1,1,0,0,1,0,1,0,1,0,1,1,0,0,0,0,0,1,1,1,0,0,1,1,1,1,1,0,1,0,1,1,0,1,
+ 1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,0,0,1,0,0,1,1,1,1,0,0,1,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,0,1,
+ 0,1,0,1,0,1,1,1,0,0,0,0,0,0,1,1,1,1,0,0,1,0,1,1,1,0,0,0,1,0,1,1,1,1,1,1,0,1,0,1,1,0,0,0,1,
+ 1,1,0,1,1,0,0,0,1,0,0,0,1,0,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,1,1,0,0,0,1,0,1,0,0,0,0,0,1,1,0,
+ 0,1,0,1,1,1,0,0,1,0,0,0,0,1,0,1,0,0,0,0,0,1,0,1,0,1,1,0,1,0,0,0,0,0,1,1,0,1,0 };
+ _Total_fixed_length -= _Adjustment[_Ryu_exponent];
+ // _Whole_digits doesn't need to be adjusted because these cases won't refer to it later.
+ }
+ } else if (_Whole_digits > 0) { // case "17.29"
+ _Total_fixed_length = __olength + 1;
+ } else { // case "0.001729"
+ _Total_fixed_length = static_cast<uint32_t>(2 - _Ryu_exponent);
+ }
+
+ if (_Last - _First < static_cast<ptrdiff_t>(_Total_fixed_length)) {
+ return { _Last, errc::value_too_large };
+ }
+
+ char* _Mid;
+ if (_Ryu_exponent > 0) { // case "172900"
+ bool _Can_use_ryu;
+
+ if (_Ryu_exponent > 22) { // 10^22 is the largest power of 10 that's exactly representable as a double.
+ _Can_use_ryu = false;
+ } else {
+ // Ryu generated X: __v.__mantissa * 10^_Ryu_exponent
+ // __v.__mantissa == 2^_Trailing_zero_bits * (__v.__mantissa >> _Trailing_zero_bits)
+ // 10^_Ryu_exponent == 2^_Ryu_exponent * 5^_Ryu_exponent
+
+ // _Trailing_zero_bits is [0, 56] (aside: because 2^56 is the largest power of 2
+ // with 17 decimal digits, which is double's round-trip limit.)
+ // _Ryu_exponent is [1, 22].
+ // Normalization adds [2, 52] (aside: at least 2 because the pre-normalized mantissa is at least 5).
+ // This adds up to [3, 130], which is well below double's maximum binary exponent 1023.
+
+ // Therefore, we just need to consider (__v.__mantissa >> _Trailing_zero_bits) * 5^_Ryu_exponent.
+
+ // If that product would exceed 53 bits, then X can't be exactly represented as a double.
+ // (That's not a problem for round-tripping, because X is close enough to the original double,
+ // but X isn't mathematically equal to the original double.) This requires a high-precision fallback.
+
+ // If the product is 53 bits or smaller, then X can be exactly represented as a double (and we don't
+ // need to re-synthesize it; the original double must have been X, because Ryu wouldn't produce the
+ // same output for two different doubles X and Y). This allows Ryu's output to be used (zero-filled).
+
+ // (2^53 - 1) / 5^0 (for indexing), (2^53 - 1) / 5^1, ..., (2^53 - 1) / 5^22
+ static constexpr uint64_t _Max_shifted_mantissa[23] = {
+ 9007199254740991u, 1801439850948198u, 360287970189639u, 72057594037927u, 14411518807585u,
+ 2882303761517u, 576460752303u, 115292150460u, 23058430092u, 4611686018u, 922337203u, 184467440u,
+ 36893488u, 7378697u, 1475739u, 295147u, 59029u, 11805u, 2361u, 472u, 94u, 18u, 3u };
+
+ unsigned long _Trailing_zero_bits;
+#ifdef _LIBCPP_HAS_BITSCAN64
+ (void) _BitScanForward64(&_Trailing_zero_bits, __v.__mantissa); // __v.__mantissa is guaranteed nonzero
+#else // ^^^ 64-bit ^^^ / vvv 32-bit vvv
+ const uint32_t _Low_mantissa = static_cast<uint32_t>(__v.__mantissa);
+ if (_Low_mantissa != 0) {
+ (void) _BitScanForward(&_Trailing_zero_bits, _Low_mantissa);
+ } else {
+ const uint32_t _High_mantissa = static_cast<uint32_t>(__v.__mantissa >> 32); // nonzero here
+ (void) _BitScanForward(&_Trailing_zero_bits, _High_mantissa);
+ _Trailing_zero_bits += 32;
+ }
+#endif // ^^^ 32-bit ^^^
+ const uint64_t _Shifted_mantissa = __v.__mantissa >> _Trailing_zero_bits;
+ _Can_use_ryu = _Shifted_mantissa <= _Max_shifted_mantissa[_Ryu_exponent];
+ }
+
+ if (!_Can_use_ryu) {
+ // Print the integer exactly.
+ // Performance note: This will redundantly perform bounds checking.
+ // Performance note: This will redundantly decompose the IEEE representation.
+ return __d2fixed_buffered_n(_First, _Last, __f, 0);
+ }
+
+ // _Can_use_ryu
+ // Print the decimal digits, left-aligned within [_First, _First + _Total_fixed_length).
+ _Mid = _First + __olength;
+ } else { // cases "1729", "17.29", and "0.001729"
+ // Print the decimal digits, right-aligned within [_First, _First + _Total_fixed_length).
+ _Mid = _First + _Total_fixed_length;
+ }
+
+ // We prefer 32-bit operations, even on 64-bit platforms.
+ // We have at most 17 digits, and uint32_t can store 9 digits.
+ // If _Output doesn't fit into uint32_t, we cut off 8 digits,
+ // so the rest will fit into uint32_t.
+ if ((_Output >> 32) != 0) {
+ // Expensive 64-bit division.
+ const uint64_t __q = __div1e8(_Output);
+ uint32_t __output2 = static_cast<uint32_t>(_Output - 100000000 * __q);
+ _Output = __q;
+
+ const uint32_t __c = __output2 % 10000;
+ __output2 /= 10000;
+ const uint32_t __d = __output2 % 10000;
+ const uint32_t __c0 = (__c % 100) << 1;
+ const uint32_t __c1 = (__c / 100) << 1;
+ const uint32_t __d0 = (__d % 100) << 1;
+ const uint32_t __d1 = (__d / 100) << 1;
+
+ _VSTD::memcpy(_Mid -= 2, __DIGIT_TABLE + __c0, 2);
+ _VSTD::memcpy(_Mid -= 2, __DIGIT_TABLE + __c1, 2);
+ _VSTD::memcpy(_Mid -= 2, __DIGIT_TABLE + __d0, 2);
+ _VSTD::memcpy(_Mid -= 2, __DIGIT_TABLE + __d1, 2);
+ }
+ uint32_t __output2 = static_cast<uint32_t>(_Output);
+ while (__output2 >= 10000) {
+#ifdef __clang__ // TRANSITION, LLVM-38217
+ const uint32_t __c = __output2 - 10000 * (__output2 / 10000);
+#else
+ const uint32_t __c = __output2 % 10000;
+#endif
+ __output2 /= 10000;
+ const uint32_t __c0 = (__c % 100) << 1;
+ const uint32_t __c1 = (__c / 100) << 1;
+ _VSTD::memcpy(_Mid -= 2, __DIGIT_TABLE + __c0, 2);
+ _VSTD::memcpy(_Mid -= 2, __DIGIT_TABLE + __c1, 2);
+ }
+ if (__output2 >= 100) {
+ const uint32_t __c = (__output2 % 100) << 1;
+ __output2 /= 100;
+ _VSTD::memcpy(_Mid -= 2, __DIGIT_TABLE + __c, 2);
+ }
+ if (__output2 >= 10) {
+ const uint32_t __c = __output2 << 1;
+ _VSTD::memcpy(_Mid -= 2, __DIGIT_TABLE + __c, 2);
+ } else {
+ *--_Mid = static_cast<char>('0' + __output2);
+ }
+
+ if (_Ryu_exponent > 0) { // case "172900" with _Can_use_ryu
+ // Performance note: it might be more efficient to do this immediately after setting _Mid.
+ _VSTD::memset(_First + __olength, '0', static_cast<size_t>(_Ryu_exponent));
+ } else if (_Ryu_exponent == 0) { // case "1729"
+ // Done!
+ } else if (_Whole_digits > 0) { // case "17.29"
+ // Performance note: moving digits might not be optimal.
+ _VSTD::memmove(_First, _First + 1, static_cast<size_t>(_Whole_digits));
+ _First[_Whole_digits] = '.';
+ } else { // case "0.001729"
+ // Performance note: a larger memset() followed by overwriting '.' might be more efficient.
+ _First[0] = '0';
+ _First[1] = '.';
+ _VSTD::memset(_First + 2, '0', static_cast<size_t>(-_Whole_digits));
+ }
+
+ return { _First + _Total_fixed_length, errc{} };
+ }
+
+ const uint32_t _Total_scientific_length = __olength + (__olength > 1) // digits + possible decimal point
+ + (-100 < _Scientific_exponent && _Scientific_exponent < 100 ? 4 : 5); // + scientific exponent
+ if (_Last - _First < static_cast<ptrdiff_t>(_Total_scientific_length)) {
+ return { _Last, errc::value_too_large };
+ }
+ char* const __result = _First;
+
+ // Print the decimal digits.
+ uint32_t __i = 0;
+ // We prefer 32-bit operations, even on 64-bit platforms.
+ // We have at most 17 digits, and uint32_t can store 9 digits.
+ // If _Output doesn't fit into uint32_t, we cut off 8 digits,
+ // so the rest will fit into uint32_t.
+ if ((_Output >> 32) != 0) {
+ // Expensive 64-bit division.
+ const uint64_t __q = __div1e8(_Output);
+ uint32_t __output2 = static_cast<uint32_t>(_Output) - 100000000 * static_cast<uint32_t>(__q);
+ _Output = __q;
+
+ const uint32_t __c = __output2 % 10000;
+ __output2 /= 10000;
+ const uint32_t __d = __output2 % 10000;
+ const uint32_t __c0 = (__c % 100) << 1;
+ const uint32_t __c1 = (__c / 100) << 1;
+ const uint32_t __d0 = (__d % 100) << 1;
+ const uint32_t __d1 = (__d / 100) << 1;
+ _VSTD::memcpy(__result + __olength - __i - 1, __DIGIT_TABLE + __c0, 2);
+ _VSTD::memcpy(__result + __olength - __i - 3, __DIGIT_TABLE + __c1, 2);
+ _VSTD::memcpy(__result + __olength - __i - 5, __DIGIT_TABLE + __d0, 2);
+ _VSTD::memcpy(__result + __olength - __i - 7, __DIGIT_TABLE + __d1, 2);
+ __i += 8;
+ }
+ uint32_t __output2 = static_cast<uint32_t>(_Output);
+ while (__output2 >= 10000) {
+#ifdef __clang__ // TRANSITION, LLVM-38217
+ const uint32_t __c = __output2 - 10000 * (__output2 / 10000);
+#else
+ const uint32_t __c = __output2 % 10000;
+#endif
+ __output2 /= 10000;
+ const uint32_t __c0 = (__c % 100) << 1;
+ const uint32_t __c1 = (__c / 100) << 1;
+ _VSTD::memcpy(__result + __olength - __i - 1, __DIGIT_TABLE + __c0, 2);
+ _VSTD::memcpy(__result + __olength - __i - 3, __DIGIT_TABLE + __c1, 2);
+ __i += 4;
+ }
+ if (__output2 >= 100) {
+ const uint32_t __c = (__output2 % 100) << 1;
+ __output2 /= 100;
+ _VSTD::memcpy(__result + __olength - __i - 1, __DIGIT_TABLE + __c, 2);
+ __i += 2;
+ }
+ if (__output2 >= 10) {
+ const uint32_t __c = __output2 << 1;
+ // We can't use memcpy here: the decimal dot goes between these two digits.
+ __result[2] = __DIGIT_TABLE[__c + 1];
+ __result[0] = __DIGIT_TABLE[__c];
+ } else {
+ __result[0] = static_cast<char>('0' + __output2);
+ }
+
+ // Print decimal point if needed.
+ uint32_t __index;
+ if (__olength > 1) {
+ __result[1] = '.';
+ __index = __olength + 1;
+ } else {
+ __index = 1;
+ }
+
+ // Print the exponent.
+ __result[__index++] = 'e';
+ if (_Scientific_exponent < 0) {
+ __result[__index++] = '-';
+ _Scientific_exponent = -_Scientific_exponent;
+ } else {
+ __result[__index++] = '+';
+ }
+
+ if (_Scientific_exponent >= 100) {
+ const int32_t __c = _Scientific_exponent % 10;
+ _VSTD::memcpy(__result + __index, __DIGIT_TABLE + 2 * (_Scientific_exponent / 10), 2);
+ __result[__index + 2] = static_cast<char>('0' + __c);
+ __index += 3;
+ } else {
+ _VSTD::memcpy(__result + __index, __DIGIT_TABLE + 2 * _Scientific_exponent, 2);
+ __index += 2;
+ }
+
+ return { _First + _Total_scientific_length, errc{} };
+}
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline bool __d2d_small_int(const uint64_t __ieeeMantissa, const uint32_t __ieeeExponent,
+ __floating_decimal_64* const __v) {
+ const uint64_t __m2 = (1ull << __DOUBLE_MANTISSA_BITS) | __ieeeMantissa;
+ const int32_t __e2 = static_cast<int32_t>(__ieeeExponent) - __DOUBLE_BIAS - __DOUBLE_MANTISSA_BITS;
+
+ if (__e2 > 0) {
+ // f = __m2 * 2^__e2 >= 2^53 is an integer.
+ // Ignore this case for now.
+ return false;
+ }
+
+ if (__e2 < -52) {
+ // f < 1.
+ return false;
+ }
+
+ // Since 2^52 <= __m2 < 2^53 and 0 <= -__e2 <= 52: 1 <= f = __m2 / 2^-__e2 < 2^53.
+ // Test if the lower -__e2 bits of the significand are 0, i.e. whether the fraction is 0.
+ const uint64_t __mask = (1ull << -__e2) - 1;
+ const uint64_t __fraction = __m2 & __mask;
+ if (__fraction != 0) {
+ return false;
+ }
+
+ // f is an integer in the range [1, 2^53).
+ // Note: __mantissa might contain trailing (decimal) 0's.
+ // Note: since 2^53 < 10^16, there is no need to adjust __decimalLength17().
+ __v->__mantissa = __m2 >> -__e2;
+ __v->__exponent = 0;
+ return true;
+}
+
+[[nodiscard]] to_chars_result __d2s_buffered_n(char* const _First, char* const _Last, const double __f,
+ const chars_format _Fmt) {
+
+ // Step 1: Decode the floating-point number, and unify normalized and subnormal cases.
+ const uint64_t __bits = __double_to_bits(__f);
+
+ // Case distinction; exit early for the easy cases.
+ if (__bits == 0) {
+ if (_Fmt == chars_format::scientific) {
+ if (_Last - _First < 5) {
+ return { _Last, errc::value_too_large };
+ }
+
+ _VSTD::memcpy(_First, "0e+00", 5);
+
+ return { _First + 5, errc{} };
+ }
+
+ // Print "0" for chars_format::fixed, chars_format::general, and chars_format{}.
+ if (_First == _Last) {
+ return { _Last, errc::value_too_large };
+ }
+
+ *_First = '0';
+
+ return { _First + 1, errc{} };
+ }
+
+ // Decode __bits into mantissa and exponent.
+ const uint64_t __ieeeMantissa = __bits & ((1ull << __DOUBLE_MANTISSA_BITS) - 1);
+ const uint32_t __ieeeExponent = static_cast<uint32_t>(__bits >> __DOUBLE_MANTISSA_BITS);
+
+ if (_Fmt == chars_format::fixed) {
+ // const uint64_t _Mantissa2 = __ieeeMantissa | (1ull << __DOUBLE_MANTISSA_BITS); // restore implicit bit
+ const int32_t _Exponent2 = static_cast<int32_t>(__ieeeExponent)
+ - __DOUBLE_BIAS - __DOUBLE_MANTISSA_BITS; // bias and normalization
+
+ // Normal values are equal to _Mantissa2 * 2^_Exponent2.
+ // (Subnormals are different, but they'll be rejected by the _Exponent2 test here, so they can be ignored.)
+
+ // For nonzero integers, _Exponent2 >= -52. (The minimum value occurs when _Mantissa2 * 2^_Exponent2 is 1.
+ // In that case, _Mantissa2 is the implicit 1 bit followed by 52 zeros, so _Exponent2 is -52 to shift away
+ // the zeros.) The dense range of exactly representable integers has negative or zero exponents
+ // (as positive exponents make the range non-dense). For that dense range, Ryu will always be used:
+ // every digit is necessary to uniquely identify the value, so Ryu must print them all.
+
+ // Positive exponents are the non-dense range of exactly representable integers. This contains all of the values
+ // for which Ryu can't be used (and a few Ryu-friendly values). We can save time by detecting positive
+ // exponents here and skipping Ryu. Calling __d2fixed_buffered_n() with precision 0 is valid for all integers
+ // (so it's okay if we call it with a Ryu-friendly value).
+ if (_Exponent2 > 0) {
+ return __d2fixed_buffered_n(_First, _Last, __f, 0);
+ }
+ }
+
+ __floating_decimal_64 __v;
+ const bool __isSmallInt = __d2d_small_int(__ieeeMantissa, __ieeeExponent, &__v);
+ if (__isSmallInt) {
+ // For small integers in the range [1, 2^53), __v.__mantissa might contain trailing (decimal) zeros.
+ // For scientific notation we need to move these zeros into the exponent.
+ // (This is not needed for fixed-point notation, so it might be beneficial to trim
+ // trailing zeros in __to_chars only if needed - once fixed-point notation output is implemented.)
+ for (;;) {
+ const uint64_t __q = __div10(__v.__mantissa);
+ const uint32_t __r = static_cast<uint32_t>(__v.__mantissa) - 10 * static_cast<uint32_t>(__q);
+ if (__r != 0) {
+ break;
+ }
+ __v.__mantissa = __q;
+ ++__v.__exponent;
+ }
+ } else {
+ __v = __d2d(__ieeeMantissa, __ieeeExponent);
+ }
+
+ return __to_chars(_First, _Last, __v, _Fmt, __f);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+// clang-format on
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/ryu/f2s.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/ryu/f2s.cpp
new file mode 100644
index 0000000000..3bcfe462c8
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/ryu/f2s.cpp
@@ -0,0 +1,716 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (c) Microsoft Corporation.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+// Copyright 2018 Ulf Adams
+// Copyright (c) Microsoft Corporation. All rights reserved.
+
+// Boost Software License - Version 1.0 - August 17th, 2003
+
+// Permission is hereby granted, free of charge, to any person or organization
+// obtaining a copy of the software and accompanying documentation covered by
+// this license (the "Software") to use, reproduce, display, distribute,
+// execute, and transmit the Software, and to prepare derivative works of the
+// Software, and to permit third-parties to whom the Software is furnished to
+// do so, all subject to the following:
+
+// The copyright notices in the Software and this entire statement, including
+// the above license grant, this restriction and the following disclaimer,
+// must be included in all copies of the Software, in whole or in part, and
+// all derivative works of the Software, unless such copies or derivative
+// works are solely in the form of machine-executable object code generated by
+// a source language processor.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+// Avoid formatting to keep the changes with the original code minimal.
+// clang-format off
+
+#include <__assert>
+#include <__config>
+#include <charconv>
+
+#include "include/ryu/common.h"
+#include "include/ryu/d2fixed.h"
+#include "include/ryu/d2s_intrinsics.h"
+#include "include/ryu/digit_table.h"
+#include "include/ryu/f2s.h"
+#include "include/ryu/ryu.h"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+inline constexpr int __FLOAT_MANTISSA_BITS = 23;
+inline constexpr int __FLOAT_EXPONENT_BITS = 8;
+inline constexpr int __FLOAT_BIAS = 127;
+
+inline constexpr int __FLOAT_POW5_INV_BITCOUNT = 59;
+inline constexpr uint64_t __FLOAT_POW5_INV_SPLIT[31] = {
+ 576460752303423489u, 461168601842738791u, 368934881474191033u, 295147905179352826u,
+ 472236648286964522u, 377789318629571618u, 302231454903657294u, 483570327845851670u,
+ 386856262276681336u, 309485009821345069u, 495176015714152110u, 396140812571321688u,
+ 316912650057057351u, 507060240091291761u, 405648192073033409u, 324518553658426727u,
+ 519229685853482763u, 415383748682786211u, 332306998946228969u, 531691198313966350u,
+ 425352958651173080u, 340282366920938464u, 544451787073501542u, 435561429658801234u,
+ 348449143727040987u, 557518629963265579u, 446014903970612463u, 356811923176489971u,
+ 570899077082383953u, 456719261665907162u, 365375409332725730u
+};
+inline constexpr int __FLOAT_POW5_BITCOUNT = 61;
+inline constexpr uint64_t __FLOAT_POW5_SPLIT[47] = {
+ 1152921504606846976u, 1441151880758558720u, 1801439850948198400u, 2251799813685248000u,
+ 1407374883553280000u, 1759218604441600000u, 2199023255552000000u, 1374389534720000000u,
+ 1717986918400000000u, 2147483648000000000u, 1342177280000000000u, 1677721600000000000u,
+ 2097152000000000000u, 1310720000000000000u, 1638400000000000000u, 2048000000000000000u,
+ 1280000000000000000u, 1600000000000000000u, 2000000000000000000u, 1250000000000000000u,
+ 1562500000000000000u, 1953125000000000000u, 1220703125000000000u, 1525878906250000000u,
+ 1907348632812500000u, 1192092895507812500u, 1490116119384765625u, 1862645149230957031u,
+ 1164153218269348144u, 1455191522836685180u, 1818989403545856475u, 2273736754432320594u,
+ 1421085471520200371u, 1776356839400250464u, 2220446049250313080u, 1387778780781445675u,
+ 1734723475976807094u, 2168404344971008868u, 1355252715606880542u, 1694065894508600678u,
+ 2117582368135750847u, 1323488980084844279u, 1654361225106055349u, 2067951531382569187u,
+ 1292469707114105741u, 1615587133892632177u, 2019483917365790221u
+};
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __pow5Factor(uint32_t __value) {
+ uint32_t __count = 0;
+ for (;;) {
+ _LIBCPP_ASSERT(__value != 0, "");
+ const uint32_t __q = __value / 5;
+ const uint32_t __r = __value % 5;
+ if (__r != 0) {
+ break;
+ }
+ __value = __q;
+ ++__count;
+ }
+ return __count;
+}
+
+// Returns true if __value is divisible by 5^__p.
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline bool __multipleOfPowerOf5(const uint32_t __value, const uint32_t __p) {
+ return __pow5Factor(__value) >= __p;
+}
+
+// Returns true if __value is divisible by 2^__p.
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline bool __multipleOfPowerOf2(const uint32_t __value, const uint32_t __p) {
+ _LIBCPP_ASSERT(__value != 0, "");
+ _LIBCPP_ASSERT(__p < 32, "");
+ // __builtin_ctz doesn't appear to be faster here.
+ return (__value & ((1u << __p) - 1)) == 0;
+}
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __mulShift(const uint32_t __m, const uint64_t __factor, const int32_t __shift) {
+ _LIBCPP_ASSERT(__shift > 32, "");
+
+ // The casts here help MSVC to avoid calls to the __allmul library
+ // function.
+ const uint32_t __factorLo = static_cast<uint32_t>(__factor);
+ const uint32_t __factorHi = static_cast<uint32_t>(__factor >> 32);
+ const uint64_t __bits0 = static_cast<uint64_t>(__m) * __factorLo;
+ const uint64_t __bits1 = static_cast<uint64_t>(__m) * __factorHi;
+
+#ifndef _LIBCPP_64_BIT
+ // On 32-bit platforms we can avoid a 64-bit shift-right since we only
+ // need the upper 32 bits of the result and the shift value is > 32.
+ const uint32_t __bits0Hi = static_cast<uint32_t>(__bits0 >> 32);
+ uint32_t __bits1Lo = static_cast<uint32_t>(__bits1);
+ uint32_t __bits1Hi = static_cast<uint32_t>(__bits1 >> 32);
+ __bits1Lo += __bits0Hi;
+ __bits1Hi += (__bits1Lo < __bits0Hi);
+ const int32_t __s = __shift - 32;
+ return (__bits1Hi << (32 - __s)) | (__bits1Lo >> __s);
+#else // ^^^ 32-bit ^^^ / vvv 64-bit vvv
+ const uint64_t __sum = (__bits0 >> 32) + __bits1;
+ const uint64_t __shiftedSum = __sum >> (__shift - 32);
+ _LIBCPP_ASSERT(__shiftedSum <= UINT32_MAX, "");
+ return static_cast<uint32_t>(__shiftedSum);
+#endif // ^^^ 64-bit ^^^
+}
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __mulPow5InvDivPow2(const uint32_t __m, const uint32_t __q, const int32_t __j) {
+ return __mulShift(__m, __FLOAT_POW5_INV_SPLIT[__q], __j);
+}
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __mulPow5divPow2(const uint32_t __m, const uint32_t __i, const int32_t __j) {
+ return __mulShift(__m, __FLOAT_POW5_SPLIT[__i], __j);
+}
+
+// A floating decimal representing m * 10^e.
+struct __floating_decimal_32 {
+ uint32_t __mantissa;
+ int32_t __exponent;
+};
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline __floating_decimal_32 __f2d(const uint32_t __ieeeMantissa, const uint32_t __ieeeExponent) {
+ int32_t __e2;
+ uint32_t __m2;
+ if (__ieeeExponent == 0) {
+ // We subtract 2 so that the bounds computation has 2 additional bits.
+ __e2 = 1 - __FLOAT_BIAS - __FLOAT_MANTISSA_BITS - 2;
+ __m2 = __ieeeMantissa;
+ } else {
+ __e2 = static_cast<int32_t>(__ieeeExponent) - __FLOAT_BIAS - __FLOAT_MANTISSA_BITS - 2;
+ __m2 = (1u << __FLOAT_MANTISSA_BITS) | __ieeeMantissa;
+ }
+ const bool __even = (__m2 & 1) == 0;
+ const bool __acceptBounds = __even;
+
+ // Step 2: Determine the interval of valid decimal representations.
+ const uint32_t __mv = 4 * __m2;
+ const uint32_t __mp = 4 * __m2 + 2;
+ // Implicit bool -> int conversion. True is 1, false is 0.
+ const uint32_t __mmShift = __ieeeMantissa != 0 || __ieeeExponent <= 1;
+ const uint32_t __mm = 4 * __m2 - 1 - __mmShift;
+
+ // Step 3: Convert to a decimal power base using 64-bit arithmetic.
+ uint32_t __vr, __vp, __vm;
+ int32_t __e10;
+ bool __vmIsTrailingZeros = false;
+ bool __vrIsTrailingZeros = false;
+ uint8_t __lastRemovedDigit = 0;
+ if (__e2 >= 0) {
+ const uint32_t __q = __log10Pow2(__e2);
+ __e10 = static_cast<int32_t>(__q);
+ const int32_t __k = __FLOAT_POW5_INV_BITCOUNT + __pow5bits(static_cast<int32_t>(__q)) - 1;
+ const int32_t __i = -__e2 + static_cast<int32_t>(__q) + __k;
+ __vr = __mulPow5InvDivPow2(__mv, __q, __i);
+ __vp = __mulPow5InvDivPow2(__mp, __q, __i);
+ __vm = __mulPow5InvDivPow2(__mm, __q, __i);
+ if (__q != 0 && (__vp - 1) / 10 <= __vm / 10) {
+ // We need to know one removed digit even if we are not going to loop below. We could use
+ // __q = X - 1 above, except that would require 33 bits for the result, and we've found that
+ // 32-bit arithmetic is faster even on 64-bit machines.
+ const int32_t __l = __FLOAT_POW5_INV_BITCOUNT + __pow5bits(static_cast<int32_t>(__q - 1)) - 1;
+ __lastRemovedDigit = static_cast<uint8_t>(__mulPow5InvDivPow2(__mv, __q - 1,
+ -__e2 + static_cast<int32_t>(__q) - 1 + __l) % 10);
+ }
+ if (__q <= 9) {
+ // The largest power of 5 that fits in 24 bits is 5^10, but __q <= 9 seems to be safe as well.
+ // Only one of __mp, __mv, and __mm can be a multiple of 5, if any.
+ if (__mv % 5 == 0) {
+ __vrIsTrailingZeros = __multipleOfPowerOf5(__mv, __q);
+ } else if (__acceptBounds) {
+ __vmIsTrailingZeros = __multipleOfPowerOf5(__mm, __q);
+ } else {
+ __vp -= __multipleOfPowerOf5(__mp, __q);
+ }
+ }
+ } else {
+ const uint32_t __q = __log10Pow5(-__e2);
+ __e10 = static_cast<int32_t>(__q) + __e2;
+ const int32_t __i = -__e2 - static_cast<int32_t>(__q);
+ const int32_t __k = __pow5bits(__i) - __FLOAT_POW5_BITCOUNT;
+ int32_t __j = static_cast<int32_t>(__q) - __k;
+ __vr = __mulPow5divPow2(__mv, static_cast<uint32_t>(__i), __j);
+ __vp = __mulPow5divPow2(__mp, static_cast<uint32_t>(__i), __j);
+ __vm = __mulPow5divPow2(__mm, static_cast<uint32_t>(__i), __j);
+ if (__q != 0 && (__vp - 1) / 10 <= __vm / 10) {
+ __j = static_cast<int32_t>(__q) - 1 - (__pow5bits(__i + 1) - __FLOAT_POW5_BITCOUNT);
+ __lastRemovedDigit = static_cast<uint8_t>(__mulPow5divPow2(__mv, static_cast<uint32_t>(__i + 1), __j) % 10);
+ }
+ if (__q <= 1) {
+ // {__vr,__vp,__vm} is trailing zeros if {__mv,__mp,__mm} has at least __q trailing 0 bits.
+ // __mv = 4 * __m2, so it always has at least two trailing 0 bits.
+ __vrIsTrailingZeros = true;
+ if (__acceptBounds) {
+ // __mm = __mv - 1 - __mmShift, so it has 1 trailing 0 bit iff __mmShift == 1.
+ __vmIsTrailingZeros = __mmShift == 1;
+ } else {
+ // __mp = __mv + 2, so it always has at least one trailing 0 bit.
+ --__vp;
+ }
+ } else if (__q < 31) { // TRANSITION(ulfjack): Use a tighter bound here.
+ __vrIsTrailingZeros = __multipleOfPowerOf2(__mv, __q - 1);
+ }
+ }
+
+ // Step 4: Find the shortest decimal representation in the interval of valid representations.
+ int32_t __removed = 0;
+ uint32_t _Output;
+ if (__vmIsTrailingZeros || __vrIsTrailingZeros) {
+ // General case, which happens rarely (~4.0%).
+ while (__vp / 10 > __vm / 10) {
+#ifdef __clang__ // TRANSITION, LLVM-23106
+ __vmIsTrailingZeros &= __vm - (__vm / 10) * 10 == 0;
+#else
+ __vmIsTrailingZeros &= __vm % 10 == 0;
+#endif
+ __vrIsTrailingZeros &= __lastRemovedDigit == 0;
+ __lastRemovedDigit = static_cast<uint8_t>(__vr % 10);
+ __vr /= 10;
+ __vp /= 10;
+ __vm /= 10;
+ ++__removed;
+ }
+ if (__vmIsTrailingZeros) {
+ while (__vm % 10 == 0) {
+ __vrIsTrailingZeros &= __lastRemovedDigit == 0;
+ __lastRemovedDigit = static_cast<uint8_t>(__vr % 10);
+ __vr /= 10;
+ __vp /= 10;
+ __vm /= 10;
+ ++__removed;
+ }
+ }
+ if (__vrIsTrailingZeros && __lastRemovedDigit == 5 && __vr % 2 == 0) {
+ // Round even if the exact number is .....50..0.
+ __lastRemovedDigit = 4;
+ }
+ // We need to take __vr + 1 if __vr is outside bounds or we need to round up.
+ _Output = __vr + ((__vr == __vm && (!__acceptBounds || !__vmIsTrailingZeros)) || __lastRemovedDigit >= 5);
+ } else {
+ // Specialized for the common case (~96.0%). Percentages below are relative to this.
+ // Loop iterations below (approximately):
+ // 0: 13.6%, 1: 70.7%, 2: 14.1%, 3: 1.39%, 4: 0.14%, 5+: 0.01%
+ while (__vp / 10 > __vm / 10) {
+ __lastRemovedDigit = static_cast<uint8_t>(__vr % 10);
+ __vr /= 10;
+ __vp /= 10;
+ __vm /= 10;
+ ++__removed;
+ }
+ // We need to take __vr + 1 if __vr is outside bounds or we need to round up.
+ _Output = __vr + (__vr == __vm || __lastRemovedDigit >= 5);
+ }
+ const int32_t __exp = __e10 + __removed;
+
+ __floating_decimal_32 __fd;
+ __fd.__exponent = __exp;
+ __fd.__mantissa = _Output;
+ return __fd;
+}
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline to_chars_result _Large_integer_to_chars(char* const _First, char* const _Last,
+ const uint32_t _Mantissa2, const int32_t _Exponent2) {
+
+ // Print the integer _Mantissa2 * 2^_Exponent2 exactly.
+
+ // For nonzero integers, _Exponent2 >= -23. (The minimum value occurs when _Mantissa2 * 2^_Exponent2 is 1.
+ // In that case, _Mantissa2 is the implicit 1 bit followed by 23 zeros, so _Exponent2 is -23 to shift away
+ // the zeros.) The dense range of exactly representable integers has negative or zero exponents
+ // (as positive exponents make the range non-dense). For that dense range, Ryu will always be used:
+ // every digit is necessary to uniquely identify the value, so Ryu must print them all.
+
+ // Positive exponents are the non-dense range of exactly representable integers.
+ // This contains all of the values for which Ryu can't be used (and a few Ryu-friendly values).
+
+ // Performance note: Long division appears to be faster than losslessly widening float to double and calling
+ // __d2fixed_buffered_n(). If __f2fixed_buffered_n() is implemented, it might be faster than long division.
+
+ _LIBCPP_ASSERT(_Exponent2 > 0, "");
+ _LIBCPP_ASSERT(_Exponent2 <= 104, ""); // because __ieeeExponent <= 254
+
+ // Manually represent _Mantissa2 * 2^_Exponent2 as a large integer. _Mantissa2 is always 24 bits
+ // (due to the implicit bit), while _Exponent2 indicates a shift of at most 104 bits.
+ // 24 + 104 equals 128 equals 4 * 32, so we need exactly 4 32-bit elements.
+ // We use a little-endian representation, visualized like this:
+
+ // << left shift <<
+ // most significant
+ // _Data[3] _Data[2] _Data[1] _Data[0]
+ // least significant
+ // >> right shift >>
+
+ constexpr uint32_t _Data_size = 4;
+ uint32_t _Data[_Data_size]{};
+
+ // _Maxidx is the index of the most significant nonzero element.
+ uint32_t _Maxidx = ((24 + static_cast<uint32_t>(_Exponent2) + 31) / 32) - 1;
+ _LIBCPP_ASSERT(_Maxidx < _Data_size, "");
+
+ const uint32_t _Bit_shift = static_cast<uint32_t>(_Exponent2) % 32;
+ if (_Bit_shift <= 8) { // _Mantissa2's 24 bits don't cross an element boundary
+ _Data[_Maxidx] = _Mantissa2 << _Bit_shift;
+ } else { // _Mantissa2's 24 bits cross an element boundary
+ _Data[_Maxidx - 1] = _Mantissa2 << _Bit_shift;
+ _Data[_Maxidx] = _Mantissa2 >> (32 - _Bit_shift);
+ }
+
+ // If Ryu hasn't determined the total output length, we need to buffer the digits generated from right to left
+ // by long division. The largest possible float is: 340'282346638'528859811'704183484'516925440
+ uint32_t _Blocks[4];
+ int32_t _Filled_blocks = 0;
+ // From left to right, we're going to print:
+ // _Data[0] will be [1, 10] digits.
+ // Then if _Filled_blocks > 0:
+ // _Blocks[_Filled_blocks - 1], ..., _Blocks[0] will be 0-filled 9-digit blocks.
+
+ if (_Maxidx != 0) { // If the integer is actually large, perform long division.
+ // Otherwise, skip to printing _Data[0].
+ for (;;) {
+ // Loop invariant: _Maxidx != 0 (i.e. the integer is actually large)
+
+ const uint32_t _Most_significant_elem = _Data[_Maxidx];
+ const uint32_t _Initial_remainder = _Most_significant_elem % 1000000000;
+ const uint32_t _Initial_quotient = _Most_significant_elem / 1000000000;
+ _Data[_Maxidx] = _Initial_quotient;
+ uint64_t _Remainder = _Initial_remainder;
+
+ // Process less significant elements.
+ uint32_t _Idx = _Maxidx;
+ do {
+ --_Idx; // Initially, _Remainder is at most 10^9 - 1.
+
+ // Now, _Remainder is at most (10^9 - 1) * 2^32 + 2^32 - 1, simplified to 10^9 * 2^32 - 1.
+ _Remainder = (_Remainder << 32) | _Data[_Idx];
+
+ // floor((10^9 * 2^32 - 1) / 10^9) == 2^32 - 1, so uint32_t _Quotient is lossless.
+ const uint32_t _Quotient = static_cast<uint32_t>(__div1e9(_Remainder));
+
+ // _Remainder is at most 10^9 - 1 again.
+ // For uint32_t truncation, see the __mod1e9() comment in d2s_intrinsics.h.
+ _Remainder = static_cast<uint32_t>(_Remainder) - 1000000000u * _Quotient;
+
+ _Data[_Idx] = _Quotient;
+ } while (_Idx != 0);
+
+ // Store a 0-filled 9-digit block.
+ _Blocks[_Filled_blocks++] = static_cast<uint32_t>(_Remainder);
+
+ if (_Initial_quotient == 0) { // Is the large integer shrinking?
+ --_Maxidx; // log2(10^9) is 29.9, so we can't shrink by more than one element.
+ if (_Maxidx == 0) {
+ break; // We've finished long division. Now we need to print _Data[0].
+ }
+ }
+ }
+ }
+
+ _LIBCPP_ASSERT(_Data[0] != 0, "");
+ for (uint32_t _Idx = 1; _Idx < _Data_size; ++_Idx) {
+ _LIBCPP_ASSERT(_Data[_Idx] == 0, "");
+ }
+
+ const uint32_t _Data_olength = _Data[0] >= 1000000000 ? 10 : __decimalLength9(_Data[0]);
+ const uint32_t _Total_fixed_length = _Data_olength + 9 * _Filled_blocks;
+
+ if (_Last - _First < static_cast<ptrdiff_t>(_Total_fixed_length)) {
+ return { _Last, errc::value_too_large };
+ }
+
+ char* _Result = _First;
+
+ // Print _Data[0]. While it's up to 10 digits,
+ // which is more than Ryu generates, the code below can handle this.
+ __append_n_digits(_Data_olength, _Data[0], _Result);
+ _Result += _Data_olength;
+
+ // Print 0-filled 9-digit blocks.
+ for (int32_t _Idx = _Filled_blocks - 1; _Idx >= 0; --_Idx) {
+ __append_nine_digits(_Blocks[_Idx], _Result);
+ _Result += 9;
+ }
+
+ return { _Result, errc{} };
+}
+
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline to_chars_result __to_chars(char* const _First, char* const _Last, const __floating_decimal_32 __v,
+ chars_format _Fmt, const uint32_t __ieeeMantissa, const uint32_t __ieeeExponent) {
+ // Step 5: Print the decimal representation.
+ uint32_t _Output = __v.__mantissa;
+ int32_t _Ryu_exponent = __v.__exponent;
+ const uint32_t __olength = __decimalLength9(_Output);
+ int32_t _Scientific_exponent = _Ryu_exponent + static_cast<int32_t>(__olength) - 1;
+
+ if (_Fmt == chars_format{}) {
+ int32_t _Lower;
+ int32_t _Upper;
+
+ if (__olength == 1) {
+ // Value | Fixed | Scientific
+ // 1e-3 | "0.001" | "1e-03"
+ // 1e4 | "10000" | "1e+04"
+ _Lower = -3;
+ _Upper = 4;
+ } else {
+ // Value | Fixed | Scientific
+ // 1234e-7 | "0.0001234" | "1.234e-04"
+ // 1234e5 | "123400000" | "1.234e+08"
+ _Lower = -static_cast<int32_t>(__olength + 3);
+ _Upper = 5;
+ }
+
+ if (_Lower <= _Ryu_exponent && _Ryu_exponent <= _Upper) {
+ _Fmt = chars_format::fixed;
+ } else {
+ _Fmt = chars_format::scientific;
+ }
+ } else if (_Fmt == chars_format::general) {
+ // C11 7.21.6.1 "The fprintf function"/8:
+ // "Let P equal [...] 6 if the precision is omitted [...].
+ // Then, if a conversion with style E would have an exponent of X:
+ // - if P > X >= -4, the conversion is with style f [...].
+ // - otherwise, the conversion is with style e [...]."
+ if (-4 <= _Scientific_exponent && _Scientific_exponent < 6) {
+ _Fmt = chars_format::fixed;
+ } else {
+ _Fmt = chars_format::scientific;
+ }
+ }
+
+ if (_Fmt == chars_format::fixed) {
+ // Example: _Output == 1729, __olength == 4
+
+ // _Ryu_exponent | Printed | _Whole_digits | _Total_fixed_length | Notes
+ // --------------|----------|---------------|----------------------|---------------------------------------
+ // 2 | 172900 | 6 | _Whole_digits | Ryu can't be used for printing
+ // 1 | 17290 | 5 | (sometimes adjusted) | when the trimmed digits are nonzero.
+ // --------------|----------|---------------|----------------------|---------------------------------------
+ // 0 | 1729 | 4 | _Whole_digits | Unified length cases.
+ // --------------|----------|---------------|----------------------|---------------------------------------
+ // -1 | 172.9 | 3 | __olength + 1 | This case can't happen for
+ // -2 | 17.29 | 2 | | __olength == 1, but no additional
+ // -3 | 1.729 | 1 | | code is needed to avoid it.
+ // --------------|----------|---------------|----------------------|---------------------------------------
+ // -4 | 0.1729 | 0 | 2 - _Ryu_exponent | C11 7.21.6.1 "The fprintf function"/8:
+ // -5 | 0.01729 | -1 | | "If a decimal-point character appears,
+ // -6 | 0.001729 | -2 | | at least one digit appears before it."
+
+ const int32_t _Whole_digits = static_cast<int32_t>(__olength) + _Ryu_exponent;
+
+ uint32_t _Total_fixed_length;
+ if (_Ryu_exponent >= 0) { // cases "172900" and "1729"
+ _Total_fixed_length = static_cast<uint32_t>(_Whole_digits);
+ if (_Output == 1) {
+ // Rounding can affect the number of digits.
+ // For example, 1e11f is exactly "99999997952" which is 11 digits instead of 12.
+ // We can use a lookup table to detect this and adjust the total length.
+ static constexpr uint8_t _Adjustment[39] = {
+ 0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,1,1,1,0,0,1,1,0,1,0,1,1,0,0,1,0,1,1,0,1,1,1 };
+ _Total_fixed_length -= _Adjustment[_Ryu_exponent];
+ // _Whole_digits doesn't need to be adjusted because these cases won't refer to it later.
+ }
+ } else if (_Whole_digits > 0) { // case "17.29"
+ _Total_fixed_length = __olength + 1;
+ } else { // case "0.001729"
+ _Total_fixed_length = static_cast<uint32_t>(2 - _Ryu_exponent);
+ }
+
+ if (_Last - _First < static_cast<ptrdiff_t>(_Total_fixed_length)) {
+ return { _Last, errc::value_too_large };
+ }
+
+ char* _Mid;
+ if (_Ryu_exponent > 0) { // case "172900"
+ bool _Can_use_ryu;
+
+ if (_Ryu_exponent > 10) { // 10^10 is the largest power of 10 that's exactly representable as a float.
+ _Can_use_ryu = false;
+ } else {
+ // Ryu generated X: __v.__mantissa * 10^_Ryu_exponent
+ // __v.__mantissa == 2^_Trailing_zero_bits * (__v.__mantissa >> _Trailing_zero_bits)
+ // 10^_Ryu_exponent == 2^_Ryu_exponent * 5^_Ryu_exponent
+
+ // _Trailing_zero_bits is [0, 29] (aside: because 2^29 is the largest power of 2
+ // with 9 decimal digits, which is float's round-trip limit.)
+ // _Ryu_exponent is [1, 10].
+ // Normalization adds [2, 23] (aside: at least 2 because the pre-normalized mantissa is at least 5).
+ // This adds up to [3, 62], which is well below float's maximum binary exponent 127.
+
+ // Therefore, we just need to consider (__v.__mantissa >> _Trailing_zero_bits) * 5^_Ryu_exponent.
+
+ // If that product would exceed 24 bits, then X can't be exactly represented as a float.
+ // (That's not a problem for round-tripping, because X is close enough to the original float,
+ // but X isn't mathematically equal to the original float.) This requires a high-precision fallback.
+
+ // If the product is 24 bits or smaller, then X can be exactly represented as a float (and we don't
+ // need to re-synthesize it; the original float must have been X, because Ryu wouldn't produce the
+ // same output for two different floats X and Y). This allows Ryu's output to be used (zero-filled).
+
+ // (2^24 - 1) / 5^0 (for indexing), (2^24 - 1) / 5^1, ..., (2^24 - 1) / 5^10
+ static constexpr uint32_t _Max_shifted_mantissa[11] = {
+ 16777215, 3355443, 671088, 134217, 26843, 5368, 1073, 214, 42, 8, 1 };
+
+ unsigned long _Trailing_zero_bits;
+ (void) _BitScanForward(&_Trailing_zero_bits, __v.__mantissa); // __v.__mantissa is guaranteed nonzero
+ const uint32_t _Shifted_mantissa = __v.__mantissa >> _Trailing_zero_bits;
+ _Can_use_ryu = _Shifted_mantissa <= _Max_shifted_mantissa[_Ryu_exponent];
+ }
+
+ if (!_Can_use_ryu) {
+ const uint32_t _Mantissa2 = __ieeeMantissa | (1u << __FLOAT_MANTISSA_BITS); // restore implicit bit
+ const int32_t _Exponent2 = static_cast<int32_t>(__ieeeExponent)
+ - __FLOAT_BIAS - __FLOAT_MANTISSA_BITS; // bias and normalization
+
+ // Performance note: We've already called Ryu, so this will redundantly perform buffering and bounds checking.
+ return _Large_integer_to_chars(_First, _Last, _Mantissa2, _Exponent2);
+ }
+
+ // _Can_use_ryu
+ // Print the decimal digits, left-aligned within [_First, _First + _Total_fixed_length).
+ _Mid = _First + __olength;
+ } else { // cases "1729", "17.29", and "0.001729"
+ // Print the decimal digits, right-aligned within [_First, _First + _Total_fixed_length).
+ _Mid = _First + _Total_fixed_length;
+ }
+
+ while (_Output >= 10000) {
+#ifdef __clang__ // TRANSITION, LLVM-38217
+ const uint32_t __c = _Output - 10000 * (_Output / 10000);
+#else
+ const uint32_t __c = _Output % 10000;
+#endif
+ _Output /= 10000;
+ const uint32_t __c0 = (__c % 100) << 1;
+ const uint32_t __c1 = (__c / 100) << 1;
+ _VSTD::memcpy(_Mid -= 2, __DIGIT_TABLE + __c0, 2);
+ _VSTD::memcpy(_Mid -= 2, __DIGIT_TABLE + __c1, 2);
+ }
+ if (_Output >= 100) {
+ const uint32_t __c = (_Output % 100) << 1;
+ _Output /= 100;
+ _VSTD::memcpy(_Mid -= 2, __DIGIT_TABLE + __c, 2);
+ }
+ if (_Output >= 10) {
+ const uint32_t __c = _Output << 1;
+ _VSTD::memcpy(_Mid -= 2, __DIGIT_TABLE + __c, 2);
+ } else {
+ *--_Mid = static_cast<char>('0' + _Output);
+ }
+
+ if (_Ryu_exponent > 0) { // case "172900" with _Can_use_ryu
+ // Performance note: it might be more efficient to do this immediately after setting _Mid.
+ _VSTD::memset(_First + __olength, '0', static_cast<size_t>(_Ryu_exponent));
+ } else if (_Ryu_exponent == 0) { // case "1729"
+ // Done!
+ } else if (_Whole_digits > 0) { // case "17.29"
+ // Performance note: moving digits might not be optimal.
+ _VSTD::memmove(_First, _First + 1, static_cast<size_t>(_Whole_digits));
+ _First[_Whole_digits] = '.';
+ } else { // case "0.001729"
+ // Performance note: a larger memset() followed by overwriting '.' might be more efficient.
+ _First[0] = '0';
+ _First[1] = '.';
+ _VSTD::memset(_First + 2, '0', static_cast<size_t>(-_Whole_digits));
+ }
+
+ return { _First + _Total_fixed_length, errc{} };
+ }
+
+ const uint32_t _Total_scientific_length =
+ __olength + (__olength > 1) + 4; // digits + possible decimal point + scientific exponent
+ if (_Last - _First < static_cast<ptrdiff_t>(_Total_scientific_length)) {
+ return { _Last, errc::value_too_large };
+ }
+ char* const __result = _First;
+
+ // Print the decimal digits.
+ uint32_t __i = 0;
+ while (_Output >= 10000) {
+#ifdef __clang__ // TRANSITION, LLVM-38217
+ const uint32_t __c = _Output - 10000 * (_Output / 10000);
+#else
+ const uint32_t __c = _Output % 10000;
+#endif
+ _Output /= 10000;
+ const uint32_t __c0 = (__c % 100) << 1;
+ const uint32_t __c1 = (__c / 100) << 1;
+ _VSTD::memcpy(__result + __olength - __i - 1, __DIGIT_TABLE + __c0, 2);
+ _VSTD::memcpy(__result + __olength - __i - 3, __DIGIT_TABLE + __c1, 2);
+ __i += 4;
+ }
+ if (_Output >= 100) {
+ const uint32_t __c = (_Output % 100) << 1;
+ _Output /= 100;
+ _VSTD::memcpy(__result + __olength - __i - 1, __DIGIT_TABLE + __c, 2);
+ __i += 2;
+ }
+ if (_Output >= 10) {
+ const uint32_t __c = _Output << 1;
+ // We can't use memcpy here: the decimal dot goes between these two digits.
+ __result[2] = __DIGIT_TABLE[__c + 1];
+ __result[0] = __DIGIT_TABLE[__c];
+ } else {
+ __result[0] = static_cast<char>('0' + _Output);
+ }
+
+ // Print decimal point if needed.
+ uint32_t __index;
+ if (__olength > 1) {
+ __result[1] = '.';
+ __index = __olength + 1;
+ } else {
+ __index = 1;
+ }
+
+ // Print the exponent.
+ __result[__index++] = 'e';
+ if (_Scientific_exponent < 0) {
+ __result[__index++] = '-';
+ _Scientific_exponent = -_Scientific_exponent;
+ } else {
+ __result[__index++] = '+';
+ }
+
+ _VSTD::memcpy(__result + __index, __DIGIT_TABLE + 2 * _Scientific_exponent, 2);
+ __index += 2;
+
+ return { _First + _Total_scientific_length, errc{} };
+}
+
+[[nodiscard]] to_chars_result __f2s_buffered_n(char* const _First, char* const _Last, const float __f,
+ const chars_format _Fmt) {
+
+ // Step 1: Decode the floating-point number, and unify normalized and subnormal cases.
+ const uint32_t __bits = __float_to_bits(__f);
+
+ // Case distinction; exit early for the easy cases.
+ if (__bits == 0) {
+ if (_Fmt == chars_format::scientific) {
+ if (_Last - _First < 5) {
+ return { _Last, errc::value_too_large };
+ }
+
+ _VSTD::memcpy(_First, "0e+00", 5);
+
+ return { _First + 5, errc{} };
+ }
+
+ // Print "0" for chars_format::fixed, chars_format::general, and chars_format{}.
+ if (_First == _Last) {
+ return { _Last, errc::value_too_large };
+ }
+
+ *_First = '0';
+
+ return { _First + 1, errc{} };
+ }
+
+ // Decode __bits into mantissa and exponent.
+ const uint32_t __ieeeMantissa = __bits & ((1u << __FLOAT_MANTISSA_BITS) - 1);
+ const uint32_t __ieeeExponent = __bits >> __FLOAT_MANTISSA_BITS;
+
+ // When _Fmt == chars_format::fixed and the floating-point number is a large integer,
+ // it's faster to skip Ryu and immediately print the integer exactly.
+ if (_Fmt == chars_format::fixed) {
+ const uint32_t _Mantissa2 = __ieeeMantissa | (1u << __FLOAT_MANTISSA_BITS); // restore implicit bit
+ const int32_t _Exponent2 = static_cast<int32_t>(__ieeeExponent)
+ - __FLOAT_BIAS - __FLOAT_MANTISSA_BITS; // bias and normalization
+
+ // Normal values are equal to _Mantissa2 * 2^_Exponent2.
+ // (Subnormals are different, but they'll be rejected by the _Exponent2 test here, so they can be ignored.)
+
+ if (_Exponent2 > 0) {
+ return _Large_integer_to_chars(_First, _Last, _Mantissa2, _Exponent2);
+ }
+ }
+
+ const __floating_decimal_32 __v = __f2d(__ieeeMantissa, __ieeeExponent);
+ return __to_chars(_First, _Last, __v, _Fmt, __ieeeMantissa, __ieeeExponent);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+// clang-format on
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/shared_mutex.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/shared_mutex.cpp
new file mode 100644
index 0000000000..deb3ced014
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/shared_mutex.cpp
@@ -0,0 +1,119 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <__config>
+
+#ifndef _LIBCPP_HAS_NO_THREADS
+
+#include <shared_mutex>
+#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
+# pragma comment(lib, "pthread")
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// Shared Mutex Base
+__shared_mutex_base::__shared_mutex_base()
+ : __state_(0)
+{
+}
+
+// Exclusive ownership
+
+void
+__shared_mutex_base::lock()
+{
+ unique_lock<mutex> lk(__mut_);
+ while (__state_ & __write_entered_)
+ __gate1_.wait(lk);
+ __state_ |= __write_entered_;
+ while (__state_ & __n_readers_)
+ __gate2_.wait(lk);
+}
+
+bool
+__shared_mutex_base::try_lock()
+{
+ unique_lock<mutex> lk(__mut_);
+ if (__state_ == 0)
+ {
+ __state_ = __write_entered_;
+ return true;
+ }
+ return false;
+}
+
+void
+__shared_mutex_base::unlock()
+{
+ lock_guard<mutex> _(__mut_);
+ __state_ = 0;
+ __gate1_.notify_all();
+}
+
+// Shared ownership
+
+void
+__shared_mutex_base::lock_shared()
+{
+ unique_lock<mutex> lk(__mut_);
+ while ((__state_ & __write_entered_) || (__state_ & __n_readers_) == __n_readers_)
+ __gate1_.wait(lk);
+ unsigned num_readers = (__state_ & __n_readers_) + 1;
+ __state_ &= ~__n_readers_;
+ __state_ |= num_readers;
+}
+
+bool
+__shared_mutex_base::try_lock_shared()
+{
+ unique_lock<mutex> lk(__mut_);
+ unsigned num_readers = __state_ & __n_readers_;
+ if (!(__state_ & __write_entered_) && num_readers != __n_readers_)
+ {
+ ++num_readers;
+ __state_ &= ~__n_readers_;
+ __state_ |= num_readers;
+ return true;
+ }
+ return false;
+}
+
+void
+__shared_mutex_base::unlock_shared()
+{
+ lock_guard<mutex> _(__mut_);
+ unsigned num_readers = (__state_ & __n_readers_) - 1;
+ __state_ &= ~__n_readers_;
+ __state_ |= num_readers;
+ if (__state_ & __write_entered_)
+ {
+ if (num_readers == 0)
+ __gate2_.notify_one();
+ }
+ else
+ {
+ if (num_readers == __n_readers_ - 1)
+ __gate1_.notify_one();
+ }
+}
+
+
+// Shared Timed Mutex
+// These routines are here for ABI stability
+shared_timed_mutex::shared_timed_mutex() : __base() {}
+void shared_timed_mutex::lock() { return __base.lock(); }
+bool shared_timed_mutex::try_lock() { return __base.try_lock(); }
+void shared_timed_mutex::unlock() { return __base.unlock(); }
+void shared_timed_mutex::lock_shared() { return __base.lock_shared(); }
+bool shared_timed_mutex::try_lock_shared() { return __base.try_lock_shared(); }
+void shared_timed_mutex::unlock_shared() { return __base.unlock_shared(); }
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // !_LIBCPP_HAS_NO_THREADS
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/stdexcept.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/stdexcept.cpp
new file mode 100644
index 0000000000..d08b6740db
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/stdexcept.cpp
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <new>
+#include <stdexcept>
+#include <string>
+#include <system_error>
+
+#ifdef _LIBCPP_ABI_VCRUNTIME
+#include "support/runtime/stdexcept_vcruntime.ipp"
+#else
+#include "support/runtime/stdexcept_default.ipp"
+#endif
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/string.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/string.cpp
new file mode 100644
index 0000000000..9d1de0cf6c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/string.cpp
@@ -0,0 +1,514 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <__assert>
+#include <cerrno>
+#include <charconv>
+#include <cstdlib>
+#include <limits>
+#include <stdexcept>
+#include <stdio.h>
+#include <string>
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# include <cwchar>
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifndef _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON
+
+template <bool>
+struct __basic_string_common;
+
+// The struct isn't declared anymore in the headers. It's only here for ABI compatibility.
+template <>
+struct __basic_string_common<true> {
+ _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_length_error() const;
+ _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_out_of_range() const;
+};
+
+void __basic_string_common<true>::__throw_length_error() const {
+ std::__throw_length_error("basic_string");
+}
+void __basic_string_common<true>::__throw_out_of_range() const {
+ std::__throw_out_of_range("basic_string");
+}
+
+#endif // _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON
+
+#define _LIBCPP_EXTERN_TEMPLATE_DEFINE(...) template __VA_ARGS__;
+#ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
+ _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, char)
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, wchar_t)
+# endif
+#else
+ _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, char)
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, wchar_t)
+# endif
+#endif
+#undef _LIBCPP_EXTERN_TEMPLATE_DEFINE
+
+template string operator+<char, char_traits<char>, allocator<char> >(char const*, string const&);
+
+namespace
+{
+
+template<typename T>
+inline
+void throw_helper( const string& msg )
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw T( msg );
+#else
+ fprintf(stderr, "%s\n", msg.c_str());
+ _VSTD::abort();
+#endif
+}
+
+inline
+void throw_from_string_out_of_range( const string& func )
+{
+ throw_helper<out_of_range>(func + ": out of range");
+}
+
+inline
+void throw_from_string_invalid_arg( const string& func )
+{
+ throw_helper<invalid_argument>(func + ": no conversion");
+}
+
+// as_integer
+
+template<typename V, typename S, typename F>
+inline
+V
+as_integer_helper(const string& func, const S& str, size_t* idx, int base, F f)
+{
+ typename S::value_type* ptr = nullptr;
+ const typename S::value_type* const p = str.c_str();
+ typename remove_reference<decltype(errno)>::type errno_save = errno;
+ errno = 0;
+ V r = f(p, &ptr, base);
+ swap(errno, errno_save);
+ if (errno_save == ERANGE)
+ throw_from_string_out_of_range(func);
+ if (ptr == p)
+ throw_from_string_invalid_arg(func);
+ if (idx)
+ *idx = static_cast<size_t>(ptr - p);
+ return r;
+}
+
+template<typename V, typename S>
+inline
+V
+as_integer(const string& func, const S& s, size_t* idx, int base);
+
+// string
+template<>
+inline
+int
+as_integer(const string& func, const string& s, size_t* idx, int base )
+{
+ // Use long as no Standard string to integer exists.
+ long r = as_integer_helper<long>( func, s, idx, base, strtol );
+ if (r < numeric_limits<int>::min() || numeric_limits<int>::max() < r)
+ throw_from_string_out_of_range(func);
+ return static_cast<int>(r);
+}
+
+template<>
+inline
+long
+as_integer(const string& func, const string& s, size_t* idx, int base )
+{
+ return as_integer_helper<long>( func, s, idx, base, strtol );
+}
+
+template<>
+inline
+unsigned long
+as_integer( const string& func, const string& s, size_t* idx, int base )
+{
+ return as_integer_helper<unsigned long>( func, s, idx, base, strtoul );
+}
+
+template<>
+inline
+long long
+as_integer( const string& func, const string& s, size_t* idx, int base )
+{
+ return as_integer_helper<long long>( func, s, idx, base, strtoll );
+}
+
+template<>
+inline
+unsigned long long
+as_integer( const string& func, const string& s, size_t* idx, int base )
+{
+ return as_integer_helper<unsigned long long>( func, s, idx, base, strtoull );
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+// wstring
+template<>
+inline
+int
+as_integer( const string& func, const wstring& s, size_t* idx, int base )
+{
+ // Use long as no Stantard string to integer exists.
+ long r = as_integer_helper<long>( func, s, idx, base, wcstol );
+ if (r < numeric_limits<int>::min() || numeric_limits<int>::max() < r)
+ throw_from_string_out_of_range(func);
+ return static_cast<int>(r);
+}
+
+template<>
+inline
+long
+as_integer( const string& func, const wstring& s, size_t* idx, int base )
+{
+ return as_integer_helper<long>( func, s, idx, base, wcstol );
+}
+
+template<>
+inline
+unsigned long
+as_integer( const string& func, const wstring& s, size_t* idx, int base )
+{
+ return as_integer_helper<unsigned long>( func, s, idx, base, wcstoul );
+}
+
+template<>
+inline
+long long
+as_integer( const string& func, const wstring& s, size_t* idx, int base )
+{
+ return as_integer_helper<long long>( func, s, idx, base, wcstoll );
+}
+
+template<>
+inline
+unsigned long long
+as_integer( const string& func, const wstring& s, size_t* idx, int base )
+{
+ return as_integer_helper<unsigned long long>( func, s, idx, base, wcstoull );
+}
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+// as_float
+
+template<typename V, typename S, typename F>
+inline
+V
+as_float_helper(const string& func, const S& str, size_t* idx, F f )
+{
+ typename S::value_type* ptr = nullptr;
+ const typename S::value_type* const p = str.c_str();
+ typename remove_reference<decltype(errno)>::type errno_save = errno;
+ errno = 0;
+ V r = f(p, &ptr);
+ swap(errno, errno_save);
+ if (errno_save == ERANGE)
+ throw_from_string_out_of_range(func);
+ if (ptr == p)
+ throw_from_string_invalid_arg(func);
+ if (idx)
+ *idx = static_cast<size_t>(ptr - p);
+ return r;
+}
+
+template<typename V, typename S>
+inline
+V as_float( const string& func, const S& s, size_t* idx = nullptr );
+
+template<>
+inline
+float
+as_float( const string& func, const string& s, size_t* idx )
+{
+ return as_float_helper<float>( func, s, idx, strtof );
+}
+
+template<>
+inline
+double
+as_float(const string& func, const string& s, size_t* idx )
+{
+ return as_float_helper<double>( func, s, idx, strtod );
+}
+
+template<>
+inline
+long double
+as_float( const string& func, const string& s, size_t* idx )
+{
+ return as_float_helper<long double>( func, s, idx, strtold );
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template<>
+inline
+float
+as_float( const string& func, const wstring& s, size_t* idx )
+{
+ return as_float_helper<float>( func, s, idx, wcstof );
+}
+
+template<>
+inline
+double
+as_float( const string& func, const wstring& s, size_t* idx )
+{
+ return as_float_helper<double>( func, s, idx, wcstod );
+}
+
+template<>
+inline
+long double
+as_float( const string& func, const wstring& s, size_t* idx )
+{
+ return as_float_helper<long double>( func, s, idx, wcstold );
+}
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+} // unnamed namespace
+
+int
+stoi(const string& str, size_t* idx, int base)
+{
+ return as_integer<int>( "stoi", str, idx, base );
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+int
+stoi(const wstring& str, size_t* idx, int base)
+{
+ return as_integer<int>( "stoi", str, idx, base );
+}
+#endif
+
+long
+stol(const string& str, size_t* idx, int base)
+{
+ return as_integer<long>( "stol", str, idx, base );
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+long
+stol(const wstring& str, size_t* idx, int base)
+{
+ return as_integer<long>( "stol", str, idx, base );
+}
+#endif
+
+unsigned long
+stoul(const string& str, size_t* idx, int base)
+{
+ return as_integer<unsigned long>( "stoul", str, idx, base );
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+unsigned long
+stoul(const wstring& str, size_t* idx, int base)
+{
+ return as_integer<unsigned long>( "stoul", str, idx, base );
+}
+#endif
+
+long long
+stoll(const string& str, size_t* idx, int base)
+{
+ return as_integer<long long>( "stoll", str, idx, base );
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+long long
+stoll(const wstring& str, size_t* idx, int base)
+{
+ return as_integer<long long>( "stoll", str, idx, base );
+}
+#endif
+
+unsigned long long
+stoull(const string& str, size_t* idx, int base)
+{
+ return as_integer<unsigned long long>( "stoull", str, idx, base );
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+unsigned long long
+stoull(const wstring& str, size_t* idx, int base)
+{
+ return as_integer<unsigned long long>( "stoull", str, idx, base );
+}
+#endif
+
+float
+stof(const string& str, size_t* idx)
+{
+ return as_float<float>( "stof", str, idx );
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+float
+stof(const wstring& str, size_t* idx)
+{
+ return as_float<float>( "stof", str, idx );
+}
+#endif
+
+double
+stod(const string& str, size_t* idx)
+{
+ return as_float<double>( "stod", str, idx );
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+double
+stod(const wstring& str, size_t* idx)
+{
+ return as_float<double>( "stod", str, idx );
+}
+#endif
+
+long double
+stold(const string& str, size_t* idx)
+{
+ return as_float<long double>( "stold", str, idx );
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+long double
+stold(const wstring& str, size_t* idx)
+{
+ return as_float<long double>( "stold", str, idx );
+}
+#endif
+
+// to_string
+
+namespace
+{
+
+// as_string
+
+template<typename S, typename P, typename V >
+inline
+S
+as_string(P sprintf_like, S s, const typename S::value_type* fmt, V a)
+{
+ typedef typename S::size_type size_type;
+ size_type available = s.size();
+ while (true)
+ {
+ int status = sprintf_like(&s[0], available + 1, fmt, a);
+ if ( status >= 0 )
+ {
+ size_type used = static_cast<size_type>(status);
+ if ( used <= available )
+ {
+ s.resize( used );
+ break;
+ }
+ available = used; // Assume this is advice of how much space we need.
+ }
+ else
+ available = available * 2 + 1;
+ s.resize(available);
+ }
+ return s;
+}
+
+template <class S>
+struct initial_string;
+
+template <>
+struct initial_string<string>
+{
+ string
+ operator()() const
+ {
+ string s;
+ s.resize(s.capacity());
+ return s;
+ }
+};
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+struct initial_string<wstring>
+{
+ wstring
+ operator()() const
+ {
+ wstring s(20, wchar_t());
+ s.resize(s.capacity());
+ return s;
+ }
+};
+
+typedef int (*wide_printf)(wchar_t* __restrict, size_t, const wchar_t*__restrict, ...);
+
+inline
+wide_printf
+get_swprintf()
+{
+#ifndef _LIBCPP_MSVCRT
+ return swprintf;
+#else
+ return static_cast<int (__cdecl*)(wchar_t* __restrict, size_t, const wchar_t*__restrict, ...)>(_snwprintf);
+#endif
+}
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+template <typename S, typename V>
+S i_to_string(V v)
+{
+// numeric_limits::digits10 returns value less on 1 than desired for unsigned numbers.
+// For example, for 1-byte unsigned value digits10 is 2 (999 can not be represented),
+// so we need +1 here.
+ constexpr size_t bufsize = numeric_limits<V>::digits10 + 2; // +1 for minus, +1 for digits10
+ char buf[bufsize];
+ const auto res = to_chars(buf, buf + bufsize, v);
+ _LIBCPP_ASSERT(res.ec == errc(), "bufsize must be large enough to accomodate the value");
+ return S(buf, res.ptr);
+}
+
+} // unnamed namespace
+
+string to_string (int val) { return i_to_string< string>(val); }
+string to_string (long val) { return i_to_string< string>(val); }
+string to_string (long long val) { return i_to_string< string>(val); }
+string to_string (unsigned val) { return i_to_string< string>(val); }
+string to_string (unsigned long val) { return i_to_string< string>(val); }
+string to_string (unsigned long long val) { return i_to_string< string>(val); }
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+wstring to_wstring(int val) { return i_to_string<wstring>(val); }
+wstring to_wstring(long val) { return i_to_string<wstring>(val); }
+wstring to_wstring(long long val) { return i_to_string<wstring>(val); }
+wstring to_wstring(unsigned val) { return i_to_string<wstring>(val); }
+wstring to_wstring(unsigned long val) { return i_to_string<wstring>(val); }
+wstring to_wstring(unsigned long long val) { return i_to_string<wstring>(val); }
+#endif
+
+string to_string (float val) { return as_string(snprintf, initial_string< string>()(), "%f", val); }
+string to_string (double val) { return as_string(snprintf, initial_string< string>()(), "%f", val); }
+string to_string (long double val) { return as_string(snprintf, initial_string< string>()(), "%Lf", val); }
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+wstring to_wstring(float val) { return as_string(get_swprintf(), initial_string<wstring>()(), L"%f", val); }
+wstring to_wstring(double val) { return as_string(get_swprintf(), initial_string<wstring>()(), L"%f", val); }
+wstring to_wstring(long double val) { return as_string(get_swprintf(), initial_string<wstring>()(), L"%Lf", val); }
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/strstream.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/strstream.cpp
new file mode 100644
index 0000000000..87c235a97a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/strstream.cpp
@@ -0,0 +1,340 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <__assert>
+#include <__utility/unreachable.h>
+#include <algorithm>
+#include <climits>
+#include <cstdlib>
+#include <cstring>
+#include <strstream>
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+strstreambuf::strstreambuf(streamsize __alsize)
+ : __strmode_(__dynamic),
+ __alsize_(__alsize),
+ __palloc_(nullptr),
+ __pfree_(nullptr)
+{
+}
+
+strstreambuf::strstreambuf(void* (*__palloc)(size_t), void (*__pfree)(void*))
+ : __strmode_(__dynamic),
+ __alsize_(__default_alsize),
+ __palloc_(__palloc),
+ __pfree_(__pfree)
+{
+}
+
+void
+strstreambuf::__init(char* __gnext, streamsize __n, char* __pbeg)
+{
+ if (__n == 0)
+ __n = static_cast<streamsize>(strlen(__gnext));
+ else if (__n < 0)
+ __n = INT_MAX;
+ if (__pbeg == nullptr)
+ setg(__gnext, __gnext, __gnext + __n);
+ else
+ {
+ setg(__gnext, __gnext, __pbeg);
+ setp(__pbeg, __pbeg + __n);
+ }
+}
+
+strstreambuf::strstreambuf(char* __gnext, streamsize __n, char* __pbeg)
+ : __strmode_(),
+ __alsize_(__default_alsize),
+ __palloc_(nullptr),
+ __pfree_(nullptr)
+{
+ __init(__gnext, __n, __pbeg);
+}
+
+strstreambuf::strstreambuf(const char* __gnext, streamsize __n)
+ : __strmode_(__constant),
+ __alsize_(__default_alsize),
+ __palloc_(nullptr),
+ __pfree_(nullptr)
+{
+ __init(const_cast<char *>(__gnext), __n, nullptr);
+}
+
+strstreambuf::strstreambuf(signed char* __gnext, streamsize __n, signed char* __pbeg)
+ : __strmode_(),
+ __alsize_(__default_alsize),
+ __palloc_(nullptr),
+ __pfree_(nullptr)
+{
+ __init(const_cast<char *>(reinterpret_cast<const char*>(__gnext)), __n, reinterpret_cast<char*>(__pbeg));
+}
+
+strstreambuf::strstreambuf(const signed char* __gnext, streamsize __n)
+ : __strmode_(__constant),
+ __alsize_(__default_alsize),
+ __palloc_(nullptr),
+ __pfree_(nullptr)
+{
+ __init(const_cast<char *>(reinterpret_cast<const char*>(__gnext)), __n, nullptr);
+}
+
+strstreambuf::strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg)
+ : __strmode_(),
+ __alsize_(__default_alsize),
+ __palloc_(nullptr),
+ __pfree_(nullptr)
+{
+ __init(const_cast<char *>(reinterpret_cast<const char*>(__gnext)), __n, reinterpret_cast<char*>(__pbeg));
+}
+
+strstreambuf::strstreambuf(const unsigned char* __gnext, streamsize __n)
+ : __strmode_(__constant),
+ __alsize_(__default_alsize),
+ __palloc_(nullptr),
+ __pfree_(nullptr)
+{
+ __init(const_cast<char *>(reinterpret_cast<const char*>(__gnext)), __n, nullptr);
+}
+
+strstreambuf::~strstreambuf()
+{
+ if (eback() && (__strmode_ & __allocated) != 0 && (__strmode_ & __frozen) == 0)
+ {
+ if (__pfree_)
+ __pfree_(eback());
+ else
+ delete [] eback();
+ }
+}
+
+void
+strstreambuf::swap(strstreambuf& __rhs)
+{
+ streambuf::swap(__rhs);
+ _VSTD::swap(__strmode_, __rhs.__strmode_);
+ _VSTD::swap(__alsize_, __rhs.__alsize_);
+ _VSTD::swap(__palloc_, __rhs.__palloc_);
+ _VSTD::swap(__pfree_, __rhs.__pfree_);
+}
+
+void
+strstreambuf::freeze(bool __freezefl)
+{
+ if (__strmode_ & __dynamic)
+ {
+ if (__freezefl)
+ __strmode_ |= __frozen;
+ else
+ __strmode_ &= ~__frozen;
+ }
+}
+
+char*
+strstreambuf::str()
+{
+ if (__strmode_ & __dynamic)
+ __strmode_ |= __frozen;
+ return eback();
+}
+
+int
+strstreambuf::pcount() const
+{
+ return static_cast<int>(pptr() - pbase());
+}
+
+strstreambuf::int_type
+strstreambuf::overflow(int_type __c)
+{
+ if (__c == EOF)
+ return int_type(0);
+ if (pptr() == epptr())
+ {
+ if ((__strmode_ & __dynamic) == 0 || (__strmode_ & __frozen) != 0)
+ return int_type(EOF);
+ size_t old_size = static_cast<size_t> ((epptr() ? epptr() : egptr()) - eback());
+ size_t new_size = max<size_t>(static_cast<size_t>(__alsize_), 2*old_size);
+ if (new_size == 0)
+ new_size = __default_alsize;
+ char* buf = nullptr;
+ if (__palloc_)
+ buf = static_cast<char*>(__palloc_(new_size));
+ else
+ buf = new char[new_size];
+ if (buf == nullptr)
+ return int_type(EOF);
+ if (old_size != 0) {
+ _LIBCPP_ASSERT(eback(), "overflow copying from NULL");
+ memcpy(buf, eback(), static_cast<size_t>(old_size));
+ }
+ ptrdiff_t ninp = gptr() - eback();
+ ptrdiff_t einp = egptr() - eback();
+ ptrdiff_t nout = pptr() - pbase();
+ if (__strmode_ & __allocated)
+ {
+ if (__pfree_)
+ __pfree_(eback());
+ else
+ delete [] eback();
+ }
+ setg(buf, buf + ninp, buf + einp);
+ setp(buf + einp, buf + new_size);
+ __pbump(nout);
+ __strmode_ |= __allocated;
+ }
+ *pptr() = static_cast<char>(__c);
+ pbump(1);
+ return int_type(static_cast<unsigned char>(__c));
+}
+
+strstreambuf::int_type
+strstreambuf::pbackfail(int_type __c)
+{
+ if (eback() == gptr())
+ return EOF;
+ if (__c == EOF)
+ {
+ gbump(-1);
+ return int_type(0);
+ }
+ if (__strmode_ & __constant)
+ {
+ if (gptr()[-1] == static_cast<char>(__c))
+ {
+ gbump(-1);
+ return __c;
+ }
+ return EOF;
+ }
+ gbump(-1);
+ *gptr() = static_cast<char>(__c);
+ return __c;
+}
+
+strstreambuf::int_type
+strstreambuf::underflow()
+{
+ if (gptr() == egptr())
+ {
+ if (egptr() >= pptr())
+ return EOF;
+ setg(eback(), gptr(), pptr());
+ }
+ return int_type(static_cast<unsigned char>(*gptr()));
+}
+
+strstreambuf::pos_type
+strstreambuf::seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __which)
+{
+ off_type __p(-1);
+ bool pos_in = (__which & ios::in) != 0;
+ bool pos_out = (__which & ios::out) != 0;
+ bool legal = false;
+ switch (__way)
+ {
+ case ios::beg:
+ case ios::end:
+ if (pos_in || pos_out)
+ legal = true;
+ break;
+ case ios::cur:
+ if (pos_in != pos_out)
+ legal = true;
+ break;
+ }
+ if (pos_in && gptr() == nullptr)
+ legal = false;
+ if (pos_out && pptr() == nullptr)
+ legal = false;
+ if (legal)
+ {
+ off_type newoff;
+ char* seekhigh = epptr() ? epptr() : egptr();
+ switch (__way)
+ {
+ case ios::beg:
+ newoff = 0;
+ break;
+ case ios::cur:
+ newoff = (pos_in ? gptr() : pptr()) - eback();
+ break;
+ case ios::end:
+ newoff = seekhigh - eback();
+ break;
+ default:
+ __libcpp_unreachable();
+ }
+ newoff += __off;
+ if (0 <= newoff && newoff <= seekhigh - eback())
+ {
+ char* newpos = eback() + newoff;
+ if (pos_in)
+ setg(eback(), newpos, _VSTD::max(newpos, egptr()));
+ if (pos_out)
+ {
+ // min(pbase, newpos), newpos, epptr()
+ __off = epptr() - newpos;
+ setp(min(pbase(), newpos), epptr());
+ __pbump((epptr() - pbase()) - __off);
+ }
+ __p = newoff;
+ }
+ }
+ return pos_type(__p);
+}
+
+strstreambuf::pos_type
+strstreambuf::seekpos(pos_type __sp, ios_base::openmode __which)
+{
+ off_type __p(-1);
+ bool pos_in = (__which & ios::in) != 0;
+ bool pos_out = (__which & ios::out) != 0;
+ if (pos_in || pos_out)
+ {
+ if (!((pos_in && gptr() == nullptr) || (pos_out && pptr() == nullptr)))
+ {
+ off_type newoff = __sp;
+ char* seekhigh = epptr() ? epptr() : egptr();
+ if (0 <= newoff && newoff <= seekhigh - eback())
+ {
+ char* newpos = eback() + newoff;
+ if (pos_in)
+ setg(eback(), newpos, _VSTD::max(newpos, egptr()));
+ if (pos_out)
+ {
+ // min(pbase, newpos), newpos, epptr()
+ off_type temp = epptr() - newpos;
+ setp(min(pbase(), newpos), epptr());
+ __pbump((epptr() - pbase()) - temp);
+ }
+ __p = newoff;
+ }
+ }
+ }
+ return pos_type(__p);
+}
+
+istrstream::~istrstream()
+{
+}
+
+ostrstream::~ostrstream()
+{
+}
+
+strstream::~strstream()
+{
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_fallback.ipp b/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_fallback.ipp
new file mode 100644
index 0000000000..ebdca7e5ee
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_fallback.ipp
@@ -0,0 +1,163 @@
+// -*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <cstdio>
+#include "../../include/atomic_support.h"
+
+namespace std {
+
+static constinit std::terminate_handler __terminate_handler = nullptr;
+static constinit std::unexpected_handler __unexpected_handler = nullptr;
+
+// libcxxrt provides implementations of these functions itself.
+unexpected_handler
+set_unexpected(unexpected_handler func) noexcept
+{
+ return __libcpp_atomic_exchange(&__unexpected_handler, func);
+}
+
+unexpected_handler
+get_unexpected() noexcept
+{
+ return __libcpp_atomic_load(&__unexpected_handler);
+}
+
+_LIBCPP_NORETURN
+void unexpected()
+{
+ (*get_unexpected())();
+ // unexpected handler should not return
+ terminate();
+}
+
+terminate_handler
+set_terminate(terminate_handler func) noexcept
+{
+ return __libcpp_atomic_exchange(&__terminate_handler, func);
+}
+
+terminate_handler
+get_terminate() noexcept
+{
+ return __libcpp_atomic_load(&__terminate_handler);
+}
+
+#ifndef __EMSCRIPTEN__ // We provide this in JS
+_LIBCPP_NORETURN
+void
+terminate() noexcept
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ (*get_terminate())();
+ // handler should not return
+ fprintf(stderr, "terminate_handler unexpectedly returned\n");
+ ::abort();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ // handler should not throw exception
+ fprintf(stderr, "terminate_handler unexpectedly threw an exception\n");
+ ::abort();
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+}
+#endif // !__EMSCRIPTEN__
+
+#if !defined(__EMSCRIPTEN__)
+bool uncaught_exception() noexcept { return uncaught_exceptions() > 0; }
+
+int uncaught_exceptions() noexcept
+{
+#warning uncaught_exception not yet implemented
+ fprintf(stderr, "uncaught_exceptions not yet implemented\n");
+ ::abort();
+}
+#endif // !__EMSCRIPTEN__
+
+
+exception::~exception() noexcept
+{
+}
+
+const char* exception::what() const noexcept
+{
+ return "std::exception";
+}
+
+bad_exception::~bad_exception() noexcept
+{
+}
+
+const char* bad_exception::what() const noexcept
+{
+ return "std::bad_exception";
+}
+
+
+bad_alloc::bad_alloc() noexcept
+{
+}
+
+bad_alloc::~bad_alloc() noexcept
+{
+}
+
+const char*
+bad_alloc::what() const noexcept
+{
+ return "std::bad_alloc";
+}
+
+bad_array_new_length::bad_array_new_length() noexcept
+{
+}
+
+bad_array_new_length::~bad_array_new_length() noexcept
+{
+}
+
+const char*
+bad_array_new_length::what() const noexcept
+{
+ return "bad_array_new_length";
+}
+
+bad_cast::bad_cast() noexcept
+{
+}
+
+bad_typeid::bad_typeid() noexcept
+{
+}
+
+bad_cast::~bad_cast() noexcept
+{
+}
+
+const char*
+bad_cast::what() const noexcept
+{
+ return "std::bad_cast";
+}
+
+bad_typeid::~bad_typeid() noexcept
+{
+}
+
+const char*
+bad_typeid::what() const noexcept
+{
+ return "std::bad_typeid";
+}
+
+} // namespace std
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_glibcxx.ipp b/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_glibcxx.ipp
new file mode 100644
index 0000000000..e478ccbb6e
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_glibcxx.ipp
@@ -0,0 +1,32 @@
+// -*- 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 __GLIBCXX__
+#error header can only be used when targeting libstdc++ or libsupc++
+#endif
+
+namespace std {
+
+bad_alloc::bad_alloc() noexcept
+{
+}
+
+bad_array_new_length::bad_array_new_length() noexcept
+{
+}
+
+bad_cast::bad_cast() noexcept
+{
+}
+
+bad_typeid::bad_typeid() noexcept
+{
+}
+
+} // namespace std
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_libcxxabi.ipp b/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_libcxxabi.ipp
new file mode 100644
index 0000000000..ee15e437e6
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_libcxxabi.ipp
@@ -0,0 +1,27 @@
+// -*- 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 _LIBCPPABI_VERSION
+#error this header can only be used with libc++abi
+#endif
+
+namespace std {
+
+bool uncaught_exception() noexcept { return uncaught_exceptions() > 0; }
+
+int uncaught_exceptions() noexcept
+{
+# if _LIBCPPABI_VERSION > 1001
+ return __cxa_uncaught_exceptions();
+# else
+ return __cxa_uncaught_exception() ? 1 : 0;
+# endif
+}
+
+} // namespace std
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_libcxxrt.ipp b/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_libcxxrt.ipp
new file mode 100644
index 0000000000..4e428d216c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_libcxxrt.ipp
@@ -0,0 +1,25 @@
+// -*- 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 LIBCXX_BUILDING_LIBCXXRT
+#error this header may only be used when targeting libcxxrt
+#endif
+
+namespace std {
+
+bad_exception::~bad_exception() noexcept
+{
+}
+
+const char* bad_exception::what() const noexcept
+{
+ return "std::bad_exception";
+}
+
+} // namespace std
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_msvc.ipp b/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_msvc.ipp
new file mode 100644
index 0000000000..409d6755f6
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_msvc.ipp
@@ -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_ABI_MICROSOFT
+#error this header can only be used when targeting the MSVC ABI
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <__config>
+
+#ifdef _LIBCPP_COMPILER_MSVC
+// We don't want to depend on MSVC headers but
+// we have conflicting definitions otherwise due to
+// some other dependency on eh.h.
+#include Y_MSVC_INCLUDE_NEXT(eh.h)
+
+#else
+extern "C" {
+typedef void (__cdecl* terminate_handler)();
+_LIBCPP_CRT_FUNC terminate_handler __cdecl set_terminate(
+ terminate_handler _NewTerminateHandler) throw();
+_LIBCPP_CRT_FUNC terminate_handler __cdecl _get_terminate();
+
+typedef void (__cdecl* unexpected_handler)();
+unexpected_handler __cdecl set_unexpected(
+ unexpected_handler _NewUnexpectedHandler) throw();
+unexpected_handler __cdecl _get_unexpected();
+
+int __cdecl __uncaught_exceptions();
+}
+#endif
+
+namespace std {
+
+unexpected_handler
+set_unexpected(unexpected_handler func) noexcept {
+ return ::set_unexpected(func);
+}
+
+unexpected_handler get_unexpected() noexcept {
+ return ::_get_unexpected();
+}
+
+_LIBCPP_NORETURN
+void unexpected() {
+ (*get_unexpected())();
+ // unexpected handler should not return
+ terminate();
+}
+
+terminate_handler set_terminate(terminate_handler func) noexcept {
+ return ::set_terminate(func);
+}
+
+terminate_handler get_terminate() noexcept {
+ return ::_get_terminate();
+}
+
+_LIBCPP_NORETURN
+void terminate() noexcept
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ (*get_terminate())();
+ // handler should not return
+ fprintf(stderr, "terminate_handler unexpectedly returned\n");
+ ::abort();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ // handler should not throw exception
+ fprintf(stderr, "terminate_handler unexpectedly threw an exception\n");
+ ::abort();
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+}
+
+bool uncaught_exception() noexcept { return uncaught_exceptions() > 0; }
+
+int uncaught_exceptions() noexcept {
+ return __uncaught_exceptions();
+}
+
+#if !defined(_LIBCPP_ABI_VCRUNTIME)
+bad_cast::bad_cast() noexcept
+{
+}
+
+bad_cast::~bad_cast() noexcept
+{
+}
+
+const char *
+bad_cast::what() const noexcept
+{
+ return "std::bad_cast";
+}
+
+bad_typeid::bad_typeid() noexcept
+{
+}
+
+bad_typeid::~bad_typeid() noexcept
+{
+}
+
+const char *
+bad_typeid::what() const noexcept
+{
+ return "std::bad_typeid";
+}
+
+exception::~exception() noexcept
+{
+}
+
+const char* exception::what() const noexcept
+{
+ return "std::exception";
+}
+
+
+bad_exception::~bad_exception() noexcept
+{
+}
+
+const char* bad_exception::what() const noexcept
+{
+ return "std::bad_exception";
+}
+
+
+bad_alloc::bad_alloc() noexcept
+{
+}
+
+bad_alloc::~bad_alloc() noexcept
+{
+}
+
+const char*
+bad_alloc::what() const noexcept
+{
+ return "std::bad_alloc";
+}
+
+bad_array_new_length::bad_array_new_length() noexcept
+{
+}
+
+bad_array_new_length::~bad_array_new_length() noexcept
+{
+}
+
+const char*
+bad_array_new_length::what() const noexcept
+{
+ return "bad_array_new_length";
+}
+#endif // !_LIBCPP_ABI_VCRUNTIME
+
+} // namespace std
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_pointer_cxxabi.ipp b/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_pointer_cxxabi.ipp
new file mode 100644
index 0000000000..33aa94502b
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_pointer_cxxabi.ipp
@@ -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 HAVE_DEPENDENT_EH_ABI
+#error this header may only be used with libc++abi or libcxxrt
+#endif
+
+namespace std {
+
+exception_ptr::~exception_ptr() noexcept {
+ __cxa_decrement_exception_refcount(__ptr_);
+}
+
+exception_ptr::exception_ptr(const exception_ptr& other) noexcept
+ : __ptr_(other.__ptr_)
+{
+ __cxa_increment_exception_refcount(__ptr_);
+}
+
+exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
+{
+ if (__ptr_ != other.__ptr_)
+ {
+ __cxa_increment_exception_refcount(other.__ptr_);
+ __cxa_decrement_exception_refcount(__ptr_);
+ __ptr_ = other.__ptr_;
+ }
+ return *this;
+}
+
+nested_exception::nested_exception() noexcept
+ : __ptr_(current_exception())
+{
+}
+
+nested_exception::~nested_exception() noexcept
+{
+}
+
+_LIBCPP_NORETURN
+void
+nested_exception::rethrow_nested() const
+{
+ if (__ptr_ == nullptr)
+ terminate();
+ rethrow_exception(__ptr_);
+}
+
+exception_ptr current_exception() noexcept
+{
+ // be nicer if there was a constructor that took a ptr, then
+ // this whole function would be just:
+ // return exception_ptr(__cxa_current_primary_exception());
+ exception_ptr ptr;
+ ptr.__ptr_ = __cxa_current_primary_exception();
+ return ptr;
+}
+
+_LIBCPP_NORETURN
+void rethrow_exception(exception_ptr p)
+{
+ __cxa_rethrow_primary_exception(p.__ptr_);
+ // if p.__ptr_ is NULL, above returns so we terminate
+ terminate();
+}
+
+} // namespace std
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_pointer_glibcxx.ipp b/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_pointer_glibcxx.ipp
new file mode 100644
index 0000000000..983a08808d
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_pointer_glibcxx.ipp
@@ -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
+//
+//===----------------------------------------------------------------------===//
+
+// libsupc++ does not implement the dependent EH ABI and the functionality
+// it uses to implement std::exception_ptr (which it declares as an alias of
+// std::__exception_ptr::exception_ptr) is not directly exported to clients. So
+// we have little choice but to hijack std::__exception_ptr::exception_ptr's
+// (which fortunately has the same layout as our std::exception_ptr) copy
+// constructor, assignment operator and destructor (which are part of its
+// stable ABI), and its rethrow_exception(std::__exception_ptr::exception_ptr)
+// function.
+
+namespace std {
+
+namespace __exception_ptr
+{
+
+struct exception_ptr
+{
+ void* __ptr_;
+
+ exception_ptr(const exception_ptr&) noexcept;
+ exception_ptr& operator=(const exception_ptr&) noexcept;
+ ~exception_ptr() noexcept;
+};
+
+}
+
+_LIBCPP_NORETURN void rethrow_exception(__exception_ptr::exception_ptr);
+
+exception_ptr::~exception_ptr() noexcept
+{
+ reinterpret_cast<__exception_ptr::exception_ptr*>(this)->~exception_ptr();
+}
+
+exception_ptr::exception_ptr(const exception_ptr& other) noexcept
+ : __ptr_(other.__ptr_)
+{
+ new (reinterpret_cast<void*>(this)) __exception_ptr::exception_ptr(
+ reinterpret_cast<const __exception_ptr::exception_ptr&>(other));
+}
+
+exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
+{
+ *reinterpret_cast<__exception_ptr::exception_ptr*>(this) =
+ reinterpret_cast<const __exception_ptr::exception_ptr&>(other);
+ return *this;
+}
+
+nested_exception::nested_exception() noexcept
+ : __ptr_(current_exception())
+{
+}
+
+
+_LIBCPP_NORETURN
+void
+nested_exception::rethrow_nested() const
+{
+ if (__ptr_ == nullptr)
+ terminate();
+ rethrow_exception(__ptr_);
+}
+
+_LIBCPP_NORETURN
+void rethrow_exception(exception_ptr p)
+{
+ rethrow_exception(reinterpret_cast<__exception_ptr::exception_ptr&>(p));
+}
+
+} // namespace std
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_pointer_msvc.ipp b/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_pointer_msvc.ipp
new file mode 100644
index 0000000000..300acbf759
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_pointer_msvc.ipp
@@ -0,0 +1,258 @@
+// -*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <atomic>
+#include <cstdint>
+#include <cstring>
+#include <malloc.h>
+#include <windows.h> // For RtlPcToFileHeader function
+
+struct EHCatchableType {
+ uint32_t properties;
+ int32_t type_info;
+ uint32_t non_virtual_adjustment;
+ uint32_t offset_to_virtual_base_ptr;
+ uint32_t virtual_base_table_index;
+ uint32_t size;
+ int32_t copy_function;
+};
+
+struct EHCatchableTypeArray {
+ uint32_t catchable_types;
+ // It is variable size but we only need the first element of this array
+ int32_t array_of_catchable_types[1];
+};
+
+struct EHThrowInfo {
+ uint32_t attributes;
+ int32_t unwind;
+ int32_t forward_compat;
+ int32_t catchable_type_array;
+};
+
+struct EHParameters {
+ uint32_t magic_number;
+ void* exception_object;
+ EHThrowInfo* throw_info;
+#ifdef _M_AMD64
+ uintptr_t throw_image_base;
+#endif
+};
+
+struct EHExceptionRecord {
+ uint32_t exception_code;
+ uint32_t exception_flags;
+ void* exception_record;
+ void* exception_address;
+ uint32_t number_of_parameters;
+ EHParameters parameters;
+};
+
+// defined in vcruntime<ver>.dll
+extern "C" EHExceptionRecord** __current_exception();
+
+// This is internal compiler definition for MSVC but not for clang.
+// We use our own EHThrowInfo because _ThrowInfo doesn't match actual
+// compiler-generated structures in 64-bit mode.
+#ifdef __clang__
+struct _ThrowInfo;
+// defined in vcruntime<ver>.dll
+_LIBCPP_NORETURN extern "C" void __stdcall _CxxThrowException(
+ void* __exc, _ThrowInfo* __throw_info);
+#endif
+
+namespace {
+struct ExceptionPtr {
+ void* exception_object;
+ const EHThrowInfo* throw_info;
+ std::atomic<size_t> counter;
+#ifdef _M_AMD64
+ PVOID image_base;
+#endif
+ template <class T>
+ T convert(int32_t offset) {
+#ifdef _M_AMD64
+ uintptr_t value = reinterpret_cast<uintptr_t>(image_base) +
+ static_cast<uintptr_t>(offset);
+#else
+ uintptr_t value = static_cast<uintptr_t>(offset);
+#endif
+ T res;
+ static_assert(
+ sizeof(value) == sizeof(res),
+ "Can only convert to pointers or pointers to member functions");
+ memcpy(&res, &value, sizeof(value));
+ return res;
+ }
+
+ void copy(void* dst, const void* src, const EHCatchableType* exc_type) {
+ struct Temp {};
+ constexpr uint32_t virtual_base = 4;
+ if (exc_type->copy_function == 0) {
+ memcpy(dst, src, exc_type->size);
+ } else if (exc_type->properties & virtual_base) {
+ auto copy_constructor =
+ convert<void (Temp::*)(const void*, int)>(exc_type->copy_function);
+ ((Temp*)dst->*copy_constructor)(src, 1);
+ } else {
+ auto copy_constructor =
+ convert<void (Temp::*)(const void*)>(exc_type->copy_function);
+ ((Temp*)dst->*copy_constructor)(src);
+ }
+ }
+
+ EHCatchableType* exception_type() {
+ return convert<EHCatchableType*>(
+ convert<EHCatchableTypeArray*>(throw_info->catchable_type_array)
+ ->array_of_catchable_types[0]);
+ }
+
+ ExceptionPtr(const void* exception_object_, const EHThrowInfo* throw_info_)
+ : exception_object(nullptr), throw_info(throw_info_), counter(1) {
+#ifdef _M_AMD64
+ RtlPcToFileHeader(
+ reinterpret_cast<PVOID>(const_cast<EHThrowInfo*>(throw_info)),
+ &image_base);
+#endif
+ EHCatchableType* exc_type = exception_type();
+ this->exception_object = malloc(exc_type->size);
+ if (this->exception_object == nullptr) {
+ throw std::bad_alloc();
+ }
+ copy(exception_object, exception_object_, exc_type);
+ }
+
+ ~ExceptionPtr() {
+ if (throw_info->unwind && exception_object) {
+ struct Temp {};
+ auto destructor = convert<void (Temp::*)()>(throw_info->unwind);
+ ((Temp*)exception_object->*destructor)();
+ }
+ free(exception_object);
+ }
+
+ // _bad_alloc_storage must be initialized before bad_alloc, so we declare and define it first.
+ static std::bad_alloc _bad_alloc_storage;
+ static ExceptionPtr bad_alloc;
+ //static ExceptionPtr bad_exception;
+};
+
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Waddress-of-temporary"
+#endif
+
+std::bad_alloc ExceptionPtr::_bad_alloc_storage;
+
+ExceptionPtr ExceptionPtr::bad_alloc(
+ &ExceptionPtr::_bad_alloc_storage,
+ reinterpret_cast<const EHThrowInfo*>(__GetExceptionInfo(ExceptionPtr::_bad_alloc_storage)));
+
+/* ExceptionPtr
+ExceptionPtr::bad_exception(&std::bad_exception(),
+ reinterpret_cast<const EHThrowInfo*>(
+ __GetExceptionInfo(std::bad_exception()))); */
+
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
+} // namespace
+
+namespace std {
+
+exception_ptr::exception_ptr(const exception_ptr& __other) noexcept
+ : __ptr_(__other.__ptr_) {
+ if (__ptr_) {
+ reinterpret_cast<ExceptionPtr*>(__ptr_)->counter.fetch_add(1);
+ }
+}
+
+exception_ptr& exception_ptr::
+operator=(const exception_ptr& __other) noexcept {
+ auto before = __ptr_;
+ __ptr_ = __other.__ptr_;
+ if (__ptr_) {
+ reinterpret_cast<ExceptionPtr*>(__ptr_)->counter.fetch_add(1);
+ }
+ if (before) {
+ if (reinterpret_cast<ExceptionPtr*>(before)->counter.fetch_sub(1) == 1) {
+ delete reinterpret_cast<ExceptionPtr*>(before);
+ }
+ }
+ return *this;
+}
+
+exception_ptr::~exception_ptr() noexcept {
+ if (__ptr_) {
+ if (reinterpret_cast<ExceptionPtr*>(__ptr_)->counter.fetch_sub(1) == 1) {
+ delete reinterpret_cast<ExceptionPtr*>(__ptr_);
+ }
+ }
+}
+
+exception_ptr __copy_exception_ptr(void* exception_object,
+ const void* throw_info) {
+ ExceptionPtr* ptr;
+ try {
+ ptr = new ExceptionPtr(exception_object,
+ reinterpret_cast<const EHThrowInfo*>(throw_info));
+ } catch (const std::bad_alloc&) {
+ ptr = &ExceptionPtr::bad_alloc;
+ ptr->counter.fetch_add(1);
+ } catch (...) {
+ //ptr = &ExceptionPtr::bad_exception;
+ //ptr->counter.fetch_add(1);
+ std::terminate();
+ }
+ exception_ptr res;
+ memcpy(&res, &ptr, sizeof(ptr));
+ return res;
+}
+
+exception_ptr current_exception() noexcept {
+ EHExceptionRecord** record = __current_exception();
+ if (*record && !std::uncaught_exception()) {
+ return __copy_exception_ptr((*record)->parameters.exception_object,
+ (*record)->parameters.throw_info);
+ }
+ return exception_ptr();
+}
+
+_LIBCPP_NORETURN
+void rethrow_exception(exception_ptr p) {
+ if (!p) {
+ throw std::bad_exception();
+ }
+ ExceptionPtr* exc_ptr = reinterpret_cast<ExceptionPtr*>(p.__ptr_);
+ EHCatchableType* exc_type = exc_ptr->exception_type();
+ // _CxxThrowException doesn't call free on exception object so we must
+ // allocate it on the stack.
+ void* dst = _alloca(exc_type->size);
+ exc_ptr->copy(dst, exc_ptr->exception_object, exc_type);
+ auto throw_info = reinterpret_cast<_ThrowInfo*>(
+ const_cast<EHThrowInfo*>(exc_ptr->throw_info));
+ // For some reason clang doesn't call p destructor during unwinding.
+ // So we must clear it ourselves.
+ p = nullptr;
+ _CxxThrowException(dst, throw_info);
+}
+
+nested_exception::nested_exception() noexcept : __ptr_(current_exception()) {}
+
+nested_exception::~nested_exception() noexcept {}
+
+_LIBCPP_NORETURN
+void nested_exception::rethrow_nested() const {
+ if (__ptr_ == nullptr)
+ terminate();
+ rethrow_exception(__ptr_);
+}
+
+} // namespace std
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_pointer_unimplemented.ipp b/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_pointer_unimplemented.ipp
new file mode 100644
index 0000000000..9e8ec04e11
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/exception_pointer_unimplemented.ipp
@@ -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
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stdlib.h>
+
+namespace std {
+
+exception_ptr::~exception_ptr() noexcept
+{
+# warning exception_ptr not yet implemented
+ fprintf(stderr, "exception_ptr not yet implemented\n");
+ ::abort();
+}
+
+exception_ptr::exception_ptr(const exception_ptr& other) noexcept
+ : __ptr_(other.__ptr_)
+{
+# warning exception_ptr not yet implemented
+ fprintf(stderr, "exception_ptr not yet implemented\n");
+ ::abort();
+}
+
+exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
+{
+# warning exception_ptr not yet implemented
+ fprintf(stderr, "exception_ptr not yet implemented\n");
+ ::abort();
+}
+
+nested_exception::nested_exception() noexcept
+ : __ptr_(current_exception())
+{
+}
+
+#if !defined(__GLIBCXX__)
+
+nested_exception::~nested_exception() noexcept
+{
+}
+
+#endif
+
+_LIBCPP_NORETURN
+void
+nested_exception::rethrow_nested() const
+{
+# warning exception_ptr not yet implemented
+ fprintf(stderr, "exception_ptr not yet implemented\n");
+ ::abort();
+#if 0
+ if (__ptr_ == nullptr)
+ terminate();
+ rethrow_exception(__ptr_);
+#endif // FIXME
+}
+
+exception_ptr current_exception() noexcept
+{
+# warning exception_ptr not yet implemented
+ fprintf(stderr, "exception_ptr not yet implemented\n");
+ ::abort();
+}
+
+_LIBCPP_NORETURN
+void rethrow_exception(exception_ptr p)
+{
+# warning exception_ptr not yet implemented
+ fprintf(stderr, "exception_ptr not yet implemented\n");
+ ::abort();
+}
+
+} // namespace std
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/new_handler_fallback.ipp b/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/new_handler_fallback.ipp
new file mode 100644
index 0000000000..7556f693a9
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/new_handler_fallback.ipp
@@ -0,0 +1,28 @@
+// -*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "../../include/atomic_support.h"
+
+namespace std {
+
+static _LIBCPP_CONSTINIT std::new_handler __new_handler = nullptr;
+
+new_handler
+set_new_handler(new_handler handler) noexcept
+{
+ return __libcpp_atomic_exchange(&__new_handler, handler);
+}
+
+new_handler
+get_new_handler() noexcept
+{
+ return __libcpp_atomic_load(&__new_handler);
+}
+
+} // namespace std
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/stdexcept_default.ipp b/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/stdexcept_default.ipp
new file mode 100644
index 0000000000..d0218bfbc6
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/stdexcept_default.ipp
@@ -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
+//
+//===----------------------------------------------------------------------===//
+
+#include "../../include/refstring.h"
+
+/* For _LIBCPPABI_VERSION */
+#if !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) && \
+ (defined(LIBCXX_BUILDING_LIBCXXABI) || defined(LIBCXX_BUILDING_LIBCXXRT))
+#include <cxxabi.h>
+#endif
+
+static_assert(sizeof(std::__libcpp_refstring) == sizeof(const char*), "");
+
+namespace std // purposefully not using versioning namespace
+{
+
+logic_error::logic_error(const string& msg) : __imp_(msg.c_str()) {}
+
+logic_error::logic_error(const char* msg) : __imp_(msg) {}
+
+logic_error::logic_error(const logic_error& le) noexcept : __imp_(le.__imp_) {}
+
+logic_error& logic_error::operator=(const logic_error& le) noexcept {
+ __imp_ = le.__imp_;
+ return *this;
+}
+
+runtime_error::runtime_error(const string& msg) : __imp_(msg.c_str()) {}
+
+runtime_error::runtime_error(const char* msg) : __imp_(msg) {}
+
+runtime_error::runtime_error(const runtime_error& re) noexcept
+ : __imp_(re.__imp_) {}
+
+runtime_error& runtime_error::operator=(const runtime_error& re) noexcept {
+ __imp_ = re.__imp_;
+ return *this;
+}
+
+#if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX)
+
+const char* logic_error::what() const noexcept { return __imp_.c_str(); }
+
+const char* runtime_error::what() const noexcept { return __imp_.c_str(); }
+
+logic_error::~logic_error() noexcept {}
+domain_error::~domain_error() noexcept {}
+invalid_argument::~invalid_argument() noexcept {}
+length_error::~length_error() noexcept {}
+out_of_range::~out_of_range() noexcept {}
+
+runtime_error::~runtime_error() noexcept {}
+range_error::~range_error() noexcept {}
+overflow_error::~overflow_error() noexcept {}
+underflow_error::~underflow_error() noexcept {}
+
+#endif
+
+} // namespace std
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/stdexcept_vcruntime.ipp b/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/stdexcept_vcruntime.ipp
new file mode 100644
index 0000000000..8a6d939cb0
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/support/runtime/stdexcept_vcruntime.ipp
@@ -0,0 +1,16 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_ABI_VCRUNTIME
+#error This file may only be used when defering to vcruntime
+#endif
+
+namespace std {
+logic_error::logic_error(std::string const& s) : exception(s.c_str()) {}
+runtime_error::runtime_error(std::string const& s) : exception(s.c_str()) {}
+} // namespace std
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/support/solaris/README b/contrib/libs/cxxsupp/libcxxmsvc/src/support/solaris/README
new file mode 100644
index 0000000000..89c887a3b4
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/support/solaris/README
@@ -0,0 +1,4 @@
+This directory contains a partial implementation of the xlocale APIs for
+Solaris. Some portions are lifted from FreeBSD libc, and so are covered by a
+2-clause BSD license instead of the MIT/UUIC license that the rest of libc++ is
+distributed under.
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/support/win32/atomic_win32.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/support/win32/atomic_win32.cpp
new file mode 100644
index 0000000000..28cb0722ce
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/support/win32/atomic_win32.cpp
@@ -0,0 +1,31 @@
+#include <intrin.h>
+#include <cstdint>
+
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace {
+static const int __msvc_locks_size = 1024;
+volatile long __msvc_locks[__msvc_locks_size];
+
+size_t __msvc_lock_hash(void* __p) {
+ uintptr_t __num = reinterpret_cast<uintptr_t>(__p);
+ return (__num ^ (__num >> 10)) & (__msvc_locks_size - 1);
+}
+}
+
+void __msvc_lock(void* __p) {
+ volatile long& __lock = __msvc_locks[__msvc_lock_hash(__p)];
+ while (_InterlockedExchange(&__lock, 1) == 0) {
+#if defined(_M_ARM) || defined(_M_ARM64)
+ __yield();
+#endif
+ }
+}
+
+void __msvc_unlock(void* __p) {
+ volatile long& __lock = __msvc_locks[__msvc_lock_hash(__p)];
+ _InterlockedExchange(&__lock, 0);
+}
+
+_LIBCPP_END_NAMESPACE_STD \ No newline at end of file
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/support/win32/locale_win32.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/support/win32/locale_win32.cpp
new file mode 100644
index 0000000000..67f4d1341a
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/support/win32/locale_win32.cpp
@@ -0,0 +1,141 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <locale>
+#include <cstdarg> // va_start, va_end
+#include <memory>
+#include <type_traits>
+
+int __libcpp_vasprintf(char **sptr, const char *__restrict fmt, va_list ap);
+
+using std::__libcpp_locale_guard;
+
+// FIXME: base currently unused. Needs manual work to construct the new locale
+locale_t newlocale( int mask, const char * locale, locale_t /*base*/ )
+{
+ return {_create_locale( LC_ALL, locale ), locale};
+}
+
+decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l )
+{
+#if defined(_LIBCPP_MSVCRT)
+ return ___mb_cur_max_l_func(__l);
+#else
+ __libcpp_locale_guard __current(__l);
+ return MB_CUR_MAX;
+#endif
+}
+
+lconv *localeconv_l( locale_t &loc )
+{
+ __libcpp_locale_guard __current(loc);
+ lconv *lc = localeconv();
+ if (!lc)
+ return lc;
+ return loc.__store_lconv(lc);
+}
+size_t mbrlen_l( const char *__restrict s, size_t n,
+ mbstate_t *__restrict ps, locale_t loc )
+{
+ __libcpp_locale_guard __current(loc);
+ return mbrlen( s, n, ps );
+}
+size_t mbsrtowcs_l( wchar_t *__restrict dst, const char **__restrict src,
+ size_t len, mbstate_t *__restrict ps, locale_t loc )
+{
+ __libcpp_locale_guard __current(loc);
+ return mbsrtowcs( dst, src, len, ps );
+}
+size_t wcrtomb_l( char *__restrict s, wchar_t wc, mbstate_t *__restrict ps,
+ locale_t loc )
+{
+ __libcpp_locale_guard __current(loc);
+ return wcrtomb( s, wc, ps );
+}
+size_t mbrtowc_l( wchar_t *__restrict pwc, const char *__restrict s,
+ size_t n, mbstate_t *__restrict ps, locale_t loc )
+{
+ __libcpp_locale_guard __current(loc);
+ return mbrtowc( pwc, s, n, ps );
+}
+size_t mbsnrtowcs_l( wchar_t *__restrict dst, const char **__restrict src,
+ size_t nms, size_t len, mbstate_t *__restrict ps, locale_t loc )
+{
+ __libcpp_locale_guard __current(loc);
+ return mbsnrtowcs( dst, src, nms, len, ps );
+}
+size_t wcsnrtombs_l( char *__restrict dst, const wchar_t **__restrict src,
+ size_t nwc, size_t len, mbstate_t *__restrict ps, locale_t loc )
+{
+ __libcpp_locale_guard __current(loc);
+ return wcsnrtombs( dst, src, nwc, len, ps );
+}
+wint_t btowc_l( int c, locale_t loc )
+{
+ __libcpp_locale_guard __current(loc);
+ return btowc( c );
+}
+int wctob_l( wint_t c, locale_t loc )
+{
+ __libcpp_locale_guard __current(loc);
+ return wctob( c );
+}
+
+int snprintf_l(char *ret, size_t n, locale_t loc, const char *format, ...)
+{
+ va_list ap;
+ va_start( ap, format );
+#if defined(_LIBCPP_MSVCRT)
+ // FIXME: Remove usage of internal CRT function and globals.
+ int result = __stdio_common_vsprintf(
+ _CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR,
+ ret, n, format, loc, ap);
+#else
+ __libcpp_locale_guard __current(loc);
+ _LIBCPP_DIAGNOSTIC_PUSH
+ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
+ int result = vsnprintf( ret, n, format, ap );
+ _LIBCPP_DIAGNOSTIC_POP
+#endif
+ va_end(ap);
+ return result;
+}
+
+int asprintf_l( char **ret, locale_t loc, const char *format, ... )
+{
+ va_list ap;
+ va_start( ap, format );
+ int result = vasprintf_l( ret, loc, format, ap );
+ va_end(ap);
+ return result;
+}
+int vasprintf_l( char **ret, locale_t loc, const char *format, va_list ap )
+{
+ __libcpp_locale_guard __current(loc);
+ return __libcpp_vasprintf( ret, format, ap );
+}
+
+#if !defined(_LIBCPP_MSVCRT)
+float strtof_l(const char* nptr, char** endptr, locale_t loc) {
+ __libcpp_locale_guard __current(loc);
+ return strtof(nptr, endptr);
+}
+
+long double strtold_l(const char* nptr, char** endptr, locale_t loc) {
+ __libcpp_locale_guard __current(loc);
+ return strtold(nptr, endptr);
+}
+#endif
+
+#if defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x0800
+size_t strftime_l(char *ret, size_t n, const char *format, const struct tm *tm,
+ locale_t loc) {
+ __libcpp_locale_guard __current(loc);
+ return strftime(ret, n, format, tm);
+}
+#endif
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/support/win32/new_win32.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/support/win32/new_win32.cpp
new file mode 100644
index 0000000000..00eff4abf9
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/support/win32/new_win32.cpp
@@ -0,0 +1,28 @@
+#include <atomic>
+#include <new>
+
+namespace std {
+
+void
+__throw_bad_alloc()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw bad_alloc();
+#endif
+}
+
+static std::atomic<std::new_handler> __new_handler;
+
+new_handler
+set_new_handler(new_handler handler) _NOEXCEPT
+{
+ return __new_handler.exchange(handler);
+}
+
+new_handler
+get_new_handler() _NOEXCEPT
+{
+ return __new_handler.load();
+}
+
+} \ No newline at end of file
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/support/win32/support.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/support/win32/support.cpp
new file mode 100644
index 0000000000..dbec4083cb
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/support/win32/support.cpp
@@ -0,0 +1,172 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <cstdarg> // va_start, va_end
+#include <cstddef> // size_t
+#include <cstdlib> // malloc
+#include <cstdio> // vsprintf, vsnprintf
+#include <cstring> // strcpy, wcsncpy
+#include <cwchar> // mbstate_t
+
+
+// Like sprintf, but when return value >= 0 it returns
+// a pointer to a malloc'd string in *sptr.
+// If return >= 0, use free to delete *sptr.
+int __libcpp_vasprintf( char **sptr, const char *__restrict format, va_list ap )
+{
+ *sptr = NULL;
+ // Query the count required.
+ va_list ap_copy;
+ va_copy(ap_copy, ap);
+ _LIBCPP_DIAGNOSTIC_PUSH
+ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
+ int count = vsnprintf( NULL, 0, format, ap_copy );
+ _LIBCPP_DIAGNOSTIC_POP
+ va_end(ap_copy);
+ if (count < 0)
+ return count;
+ size_t buffer_size = static_cast<size_t>(count) + 1;
+ char* p = static_cast<char*>(malloc(buffer_size));
+ if ( ! p )
+ return -1;
+ // If we haven't used exactly what was required, something is wrong.
+ // Maybe bug in vsnprintf. Report the error and return.
+ _LIBCPP_DIAGNOSTIC_PUSH
+ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
+ if (vsnprintf(p, buffer_size, format, ap) != count) {
+ _LIBCPP_DIAGNOSTIC_POP
+ free(p);
+ return -1;
+ }
+ // All good. This is returning memory to the caller not freeing it.
+ *sptr = p;
+ return count;
+}
+
+// Returns >= 0: the number of wide characters found in the
+// multi byte sequence src (of src_size_bytes), that fit in the buffer dst
+// (of max_dest_chars elements size). The count returned excludes the
+// null terminator. When dst is NULL, no characters are copied
+// and no "out" parameters are updated.
+// Returns (size_t) -1: an incomplete sequence encountered.
+// Leaves *src pointing the next character to convert or NULL
+// if a null character was converted from *src.
+size_t mbsnrtowcs( wchar_t *__restrict dst, const char **__restrict src,
+ size_t src_size_bytes, size_t max_dest_chars, mbstate_t *__restrict ps )
+{
+ const size_t terminated_sequence = static_cast<size_t>(0);
+ //const size_t invalid_sequence = static_cast<size_t>(-1);
+ const size_t incomplete_sequence = static_cast< size_t>(-2);
+
+ size_t dest_converted = 0;
+ size_t source_converted = 0;
+ size_t source_remaining = src_size_bytes;
+ size_t result = 0;
+ bool have_result = false;
+
+ // If dst is null then max_dest_chars should be ignored according to the
+ // standard. Setting max_dest_chars to a large value has this effect.
+ if (!dst)
+ max_dest_chars = static_cast<size_t>(-1);
+
+ while ( source_remaining ) {
+ if ( dst && dest_converted >= max_dest_chars )
+ break;
+ // Converts one multi byte character.
+ // if result > 0, it's the size in bytes of that character.
+ // othewise if result is zero it indicates the null character has been found.
+ // otherwise it's an error and errno may be set.
+ size_t char_size = mbrtowc( dst ? dst + dest_converted : NULL, *src + source_converted, source_remaining, ps );
+ // Don't do anything to change errno from here on.
+ if ( char_size > 0 ) {
+ source_remaining -= char_size;
+ source_converted += char_size;
+ ++dest_converted;
+ continue;
+ }
+ result = char_size;
+ have_result = true;
+ break;
+ }
+ if ( dst ) {
+ if ( have_result && result == terminated_sequence )
+ *src = NULL;
+ else
+ *src += source_converted;
+ }
+ if ( have_result && result != terminated_sequence && result != incomplete_sequence )
+ return static_cast<size_t>(-1);
+
+ return dest_converted;
+}
+
+// Converts max_source_chars from the wide character buffer pointer to by *src,
+// into the multi byte character sequence buffer stored at dst which must be
+// dst_size_bytes bytes in size.
+// Returns >= 0: the number of bytes in the sequence
+// converted from *src, excluding the null terminator.
+// Returns size_t(-1) if an error occurs, also sets errno.
+// If dst is NULL dst_size_bytes is ignored and no bytes are copied to dst
+// and no "out" parameters are updated.
+size_t wcsnrtombs( char *__restrict dst, const wchar_t **__restrict src,
+ size_t max_source_chars, size_t dst_size_bytes, mbstate_t *__restrict ps )
+{
+ //const size_t invalid_sequence = static_cast<size_t>(-1);
+
+ size_t source_converted = 0;
+ size_t dest_converted = 0;
+ size_t dest_remaining = dst_size_bytes;
+ size_t char_size = 0;
+ const errno_t no_error = ( errno_t) 0;
+ errno_t result = ( errno_t ) 0;
+ bool have_result = false;
+ bool terminator_found = false;
+
+ // If dst is null then dst_size_bytes should be ignored according to the
+ // standard. Setting dest_remaining to a large value has this effect.
+ if (!dst)
+ dest_remaining = static_cast<size_t>(-1);
+
+ while ( source_converted != max_source_chars ) {
+ if ( ! dest_remaining )
+ break;
+ wchar_t c = (*src)[source_converted];
+ if ( dst )
+ result = wcrtomb_s( &char_size, dst + dest_converted, dest_remaining, c, ps);
+ else
+ result = wcrtomb_s( &char_size, NULL, 0, c, ps);
+ // If result is zero there is no error and char_size contains the
+ // size of the multi-byte-sequence converted.
+ // Otherwise result indicates an errno type error.
+ if ( result == no_error ) {
+ if ( c == L'\0' ) {
+ terminator_found = true;
+ break;
+ }
+ ++source_converted;
+ if ( dst )
+ dest_remaining -= char_size;
+ dest_converted += char_size;
+ continue;
+ }
+ have_result = true;
+ break;
+ }
+ if ( dst ) {
+ if ( terminator_found )
+ *src = NULL;
+ else
+ *src = *src + source_converted;
+ }
+ if ( have_result && result != no_error ) {
+ errno = result;
+ return static_cast<size_t>(-1);
+ }
+
+ return dest_converted;
+}
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/support/win32/thread_win32.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/support/win32/thread_win32.cpp
new file mode 100644
index 0000000000..f2072b1435
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/support/win32/thread_win32.cpp
@@ -0,0 +1,274 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <__threading_support>
+#define NOMINMAX
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <process.h>
+#include <fibersapi.h>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+static_assert(sizeof(__libcpp_mutex_t) == sizeof(SRWLOCK), "");
+static_assert(alignof(__libcpp_mutex_t) == alignof(SRWLOCK), "");
+
+static_assert(sizeof(__libcpp_recursive_mutex_t) == sizeof(CRITICAL_SECTION),
+ "");
+static_assert(alignof(__libcpp_recursive_mutex_t) == alignof(CRITICAL_SECTION),
+ "");
+
+static_assert(sizeof(__libcpp_condvar_t) == sizeof(CONDITION_VARIABLE), "");
+static_assert(alignof(__libcpp_condvar_t) == alignof(CONDITION_VARIABLE), "");
+
+static_assert(sizeof(__libcpp_exec_once_flag) == sizeof(INIT_ONCE), "");
+static_assert(alignof(__libcpp_exec_once_flag) == alignof(INIT_ONCE), "");
+
+static_assert(sizeof(__libcpp_thread_id) == sizeof(DWORD), "");
+static_assert(alignof(__libcpp_thread_id) == alignof(DWORD), "");
+
+static_assert(sizeof(__libcpp_thread_t) == sizeof(HANDLE), "");
+static_assert(alignof(__libcpp_thread_t) == alignof(HANDLE), "");
+
+static_assert(sizeof(__libcpp_tls_key) == sizeof(DWORD), "");
+static_assert(alignof(__libcpp_tls_key) == alignof(DWORD), "");
+
+// Mutex
+int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m)
+{
+ InitializeCriticalSection((LPCRITICAL_SECTION)__m);
+ return 0;
+}
+
+int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m)
+{
+ EnterCriticalSection((LPCRITICAL_SECTION)__m);
+ return 0;
+}
+
+bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m)
+{
+ return TryEnterCriticalSection((LPCRITICAL_SECTION)__m) != 0;
+}
+
+int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m)
+{
+ LeaveCriticalSection((LPCRITICAL_SECTION)__m);
+ return 0;
+}
+
+int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m)
+{
+ DeleteCriticalSection((LPCRITICAL_SECTION)__m);
+ return 0;
+}
+
+int __libcpp_mutex_lock(__libcpp_mutex_t *__m)
+{
+ AcquireSRWLockExclusive((PSRWLOCK)__m);
+ return 0;
+}
+
+bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m)
+{
+ return TryAcquireSRWLockExclusive((PSRWLOCK)__m) != 0;
+}
+
+int __libcpp_mutex_unlock(__libcpp_mutex_t *__m)
+{
+ ReleaseSRWLockExclusive((PSRWLOCK)__m);
+ return 0;
+}
+
+int __libcpp_mutex_destroy(__libcpp_mutex_t *__m)
+{
+ static_cast<void>(__m);
+ return 0;
+}
+
+// Condition Variable
+int __libcpp_condvar_signal(__libcpp_condvar_t *__cv)
+{
+ WakeConditionVariable((PCONDITION_VARIABLE)__cv);
+ return 0;
+}
+
+int __libcpp_condvar_broadcast(__libcpp_condvar_t *__cv)
+{
+ WakeAllConditionVariable((PCONDITION_VARIABLE)__cv);
+ return 0;
+}
+
+int __libcpp_condvar_wait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m)
+{
+ SleepConditionVariableSRW((PCONDITION_VARIABLE)__cv, (PSRWLOCK)__m, INFINITE, 0);
+ return 0;
+}
+
+int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
+ __libcpp_timespec_t *__ts)
+{
+ using namespace _VSTD::chrono;
+
+ auto duration = seconds(__ts->tv_sec) + nanoseconds(__ts->tv_nsec);
+ auto abstime =
+ system_clock::time_point(duration_cast<system_clock::duration>(duration));
+ auto timeout_ms = duration_cast<milliseconds>(abstime - system_clock::now());
+
+ if (!SleepConditionVariableSRW((PCONDITION_VARIABLE)__cv, (PSRWLOCK)__m,
+ timeout_ms.count() > 0 ? timeout_ms.count()
+ : 0,
+ 0))
+ {
+ auto __ec = GetLastError();
+ return __ec == ERROR_TIMEOUT ? ETIMEDOUT : __ec;
+ }
+ return 0;
+}
+
+int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv)
+{
+ static_cast<void>(__cv);
+ return 0;
+}
+
+// Execute Once
+static inline _LIBCPP_INLINE_VISIBILITY BOOL CALLBACK
+__libcpp_init_once_execute_once_thunk(PINIT_ONCE __init_once, PVOID __parameter,
+ PVOID *__context)
+{
+ static_cast<void>(__init_once);
+ static_cast<void>(__context);
+
+ void (*init_routine)(void) = reinterpret_cast<void (*)(void)>(__parameter);
+ init_routine();
+ return TRUE;
+}
+
+int __libcpp_execute_once(__libcpp_exec_once_flag *__flag,
+ void (*__init_routine)(void))
+{
+ if (!InitOnceExecuteOnce((PINIT_ONCE)__flag, __libcpp_init_once_execute_once_thunk,
+ reinterpret_cast<void *>(__init_routine), NULL))
+ return GetLastError();
+ return 0;
+}
+
+// Thread ID
+bool __libcpp_thread_id_equal(__libcpp_thread_id __lhs,
+ __libcpp_thread_id __rhs)
+{
+ return __lhs == __rhs;
+}
+
+bool __libcpp_thread_id_less(__libcpp_thread_id __lhs, __libcpp_thread_id __rhs)
+{
+ return __lhs < __rhs;
+}
+
+// Thread
+struct __libcpp_beginthreadex_thunk_data
+{
+ void *(*__func)(void *);
+ void *__arg;
+};
+
+static inline _LIBCPP_INLINE_VISIBILITY unsigned WINAPI
+__libcpp_beginthreadex_thunk(void *__raw_data)
+{
+ auto *__data =
+ static_cast<__libcpp_beginthreadex_thunk_data *>(__raw_data);
+ auto *__func = __data->__func;
+ void *__arg = __data->__arg;
+ delete __data;
+ return static_cast<unsigned>(reinterpret_cast<uintptr_t>(__func(__arg)));
+}
+
+bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {
+ return *__t == 0;
+}
+
+int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
+ void *__arg)
+{
+ auto *__data = new __libcpp_beginthreadex_thunk_data;
+ __data->__func = __func;
+ __data->__arg = __arg;
+
+ *__t = reinterpret_cast<HANDLE>(_beginthreadex(nullptr, 0,
+ __libcpp_beginthreadex_thunk,
+ __data, 0, nullptr));
+
+ if (*__t)
+ return 0;
+ return GetLastError();
+}
+
+__libcpp_thread_id __libcpp_thread_get_current_id()
+{
+ return GetCurrentThreadId();
+}
+
+__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t)
+{
+ return GetThreadId(*__t);
+}
+
+int __libcpp_thread_join(__libcpp_thread_t *__t)
+{
+ if (WaitForSingleObjectEx(*__t, INFINITE, FALSE) == WAIT_FAILED)
+ return GetLastError();
+ if (!CloseHandle(*__t))
+ return GetLastError();
+ return 0;
+}
+
+int __libcpp_thread_detach(__libcpp_thread_t *__t)
+{
+ if (!CloseHandle(*__t))
+ return GetLastError();
+ return 0;
+}
+
+void __libcpp_thread_yield()
+{
+ SwitchToThread();
+}
+
+void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns)
+{
+ // round-up to the nearest millisecond
+ chrono::milliseconds __ms = chrono::ceil<chrono::milliseconds>(__ns);
+ // FIXME(compnerd) this should be an alertable sleep (WFSO or SleepEx)
+ Sleep(__ms.count());
+}
+
+// Thread Local Storage
+int __libcpp_tls_create(__libcpp_tls_key* __key,
+ void(_LIBCPP_TLS_DESTRUCTOR_CC* __at_exit)(void*))
+{
+ DWORD index = FlsAlloc(__at_exit);
+ if (index == FLS_OUT_OF_INDEXES)
+ return GetLastError();
+ *__key = index;
+ return 0;
+}
+
+void *__libcpp_tls_get(__libcpp_tls_key __key)
+{
+ return FlsGetValue(__key);
+}
+
+int __libcpp_tls_set(__libcpp_tls_key __key, void *__p)
+{
+ if (!FlsSetValue(__key, __p))
+ return GetLastError();
+ return 0;
+}
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/system_error.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/system_error.cpp
new file mode 100644
index 0000000000..66db76c37b
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/system_error.cpp
@@ -0,0 +1,294 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <__assert>
+#include <__config>
+#include <cerrno>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <string>
+#include <string.h>
+#include <system_error>
+
+#include "include/config_elast.h"
+
+#if defined(__ANDROID__)
+#include <android/api-level.h>
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// class error_category
+
+#if defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS)
+error_category::error_category() noexcept
+{
+}
+#endif
+
+error_category::~error_category() noexcept
+{
+}
+
+error_condition
+error_category::default_error_condition(int ev) const noexcept
+{
+ return error_condition(ev, *this);
+}
+
+bool
+error_category::equivalent(int code, const error_condition& condition) const noexcept
+{
+ return default_error_condition(code) == condition;
+}
+
+bool
+error_category::equivalent(const error_code& code, int condition) const noexcept
+{
+ return *this == code.category() && code.value() == condition;
+}
+
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+namespace {
+
+// GLIBC also uses 1024 as the maximum buffer size internally.
+constexpr size_t strerror_buff_size = 1024;
+
+string do_strerror_r(int ev);
+
+#if defined(_LIBCPP_MSVCRT_LIKE)
+string do_strerror_r(int ev) {
+ char buffer[strerror_buff_size];
+ if (::strerror_s(buffer, strerror_buff_size, ev) == 0)
+ return string(buffer);
+ std::snprintf(buffer, strerror_buff_size, "unknown error %d", ev);
+ return string(buffer);
+}
+#else
+
+// Only one of the two following functions will be used, depending on
+// the return type of strerror_r:
+
+// For the GNU variant, a char* return value:
+__attribute__((unused)) const char *
+handle_strerror_r_return(char *strerror_return, char *buffer) {
+ // GNU always returns a string pointer in its return value. The
+ // string might point to either the input buffer, or a static
+ // buffer, but we don't care which.
+ return strerror_return;
+}
+
+// For the POSIX variant: an int return value.
+__attribute__((unused)) const char *
+handle_strerror_r_return(int strerror_return, char *buffer) {
+ // The POSIX variant either:
+ // - fills in the provided buffer and returns 0
+ // - returns a positive error value, or
+ // - returns -1 and fills in errno with an error value.
+ if (strerror_return == 0)
+ return buffer;
+
+ // Only handle EINVAL. Other errors abort.
+ int new_errno = strerror_return == -1 ? errno : strerror_return;
+ if (new_errno == EINVAL)
+ return "";
+
+ _LIBCPP_ASSERT(new_errno == ERANGE, "unexpected error from ::strerror_r");
+ // FIXME maybe? 'strerror_buff_size' is likely to exceed the
+ // maximum error size so ERANGE shouldn't be returned.
+ std::abort();
+}
+
+// This function handles both GNU and POSIX variants, dispatching to
+// one of the two above functions.
+string do_strerror_r(int ev) {
+ char buffer[strerror_buff_size];
+ // Preserve errno around the call. (The C++ standard requires that
+ // system_error functions not modify errno).
+ const int old_errno = errno;
+ const char *error_message = handle_strerror_r_return(
+ ::strerror_r(ev, buffer, strerror_buff_size), buffer);
+ // If we didn't get any message, print one now.
+ if (!error_message[0]) {
+ std::snprintf(buffer, strerror_buff_size, "Unknown error %d", ev);
+ error_message = buffer;
+ }
+ errno = old_errno;
+ return string(error_message);
+}
+#endif
+} // end namespace
+#endif
+
+string
+__do_message::message(int ev) const
+{
+#if defined(_LIBCPP_HAS_NO_THREADS)
+ return string(::strerror(ev));
+#else
+ return do_strerror_r(ev);
+#endif
+}
+
+class _LIBCPP_HIDDEN __generic_error_category
+ : public __do_message
+{
+public:
+ virtual const char* name() const noexcept;
+ virtual string message(int ev) const;
+};
+
+const char*
+__generic_error_category::name() const noexcept
+{
+ return "generic";
+}
+
+string
+__generic_error_category::message(int ev) const
+{
+#ifdef _LIBCPP_ELAST
+ if (ev > _LIBCPP_ELAST)
+ return string("unspecified generic_category error");
+#endif // _LIBCPP_ELAST
+ return __do_message::message(ev);
+}
+
+const error_category&
+generic_category() noexcept
+{
+ static __generic_error_category s;
+ return s;
+}
+
+class _LIBCPP_HIDDEN __system_error_category
+ : public __do_message
+{
+public:
+ virtual const char* name() const noexcept;
+ virtual string message(int ev) const;
+ virtual error_condition default_error_condition(int ev) const noexcept;
+};
+
+const char*
+__system_error_category::name() const noexcept
+{
+ return "system";
+}
+
+string
+__system_error_category::message(int ev) const
+{
+#ifdef _LIBCPP_ELAST
+ if (ev > _LIBCPP_ELAST)
+ return string("unspecified system_category error");
+#endif // _LIBCPP_ELAST
+ return __do_message::message(ev);
+}
+
+error_condition
+__system_error_category::default_error_condition(int ev) const noexcept
+{
+#ifdef _LIBCPP_ELAST
+ if (ev > _LIBCPP_ELAST)
+ return error_condition(ev, system_category());
+#endif // _LIBCPP_ELAST
+ return error_condition(ev, generic_category());
+}
+
+const error_category&
+system_category() noexcept
+{
+ static __system_error_category s;
+ return s;
+}
+
+// error_condition
+
+string
+error_condition::message() const
+{
+ return __cat_->message(__val_);
+}
+
+// error_code
+
+string
+error_code::message() const
+{
+ return __cat_->message(__val_);
+}
+
+// system_error
+
+string
+system_error::__init(const error_code& ec, string what_arg)
+{
+ if (ec)
+ {
+ if (!what_arg.empty())
+ what_arg += ": ";
+ what_arg += ec.message();
+ }
+ return what_arg;
+}
+
+system_error::system_error(error_code ec, const string& what_arg)
+ : runtime_error(__init(ec, what_arg)),
+ __ec_(ec)
+{
+}
+
+system_error::system_error(error_code ec, const char* what_arg)
+ : runtime_error(__init(ec, what_arg)),
+ __ec_(ec)
+{
+}
+
+system_error::system_error(error_code ec)
+ : runtime_error(__init(ec, "")),
+ __ec_(ec)
+{
+}
+
+system_error::system_error(int ev, const error_category& ecat, const string& what_arg)
+ : runtime_error(__init(error_code(ev, ecat), what_arg)),
+ __ec_(error_code(ev, ecat))
+{
+}
+
+system_error::system_error(int ev, const error_category& ecat, const char* what_arg)
+ : runtime_error(__init(error_code(ev, ecat), what_arg)),
+ __ec_(error_code(ev, ecat))
+{
+}
+
+system_error::system_error(int ev, const error_category& ecat)
+ : runtime_error(__init(error_code(ev, ecat), "")),
+ __ec_(error_code(ev, ecat))
+{
+}
+
+system_error::~system_error() noexcept
+{
+}
+
+void
+__throw_system_error(int ev, const char* what_arg)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw system_error(error_code(ev, system_category()), what_arg);
+#else
+ (void)ev;
+ (void)what_arg;
+ _VSTD::abort();
+#endif
+}
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/thread.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/thread.cpp
new file mode 100644
index 0000000000..0734659d2d
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/thread.cpp
@@ -0,0 +1,212 @@
+//===------------------------- thread.cpp----------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <__config>
+
+#ifndef _LIBCPP_HAS_NO_THREADS
+
+#include <exception>
+#include <future>
+#include <limits>
+#include <thread>
+#include <vector>
+
+#if __has_include(<unistd.h>)
+# include <unistd.h> // for sysconf
+#endif
+
+#if defined(__NetBSD__)
+#pragma weak pthread_create // Do not create libpthread dependency
+#endif
+
+#if defined(_LIBCPP_WIN32API)
+#include <windows.h>
+#endif
+
+#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
+#pragma comment(lib, "pthread")
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+thread::~thread()
+{
+ if (!__libcpp_thread_isnull(&__t_))
+ terminate();
+}
+
+void
+thread::join()
+{
+ int ec = EINVAL;
+ if (!__libcpp_thread_isnull(&__t_))
+ {
+ ec = __libcpp_thread_join(&__t_);
+ if (ec == 0)
+ __t_ = _LIBCPP_NULL_THREAD;
+ }
+
+ if (ec)
+ __throw_system_error(ec, "thread::join failed");
+}
+
+void
+thread::detach()
+{
+ int ec = EINVAL;
+ if (!__libcpp_thread_isnull(&__t_))
+ {
+ ec = __libcpp_thread_detach(&__t_);
+ if (ec == 0)
+ __t_ = _LIBCPP_NULL_THREAD;
+ }
+
+ if (ec)
+ __throw_system_error(ec, "thread::detach failed");
+}
+
+unsigned
+thread::hardware_concurrency() noexcept
+{
+#if defined(_SC_NPROCESSORS_ONLN)
+ long result = sysconf(_SC_NPROCESSORS_ONLN);
+ // sysconf returns -1 if the name is invalid, the option does not exist or
+ // does not have a definite limit.
+ // if sysconf returns some other negative number, we have no idea
+ // what is going on. Default to something safe.
+ if (result < 0)
+ return 0;
+ return static_cast<unsigned>(result);
+#elif defined(_LIBCPP_WIN32API)
+ SYSTEM_INFO info;
+ GetSystemInfo(&info);
+ return info.dwNumberOfProcessors;
+#else // defined(CTL_HW) && defined(HW_NCPU)
+ // TODO: grovel through /proc or check cpuid on x86 and similar
+ // instructions on other architectures.
+# if defined(_LIBCPP_WARNING)
+ _LIBCPP_WARNING("hardware_concurrency not yet implemented")
+# else
+# warning hardware_concurrency not yet implemented
+# endif
+ return 0; // Means not computable [thread.thread.static]
+#endif // defined(CTL_HW) && defined(HW_NCPU)
+}
+
+namespace this_thread
+{
+
+void
+sleep_for(const chrono::nanoseconds& ns)
+{
+ if (ns > chrono::nanoseconds::zero())
+ {
+ __libcpp_thread_sleep_for(ns);
+ }
+}
+
+} // this_thread
+
+__thread_specific_ptr<__thread_struct>&
+__thread_local_data()
+{
+ static __thread_specific_ptr<__thread_struct> __p;
+ return __p;
+}
+
+// __thread_struct_imp
+
+template <class T>
+class _LIBCPP_HIDDEN __hidden_allocator
+{
+public:
+ typedef T value_type;
+
+ T* allocate(size_t __n)
+ {return static_cast<T*>(::operator new(__n * sizeof(T)));}
+ void deallocate(T* __p, size_t) {::operator delete(static_cast<void*>(__p));}
+
+ size_t max_size() const {return size_t(~0) / sizeof(T);}
+};
+
+class _LIBCPP_HIDDEN __thread_struct_imp
+{
+ typedef vector<__assoc_sub_state*,
+ __hidden_allocator<__assoc_sub_state*> > _AsyncStates;
+ typedef vector<pair<condition_variable*, mutex*>,
+ __hidden_allocator<pair<condition_variable*, mutex*> > > _Notify;
+
+ _AsyncStates async_states_;
+ _Notify notify_;
+
+ __thread_struct_imp(const __thread_struct_imp&);
+ __thread_struct_imp& operator=(const __thread_struct_imp&);
+public:
+ __thread_struct_imp() {}
+ ~__thread_struct_imp();
+
+ void notify_all_at_thread_exit(condition_variable* cv, mutex* m);
+ void __make_ready_at_thread_exit(__assoc_sub_state* __s);
+};
+
+__thread_struct_imp::~__thread_struct_imp()
+{
+ for (_Notify::iterator i = notify_.begin(), e = notify_.end();
+ i != e; ++i)
+ {
+ i->second->unlock();
+ i->first->notify_all();
+ }
+ for (_AsyncStates::iterator i = async_states_.begin(), e = async_states_.end();
+ i != e; ++i)
+ {
+ (*i)->__make_ready();
+ (*i)->__release_shared();
+ }
+}
+
+void
+__thread_struct_imp::notify_all_at_thread_exit(condition_variable* cv, mutex* m)
+{
+ notify_.push_back(pair<condition_variable*, mutex*>(cv, m));
+}
+
+void
+__thread_struct_imp::__make_ready_at_thread_exit(__assoc_sub_state* __s)
+{
+ async_states_.push_back(__s);
+ __s->__add_shared();
+}
+
+// __thread_struct
+
+__thread_struct::__thread_struct()
+ : __p_(new __thread_struct_imp)
+{
+}
+
+__thread_struct::~__thread_struct()
+{
+ delete __p_;
+}
+
+void
+__thread_struct::notify_all_at_thread_exit(condition_variable* cv, mutex* m)
+{
+ __p_->notify_all_at_thread_exit(cv, m);
+}
+
+void
+__thread_struct::__make_ready_at_thread_exit(__assoc_sub_state* __s)
+{
+ __p_->__make_ready_at_thread_exit(__s);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // !_LIBCPP_HAS_NO_THREADS
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/typeinfo.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/typeinfo.cpp
new file mode 100644
index 0000000000..a98ceb0034
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/typeinfo.cpp
@@ -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
+//
+//===----------------------------------------------------------------------===//
+
+#include <typeinfo>
+
+#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_ABI_VCRUNTIME)
+
+#include <string.h>
+
+int std::type_info::__compare(const type_info &__rhs) const noexcept {
+ if (&__data == &__rhs.__data)
+ return 0;
+ return strcmp(&__data.__decorated_name[1], &__rhs.__data.__decorated_name[1]);
+}
+
+const char *std::type_info::name() const noexcept {
+ // TODO(compnerd) cache demangled &__data.__decorated_name[1]
+ return &__data.__decorated_name[1];
+}
+
+size_t std::type_info::hash_code() const noexcept {
+#if defined(_WIN64)
+ constexpr size_t fnv_offset_basis = 14695981039346656037ull;
+ constexpr size_t fnv_prime = 10995116282110ull;
+#else
+ constexpr size_t fnv_offset_basis = 2166136261ull;
+ constexpr size_t fnv_prime = 16777619ull;
+#endif
+
+ size_t value = fnv_offset_basis;
+ for (const char* c = &__data.__decorated_name[1]; *c; ++c) {
+ value ^= static_cast<size_t>(static_cast<unsigned char>(*c));
+ value *= fnv_prime;
+ }
+
+#if defined(_WIN64)
+ value ^= value >> 32;
+#endif
+
+ return value;
+}
+#endif // _LIBCPP_ABI_MICROSOFT
+
+// FIXME: Remove the _LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY configuration.
+#if (!defined(LIBCXX_BUILDING_LIBCXXABI) && \
+ !defined(LIBCXX_BUILDING_LIBCXXRT) && \
+ !defined(__GLIBCXX__) && \
+ !defined(_LIBCPP_ABI_VCRUNTIME)) || \
+ defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY)
+std::type_info::~type_info()
+{
+}
+#endif
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/utility.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/utility.cpp
new file mode 100644
index 0000000000..44433d11d7
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/utility.cpp
@@ -0,0 +1,15 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <utility>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+const piecewise_construct_t piecewise_construct{};
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/valarray.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/valarray.cpp
new file mode 100644
index 0000000000..5d63bc1184
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/valarray.cpp
@@ -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
+//
+//===----------------------------------------------------------------------===//
+
+#include <valarray>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// These two symbols are part of the v1 ABI but not part of the >=v2 ABI.
+#if _LIBCPP_ABI_VERSION == 1
+template _LIBCPP_FUNC_VIS valarray<size_t>::valarray(size_t);
+template _LIBCPP_FUNC_VIS valarray<size_t>::~valarray();
+#endif
+
+template void valarray<size_t>::resize(size_t, size_t);
+
+void
+gslice::__init(size_t __start)
+{
+ valarray<size_t> __indices(__size_.size());
+ size_t __k = __size_.size() != 0;
+ for (size_t __i = 0; __i < __size_.size(); ++__i)
+ __k *= __size_[__i];
+ __1d_.resize(__k);
+ if (__1d_.size())
+ {
+ __k = 0;
+ __1d_[__k] = __start;
+ while (true)
+ {
+ size_t __i = __indices.size() - 1;
+ while (true)
+ {
+ if (++__indices[__i] < __size_[__i])
+ {
+ ++__k;
+ __1d_[__k] = __1d_[__k-1] + __stride_[__i];
+ for (size_t __j = __i + 1; __j != __indices.size(); ++__j)
+ __1d_[__k] -= __stride_[__j] * (__size_[__j] - 1);
+ break;
+ }
+ else
+ {
+ if (__i == 0)
+ return;
+ __indices[__i--] = 0;
+ }
+ }
+ }
+ }
+}
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/variant.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/variant.cpp
new file mode 100644
index 0000000000..b6ec448081
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/variant.cpp
@@ -0,0 +1,17 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <variant>
+
+namespace std {
+
+const char* bad_variant_access::what() const noexcept {
+ return "bad_variant_access";
+}
+
+} // namespace std
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/src/vector.cpp b/contrib/libs/cxxsupp/libcxxmsvc/src/vector.cpp
new file mode 100644
index 0000000000..fa63d5c5e3
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/src/vector.cpp
@@ -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
+//
+//===----------------------------------------------------------------------===//
+
+#include <vector>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifndef _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON
+
+template <bool>
+struct __vector_base_common;
+
+template <>
+struct __vector_base_common<true> {
+ _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_length_error() const;
+ _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_out_of_range() const;
+};
+
+void __vector_base_common<true>::__throw_length_error() const {
+ _VSTD::__throw_length_error("vector");
+}
+
+void __vector_base_common<true>::__throw_out_of_range() const {
+ _VSTD::__throw_out_of_range("vector");
+}
+
+#endif // _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/ya.make b/contrib/libs/cxxsupp/libcxxmsvc/ya.make
new file mode 100644
index 0000000000..71715890a5
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxxmsvc/ya.make
@@ -0,0 +1,258 @@
+LIBRARY()
+
+LICENSE(
+ Apache-2.0 AND
+ Apache-2.0 WITH LLVM-exception AND
+ BSD-2-Clause AND
+ BSL-1.0 AND
+ MIT AND
+ NCSA
+)
+
+LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
+
+VERSION(2022-02-18)
+
+ORIGINAL_SOURCE(https://github.com/llvm/llvm-project/archive/34313583331e5c8cb0d3df28efb6c34c428fd235.tar.gz)
+
+ADDINCL(
+ GLOBAL contrib/libs/cxxsupp/libcxxmsvc/include
+ contrib/libs/cxxsupp/libcxxmsvc/src
+)
+
+CXXFLAGS(-D_LIBCPP_BUILDING_LIBRARY)
+
+IF (OS_ANDROID)
+ DEFAULT(CXX_RT "default")
+ IF (ARCH_I686 OR ARCH_ARM7)
+ # 32-bit architectures require additional libandroid_support.so to be linked
+ # We add --start-group / --end-group statements due to the issue in NDK < r22.
+ # See: https://github.com/android/ndk/issues/1130
+ #
+ # Though these statements are not respected by LLD, they might have sense for other linkers.
+ LDFLAGS(
+ -Wl,--start-group
+ -lc++abi
+ -landroid_support
+ -Wl,--end-group
+ )
+ ELSE()
+ LDFLAGS(-lc++abi)
+ ENDIF()
+ CFLAGS(
+ -DLIBCXX_BUILDING_LIBCXXABI
+ )
+# Take cxxabi implementation from system.
+ELSEIF (OS_IOS)
+ LDFLAGS(-lc++abi)
+ CFLAGS(
+ -DLIBCXX_BUILDING_LIBCXXABI
+ )
+ # Yet take builtins library from Arcadia
+ PEERDIR(
+ contrib/libs/cxxsupp/builtins
+ )
+ELSEIF (OS_LINUX OR OS_DARWIN)
+ IF (ARCH_ARM7)
+ # XXX: libcxxrt support for ARM is currently broken
+ DEFAULT(CXX_RT "glibcxx_static")
+ # ARM7 OS_SDK has old libstdc++ without aligned allocation support
+ CFLAGS(
+ GLOBAL -fno-aligned-new
+ )
+ ELSE()
+ DEFAULT(CXX_RT "libcxxrt")
+ ENDIF()
+ IF (MUSL)
+ PEERDIR(
+ contrib/libs/musl/include
+ )
+ ENDIF()
+ELSEIF (OS_WINDOWS)
+ SRCS(
+ src/support/win32/locale_win32.cpp
+ src/support/win32/support.cpp
+ src/support/win32/atomic_win32.cpp
+ src/support/win32/new_win32.cpp
+ src/support/win32/thread_win32.cpp
+ )
+ CFLAGS(
+ GLOBAL -D_LIBCPP_VASPRINTF_DEFINED
+ GLOBAL -D_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_
+ )
+ IF (CLANG_CL)
+ PEERDIR(
+ contrib/libs/cxxsupp/builtins
+ )
+ ENDIF()
+ELSE()
+ DEFAULT(CXX_RT "glibcxx_static")
+ CXXFLAGS(
+ -Wno-unknown-pragmas
+ -nostdinc++
+ )
+ENDIF()
+
+IF (OS_LINUX)
+ EXTRALIBS(-lpthread)
+ENDIF()
+
+IF (CLANG)
+ CFLAGS(
+ GLOBAL -nostdinc++
+ )
+ENDIF()
+
+# The CXX_RT variable controls which C++ runtime is used.
+# * libcxxrt - https://github.com/libcxxrt/libcxxrt library stored in Arcadia
+# * glibcxx_static - GNU C++ Library runtime with static linkage
+# * glibcxx_dynamic - GNU C++ Library runtime with dynamic linkage
+# * default - default C++ runtime provided by the compiler driver
+#
+# All glibcxx* runtimes are taken from system/compiler SDK
+
+DEFAULT(CXX_RT "default")
+
+DISABLE(NEED_GLIBCXX_CXX17_SHIMS)
+
+DISABLE(NEED_CXX_RT_ADDINCL)
+
+IF (CXX_RT == "libcxxrt")
+ PEERDIR(
+ contrib/libs/cxxsupp/libcxxabi-parts
+ contrib/libs/cxxsupp/libcxxrt
+ contrib/libs/cxxsupp/builtins
+ )
+ ADDINCL(
+ GLOBAL contrib/libs/cxxsupp/libcxxrt/include
+ )
+ CFLAGS(
+ GLOBAL -DLIBCXX_BUILDING_LIBCXXRT
+ )
+ # These builtins are equivalent to clang -rtlib=compiler_rt and
+ # are needed by potentially any code generated by clang.
+ # With glibcxx runtime, builtins are provided by libgcc
+ELSEIF (CXX_RT == "glibcxx_static")
+ LDFLAGS(
+ -Wl,-Bstatic
+ -lsupc++
+ -lgcc
+ -lgcc_eh
+ -Wl,-Bdynamic
+ )
+ CXXFLAGS(-D__GLIBCXX__=1)
+ ENABLE(NEED_GLIBCXX_CXX17_SHIMS)
+ ENABLE(NEED_CXX_RT_ADDINCL)
+ CFLAGS(
+ GLOBAL -DLIBCXX_BUILDING_LIBGCC
+ )
+ELSEIF (CXX_RT == "glibcxx_dynamic")
+ LDFLAGS(
+ -lgcc_s
+ -lstdc++
+ )
+ CXXFLAGS(-D__GLIBCXX__=1)
+ CFLAGS(
+ GLOBAL -DLIBCXX_BUILDING_LIBGCC
+ )
+ ENABLE(NEED_GLIBCXX_CXX17_SHIMS)
+ ENABLE(NEED_CXX_RT_ADDINCL)
+ELSEIF (CXX_RT == "default")
+ # Do nothing
+ELSE()
+ MESSAGE(FATAL_ERROR "Unexpected CXX_RT value: ${CXX_RT}")
+ENDIF()
+
+IF (NEED_GLIBCXX_CXX17_SHIMS)
+ IF (GCC)
+ # Assume GCC is bundled with a modern enough version of C++ runtime
+ ELSEIF (OS_SDK == "ubuntu-12" OR OS_SDK == "ubuntu-14" OR OS_SDK == "ubuntu-16")
+ # Prior to ubuntu-18, system C++ runtime for C++17 is incomplete
+ # and requires std::uncaught_exceptions() to be implemented.
+ SRCS(
+ glibcxx_eh_cxx17.cpp
+ )
+ ENDIF()
+ENDIF()
+
+IF (NEED_CXX_RT_ADDINCL)
+ # FIXME:
+ # This looks extremely weird and we have to use cxxabi.h from libsupc++ instead.
+ # This ADDINCL is placed here just to fix the status quo
+ ADDINCL(
+ GLOBAL contrib/libs/cxxsupp/libcxxrt/include
+ )
+ENDIF()
+
+NO_UTIL()
+
+NO_RUNTIME()
+
+NO_COMPILER_WARNINGS()
+
+IF (FUZZING)
+ NO_SANITIZE()
+ NO_SANITIZE_COVERAGE()
+ENDIF()
+
+SRCS(
+ src/algorithm.cpp
+ src/any.cpp
+ src/assert.cpp
+ src/atomic.cpp
+ src/barrier.cpp
+ src/bind.cpp
+ src/charconv.cpp
+ src/chrono.cpp
+ src/condition_variable.cpp
+ src/condition_variable_destructor.cpp
+ src/debug.cpp
+ src/exception.cpp
+ src/filesystem/directory_iterator.cpp
+ src/filesystem/operations.cpp
+ src/functional.cpp
+ src/future.cpp
+ src/hash.cpp
+ src/ios.cpp
+ src/ios.instantiations.cpp
+ src/iostream.cpp
+ src/legacy_pointer_safety.cpp
+ src/locale.cpp
+ src/memory.cpp
+ src/mutex.cpp
+ src/mutex_destructor.cpp
+ src/optional.cpp
+ src/random.cpp
+ src/random_shuffle.cpp
+ src/regex.cpp
+ src/ryu/d2fixed.cpp
+ src/ryu/d2s.cpp
+ src/ryu/f2s.cpp
+ src/shared_mutex.cpp
+ src/stdexcept.cpp
+ src/string.cpp
+ src/strstream.cpp
+ src/system_error.cpp
+ src/thread.cpp
+ src/typeinfo.cpp
+ src/utility.cpp
+ src/valarray.cpp
+ src/variant.cpp
+ src/vector.cpp
+)
+
+IF (NOT GCC)
+ # compiling src/format.cpp requires -std=c++20,
+ # yet our GCC version it too auld for this.
+ SRCS(
+ src/format.cpp
+ )
+ENDIF()
+
+IF (NOT OS_WINDOWS)
+ SRCS(
+ src/new.cpp
+ )
+ENDIF()
+
+END()
diff --git a/contrib/libs/cxxsupp/ya.make b/contrib/libs/cxxsupp/ya.make
index 8b0ea36c13..1244158676 100644
--- a/contrib/libs/cxxsupp/ya.make
+++ b/contrib/libs/cxxsupp/ya.make
@@ -8,9 +8,15 @@ LICENSE(Not-Applicable)
NO_PLATFORM()
IF (NOT USE_STL_SYSTEM)
- PEERDIR(
- contrib/libs/cxxsupp/libcxx
- )
+ IF (MSVC)
+ PEERDIR(
+ contrib/libs/cxxsupp/libcxxmsvc
+ )
+ ELSE()
+ PEERDIR(
+ contrib/libs/cxxsupp/libcxx
+ )
+ ENDIF()
ELSE()
PEERDIR(
contrib/libs/cxxsupp/system_stl
@@ -22,6 +28,7 @@ END()
RECURSE(
libcxx
libcxxabi
+ libcxxmsvc
libcxxrt
openmp
)